本文整理汇总了Java中org.broad.igv.feature.Chromosome.getIndex方法的典型用法代码示例。如果您正苦于以下问题:Java Chromosome.getIndex方法的具体用法?Java Chromosome.getIndex怎么用?Java Chromosome.getIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.broad.igv.feature.Chromosome
的用法示例。
在下文中一共展示了Chromosome.getIndex方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addToList
import org.broad.igv.feature.Chromosome; //导入方法依赖的package包/类
private static void addToList(String chr1Name, String chr2Name, ChromosomeHandler handler, String nextLine,
Feature2DList newList, boolean useFeature2DWithMotif, Feature2D.FeatureType featureType,
int start1, int end1, int start2, int end2, Color c, Map<String, String> attrs) {
Chromosome chr1 = handler.getChromosomeFromName(chr1Name);
Chromosome chr2 = handler.getChromosomeFromName(chr2Name);
if (chr1 == null || chr2 == null) {
handleError(nextLine);
return;
}
// Convention is chr1 is lowest "index". Swap if necessary
if (useFeature2DWithMotif) {
if (chr1.getIndex() <= chr2.getIndex()) {
newList.add(chr1.getIndex(), chr2.getIndex(), new Feature2DWithMotif(featureType, chr1Name, chr1.getIndex(), start1, end1, chr2Name, chr2.getIndex(), start2, end2, c, attrs));
} else {
newList.add(chr2.getIndex(), chr1.getIndex(), new Feature2DWithMotif(featureType, chr2Name, chr2.getIndex(), start2, end2, chr1Name, chr1.getIndex(), start1, end1, c, attrs));
}
} else {
if (chr1.getIndex() <= chr2.getIndex()) {
newList.add(chr1.getIndex(), chr2.getIndex(), new Feature2D(featureType, chr1Name, start1, end1, chr2Name, start2, end2, c, attrs));
} else {
newList.add(chr2.getIndex(), chr1.getIndex(), new Feature2D(featureType, chr2Name, start2, end2, chr1Name, start1, end1, c, attrs));
}
}
}
示例2: unsafeRefreshChromosomes
import org.broad.igv.feature.Chromosome; //导入方法依赖的package包/类
public void unsafeRefreshChromosomes(SuperAdapter superAdapter) {
if (chrBox1.getSelectedIndex() == 0 || chrBox2.getSelectedIndex() == 0) {
chrBox1.setSelectedIndex(0);
chrBox2.setSelectedIndex(0);
MatrixType matrixType = (MatrixType) displayOptionComboBox.getSelectedItem();
if (MatrixType.isPearsonType(matrixType)) {
// can't do pearson's genomewide
displayOptionComboBox.setSelectedIndex(0);
superAdapter.unsafeDisplayOptionComboBoxActionPerformed();
}
}
Chromosome chr1 = (Chromosome) chrBox1.getSelectedItem();
Chromosome chr2 = (Chromosome) chrBox2.getSelectedItem();
Chromosome chrX = chr1.getIndex() < chr2.getIndex() ? chr1 : chr2;
Chromosome chrY = chr1.getIndex() < chr2.getIndex() ? chr2 : chr1;
superAdapter.unsafeUpdateHiCChromosomes(chrX, chrY);
setNormalizationDisplayState(superAdapter.getHiC());
updateThumbnail(superAdapter.getHiC());
}
示例3: unsafeSave1DTrackToWigFile
import org.broad.igv.feature.Chromosome; //导入方法依赖的package包/类
private void unsafeSave1DTrackToWigFile(Chromosome chromosomeForPosition, PrintWriter printWriter,
int binStartPosition) {
// todo could crash with custom chromosomes - so make sure this doesn't get called on those chromosomes
int resolution = getZoom().getBinSize();
for (Chromosome chromosome : chromosomeHandler.getChromosomeArrayWithoutAllByAll()) {
Matrix matrix = null;
if (displayOption == MatrixType.OBSERVED) {
matrix = dataset.getMatrix(chromosomeForPosition, chromosome);
} else if (displayOption == MatrixType.CONTROL) {
matrix = controlDataset.getMatrix(chromosomeForPosition, chromosome);
}
if (matrix == null) continue;
MatrixZoomData zd = matrix.getZoomData(currentZoom);
printWriter.println("fixedStep chrom=chr" + chromosome.getName().replace("chr", "")
+ " start=1 step=" + resolution + " span=" + resolution);
int[] regionIndices;
if (chromosomeForPosition.getIndex() < chromosome.getIndex()) {
regionIndices = new int[]{binStartPosition, binStartPosition, 0, chromosome.getLength()};
} else {
regionIndices = new int[]{0, chromosome.getLength(), binStartPosition, binStartPosition};
}
zd.dump1DTrackFromCrossHairAsWig(printWriter, binStartPosition,
chromosomeForPosition.getIndex() == chromosome.getIndex(), regionIndices,
normalizationType, displayOption);
}
}
示例4: initializeCleanedChromosomesList
import org.broad.igv.feature.Chromosome; //导入方法依赖的package包/类
private void initializeCleanedChromosomesList(List<Chromosome> chromosomes) {
cleanedChromosomes.clear();
for (Chromosome c : chromosomes) {
String cleanName = cleanUpName(c.getName());
Chromosome cleanChromosome = new Chromosome(c.getIndex(), cleanName, c.getLength());
cleanedChromosomes.add(cleanChromosome);
}
}
示例5: initialize
import org.broad.igv.feature.Chromosome; //导入方法依赖的package包/类
/**
* @param handler
*/
public void initialize(Chromosome chr1, Chromosome chr2, HiCZoom zoom, ChromosomeHandler handler) {
allRegionsForChr.clear();
boundariesOfCustomChromosomeX.clear();
boundariesOfCustomChromosomeY.clear();
populateRegions(chr1, handler, boundariesOfCustomChromosomeX, zoom);
if (chr1.getIndex() != chr2.getIndex()) {
populateRegions(chr2, handler, boundariesOfCustomChromosomeY, zoom);
} else {
boundariesOfCustomChromosomeY.addAll(boundariesOfCustomChromosomeX);
}
}
示例6: populateRegions
import org.broad.igv.feature.Chromosome; //导入方法依赖的package包/类
private void populateRegions(Chromosome chr, ChromosomeHandler handler, List<Integer> boundaries, HiCZoom zoom) {
int chrIndex = chr.getIndex();
Pair<List<MotifAnchor>, List<MotifAnchor>> allRegionsInfo = getAllRegionsFromSubChromosomes(handler, chr);
if (allRegionsInfo != null) {
allRegionsForChr.put(chrIndex, allRegionsInfo);
List<MotifAnchor> translatedRegions = allRegionsInfo.getSecond();
for (MotifAnchor anchor : translatedRegions) {
boundaries.add(anchor.getX2() / zoom.getBinSize());
}
}
}
示例7: extractAllGenes
import org.broad.igv.feature.Chromosome; //导入方法依赖的package包/类
private static List<MotifAnchor> extractAllGenes(BufferedReader reader, ChromosomeHandler handler) {
List<MotifAnchor> genes = new ArrayList<>();
String nextLine;
try {
while ((nextLine = reader.readLine()) != null) {
String[] values = nextLine.split("\\s+");
if (values.length == 4 || values.length == 16) { // 16 is refGene official format
Chromosome chr = handler.getChromosomeFromName(values[2]);
// refGene contains contigs as well, ignore these genes
if (chr != null) {
int chrIndex = chr.getIndex();
// transcript start; for 4 column format, just position-1
int txStart = (values.length==4) ? Integer.valueOf(values[3].trim())-1 : Integer.valueOf(values[4].trim());
// transcript end; for 4 column format, just position+1
int txEnd = (values.length==4) ? Integer.valueOf(values[3].trim())+1 : Integer.valueOf(values[5].trim());
String name = (values.length==4) ? values[1].trim() : values[12].trim();
MotifAnchor gene = new MotifAnchor(chrIndex, txStart, txEnd, name);
genes.add(gene);
}
}
}
} catch (Exception e) {
System.err.println("Gene database not properly formatted");
System.exit(50);
}
if (genes.size() == 0) {
System.err.println("Gene database not properly formatted");
System.exit(51);
}
return genes;
}
示例8: createWholeGenomeRecords
import org.broad.igv.feature.Chromosome; //导入方法依赖的package包/类
public static ArrayList<ContactRecord> createWholeGenomeRecords(Dataset dataset, ChromosomeHandler handler,
HiCZoom zoom, boolean includeIntra) {
ArrayList<ContactRecord> recordArrayList = new ArrayList<>();
int addX = 0;
int addY = 0;
for (Chromosome c1 : handler.getChromosomeArrayWithoutAllByAll()) {
for (Chromosome c2 : handler.getChromosomeArrayWithoutAllByAll()) {
if (c1.getIndex() < c2.getIndex() || (c1.equals(c2) && includeIntra)) {
Matrix matrix = dataset.getMatrix(c1, c2);
if (matrix != null) {
MatrixZoomData zd = matrix.getZoomData(zoom);
if (zd != null) {
Iterator<ContactRecord> iter = zd.contactRecordIterator();
while (iter.hasNext()) {
ContactRecord cr = iter.next();
int binX = cr.getBinX() + addX;
int binY = cr.getBinY() + addY;
recordArrayList.add(new ContactRecord(binX, binY, cr.getCounts()));
}
}
}
}
addY += c2.getLength() / zoom.getBinSize() + 1;
}
addX += c1.getLength() / zoom.getBinSize() + 1;
addY = 0;
}
return recordArrayList;
}
示例9: liftDataArrayFromAsm
import org.broad.igv.feature.Chromosome; //导入方法依赖的package包/类
public static HiCDataPoint[] liftDataArrayFromAsm(HiCDataSource dataSource, HiC hic, Chromosome chromosome, int binX1, int binX2, HiCGridAxis gridAxis, double scaleFactor, WindowFunction windowFunction) {
HiCZoom zoom = hic.getZoom();
// get aggregate scaffold handler
AssemblyScaffoldHandler aFragHandler = AssemblyHeatmapHandler.getSuperAdapter().getAssemblyStateTracker().getAssemblyHandler();
final int binSize = zoom.getBinSize();
long actualBinSize = (long) binSize;
if (chromosome.getIndex() == 0) {
actualBinSize = 1000 * actualBinSize;
}
List<Scaffold> xAxisAggregateScaffolds = aFragHandler.getIntersectingAggregateFeatures(
(long) (actualBinSize * binX1 * HiCGlobals.hicMapScale), (long) (actualBinSize * binX2 * HiCGlobals.hicMapScale));
List<HiCDataPoint> modifiedDataPoints = new ArrayList<>();
int x1pos, x2pos;
for (Scaffold xScaffold : xAxisAggregateScaffolds) {
x1pos = (int) (xScaffold.getOriginalStart() / HiCGlobals.hicMapScale);
x2pos = (int) (xScaffold.getOriginalEnd() / HiCGlobals.hicMapScale);
// have to case long because of thumbnail, maybe fix thumbnail instead
if (xScaffold.getCurrentStart() < actualBinSize * binX1 * HiCGlobals.hicMapScale) {
if (!xScaffold.getInvertedVsInitial()) {
x1pos = (int) ((xScaffold.getOriginalStart() + actualBinSize * binX1 * HiCGlobals.hicMapScale - xScaffold.getCurrentStart()) / HiCGlobals.hicMapScale);
} else {
x2pos = (int) ((xScaffold.getOriginalStart() - actualBinSize * binX1 * HiCGlobals.hicMapScale + xScaffold.getCurrentEnd()) / HiCGlobals.hicMapScale);
}
}
if (xScaffold.getCurrentEnd() > actualBinSize * binX2 * HiCGlobals.hicMapScale) {
if (!xScaffold.getInvertedVsInitial()) {
x2pos = (int) ((xScaffold.getOriginalStart() + actualBinSize * binX2 * HiCGlobals.hicMapScale - xScaffold.getCurrentStart()) / HiCGlobals.hicMapScale);
} else {
x1pos = (int) ((xScaffold.getOriginalStart() - actualBinSize * binX2 * HiCGlobals.hicMapScale + xScaffold.getCurrentEnd()) / HiCGlobals.hicMapScale);
}
}
HiCDataPoint[] dataArray = dataSource.getData(chromosome, (int) (x1pos / actualBinSize), (int) (x2pos / actualBinSize), gridAxis, scaleFactor, windowFunction);
for (HiCDataPoint point : dataArray) {
int newStart;
int newEnd;
int newBin;
if (!xScaffold.getInvertedVsInitial()) {
newStart = (int) ((xScaffold.getCurrentStart() + HiCGlobals.hicMapScale * point.getGenomicStart() - xScaffold.getOriginalStart()) / HiCGlobals.hicMapScale);
newBin = (int) ((xScaffold.getCurrentStart() + HiCGlobals.hicMapScale * point.getBinNumber() * binSize - xScaffold.getOriginalStart()) / HiCGlobals.hicMapScale / binSize);
} else {
newStart = (int) ((xScaffold.getCurrentEnd() - HiCGlobals.hicMapScale * point.getGenomicEnd() + xScaffold.getOriginalStart()) / HiCGlobals.hicMapScale);
newBin = (int) ((xScaffold.getCurrentEnd() - HiCGlobals.hicMapScale * point.getBinNumber() * binSize + xScaffold.getOriginalStart()) / HiCGlobals.hicMapScale / binSize - 1);
}
newEnd = newStart + point.getGenomicEnd() - point.getGenomicStart();
// newBin=newStart/binSize;
if (point instanceof HiCCoverageDataSource.CoverageDataPoint) {
HiCCoverageDataSource.CoverageDataPoint covPoint = (HiCCoverageDataSource.CoverageDataPoint) point;
modifiedDataPoints.add(new HiCCoverageDataSource.CoverageDataPoint(newStart / binSize, newStart, newEnd, covPoint.value));
}
// else if (point instanceof HiCDataAdapter.DataAccumulator) { // not working quite as supposed to, seems like does not remove prev? confusing...
// HiCDataAdapter.DataAccumulator accumPoint = (HiCDataAdapter.DataAccumulator) point;
// HiCDataAdapter.DataAccumulator newAccumPoint = new HiCDataAdapter.DataAccumulator((double) newBin, accumPoint.width, newStart, newEnd);
// newAccumPoint.nPts = accumPoint.nPts;
// newAccumPoint.weightedSum = accumPoint.weightedSum;
// newAccumPoint.max = accumPoint.max;
// modifiedDataPoints.add(newAccumPoint);
// //if(accumPoint.getBinNumber()!=(double)newBin) System.out.println(accumPoint.getBinNumber()+" "+(double)newBin); // why do these not match?
// }
}
}
HiCDataPoint[] points = new HiCDataPoint[modifiedDataPoints.size()];
for (int i = 0; i < points.length; i++) {
points[i] = modifiedDataPoints.get(i);
}
return points;
}
示例10: dumpMatrix
import org.broad.igv.feature.Chromosome; //导入方法依赖的package包/类
/**
* Dumps the matrix. Does more argument checking, thus this should not be called outside of this class.
*
* @throws java.io.IOException In case of problems writing out matrix
*/
private void dumpMatrix() throws IOException {
Chromosome chromosome1 = chromosomeHandler.getChromosomeFromName(chr1);
Chromosome chromosome2 = chromosomeHandler.getChromosomeFromName(chr2);
Matrix matrix = dataset.getMatrix(chromosome1, chromosome2);
if (matrix == null) {
System.err.println("No reads in " + chr1 + " " + chr2);
return;
}
if (chromosome2.getIndex() < chromosome1.getIndex()) {
regionIndices = new int[]{regionIndices[2], regionIndices[3], regionIndices[0], regionIndices[1]};
}
MatrixZoomData zd = matrix.getZoomData(zoom);
if (zd == null) {
System.err.println("Unknown resolution: " + zoom);
System.err.println("This data set has the following bin sizes (in bp): ");
for (int zoomIdx = 0; zoomIdx < dataset.getNumberZooms(HiC.Unit.BP); zoomIdx++) {
System.err.print(dataset.getZoom(HiC.Unit.BP, zoomIdx).getBinSize() + " ");
}
System.err.println("\nand the following bin sizes (in frag): ");
for (int zoomIdx = 0; zoomIdx < dataset.getNumberZooms(HiC.Unit.FRAG); zoomIdx++) {
System.err.print(dataset.getZoom(HiC.Unit.FRAG, zoomIdx).getBinSize() + " ");
}
System.exit(13);
}
ExpectedValueFunction df = null;
if (MatrixType.isExpectedValueType(matrixType)) {
df = dataset.getExpectedValues(zd.getZoom(), norm);
if (df == null) {
System.err.println(matrixType + " not available at " + chr1 + " " + zoom + " " + norm);
System.exit(14);
}
}
zd.dump(pw, les, norm, matrixType, useRegionIndices, regionIndices, df, dense);
}
示例11: isInterChromosomal
import org.broad.igv.feature.Chromosome; //导入方法依赖的package包/类
private boolean isInterChromosomal() {
Chromosome chr1 = (Chromosome) chrBox1.getSelectedItem();
Chromosome chr2 = (Chromosome) chrBox2.getSelectedItem();
return chr1.getIndex() != chr2.getIndex();
}