Exemplo n.º 1
0
        public void CompareOneOutput_batch_channel()
        {
            var position = 1234689;
            var variant1 = AnnotatedVariant.Create(position);
            var variant2 = AnnotatedVariant.Create(position);

            SerialAnnotator.Annotate(variant1);
            var serialJson = Utf8Json.JsonSerializer.ToJsonString(variant1);

            var annotator     = new BatchChannelAnnotator();
            var annotatorTask = Task.Run(async() =>
            {
                await annotator.Submit(new List <AnnotatedVariant>()
                {
                    variant2
                });
                annotator.Complete();
            });

            annotatorTask.Wait();

            var parallelJson = Utf8Json.JsonSerializer.ToJsonString(variant2);

            Assert.Equal(serialJson, parallelJson);
        }
Exemplo n.º 2
0
        public static void Annotate(AnnotatedVariant variant)
        {
            _countToDelay--;
            if (_countToDelay == 0)
            {
                _countToDelay = RateLimit;
                Thread.Sleep(1);
            }

            var position  = variant.Position;
            var refAllele = variant.RefAllele;
            var altAllele = variant.AltAllele;
            var random    = position ^ refAllele.GetHashCode() ^ altAllele.GetHashCode() ^ Utilities.Prime9;

            if (random < 0)
            {
                random = -random;
            }

            var pathogenicity = PathogenicitySet[random % PathogenicitySet.Length];
            var reviewStatus  = ReviewStatusSet[random % ReviewStatusSet.Length];
            var pubmedIds     = new int[1 + random % 11];

            for (int i = 0; i < pubmedIds.Length; i++)
            {
                pubmedIds[i] = 1 + random % Utilities.Prime4;
                random      ^= Utilities.Prime9;
            }

            variant.ClinicalAnnotation = new ClinicalAnnotation(pathogenicity, pubmedIds, reviewStatus);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public static void Annotate(AnnotatedVariant variant)
 {
     CoreAnnotationProvider.Annotate(variant);
     VariantIdProvider.Annotate(variant);
     AlleleFreqProvider.Annotate(variant);
     ClinicalAnnotationProvider.Annotate(variant);
 }
Exemplo n.º 5
0
        public void GenotypeIndex_is_correct_w_refMinor_allele()
        {
            var vcfFields1 =
                "1	10628385	.	C	<NON_REF>	.	LowGQX;HighDPFRatio	END=10628385;BLOCKAVG_min30p3a	GT:GQX:DP:DPF	0/0:24:9:18".Split('\t');
            var vcfFields2 =
                "1	10628385	.	C	<NON_REF>	.	LowGQX;HighDPFRatio	END=10628385;BLOCKAVG_min30p3a	GT:GQX:DP:DPF	0/0:24:9:18".Split('\t');
            var chromosome = new Chromosome("chr1", "1", 0);
            var inforData  = new InfoData(null, null, VariantType.SNV, null, null, null, null, null, false, null, null,
                                          false, false, "", null, null);
            var position1        = new Position(chromosome, 10628385, 10628385, "C", new[] { "." }, 100, null, null, null, inforData, vcfFields1, new[] { false }, false);
            var position2        = new Position(chromosome, 10628385, 10628385, "C", new[] { "." }, 100, null, null, null, inforData, vcfFields2, new[] { false }, false);
            var variant          = new Variant(chromosome, 10628385, 10628385, "C", "<NON_REF>", VariantType.reference, null, true, false, false, null, null, new AnnotationBehavior(true, false, false, true, false, false));
            var annotatedVariant = new AnnotatedVariant(variant);

            annotatedVariant.SupplementaryAnnotations.Add(new AnnotatedSaDataSource(new SaDataSource("testSource", "Test", "C", false, true, "pathogenic", null), "C"));

            var annotatedPosition1 = new AnnotatedPosition(position1, new IAnnotatedVariant[] { annotatedVariant });
            var annotatedPosition2 = new AnnotatedPosition(position2, new IAnnotatedVariant[] { annotatedVariant });
            var converter          = new VcfConversion();
            var observedVcf1       = converter.Convert(annotatedPosition1).Split("\t")[VcfCommon.InfoIndex];
            var observedVcf2       = converter.Convert(annotatedPosition2).Split("\t")[VcfCommon.InfoIndex];

            Assert.Equal("RefMinor;Test=1|pathogenic", observedVcf1);
            Assert.Equal("RefMinor;Test=1|pathogenic", observedVcf2);
        }
Exemplo n.º 6
0
        public void Add(AnnotatedVariant variant)
        {
            var coreSubmit = Task.Run(() =>
            {
                _coreProducer.Wait();
                _coreQueue.Enqueue(variant);
                _coreConsumer.Release();
            });

            var alleleSubmit = Task.Run(() =>
            {
                _alleleProducer.Wait();
                _alleleFreqQueue.Enqueue(variant);
                _alleleConsumer.Release();
            });

            var idSubmit = Task.Run(() =>
            {
                _idProducer.Wait();
                _idQueue.Enqueue(variant);
                _idConsumer.Release();
            });
            var clinicalSubmit = Task.Run(() =>
            {
                _clinicalProducer.Wait();
                _clinicalQueue.Enqueue(variant);
                _clinicalConsumer.Release();
            });

            coreSubmit.Wait();
            alleleSubmit.Wait();
            idSubmit.Wait();
            clinicalSubmit.Wait();
        }
Exemplo n.º 7
0
        public static void Annotate(AnnotatedVariant variant)
        {
            _countToDelay--;
            if (_countToDelay == 0)
            {
                _countToDelay = RateLimit;
                Thread.Sleep(1);
            }

            var position  = variant.Position;
            var refAllele = variant.RefAllele;
            var altAllele = variant.AltAllele;
            var random    = position ^ refAllele.GetHashCode() ^ altAllele.GetHashCode() ^ Utilities.Prime9;

            if (random < 0)
            {
                random = -random;
            }

            var count = random % 13 + 1;
            var ids   = new string[count];

            for (int i = 0; i < count; i++)
            {
                ids[i]  = $"rs{random:0000000000}";
                random ^= Utilities.Prime9;
            }

            variant.Ids = ids;
        }
Exemplo n.º 8
0
        public async ValueTask Submit(AnnotatedVariant variant)
        {
            await _coreChannel.Writer.WriteAsync(variant);

            await _alleleFreqChannel.Writer.WriteAsync(variant);

            await _idChannel.Writer.WriteAsync(variant);

            await _clinicalChannel.Writer.WriteAsync(variant);
        }
Exemplo n.º 9
0
        public void GenotypeIndex_is_correct_w_nonInformative_altAlleles_filtered()
        {
            var vcfFields1 = "chr1	101	sa123	A	<*>,T	.	.	.".Split("\t");
            var vcfFields2 = "chr1	101	sa123	A	<M>,T	.	.	.".Split("\t");
            var vcfFields3 = "chr1	101	sa123	A	*,T	.	.	.".Split("\t");
            var vcfFields4 = "chr1	101	sa123	A	<NON_REF>,T	.	.	.".Split("\t");
            var vcfFields5 = "chr1	101	sa123	A	T,<*>	.	.	.".Split("\t");
            var vcfFields6 = "chr1	101	sa123	A	T,<M>	.	.	.".Split("\t");
            var vcfFields7 = "chr1	101	sa123	A	T,*	.	.	.".Split("\t");
            var vcfFields8 = "chr1	101	sa123	A	T,<NON_REF>	.	.	.".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, "", null, null);
            var position1        = new Position(chrom, 101, 101, "A", new[] { "<*>", "T" }, 100, null, null, null, inforData, vcfFields1, new[] { false }, false);
            var position2        = new Position(chrom, 101, 101, "A", new[] { "<M>", "T" }, 100, null, null, null, inforData, vcfFields2, new[] { false }, false);
            var position3        = new Position(chrom, 101, 101, "A", new[] { "*", "T" }, 100, null, null, null, inforData, vcfFields3, new[] { false }, false);
            var position4        = new Position(chrom, 101, 101, "A", new[] { "<NON_REF>", "T" }, 100, null, null, null, inforData, vcfFields4, new[] { false }, false);
            var position5        = new Position(chrom, 101, 101, "A", new[] { "T", "<*>" }, 100, null, null, null, inforData, vcfFields5, new[] { false }, false);
            var position6        = new Position(chrom, 101, 101, "A", new[] { "T", "<M>" }, 100, null, null, null, inforData, vcfFields6, new[] { false }, false);
            var position7        = new Position(chrom, 101, 101, "A", new[] { "T", "*" }, 100, null, null, null, inforData, vcfFields7, new[] { false }, false);
            var position8        = new Position(chrom, 101, 101, "A", new[] { "T", "<NON_REF>" }, 100, null, null, null, inforData, vcfFields8, new[] { false }, false);
            var variant          = new Variant(chrom, 101, 101, "A", "T", VariantType.SNV, null, false, false, false, null, null, new AnnotationBehavior(true, false, false, true, false, false));
            var annotatedVariant = new AnnotatedVariant(variant);

            annotatedVariant.SupplementaryAnnotations.Add(new AnnotatedSaDataSource(new SaDataSource("testSource", "Test", "T", false, true, "pathogenic", null), "T"));
            IAnnotatedVariant[] annotatedVariants = { annotatedVariant };
            var annotatedPosition1 = new AnnotatedPosition(position1, annotatedVariants);
            var annotatedPosition2 = new AnnotatedPosition(position2, annotatedVariants);
            var annotatedPosition3 = new AnnotatedPosition(position3, annotatedVariants);
            var annotatedPosition4 = new AnnotatedPosition(position4, annotatedVariants);
            var annotatedPosition5 = new AnnotatedPosition(position5, annotatedVariants);
            var annotatedPosition6 = new AnnotatedPosition(position6, annotatedVariants);
            var annotatedPosition7 = new AnnotatedPosition(position7, annotatedVariants);
            var annotatedPosition8 = new AnnotatedPosition(position8, annotatedVariants);

            var converter    = new VcfConversion();
            var observedVcf1 = converter.Convert(annotatedPosition1).Split("\t")[VcfCommon.InfoIndex];
            var observedVcf2 = converter.Convert(annotatedPosition2).Split("\t")[VcfCommon.InfoIndex];
            var observedVcf3 = converter.Convert(annotatedPosition3).Split("\t")[VcfCommon.InfoIndex];
            var observedVcf4 = converter.Convert(annotatedPosition4).Split("\t")[VcfCommon.InfoIndex];
            var observedVcf5 = converter.Convert(annotatedPosition5).Split("\t")[VcfCommon.InfoIndex];
            var observedVcf6 = converter.Convert(annotatedPosition6).Split("\t")[VcfCommon.InfoIndex];
            var observedVcf7 = converter.Convert(annotatedPosition7).Split("\t")[VcfCommon.InfoIndex];
            var observedVcf8 = converter.Convert(annotatedPosition8).Split("\t")[VcfCommon.InfoIndex];

            Assert.Equal("Test=2|pathogenic", observedVcf1);
            Assert.Equal("Test=2|pathogenic", observedVcf2);
            Assert.Equal("Test=2|pathogenic", observedVcf3);
            Assert.Equal("Test=2|pathogenic", observedVcf4);
            Assert.Equal("Test=1|pathogenic", observedVcf5);
            Assert.Equal("Test=1|pathogenic", observedVcf6);
            Assert.Equal("Test=1|pathogenic", observedVcf7);
            Assert.Equal("Test=1|pathogenic", observedVcf8);
        }
Exemplo n.º 10
0
        public void GetJsonString_RecomposedSnvAfterTrimming_IsRecomposedTrue()
        {
            IVariant variant = new Variant(ChromosomeUtilities.Bob, 100, 200, "A", "G", VariantType.SNV, "bob-100-A-G", false, false, true,
                                           new[] { "bob-100-A-G" }, AnnotationBehavior.SmallVariants, false);
            var annotatedVariant = new AnnotatedVariant(variant);

            const string expectedResult = "{\"vid\":\"bob-100-A-G\",\"chromosome\":\"BoB\",\"begin\":100,\"end\":200,\"refAllele\":\"A\",\"altAllele\":\"G\",\"variantType\":\"SNV\",\"isRecomposedVariant\":true,\"linkedVids\":[\"bob-100-A-G\"]}";
            string       observedResult = annotatedVariant.GetJsonString(OriginalChromosomeName);

            Assert.Equal(expectedResult, observedResult);
        }
Exemplo n.º 11
0
        public static AnnotatedVariant[] CreateAnnotatedVariants(int count)
        {
            var annoVariants = new AnnotatedVariant[count];

            for (int i = 0; i < count; i++)
            {
                annoVariants[i] = AnnotatedVariant.Create();
            }

            return(annoVariants);
        }
Exemplo n.º 12
0
        public static List <AnnotatedVariant> DeepCopy(List <AnnotatedVariant> variants)
        {
            var newVariants = new List <AnnotatedVariant>(variants.Count);

            for (int i = 0; i < variants.Count; i++)
            {
                newVariants.Add(AnnotatedVariant.Create(variants[i].Position));
            }

            return(newVariants);
        }
        private static IAnnotatedPosition GetAnnotatedPosition(IVariant variant)
        {
            IVariant[] variants = { variant };
            var        position = new Position(ChromosomeUtilities.Chr3, Start, End, null, null, null, null, variants, null, null, null, null,
                                               false);

            var annotatedVariant = new AnnotatedVariant(variant);

            IAnnotatedVariant[] annotatedVariants = { annotatedVariant };

            return(new AnnotatedPosition(position, annotatedVariants));
        }
Exemplo n.º 14
0
        public void Only_canonical_transcripts_are_reported_in_vcf()
        {
            var mockedTranscript1 = new Mock <IAnnotatedTranscript>();

            mockedTranscript1.Setup(x => x.Transcript.IsCanonical).Returns(true);
            mockedTranscript1.Setup(x => x.Transcript.Id).Returns(CompactId.Convert("ENST12345", 1));
            mockedTranscript1.Setup(x => x.Transcript.Gene.Symbol).Returns("testGene1");
            mockedTranscript1.SetupGet(x => x.Consequences)
            .Returns(new List <ConsequenceTag> {
                ConsequenceTag.five_prime_UTR_variant
            });

            var mockedTranscript2 = new Mock <IAnnotatedTranscript>();

            mockedTranscript2.Setup(x => x.Transcript.IsCanonical).Returns(false);
            mockedTranscript2.Setup(x => x.Transcript.Id).Returns(CompactId.Convert("ENST23456", 2));
            mockedTranscript2.Setup(x => x.Transcript.Gene.Symbol).Returns("testGene2");
            mockedTranscript2.SetupGet(x => x.Consequences)
            .Returns(new List <ConsequenceTag> {
                ConsequenceTag.missense_variant
            });

            var mockedTranscript3 = new Mock <IAnnotatedTranscript>();

            mockedTranscript3.Setup(x => x.Transcript.IsCanonical).Returns(true);
            mockedTranscript3.Setup(x => x.Transcript.Id).Returns(CompactId.Convert("NM_1234", 3));
            mockedTranscript3.Setup(x => x.Transcript.Gene.Symbol).Returns("testGene3");
            mockedTranscript3.SetupGet(x => x.Consequences)
            .Returns(new List <ConsequenceTag> {
                ConsequenceTag.missense_variant, ConsequenceTag.splice_region_variant
            });


            var vcfFields = "chr1	101	sa123	A	T	.	.	.".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, "", null, null);
            var position         = new Position(chrom, 101, 101, "A", new[] { "T" }, 100, null, null, null, inforData, vcfFields, new[] { false }, false);
            var variant          = new Variant(chrom, 101, 101, "A", "T", VariantType.SNV, null, false, false, false, null, null, new AnnotationBehavior(true, false, false, true, false, false));
            var annotatedVariant = new AnnotatedVariant(variant);

            annotatedVariant.EnsemblTranscripts.Add(mockedTranscript1.Object);
            annotatedVariant.EnsemblTranscripts.Add(mockedTranscript2.Object);
            annotatedVariant.RefSeqTranscripts.Add(mockedTranscript3.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("CSQT=1|testGene1|ENST12345.1|5_prime_UTR_variant,1|testGene3|NM_1234.3|missense_variant&splice_region_variant", observedVcf);
        }
Exemplo n.º 15
0
        public void GetJsonString_RefMinor_WithTranscripts()
        {
            IVariant variant          = GetRefMinorVariant();
            var      annotatedVariant = new AnnotatedVariant(variant);

            AddRegulatoryRegion(annotatedVariant);
            AddTranscript(annotatedVariant);

            const string expectedResult = "{\"vid\":\"bob:100:G\",\"chromosome\":\"BoB\",\"begin\":100,\"end\":200,\"isReferenceMinorAllele\":true,\"refAllele\":\"A\",\"altAllele\":\"G\",\"variantType\":\"SNV\",\"linkedVids\":[\"bob:100:102:TAT\"],\"regulatoryRegions\":[{\"id\":\"7157\",\"type\":\"TF_binding_site\",\"consequence\":[\"regulatory_region_amplification\"]}],\"transcripts\":[]}";
            var          observedResult = annotatedVariant.GetJsonString(OriginalChromosomeName);

            Assert.Equal(expectedResult, observedResult);
        }
Exemplo n.º 16
0
        public void Test1()
        {
            var variant = AnnotatedVariant.Create();

            var nirvanaJson    = variant.SerializeJson();
            var newtonsoftJson = JsonConvert.SerializeObject(variant);
            var utf8Json       = Utf8Json.JsonSerializer.ToJsonString(variant);
            var utf8Bytes      = Utf8Json.JsonSerializer.Serialize(variant);
            var systemJson     = JsonSerializer.Serialize(variant);

            Assert.Equal(nirvanaJson, newtonsoftJson);
            Assert.Equal(nirvanaJson, utf8Json);
            Assert.Equal(nirvanaJson, Encoding.UTF8.GetString(utf8Bytes));
            Assert.Equal(nirvanaJson, systemJson);
        }
Exemplo n.º 17
0
        internal static IAnnotatedVariant[] GetAnnotatedVariants(IVariant[] variants)
        {
            if (variants?[0].Behavior == null)
            {
                return(null);
            }
            var numVariants       = variants.Length;
            var annotatedVariants = new IAnnotatedVariant[numVariants];

            for (var i = 0; i < numVariants; i++)
            {
                annotatedVariants[i] = new AnnotatedVariant(variants[i]);
            }
            return(annotatedVariants);
        }
Exemplo n.º 18
0
        public static List <AnnotatedVariant> GetVariants(int n)
        {
            var delta    = new Random();
            var variants = new List <AnnotatedVariant>(n);

            var position = delta.Next(1000, 5000);

            for (int i = 0; i < n; i++)
            {
                position += delta.Next(0, 500);
                variants.Add(AnnotatedVariant.Create(position));
            }

            return(variants);
        }
Exemplo n.º 19
0
        public void GetJsonString_Variant_WithSupplementaryAnnotation()
        {
            IVariant variant          = GetVariant();
            var      annotatedVariant = new AnnotatedVariant(variant);

            const string originalChromosomeName = "BoB";

            AddRegulatoryRegion(annotatedVariant);
            AddSupplementaryAnnotation(annotatedVariant);
            annotatedVariant.PhylopScore = -0.314;

            const string expectedResult = "{\"vid\":\"bob:100:G\",\"chromosome\":\"BoB\",\"begin\":100,\"end\":200,\"refAllele\":\"A\",\"altAllele\":\"G\",\"variantType\":\"SNV\",\"phylopScore\":-0.314,\"regulatoryRegions\":[{\"id\":\"7157\",\"type\":\"TF_binding_site\",\"consequence\":[\"regulatory_region_amplification\"]}],\"clinVar\":{\"good\":\"result\"},\"exac\":[{\"bad\":\"temper\"},{\"brutal\":\"kangaroo\"}]}";
            var          observedResult = annotatedVariant.GetJsonString(originalChromosomeName);

            Assert.Equal(expectedResult, observedResult);
        }
Exemplo n.º 20
0
        public void original_updated_info_is_added_to_info_field()
        {
            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, true, false, false, null, null, new AnnotationBehavior(true, false, false, true, false, false));
            var annotatedVariant = new AnnotatedVariant(variant);

            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;RefMinor", observedVcf);
        }
Exemplo n.º 21
0
        public void CompareOneOutput_conQ()
        {
            var position = 1234689;
            var variant1 = AnnotatedVariant.Create(position);
            var variant2 = AnnotatedVariant.Create(position);

            SerialAnnotator.Annotate(variant1);
            var serialJson = Utf8Json.JsonSerializer.ToJsonString(variant1);

            var conQAnnotator = new ConQAnnotator(50);

            conQAnnotator.Add(variant2);
            conQAnnotator.Complete();

            var conqJson = Utf8Json.JsonSerializer.ToJsonString(variant2);

            Assert.Equal(serialJson, conqJson);
        }
Exemplo n.º 22
0
        public void CompareOneOutput_channel()
        {
            var position = 1234689;
            var variant1 = AnnotatedVariant.Create(position);
            var variant2 = AnnotatedVariant.Create(position);

            SerialAnnotator.Annotate(variant1);
            var serialJson = Utf8Json.JsonSerializer.ToJsonString(variant1);

            var channelAnnotator = new ChannelAnnotator();

            channelAnnotator.Submit(variant2);
            channelAnnotator.Complete();

            var parallelJson = Utf8Json.JsonSerializer.ToJsonString(variant2);

            Assert.Equal(serialJson, parallelJson);
        }
Exemplo n.º 23
0
        public void Original_dbsnp_nonrsid_get_kept()
        {
            var vcfFields = "chr1	101	sa123	A	T	.	.	.".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, "", null, null);
            var position         = new Position(chrom, 101, 101, "A", new[] { "T" }, 100, null, null, null, inforData, vcfFields, new[] { false }, false);
            var variant          = new Variant(chrom, 101, 101, "A", "T", VariantType.SNV, null, false, false, false, null, null, new AnnotationBehavior(true, false, false, true, false, false));
            var annotatedVariant = new AnnotatedVariant(variant);

            IAnnotatedVariant[] annotatedVariants = { annotatedVariant };
            var annotatedPosition = new AnnotatedPosition(position, annotatedVariants);

            var converter   = new VcfConversion();
            var observedVcf = converter.Convert(annotatedPosition).Split("\t")[VcfCommon.IdIndex];

            Assert.Equal("sa123", observedVcf);
        }
Exemplo n.º 24
0
        public void Annotate(AnnotatedVariant variant)
        {
            if (_isComplete)
            {
                return;
            }
            _variant = variant;

            _coreSemaphore.Release();
            _alleleFreqSemaphore.Release();
            _idSemaphore.Release();
            _clinicalSemaphore.Release();

            //now wait for the annotations to be done
            _coreDone.Wait();
            _alleleFreqDone.Wait();
            _idDone.Wait();
            _clinicalDone.Wait();
        }
Exemplo n.º 25
0
        public void Gmaf_outputed()
        {
            var vcfFields = "chr1	101	sa123	A	T	.	.	.".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, "", null, null);
            var position         = new Position(chrom, 101, 101, "A", new[] { "T" }, 100, null, null, null, inforData, vcfFields, new[] { false }, false);
            var variant          = new Variant(chrom, 101, 101, "A", "T", VariantType.SNV, null, false, false, false, null, null, new AnnotationBehavior(true, false, false, true, false, false));
            var annotatedVariant = new AnnotatedVariant(variant);

            annotatedVariant.SupplementaryAnnotations.Add(new AnnotatedSaDataSource(new SaDataSource("globalAllele", "GMAF", "N", false, false, "G|0.002", null), "N"));
            IAnnotatedVariant[] annotatedVariants = { annotatedVariant };
            var annotatedPosition = new AnnotatedPosition(position, annotatedVariants);

            var converter   = new VcfConversion();
            var observedVcf = converter.Convert(annotatedPosition).Split("\t")[VcfCommon.InfoIndex];

            Assert.Equal("GMAF=G|0.002", observedVcf);
        }
Exemplo n.º 26
0
        public void Original_dbsnp_nonrsid_merged_with_rsid_from_dbsnp()
        {
            var vcfFields = "chr1	101	sa123	A	T	.	.	.".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, "", null, null);
            var position         = new Position(chrom, 101, 101, "A", new[] { "T" }, 100, null, null, null, inforData, vcfFields, new[] { false }, false);
            var variant          = new Variant(chrom, 101, 101, "A", "T", VariantType.SNV, null, false, false, false, null, null, new AnnotationBehavior(true, false, false, true, false, false));
            var annotatedVariant = new AnnotatedVariant(variant);

            annotatedVariant.SupplementaryAnnotations.Add(new AnnotatedSaDataSource(new SaDataSource("dbsnp", "", "T", true, false, "rs456", null), "T"));
            IAnnotatedVariant[] annotatedVariants = { annotatedVariant };
            var annotatedPosition = new AnnotatedPosition(position, annotatedVariants);

            var converter   = new VcfConversion();
            var observedVcf = converter.Convert(annotatedPosition).Split("\t")[VcfCommon.IdIndex];

            Assert.Equal("sa123;rs456", observedVcf);
        }
Exemplo n.º 27
0
        public void OneKGAnnotation_is_handled()
        {
            var vcfFields = "chr1	101	sa123	A	T	.	.	.".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, "", null, null);
            var position         = new Position(chrom, 101, 101, "A", new[] { "T" }, 100, null, null, null, inforData, vcfFields, new[] { false }, false);
            var variant          = new Variant(chrom, 101, 101, "A", "T", VariantType.SNV, null, false, false, false, null, null, new AnnotationBehavior(true, false, false, true, false, false));
            var annotatedVariant = new AnnotatedVariant(variant);

            annotatedVariant.SupplementaryAnnotations.Add(new AnnotatedSaDataSource(new SaDataSource("oneKg", "AF1000G", "T", true, false, "0.000599;t", null), "T"));
            IAnnotatedVariant[] annotatedVariants = { annotatedVariant };
            var annotatedPosition = new AnnotatedPosition(position, annotatedVariants);

            var converter   = new VcfConversion();
            var observedVcf = converter.Convert(annotatedPosition).Split("\t")[VcfCommon.InfoIndex];

            Assert.Equal("AA=t;AF1000G=0.000599", observedVcf);
        }
Exemplo n.º 28
0
        public void Only_allele_specific_entry_for_annotation_not_matched_by_allele_is_output()
        {
            var vcfFields = "chr1	101	sa123	A	T	.	.	.".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, "", null, null);
            var position         = new Position(chrom, 101, 101, "A", new[] { "T" }, 100, null, null, null, inforData, vcfFields, new[] { false }, false);
            var variant          = new Variant(chrom, 101, 101, "A", "T", VariantType.SNV, null, false, false, false, null, null, new AnnotationBehavior(true, false, false, true, false, false));
            var annotatedVariant = new AnnotatedVariant(variant);

            annotatedVariant.SupplementaryAnnotations.Add(new AnnotatedSaDataSource(new SaDataSource("testSource", "Test", "T", false, true, "pathogenic", null), "T"));
            annotatedVariant.SupplementaryAnnotations.Add(new AnnotatedSaDataSource(new SaDataSource("testSource", "Test", "G", false, true, "benign", null), "T"));
            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=1|pathogenic", observedVcf);
        }
Exemplo n.º 29
0
        public static void Annotate(AnnotatedVariant variant)
        {
            _countToDelay--;
            if (_countToDelay == 0)
            {
                _countToDelay = RateLimit;
                Thread.Sleep(1);
            }

            var position = variant.Position;

            var n           = 1 + position % 13;// that its never 0
            var transcripts = new AnnotatedTranscript[n];

            for (int i = 0; i < n; i++)
            {
                transcripts[i] = AnnotatedTranscript.Create(position, i);
            }

            variant.Transcripts = transcripts;
        }
Exemplo n.º 30
0
        public static void Annotate(AnnotatedVariant variant)
        {
            _countToDelay--;
            if (_countToDelay == 0)
            {
                _countToDelay = RateLimit;
                Thread.Sleep(1);
            }
            var position  = variant.Position;
            var refAllele = variant.RefAllele;
            var altAllele = variant.AltAllele;
            var random    = position ^ refAllele.GetHashCode() ^ altAllele.GetHashCode() ^ Utilities.Prime9;

            var count       = 15;
            var frequencies = new double[count];

            for (int i = 0; i < count; i++)
            {
                frequencies[i] = (random % Utilities.Prime6) * 1.0 / 1_000_000;
                random        ^= Utilities.Prime9;
            }

            variant.AlleleFrequencies = frequencies;
        }