public void GetAnnotatedTranscripts_ReturnEmptyList() { var variant = new Mock <IVariant>(); var transcript1 = new Mock <ITranscript>(); var transcript2 = new Mock <ITranscript>(); var transcripts = new[] { transcript1.Object, transcript2.Object }; variant.SetupGet(x => x.Behavior).Returns(new AnnotationBehavior(true, false, false, true, false)); variant.SetupGet(x => x.Start).Returns(123456); variant.SetupGet(x => x.End).Returns(123456); transcript1.SetupGet(x => x.Id).Returns(CompactId.Convert("NR_046018.2")); transcript1.SetupGet(x => x.Start).Returns(108455); transcript1.SetupGet(x => x.End).Returns(118455); transcript1.SetupGet(x => x.Gene.Start).Returns(108455); transcript1.SetupGet(x => x.Gene.End).Returns(118455); transcript2.SetupGet(x => x.Id).Returns(CompactId.Convert("NR_106918.1")); transcript2.SetupGet(x => x.Start).Returns(128460); transcript2.SetupGet(x => x.End).Returns(129489); transcript2.SetupGet(x => x.Gene.Start).Returns(128460); transcript2.SetupGet(x => x.Gene.End).Returns(129489); var compressedSequence = new Mock <ISequence>(); var observedAnnotatedTranscripts = TranscriptAnnotationFactory.GetAnnotatedTranscripts(variant.Object, transcripts, compressedSequence.Object, null, null); Assert.Empty(observedAnnotatedTranscripts); }
public void GetAnnotatedTranscripts_RohAnnotation_ReturnsCanonicalOnly() { var variant = new Mock <IVariant>(); var transcript1 = new Mock <ITranscript>(); var transcript2 = new Mock <ITranscript>(); var transcripts = new[] { transcript1.Object, transcript2.Object }; variant.SetupGet(x => x.Behavior).Returns(AnnotationBehavior.RohBehavior); variant.SetupGet(x => x.Start).Returns(10000); variant.SetupGet(x => x.End).Returns(20000); transcript1.SetupGet(x => x.Id).Returns(CompactId.Convert("NM_123.1")); transcript1.SetupGet(x => x.Start).Returns(11000); transcript1.SetupGet(x => x.End).Returns(15000); transcript1.SetupGet(x => x.IsCanonical).Returns(true); transcript2.SetupGet(x => x.Id).Returns(CompactId.Convert("NM_456.2")); transcript2.SetupGet(x => x.Start).Returns(11000); transcript2.SetupGet(x => x.End).Returns(15000); transcript2.SetupGet(x => x.IsCanonical).Returns(false); var observedAnnotatedTranscripts = TranscriptAnnotationFactory.GetAnnotatedTranscripts(variant.Object, transcripts, null, null, null); Assert.Single(observedAnnotatedTranscripts); Assert.Equal("NM_123", observedAnnotatedTranscripts[0].Transcript.Id.WithVersion); }
public void refSeq_gene_return_entrezId() { var mockedTranscript = new Mock <ITranscript>(); mockedTranscript.Setup(x => x.Source).Returns(Source.RefSeq); mockedTranscript.Setup(x => x.Gene.EntrezGeneId.ToString()).Returns("12345"); mockedTranscript.Setup(x => x.Gene.Symbol).Returns("TestGene"); mockedTranscript.Setup(x => x.Id).Returns(CompactId.Convert("NM_124")); mockedTranscript.Setup(x => x.Version).Returns(1); mockedTranscript.Setup(x => x.Translation.ProteinId).Returns(CompactId.Convert("NP_342")); mockedTranscript.Setup(x => x.Translation.ProteinVersion).Returns(2); var mappedPosition = new Mock <IMappedPositions>(); mappedPosition.Setup(x => x.ProteinInterval).Returns(new NullableInterval(100, 101)); var transcript = new PianoAnnotatedTranscript(mockedTranscript.Object, "AT", "GR", mappedPosition.Object, "KILGF", "ATYRGD", new List <ConsequenceTag> { ConsequenceTag.missense_variant, ConsequenceTag.splice_region_variant }); var expectedOut = "TestGene 12345 NM_124.1 NP_342.2 100-101 KILGF AT/GR ATYRGD missense_variant,splice_region_variant"; Assert.Equal(expectedOut, transcript.ToString()); }
public void Empty_upstreamAminoAcids_return_dot() { var mockedTranscript = new Mock <ITranscript>(); mockedTranscript.Setup(x => x.Source).Returns(Source.Ensembl); mockedTranscript.Setup(x => x.Gene.EnsemblId.ToString()).Returns("ENSG12345"); mockedTranscript.Setup(x => x.Gene.Symbol).Returns("TestGene"); mockedTranscript.Setup(x => x.Id).Returns(CompactId.Convert("ENST124")); mockedTranscript.Setup(x => x.Version).Returns(1); mockedTranscript.Setup(x => x.Translation.ProteinId).Returns(CompactId.Convert("ENSP123456")); mockedTranscript.Setup(x => x.Translation.ProteinVersion).Returns(2); var mappedPosition = new Mock <IMappedPositions>(); mappedPosition.Setup(x => x.ProteinInterval).Returns(new NullableInterval(100, 100)); var transcript = new PianoAnnotatedTranscript(mockedTranscript.Object, "A", "R", mappedPosition.Object, "", "ATYRGD", new List <ConsequenceTag> { ConsequenceTag.missense_variant }); var expectedOut = "TestGene ENSG12345 ENST124.1 ENSP123456.2 100 . A/R ATYRGD missense_variant"; Assert.Equal(expectedOut, transcript.ToString()); }
public void Translation_EndToEnd() { ICodingRegion expectedCodingRegion = new CodingRegion(100, 200, 300, 400, 101); const string expectedProteinId = "ENSP00000446475.7"; const string expectedPeptideSeq = "VEIDSD"; string[] peptideSeqs = { expectedPeptideSeq }; ITranslation expectedTranslation = new Translation(expectedCodingRegion, CompactId.Convert(expectedProteinId, 7), expectedPeptideSeq); ITranslation observedTranslation; using (var ms = new MemoryStream()) { using (var writer = new ExtendedBinaryWriter(ms, Encoding.UTF8, true)) { expectedTranslation.Write(writer, 0); } ms.Position = 0; using (var reader = new BufferedBinaryReader(ms)) { observedTranslation = Translation.Read(reader, peptideSeqs); } } Assert.NotNull(observedTranslation); Assert.Equal(expectedCodingRegion.CdnaStart, observedTranslation.CodingRegion.CdnaStart); Assert.Equal(expectedProteinId, observedTranslation.ProteinId.WithVersion); Assert.Equal(expectedPeptideSeq, observedTranslation.PeptideSeq); }
public void CompactId_IO_EndToEnd() { const string expectedResults = "ENSP00000334393.3"; var id = CompactId.Convert("ENSP00000334393", 3); ICompactId observedId; using (var ms = new MemoryStream()) { using (var writer = new ExtendedBinaryWriter(ms, Encoding.UTF8, true)) { id.Write(writer); } ms.Position = 0; using (var reader = new BufferedBinaryReader(ms)) { observedId = CompactId.Read(reader); } } Assert.NotNull(observedId); Assert.Equal(expectedResults, observedId.WithVersion); }
internal static ITranscript GetReverseTranscript() { // get info from "ENST00000423372.3 var regions = new ITranscriptRegion[] { new TranscriptRegion(TranscriptRegionType.Exon, 2, 134901, 135802, 1760, 2661), new TranscriptRegion(TranscriptRegionType.Intron, 1, 135803, 137620, 1759, 1760), new TranscriptRegion(TranscriptRegionType.Exon, 1, 137621, 139379, 1, 1759) }; var translation = new Mock <ITranslation>(); translation.SetupGet(x => x.CodingRegion).Returns(new CodingRegion(138530, 139309, 71, 850, 780)); var transcript = new Mock <ITranscript>(); transcript.SetupGet(x => x.Id).Returns(CompactId.Convert("ENST00000423372", 3)); transcript.SetupGet(x => x.Chromosome).Returns(Chromosome); transcript.SetupGet(x => x.Start).Returns(134901); transcript.SetupGet(x => x.End).Returns(139379); transcript.SetupGet(x => x.Gene.OnReverseStrand).Returns(true); transcript.SetupGet(x => x.TranscriptRegions).Returns(regions); transcript.SetupGet(x => x.Translation).Returns(translation.Object); transcript.SetupGet(x => x.TotalExonLength).Returns(2661); return(transcript.Object); }
internal static ITranscript GetForwardTranscript() { // get info from ENST00000343938.4 var regions = new ITranscriptRegion[] { new TranscriptRegion(TranscriptRegionType.Exon, 1, 1260147, 1260482, 1, 336), new TranscriptRegion(TranscriptRegionType.Intron, 1, 1260483, 1262215, 336, 337), new TranscriptRegion(TranscriptRegionType.Exon, 2, 1262216, 1262412, 337, 533), new TranscriptRegion(TranscriptRegionType.Intron, 2, 1262413, 1262620, 533, 534), new TranscriptRegion(TranscriptRegionType.Exon, 3, 1262621, 1264277, 534, 2190) }; var translation = new Mock <ITranslation>(); translation.SetupGet(x => x.CodingRegion).Returns(new CodingRegion(1262291, 1263143, 412, 1056, 645)); var transcript = new Mock <ITranscript>(); transcript.SetupGet(x => x.Id).Returns(CompactId.Convert("ENST00000343938", 4)); transcript.SetupGet(x => x.Chromosome).Returns(Chromosome); transcript.SetupGet(x => x.Start).Returns(1260147); transcript.SetupGet(x => x.End).Returns(1264277); transcript.SetupGet(x => x.Gene.OnReverseStrand).Returns(false); transcript.SetupGet(x => x.TranscriptRegions).Returns(regions); transcript.SetupGet(x => x.Translation).Returns(translation.Object); transcript.SetupGet(x => x.TotalExonLength).Returns(2190); return(transcript.Object); }
public void GetAnnotatedTranscripts_ReturnEmptyList() { var variant = new Mock <IVariant>(); var transcript1 = new Mock <ITranscript>(); var transcript2 = new Mock <ITranscript>(); ITranscript[] transcripts = { transcript1.Object, transcript2.Object }; variant.SetupGet(x => x.Behavior).Returns(AnnotationBehavior.SmallVariants); variant.SetupGet(x => x.Chromosome.FlankingLength).Returns(Chromosome.ShortFlankingLength); variant.SetupGet(x => x.Start).Returns(123456); variant.SetupGet(x => x.End).Returns(123456); transcript1.SetupGet(x => x.Id).Returns(CompactId.Convert("NR_046018.2")); transcript1.SetupGet(x => x.Start).Returns(108455); transcript1.SetupGet(x => x.End).Returns(118455); transcript1.SetupGet(x => x.Gene.Start).Returns(108455); transcript1.SetupGet(x => x.Gene.End).Returns(118455); transcript2.SetupGet(x => x.Id).Returns(CompactId.Convert("NR_106918.1")); transcript2.SetupGet(x => x.Start).Returns(128460); transcript2.SetupGet(x => x.End).Returns(129489); transcript2.SetupGet(x => x.Gene.Start).Returns(128460); transcript2.SetupGet(x => x.Gene.End).Returns(129489); var compressedSequence = new Mock <ISequence>(); IList <IAnnotatedTranscript> observedAnnotatedTranscripts = TranscriptAnnotationFactory.GetAnnotatedTranscripts(variant.Object, transcripts, compressedSequence.Object, null, null); Assert.Empty(observedAnnotatedTranscripts); }
public void GetAnnotatedTranscripts_RohAnnotation_ReturnsCanonicalOnly() { var variant = new Mock <IVariant>(); var transcript1 = new Mock <ITranscript>(); var transcript2 = new Mock <ITranscript>(); ITranscript[] transcripts = { transcript1.Object, transcript2.Object }; variant.SetupGet(x => x.Behavior).Returns(AnnotationBehavior.RunsOfHomozygosity); variant.SetupGet(x => x.Chromosome.FlankingLength).Returns(Chromosome.ShortFlankingLength); variant.SetupGet(x => x.Start).Returns(10000); variant.SetupGet(x => x.End).Returns(20000); transcript1.SetupGet(x => x.Id).Returns(CompactId.Convert("NM_123.1")); transcript1.SetupGet(x => x.Start).Returns(11000); transcript1.SetupGet(x => x.End).Returns(15000); transcript1.SetupGet(x => x.IsCanonical).Returns(true); transcript2.SetupGet(x => x.Id).Returns(CompactId.Convert("NM_456.2")); transcript2.SetupGet(x => x.Start).Returns(11000); transcript2.SetupGet(x => x.End).Returns(15000); transcript2.SetupGet(x => x.IsCanonical).Returns(false); IList <IAnnotatedTranscript> observedAnnotatedTranscripts = TranscriptAnnotationFactory.GetAnnotatedTranscripts(variant.Object, transcripts, null, null, null); Assert.Single(observedAnnotatedTranscripts); Assert.Equal("NM_123", observedAnnotatedTranscripts[0].Transcript.Id.WithVersion); }
public void CombineIdAndVersion() { const string expectedResult = "ENSG00000141510.7"; var id = CompactId.Convert("ENSG00000141510"); var observedResult = FormatUtilities.CombineIdAndVersion(id, 7); Assert.Equal(expectedResult, observedResult); }
private List <MutableGene> GetSrgap2CRefSeqGenes() { ushort refIndex = 0; var geneId = CompactId.Convert("653464"); var symbol = "SRGAP2C"; var hgncId = -1; var transcriptSource = TranscriptDataSource.RefSeq; return(new List <MutableGene> { new MutableGene { ReferenceIndex = refIndex, Start = 120835810, End = 120838261, OnReverseStrand = true, Symbol = symbol, HgncId = hgncId, EntrezGeneId = geneId, TranscriptDataSource = transcriptSource }, new MutableGene { ReferenceIndex = refIndex, Start = 121107154, End = 121131061, OnReverseStrand = false, Symbol = symbol, HgncId = hgncId, EntrezGeneId = geneId, TranscriptDataSource = transcriptSource } }); }
private static List <MutableGene> GetSh3RefSeqGenes() { ushort refIndex = 1; var geneId = CompactId.Convert("344558"); var symbol = "SH3RF3"; var hgncId = -1; var transcriptSource = TranscriptDataSource.RefSeq; return(new List <MutableGene> { new MutableGene { ReferenceIndex = refIndex, Start = 109745997, End = 110107395, OnReverseStrand = false, Symbol = symbol, HgncId = hgncId, EntrezGeneId = geneId, TranscriptDataSource = transcriptSource }, new MutableGene { ReferenceIndex = refIndex, Start = 110259067, End = 110262207, OnReverseStrand = false, Symbol = symbol, HgncId = hgncId, EntrezGeneId = geneId, TranscriptDataSource = transcriptSource } }); }
public void CombineIdAndVersion(string id, byte version, string expectedVersion) { var compactId = CompactId.Convert(id); var observedVersion = FormatUtilities.CombineIdAndVersion(compactId, version); Assert.Equal(expectedVersion, observedVersion); }
public void Convert_Unknown() { var id = CompactId.Convert("ABC123"); Assert.True(id.IsEmpty()); Assert.Null(id.WithVersion); }
public void regulatory_region_is_added() { var mockedRegulatory = new Mock <IAnnotatedRegulatoryRegion>(); mockedRegulatory.SetupGet(x => x.Consequences).Returns(new List <ConsequenceTag> { ConsequenceTag.regulatory_region_variant }); mockedRegulatory.SetupGet(x => x.RegulatoryRegion.Id).Returns(CompactId.Convert("ENSR12345")); var vcfFields = "chr1 101 sa123 A . . . . .".Split("\t"); var chrom = new Chromosome("chr1", "1", 0); var inforData = new InfoData(null, null, VariantType.SNV, null, null, null, null, null, false, null, null, false, false, "Test=abc", null, null); var position = new Position(chrom, 101, 101, "A", new[] { "." }, 100, null, null, null, inforData, vcfFields, new[] { false }, false); var variant = new Variant(chrom, 101, 101, "A", ".", VariantType.reference, null, false, false, false, null, null, new AnnotationBehavior(true, false, false, true, false, false)); var annotatedVariant = new AnnotatedVariant(variant); annotatedVariant.RegulatoryRegions.Add(mockedRegulatory.Object); IAnnotatedVariant[] annotatedVariants = { annotatedVariant }; var annotatedPosition = new AnnotatedPosition(position, annotatedVariants); var converter = new VcfConversion(); var observedVcf = converter.Convert(annotatedPosition).Split("\t")[VcfCommon.InfoIndex]; Assert.Equal("Test=abc;CSQR=1|ENSR12345|regulatory_region_variant", observedVcf); }
public RegulatoryRegion(IChromosome chromosome, int start, int end, CompactId id, RegulatoryRegionType type) { Id = id; Type = type; Start = start; End = end; Chromosome = chromosome; }
public void Convert_OnlyNumbers_ThrowException_NumberTooLarge() { Assert.Throws <ArgumentOutOfRangeException>(delegate { // ReSharper disable once UnusedVariable var id = CompactId.Convert("268435456"); }); }
public void IsPredictedTranscript_ReturnsTrue() { var id = CompactId.Convert("XM_005244780", 1); var id2 = CompactId.Convert("XR_005244780", 1); Assert.True(id.IsPredictedTranscript()); Assert.True(id2.IsPredictedTranscript()); }
/// <summary> /// parses the relevant data from each regulatory element /// </summary> public static IRegulatoryRegion Parse(ObjectValueNode objectValue, IChromosome chromosome) { int start = -1; int end = -1; string stableId = null; string type = null; foreach (var node in objectValue.Values) { // sanity check: make sure we know about the keys are used for if (!KnownKeys.Contains(node.Key)) { throw new InvalidDataException($"Encountered an unknown key in the dumper regulatory element object: {node.Key}"); } switch (node.Key) { case ImportKeys.AnalysisId: case ImportKeys.BoundLengths: case ImportKeys.CellTypeCount: case ImportKeys.CellTypes: case ImportKeys.DbId: case ImportKeys.DisplayLabel: case ImportKeys.EpigenomeCount: case ImportKeys.HasEvidence: case ImportKeys.Projected: case ImportKeys.RegulatoryBuildId: case ImportKeys.Set: case ImportKeys.Strand: case ImportKeys.Slice: case ImportKeys.VepFeatureType: // not used break; case ImportKeys.FeatureType: type = node.GetString(); break; case ImportKeys.End: end = node.GetInt32(); break; case ImportKeys.StableId: stableId = node.GetString(); break; case ImportKeys.Start: start = node.GetInt32(); break; default: throw new InvalidDataException($"Unknown key found: {node.Key}"); } } return(new RegulatoryRegion(chromosome, start, end, CompactId.Convert(stableId), RegulatoryRegionTypeHelper.GetRegulatoryRegionType(type))); }
public GeneComparerTests() { var chromosome = new Chromosome("chr1", "1", 0); _geneA = new Gene(chromosome, 100, 200, false, "PAX", 123, CompactId.Convert("NM_123"), CompactId.Convert("ENST0000123")); _geneB = new Gene(chromosome, 100, 200, false, "PAX", 123, CompactId.Convert("NM_123"), CompactId.Convert("ENST0000123")); _geneC = new Gene(chromosome, 101, 200, false, "PAX", 123, CompactId.Convert("NM_123"), CompactId.Convert("ENST0000123")); _geneComparer = new GeneComparer(); }
public static ITranslation Read(ExtendedBinaryReader reader, string[] peptideSeqs) { var codingRegion = DataStructures.CodingRegion.Read(reader); var proteinId = CompactId.Read(reader); var peptideIndex = reader.ReadOptInt32(); var peptideSeq = peptideIndex == -1 ? null : peptideSeqs[peptideIndex]; return(new Translation(codingRegion, proteinId, peptideSeq)); }
public void RegulatoryFeatureEqualityTests() { var regulatoryFeature1 = new RegulatoryElement(2, 100, 200, CompactId.Convert("1"), RegulatoryElementType.promoter); var regulatoryFeature2 = new RegulatoryElement(2, 100, 200, CompactId.Convert("1"), RegulatoryElementType.promoter); var regulatoryFeature3 = new RegulatoryElement(4, 105, 201, CompactId.Convert("3"), RegulatoryElementType.CTCF_binding_site); Assert.Equal(regulatoryFeature1, regulatoryFeature2); Assert.False(regulatoryFeature1 == regulatoryFeature3); }
private static ITranscript[] GetTranscripts(IChromosome chromosome, IGene[] genes, ITranscriptRegion[] regions, IInterval[] mirnas) { return(new ITranscript[] { new Transcript(chromosome, 120, 180, CompactId.Convert("789"), null, BioType.IG_D_gene, genes[0], 0, 0, false, regions, 0, mirnas, -1, -1, Source.None, false, false, null, null) }); }
/// <summary> /// retrieves the next gene. Returns false if there are no more genes available /// </summary> public MutableGene Next() { // get the next line string line = _reader.ReadLine(); if (line == null) { return(null); } var cols = line.Split('\t'); if (cols.Length != 10) { throw new GeneralException($"Expected 10 columns but found {cols.Length} when parsing the gene entry."); } try { var referenceIndex = ushort.Parse(cols[1]); var start = int.Parse(cols[2]); var end = int.Parse(cols[3]); var onReverseStrand = cols[4] == "R"; var symbol = cols[5]; var hgnc = cols[6]; var entrezId = CompactId.Convert(cols[7]); var ensemblId = CompactId.Convert(cols[8]); var omimId = int.Parse(cols[9]); var hgncId = hgnc == "" ? -1 : int.Parse(hgnc); var gene = new MutableGene { ReferenceIndex = referenceIndex, Start = start, End = end, OnReverseStrand = onReverseStrand, Symbol = symbol, HgncId = hgncId, EntrezGeneId = entrezId, EnsemblId = ensemblId, MimNumber = omimId, TranscriptDataSource = Header.TranscriptSource }; return(gene); } catch (Exception) { Console.WriteLine("Offending line: {0}", line); for (int i = 0; i < cols.Length; i++) { Console.WriteLine("- col {0}: [{1}]", i, cols[i]); } throw; } }
private void AddRegulatoryRegion(IAnnotatedVariant annotatedVariant) { var regulatoryRegion = new RegulatoryRegion(_chromosome, 103, 104, CompactId.Convert("7157"), RegulatoryRegionType.TF_binding_site); var consequences = new List <ConsequenceTag> { ConsequenceTag.regulatory_region_amplification }; annotatedVariant.RegulatoryRegions.Add(new AnnotatedRegulatoryRegion(regulatoryRegion, consequences)); }
public static IRegulatoryRegion Read(IBufferedBinaryReader reader, IDictionary <ushort, IChromosome> chromosomeIndexDictionary) { var refIndex = reader.ReadOptUInt16(); int start = reader.ReadOptInt32(); int end = reader.ReadOptInt32(); var type = (RegulatoryRegionType)reader.ReadByte(); var id = CompactId.Read(reader); return(new RegulatoryRegion(chromosomeIndexDictionary[refIndex], start, end, id, type)); }
/// <summary> /// constructor /// </summary> public TranscriptMetadata(CompactId transcriptId, int transcriptLength, int cdsLength, bool isLrg) { var id = transcriptId.ToString(); TranscriptId = id; TranscriptLength = transcriptLength; CdsLength = cdsLength; IsLrg = isLrg; AccessionNumber = GetAccessionNumber(id); }
public void Convert_NullInput_ReturnsEmptyId() { var id = CompactId.Convert(null); Assert.True(id.IsEmpty()); Assert.Null(id.WithVersion); id = CompactId.Convert(string.Empty); Assert.True(id.IsEmpty()); Assert.Null(id.WithVersion); }
private static void AddTranscript(IAnnotatedVariant annotatedVariant) { var annotatedTranscript = new Mock <IAnnotatedTranscript>(); annotatedTranscript.SetupGet(x => x.Transcript.Id).Returns(CompactId.Convert("ENST00000540021")); annotatedTranscript.SetupGet(x => x.Transcript.Start).Returns(966300); annotatedTranscript.SetupGet(x => x.Transcript.End).Returns(966405); annotatedTranscript.SetupGet(x => x.AlternateCodons).Returns("cAt/cGt"); annotatedVariant.EnsemblTranscripts.Add(annotatedTranscript.Object); }