/// <summary> /// calculates the cDNA coordinates given the specified genomic coordinates [Transcript.pm:927 cdna_coding_start] /// genomic2pep [TransciptMapper:482] /// </summary> public static void GetCodingDnaEndpoints(CdnaCoordinateMap[] cdnaMaps, int genomicBegin, int genomicEnd, out int cdnaBegin, out int cdnaEnd) { // find an overlapping mapper pair var coordinateMap = CdnaCoordinateMap.Null(); bool foundOverlap = false; for (int i = 0; i < cdnaMaps.Length; i++) { coordinateMap = cdnaMaps[i]; if (genomicEnd >= coordinateMap.GenomicStart && genomicBegin <= coordinateMap.GenomicEnd) { foundOverlap = true; break; } } if (!foundOverlap) { throw new GeneralException($"Unable to find an overlapping mapping pair for these genomic coordinates: ({genomicBegin}, {genomicEnd})"); } // calculate the cDNA position cdnaBegin = coordinateMap.CdnaEnd - (genomicEnd - coordinateMap.GenomicStart); cdnaEnd = coordinateMap.CdnaEnd - (genomicBegin - coordinateMap.GenomicStart); }
/// <summary> /// sets both the exon and intron number strings according to which were affected by the variant [BaseTranscriptVariation.pm:474 _exon_intron_number] /// </summary> public static void ExonIntronNumber(CdnaCoordinateMap[] cdnaMaps, SimpleInterval[] introns, bool onReverseStrand, TranscriptAnnotation ta, out string exonNumber, out string intronNumber) { int exonCount = 0; var altAllele = ta.AlternateAllele; var variantInterval = new AnnotationInterval(altAllele.Start, altAllele.End); var overlappedExons = new List <int>(); var overlappedIntrons = new List <int>(); var prevExon = CdnaCoordinateMap.Null(); foreach (var exon in cdnaMaps) { exonCount++; if (variantInterval.Overlaps(exon.GenomicStart, exon.GenomicEnd)) { overlappedExons.Add(exonCount); } if (!prevExon.IsNull) { int intronStart = prevExon.GenomicEnd + 1; int intronEnd = exon.GenomicStart - 1; if (variantInterval.Overlaps(intronStart, intronEnd)) { overlappedIntrons.Add(exonCount - 1); } } prevExon = exon; } exonNumber = GetExonIntronNumber(overlappedExons, cdnaMaps.Length, onReverseStrand); intronNumber = introns != null?GetExonIntronNumber(overlappedIntrons, introns.Length, onReverseStrand) : null; if (overlappedExons.Count > 0) { ta.HasExonOverlap = true; } }