internal static List <T> FlattenWithSameId <T>(List <T> genes) where T : IFlatGene <T> { if (genes == null || genes.Count == 1) { return(genes); } var flatGenes = new List <T>(); var seedGene = genes[0].Clone(); foreach (var gene in genes) { if (IntervalUtilities.Overlaps(seedGene.Start, seedGene.End, gene.Start, gene.End)) { seedGene.End = Math.Max(seedGene.End, gene.End); continue; } flatGenes.Add(seedGene); seedGene = gene.Clone(); } flatGenes.Add(seedGene); return(flatGenes); }
internal static bool IsBeforeCoding(int variantRefBegin, int variantRefEnd, int transcriptStart, int codingRegionStart) { // special case to handle insertions before the CDS start if (variantRefBegin == variantRefEnd + 1 && variantRefBegin == codingRegionStart) { return(true); } bool result = IntervalUtilities.Overlaps(variantRefBegin, variantRefEnd, transcriptStart, codingRegionStart - 1); return(result); }
internal static bool IsAfterCoding(int variantRefBegin, int variantRefEnd, int transcriptEnd, int codingRegionEnd) { // special case to handle insertions after the CDS end if (variantRefBegin == variantRefEnd + 1 && variantRefEnd == codingRegionEnd) { return(true); } var result = IntervalUtilities.Overlaps(variantRefBegin, variantRefEnd, codingRegionEnd + 1, transcriptEnd); return(result); }
private static void ReplaceHgncIds(IEnumerable <MutableGene> genes, IReadOnlyDictionary <string, HgncGene> geneIdToHgncGene) { foreach (var gene in genes) { gene.HgncId = -1; if (!geneIdToHgncGene.TryGetValue(gene.GeneId, out var hgncGene)) { continue; } if (!IntervalUtilities.Overlaps(hgncGene.Start, hgncGene.End, gene.Start, gene.End)) { continue; } gene.HgncId = hgncGene.HgncId; } }
private static void AddCoordinatesFromMultipleGenes(HgncGene hgncGene, EnsemblGene ensemblGene, IEnumerable <RefSeqGene> refSeqGenes) { if (ensemblGene == null) { return; } AddCoordinatesFromGene(hgncGene, ensemblGene); foreach (var refSeqGene in refSeqGenes) { if (!IntervalUtilities.Overlaps(hgncGene.Start, hgncGene.End, refSeqGene.Start, refSeqGene.End)) { continue; } AddCoordinatesFromGene(hgncGene, refSeqGene); } }
public void Overlaps_Theory(int start1, int end1, int start2, int end2, bool expectedResult) { var observedResult = IntervalUtilities.Overlaps(start1, end1, start2, end2); Assert.Equal(expectedResult, observedResult); }