本文整理汇总了Java中org.broad.igv.feature.Chromosome类的典型用法代码示例。如果您正苦于以下问题:Java Chromosome类的具体用法?Java Chromosome怎么用?Java Chromosome使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Chromosome类属于org.broad.igv.feature包,在下文中一共展示了Chromosome类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Genome
import org.broad.igv.feature.Chromosome; //导入依赖的package包/类
/**
* Alternate constructor for defining a minimal genome, usually from parsing a chrom.sizes file.
*
* @param id
* @param chromosomes
*/
public Genome(String id, List<Chromosome> chromosomes) {
this.id = id;
this.displayName = id;
this.chrAliasTable = new HashMap<String, String>();
this.sequence = null;
chromosomeNames = new ArrayList<String>(chromosomes.size());
chromosomeMap = new LinkedHashMap<String, Chromosome>(chromosomes.size());
for (Chromosome chromosome : chromosomes) {
chromosomeNames.add(chromosome.getName());
chromosomeMap.put(chromosome.getName(), chromosome);
}
initializeChromosomeAliases();
}
示例2: getSequence
import org.broad.igv.feature.Chromosome; //导入依赖的package包/类
/**
* Return the nucleotide sequence on the + strand for the genomic interval. This method can return null
* if sequence is not available.
*
* @param chr
* @param start start position in "zero-based" coordinates
* @param end end position
* @return sequence, or null if not available
* @api
*/
public byte[] getSequence(String chr, int start, int end) {
if (sequence == null) {
return null;
}
Chromosome c = getChromosome(chr);
if (c == null) {
return null;
}
end = Math.min(end, c.getLength());
if (end <= start) {
return null;
}
return sequence.getSequence(chr, start, end);
}
示例3: exportChromSizes
import org.broad.igv.feature.Chromosome; //导入依赖的package包/类
/**
* Export a "chrom.sizes" file for the specified genome
*
* @param directory output directory
* @param genome
* @throws FileNotFoundException
*/
public static void exportChromSizes(File directory, Genome genome) throws FileNotFoundException {
String fn = genome.getId() + ".chrom.sizes";
File file = new File(directory, fn);
PrintWriter pw = null;
try {
pw = new PrintWriter(file);
for (String chr : genome.getAllChromosomeNames()) {
Chromosome chromosome = genome.getChromosome(chr);
pw.println(chromosome.getName() + "\t" + chromosome.getLength());
}
} finally {
if (pw != null) pw.close();
}
}
示例4: DatasetDataSource
import org.broad.igv.feature.Chromosome; //导入依赖的package包/类
/**
*
* @param trackId
* @param dataset
* @param genome
*/
public DatasetDataSource(String trackId, Dataset dataset, Genome genome) {
super(genome);
this.trackId = trackId;
this.dataset = dataset;
// TODO -- remove this "instanceof" hack
if (genome.getHomeChromosome().equals(Globals.CHR_ALL)) {
if (dataset instanceof IGVDataset) {
genomeSummaryData = ((IGVDataset) dataset).getGenomeSummary();
} else {
genomeSummaryData = new GenomeSummaryData(genome, new String[]{trackId});
for (Chromosome chr : genome.getChromosomes()) {
int[] startLocations = dataset.getStartLocations(chr.getName());
if (!chr.getName().equals(Globals.CHR_ALL) && (startLocations != null) && (startLocations.length > 0)) {
Map<String, float[]> dMap = new HashMap<String, float[]>();
dMap.put(trackId, dataset.getData(trackId, chr.getName()));
genomeSummaryData.addData(chr.getName(), startLocations, dMap);
}
}
}
}
}
示例5: getChromosomeLength
import org.broad.igv.feature.Chromosome; //导入依赖的package包/类
private static int getChromosomeLength(String chrName) {
Genome genome = getGenome();
if (genome == null) {
return 1;
}
if (chrName.equals("All")) {
// TODO -- remove the hardcoded unit divider ("1000")
return (int) (genome.getNominalLength() / 1000);
} else {
Chromosome chromosome = genome.getChromosome(chrName);
if (chromosome == null) {
log.error("Null chromosome: " + chrName);
if (genome.getChromosomes().size() == 0) {
return 1;
} else {
return genome.getChromosomes().iterator().next().getLength();
}
}
return chromosome.getLength();
}
}
示例6: setChromosomesFromBroadcast
import org.broad.igv.feature.Chromosome; //导入依赖的package包/类
private void setChromosomesFromBroadcast(String chrXName, String chrYName) {
if (!chrXName.equals(xContext.getChromosome().getName()) || !chrYName.equals(yContext.getChromosome().getName())) {
Chromosome chrX = chromosomeHandler.getChromosomeFromName(chrXName);
Chromosome chrY = chromosomeHandler.getChromosomeFromName(chrYName);
if (chrX == null || chrY == null) {
//System.out.println("Most probably origin is a different species saved location or sync/link between two different species maps.");
return;
}
this.xContext = new Context(chrX);
this.yContext = new Context(chrY);
superAdapter.setSelectedChromosomesNoRefresh(chrX, chrY);
refreshEigenvectorTrackIfExists();
}
}
示例7: safeSave1DTrackToWigFile
import org.broad.igv.feature.Chromosome; //导入依赖的package包/类
private void safeSave1DTrackToWigFile(final Chromosome chromosomeForPosition, final File outputWigFile,
final int binStartPosition) {
superAdapter.getMainWindow().executeLongRunningTask(new Runnable() {
@Override
public void run() {
try {
PrintWriter printWriter = new PrintWriter(outputWigFile);
unsafeSave1DTrackToWigFile(chromosomeForPosition, printWriter, binStartPosition);
printWriter.close();
if (outputWigFile.exists() && outputWigFile.length() > 0) {
// TODO this still doesn't add to the resource tree / load annotation dialog box
//superAdapter.getTrackLoadAction();
//getResourceTree().add1DCustomTrack(outputWigFile);
HiC.this.unsafeLoadTrack(outputWigFile.getAbsolutePath());
LoadAction loadAction = superAdapter.getTrackLoadAction();
loadAction.checkBoxesForReload(outputWigFile.getName());
}
} catch (Exception e) {
System.err.println("Unable to generate and save 1D HiC track");
}
}
}, "Saving_1D_track_as_wig");
}
示例8: getIndicesFromSubChromosomes
import org.broad.igv.feature.Chromosome; //导入依赖的package包/类
private static List<Chromosome> getIndicesFromSubChromosomes(final ChromosomeHandler handler, Chromosome chromosome) {
final List<Chromosome> indices = new ArrayList<>();
if (handler.isCustomChromosome(chromosome)) {
GenomeWideList<MotifAnchor> regions = handler.getListOfRegionsInCustomChromosome(chromosome.getIndex());
regions.processLists(new FeatureFunction<MotifAnchor>() {
@Override
public void process(String chr, List<MotifAnchor> featureList) {
if (featureList.size() > 0) {
Chromosome chromosomeN = handler.getChromosomeFromName(chr);
if (chromosomeN != null) {
indices.add(chromosomeN);
}
}
}
});
} else {
indices.add(chromosome);
}
return indices;
}
示例9: stringToChromosomes
import org.broad.igv.feature.Chromosome; //导入依赖的package包/类
/**
* For each given chromosome name, find its equivalent Chromosome object
*
* @param chromosomesSpecified by strings
* @param handler as Chromosome objects
* @return the specified Chromosomes corresponding to the given strings
*/
public static ChromosomeHandler stringToChromosomes(Set<String> chromosomesSpecified,
ChromosomeHandler handler) {
List<Chromosome> chromosomes = new ArrayList<>();
chromosomes.add(0, null);
for (String strKey : chromosomesSpecified) {
boolean chrFound = false;
for (Chromosome chrKey : handler.getChromosomeArray()) {
if (equivalentChromosome(strKey, chrKey)) {
chromosomes.add(chrKey);
chrFound = true;
break;
}
}
if (!chrFound) {
System.err.println("Chromosome " + strKey + " not found");
}
}
return new ChromosomeHandler(chromosomes);
}
示例10: getEigenvector
import org.broad.igv.feature.Chromosome; //导入依赖的package包/类
public double[] getEigenvector(Chromosome chr, HiCZoom zoom, int number, NormalizationType type) {
String key = chr.getName() + "_" + zoom.getKey() + "_" + number + "_" + type;
if (!eigenvectorCache.containsKey(key)) {
double[] eigenvector;
//eigenvector = reader.readEigenvector(chr.getName(), zoom, number, type.toString());
ExpectedValueFunction df = getExpectedValues(zoom, type);
Matrix m = getMatrix(chr, chr);
MatrixZoomData mzd = m.getZoomData(zoom);
if (df != null && mzd.getPearsons(df) != null) {
eigenvector = mzd.computeEigenvector(df, number);
} else {
eigenvector = new double[0];
}
eigenvectorCache.put(key, eigenvector);
}
return eigenvectorCache.get(key);
}
示例11: extractAllAnchorsFromAllFeatures
import org.broad.igv.feature.Chromosome; //导入依赖的package包/类
public static GenomeWideList<MotifAnchor> extractAllAnchorsFromAllFeatures(Feature2DList features, final ChromosomeHandler handler) {
final GenomeWideList<MotifAnchor> extractedAnchorList = new GenomeWideList<>();
features.processLists(new FeatureFunction() {
@Override
public void process(String chr, List<Feature2D> feature2DList) {
for (Feature2D f : feature2DList) {
Chromosome chrom = handler.getChromosomeFromName((f.getChr1()));
extractedAnchorList.addFeature(chrom.getName(), new MotifAnchor(chrom.getIndex(), f.getStart1(), f.getEnd1()));
chrom = handler.getChromosomeFromName((f.getChr2()));
extractedAnchorList.addFeature(chrom.getName(), new MotifAnchor(chrom.getIndex(), f.getStart2(), f.getEnd2()));
}
}
});
mergeAndExpandSmallAnchors(extractedAnchorList, getMinSizeForExpansionFromGUI());
return extractedAnchorList;
}
示例12: 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));
}
}
}
示例13: getLocationMap
import org.broad.igv.feature.Chromosome; //导入依赖的package包/类
public static Map<String, GeneLocation> getLocationMap(BufferedReader reader, ChromosomeHandler handler) throws IOException {
Map<String, GeneLocation> geneLocationHashMap = new HashMap<>();
String nextLine;
while ((nextLine = reader.readLine()) != null) {
String[] values = nextLine.split("\\s+");
if (values.length == 4 || values.length == 16) { // 16 is refGene official format
// 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[1].trim();
String name2 = (values.length==4) ? values[0].trim() : values[12].trim();
Chromosome chr = handler.getChromosomeFromName(values[2]);
GeneLocation location = new GeneLocation(chr, txStart);
geneLocationHashMap.put(name2.toLowerCase(), location);
geneLocationHashMap.put(name.trim().toLowerCase(), location);
}
}
return geneLocationHashMap;
}
示例14: MatrixZoomDataPP
import org.broad.igv.feature.Chromosome; //导入依赖的package包/类
/**
* Representation of MatrixZoomData used for preprocessing
*
* @param chr1 index of first chromosome (x-axis)
* @param chr2 index of second chromosome
* @param binSize size of each grid bin in bp
* @param blockColumnCount number of block columns
* @param zoom integer zoom (resolution) level index. TODO Is this needed?
*/
MatrixZoomDataPP(Chromosome chr1, Chromosome chr2, int binSize, int blockColumnCount, int zoom, boolean isFrag) {
this.tmpFiles = new ArrayList<>();
this.blockNumbers = new HashSet<>(1000);
this.sum = 0;
this.chr1 = chr1;
this.chr2 = chr2;
this.binSize = binSize;
this.blockColumnCount = blockColumnCount;
this.zoom = zoom;
this.isFrag = isFrag;
// Get length in proper units
Chromosome longChr = chr1.getLength() > chr2.getLength() ? chr1 : chr2;
int len = isFrag ? fragmentCalculation.getNumberFragments(longChr.getName()) : longChr.getLength();
int nBinsX = len / binSize + 1;
blockBinCount = nBinsX / blockColumnCount + 1;
blocks = new LinkedHashMap<>(blockColumnCount * blockColumnCount);
}
示例15: addDistance
import org.broad.igv.feature.Chromosome; //导入依赖的package包/类
/**
* Add an observed distance. This is called for each pair in the data set
*
* @param chrIdx index of chromosome where observed, so can increment count
* @param bin1 Position1 observed in units of "bins"
* @param bin2 Position2 observed in units of "bins"
*/
public void addDistance(Integer chrIdx, int bin1, int bin2, double weight) {
// Ignore NaN values TODO -- is this the right thing to do?
if (Double.isNaN(weight)) return;
int dist;
Chromosome chr = chromosomesMap.get(chrIdx);
if (chr == null) return;
Double count = chromosomeCounts.get(chrIdx);
if (count == null) {
chromosomeCounts.put(chrIdx, weight);
} else {
chromosomeCounts.put(chrIdx, count + weight);
}
dist = Math.abs(bin1 - bin2);
actualDistances[dist] += weight;
}