/** * Initialize the object with the given values. * * @param refDict * the {@link ReferenceDictionary} to use in this object * @param transcriptModels * the list of {@link TranscriptModel} objects to use in this object */ public JannovarData(ReferenceDictionary refDict, ImmutableList<TranscriptModel> transcriptModels) { this.refDict = refDict; this.chromosomes = makeChromsomes(refDict, transcriptModels); this.tmByAccession = makeTMByAccession(transcriptModels); this.tmByGeneSymbol = makeTMByGeneSymbol(transcriptModels); }
/** * Deserialize the transcript definition file from {@link pathToDataFile}. * * @param pathToDataFile * String with the path to the data file to deserialize * @throws JannovarException * when there is a problem with the deserialization * @throws HelpRequestedException * when the user requested the help page */ protected void deserializeTranscriptDefinitionFile(String pathToDataFile) throws JannovarException, HelpRequestedException { this.jannovarData = new JannovarDataSerializer(pathToDataFile).load(); this.refDict = this.jannovarData.getRefDict(); this.chromosomeMap = this.jannovarData.getChromosomes(); }
public static ReferenceDictionary build() { ReferenceDictionaryBuilder builder = new ReferenceDictionaryBuilder(); builder.putContigLength(1, 249250621); builder.putContigLength(2, 243199373); builder.putContigLength(3, 198022430); builder.putContigLength(4, 191154276); builder.putContigLength(5, 180915260); builder.putContigLength(6, 171115067); builder.putContigLength(7, 159138663); builder.putContigLength(8, 146364022); builder.putContigLength(9, 141213431); builder.putContigLength(10, 135534747); builder.putContigLength(11, 135006516); builder.putContigLength(12, 133851895); builder.putContigLength(13, 115169878); builder.putContigLength(14, 107349540); builder.putContigLength(15, 102531392); builder.putContigLength(16, 90354753); builder.putContigLength(17, 81195210); builder.putContigLength(18, 78077248); builder.putContigLength(19, 59128983); builder.putContigLength(20, 63025520); builder.putContigLength(21, 48129895); builder.putContigLength(22, 51304566); builder.putContigLength(23, 155270560); builder.putContigLength(24, 59373566); builder.putContigLength(25, 16571); builder.putContigName(i, "" + i);
/** Map contig name (from genome variant) to contig name in FASTA */ private String mapContigToFasta(String contigName) { // Map genome variant's contig to unique ID Integer contigID = jannovarData.getRefDict().getContigNameToID().get(contigName); if (contigID == null) throw new UncheckedJannovarException("Unknown contig name " + contigName); // Try to find matching contig in fasta String nameInFasta = null; for (SAMSequenceRecord record : indexedFile.getSequenceDictionary().getSequences()) { if (jannovarData.getRefDict().getContigNameToID().containsKey(record.getSequenceName())) { String contigInFasta = record.getSequenceName(); if (jannovarData.getRefDict().getContigNameToID().get(contigInFasta) == contigID) { nameInFasta = contigInFasta; break; } } } if (nameInFasta == null) throw new UncheckedJannovarException("Could not find corresponding contig in FASTA for " + contigName); return nameInFasta; }
private static JannovarProto.ReferenceDictionary toProtoReferenceDictionary(ReferenceDictionary referenceDictionary) { return JannovarProto.ReferenceDictionary.newBuilder() .putAllContigNameToId(referenceDictionary.getContigNameToID()) .putAllContigIdToLength(referenceDictionary.getContigIDToLength()) .putAllContigIdToName(referenceDictionary.getContigIDToName()) .build(); }
public JannovarAnnotationService(JannovarData jannovarData) { this.referenceDictionary = jannovarData.getRefDict(); this.variantAnnotator = new VariantAnnotator(jannovarData.getRefDict(), jannovarData.getChromosomes(), new AnnotationBuilderOptions()); }
/** * @return String representation of name of chromosome, e.g., <code>"chr2"</code> */ public String getChromosomeName() { return refDict.getContigIDToName().get(chrID); }
private Integer getIntValueOfChromosomeOrZero(String contig) { return referenceDictionary.getContigNameToID().getOrDefault(contig, UNKNOWN_CHROMOSOME); }
private static ReferenceDictionary toReferenceDictionary(JannovarProto.ReferenceDictionary protoRefDict) { ReferenceDictionaryBuilder referenceDictionaryBuilder = new ReferenceDictionaryBuilder(); protoRefDict.getContigNameToIdMap().forEach(referenceDictionaryBuilder::putContigID); protoRefDict.getContigIdToNameMap().forEach(referenceDictionaryBuilder::putContigName); protoRefDict.getContigIdToLengthMap().forEach(referenceDictionaryBuilder::putContigLength); return referenceDictionaryBuilder.build(); }
@Bean public JannovarData jannovarData() { logger.info("Stubbing Jannovar data"); return new JannovarData(HG19RefDictBuilder.build(), ImmutableList.of()); }
/** construct genome position from other with the selected strand */ public GenomePosition(GenomePosition other, Strand strand) { this.refDict = other.refDict; this.strand = strand; this.chr = other.chr; // transform coordinate system if (strand == other.strand) this.pos = other.pos; else this.pos = refDict.getContigIDToLength().get(other.chr) - other.pos - 1; }
/** * @return instance of immutable ReferenceDictionary object */ public ReferenceDictionary build() { return new ReferenceDictionary(contigID.build(), contigName.build(), contigLength.build()); }
/** * Add a contig name to numeric ID mapping to builder. * * @param name * contig name * @param id * numeric contig ID */ public void putContigID(String name, int id) { if (getContigID(name) != null) return; tmpContigID.put(name, id); contigID.put(name, id); }
/** Map contig name (from genome variant) to contig name in FASTA */ private String mapContigToFasta(String contigName) { // Map genome variant's contig to unique ID Integer contigID = jannovarData.getRefDict().getContigNameToID().get(contigName); if (contigID == null) throw new UncheckedJannovarException("Unknown contig name " + contigName); // Try to find matching contig in fasta String nameInFasta = null; for (SAMSequenceRecord record : fasta.getSequenceDictionary().getSequences()) { if (jannovarData.getRefDict().getContigNameToID().containsKey(record.getSequenceName())) { nameInFasta = record.getSequenceName(); break; } } if (nameInFasta == null) throw new UncheckedJannovarException("Could not find corresponding contig in FASTA for " + contigName); return nameInFasta; }
@Override public String getChrName() { return this.pos.getRefDict().getContigIDToName().get(this.pos.getChr()); }
public static JannovarData toJannovarData(JannovarProto.JannovarData protoJannovarData) { logger.debug("Converting to jannovar data..."); ReferenceDictionary referenceDictionary = toReferenceDictionary(protoJannovarData.getReferenceDictionary()); ImmutableList<TranscriptModel> transcriptModels = protoJannovarData.getTranscriptModelsList() .parallelStream() .map(toTranscriptModel(referenceDictionary)) .collect(ImmutableList.toImmutableList()); logger.debug("Done"); return new JannovarData(referenceDictionary, transcriptModels); }
/** construct genome interval from other with selected strand */ public GenomeInterval(GenomeInterval other, Strand strand) { this.refDict = other.refDict; this.strand = strand; this.chr = other.chr; // transform coordinate system if (strand == other.strand) { this.beginPos = other.beginPos; this.endPos = other.endPos; } else { int beginPos = refDict.getContigIDToLength().get(other.chr) - other.beginPos; int endPos = refDict.getContigIDToLength().get(other.chr) - other.endPos; this.endPos = beginPos; this.beginPos = endPos; } }
/** * @return <code>true</code> if <code>gene</code> is affected by <code>variantContext</code> */ private boolean isGeneAffectedByChange(Gene gene, VariantContext vc) { final ReferenceDictionary refDict = jannovarData.getRefDict(); final int contigID = refDict.getContigNameToID().get(vc.getContig()); final GenomeInterval changeInterval = new GenomeInterval(refDict, Strand.FWD, contigID, vc.getStart() - 1, vc.getEnd()); if (changeInterval.length() == 0 && gene.getRegion().contains(changeInterval.getGenomeBeginPos()) && gene.getRegion().contains(changeInterval.getGenomeBeginPos().shifted(-1))) return false; else if (changeInterval.length() != 0 && gene.getRegion().overlapsWith(changeInterval)) return true; else return false; }
@Override public String toString() { if (strand.isReverse()) return withStrand(Strand.FWD).toString(); return StringUtil.concatenate(refDict.getContigIDToName().get(chr), ":g.", beginPos + 1, "_", endPos); }
@Override public String toString() { if (strand.isReverse()) return withStrand(Strand.FWD).toString(); return StringUtil.concatenate(refDict.getContigIDToName().get(chr), ":g.", pos + 1); }