/** * @return String representation of name of chromosome, e.g., <code>"chr2"</code> */ public String getChromosomeName() { return refDict.getContigIDToName().get(chrID); }
@Override public String getChrName() { return this.pos.getRefDict().getContigIDToName().get(this.pos.getChr()); }
/** * This function constructs a HashMap<Byte,Chromosome> map of Chromosome objects in which the {@link TranscriptModel} * objects are entered into an {@link IntervalArray} for the appropriate Chromosome. * * @param refDict * the {@link ReferenceDictionary} to use for the construction * @param transcriptModels * list of {@link TranscriptModel} objects with the transcripts of all chromosomes * @return a mapping from numeric chromsome ID to {@link Chromosome} object */ private static ImmutableMap<Integer, Chromosome> makeChromsomes(ReferenceDictionary refDict, ImmutableList<TranscriptModel> transcriptModels) { ImmutableMap.Builder<Integer, Chromosome> builder = new ImmutableMap.Builder<Integer, Chromosome>(); // First, factorize the TranscriptModel objects by chromosome ID. // create hash map for this HashMap<Integer, ArrayList<TranscriptModel>> transcripts = new HashMap<Integer, ArrayList<TranscriptModel>>(); for (Integer chrID : refDict.getContigIDToName().keySet()) transcripts.put(chrID, new ArrayList<TranscriptModel>()); // distribute TranscriptModel lists for (TranscriptModel transcript : transcriptModels) transcripts.get(transcript.getChr()).add(transcript); // Then, construct an interval tree for each chromosome and add the lists of intervals. for (Integer chrID : transcripts.keySet()) { IntervalArray<TranscriptModel> iTree = new IntervalArray<TranscriptModel>(transcripts.get(chrID), new TranscriptIntervalEndExtractor()); builder.put(chrID, new Chromosome(refDict, chrID, iTree)); } return builder.build(); }
@Override public String toString() { if (strand.isReverse()) return withStrand(Strand.FWD).toString(); return StringUtil.concatenate(refDict.getContigIDToName().get(chr), ":g.", pos + 1); }
@Override public String toString() { if (strand.isReverse()) return withStrand(Strand.FWD).toString(); return StringUtil.concatenate(refDict.getContigIDToName().get(chr), ":g.", beginPos + 1, "_", endPos); }
/** * Load sequence from the given <code>region</code> from {@link #indexedFile} * * @param region * {@link GenomeInterval} to load sequence for * @return String with the selected sequenced loaded from {@link #indexedFile}. */ public String load(GenomeInterval region) { region = region.withStrand(Strand.FWD); String contigName = region.getRefDict().getContigIDToName().get(region.getChr()); contigName = mapContigToFasta(contigName); ReferenceSequence seq = indexedFile.getSubsequenceAt(contigName, region.getBeginPos() + 1, region.getEndPos()); return new String(seq.getBases()); }
private static JannovarProto.ReferenceDictionary toProtoReferenceDictionary(ReferenceDictionary referenceDictionary) { return JannovarProto.ReferenceDictionary.newBuilder() .putAllContigNameToId(referenceDictionary.getContigNameToID()) .putAllContigIdToLength(referenceDictionary.getContigIDToLength()) .putAllContigIdToName(referenceDictionary.getContigIDToName()) .build(); }