private SortedDictionary <int, HashSet <TranscriptMetadata> > GetTranscriptsByEntrezGeneId(IEnumerable <MutableTranscript> transcripts) { var genes = new SortedDictionary <int, HashSet <TranscriptMetadata> >(); foreach (var transcript in transcripts) { string idWithVersion = transcript.Id + '.' + transcript.Version; int cdsLength = transcript.CodingRegion?.Length ?? 0; int transcriptLength = transcript.End - transcript.Start + 1; bool isLrg = _lrgTranscriptIds.Contains(transcript.Id); int accession = AccessionUtilities.GetAccessionNumber(transcript.Id); var metadata = new TranscriptMetadata(idWithVersion, accession, transcriptLength, cdsLength, isLrg); int geneId = ConvertGeneIdToInt(transcript.Gene.GeneId); if (genes.TryGetValue(geneId, out var observedMetadata)) { observedMetadata.Add(metadata); } else { genes[geneId] = new HashSet <TranscriptMetadata> { metadata } }; } return(genes); }
public void GetAccessionNumber_ReturnNumber_Ensembl() { const int expectedResult = 515242; var observedResult = AccessionUtilities.GetAccessionNumber("ENST00000515242"); Assert.Equal(expectedResult, observedResult); }
public void GetAccessionNumber_ReturnMinusOne() { const int expectedResult = -1; var observedResult = AccessionUtilities.GetAccessionNumber(null); Assert.Equal(expectedResult, observedResult); }
public void GetAccessionNumber_ReturnNumber_RefSeq() { const int expectedResult = 4522; var observedResult = AccessionUtilities.GetAccessionNumber("NM_004522"); Assert.Equal(expectedResult, observedResult); }
public void GetAccessionNumber_ThrowException_IfUnderlineMissingRefSeq() { Assert.Throws <InvalidDataException>(delegate { // ReSharper disable once UnusedVariable var observedResult = AccessionUtilities.GetAccessionNumber("NM004522"); }); }