Пример #1
0
        public void MergeDbSnp1KpEvsRefMinor()
        {
            const string vcfLine1 = "1	69428	rs140739101	T	G	.	.	RS=140739101;RSPOS=69428;dbSNPBuildID=134;SSR=0;SAO=0;VP=0x050200000a05140026000100;WGT=1;VC=SNV;S3D;NSM;REF;ASP;VLD;KGPhase3;CAF=0.981,0.01897;COMMON=1";
            //vcf line is modified
            const string vcfLine2 = "1	69428	rs140739101	T	G	100	PASS	AC=4956;AF=0.989617;AN=5008;NS=2504;DP=17611;EAS_AF=0.003;AMR_AF=0.036;AFR_AF=0.0015;EUR_AF=0.0497;SAS_AF=0.0153;AA=.|||;VT=SNP;EX_TARGET;EAS_AN=1008;EAS_AC=3;EUR_AN=1006;EUR_AC=50;AFR_AN=1322;AFR_AC=2;AMR_AN=694;AMR_AC=25;SAS_AN=978;SAS_AC=15";
            const string vcfLine3 = "1	69428	rs140739101	T	G	.	PASS	BSNP=dbSNP_134;EA_AC=313,6535;AA_AC=14,3808;TAC=327,10343;MAF=4.5707,0.3663,3.0647;GTS=GG,GT,TT;EA_GTC=92,129,3203;AA_GTC=1,12,1898;GTC=93,141,5101;DP=110;GL=OR4F5;CP=1.0;CG=0.9;AA=T;CA=.;EXOME_CHIP=no;GWAS_PUBMED=.;FG=NM_001005484.1:missense;HGVS_CDNA_VAR=NM_001005484.1:c.338T>G;HGVS_PROTEIN_VAR=NM_001005484.1:p.(F113C);CDS_SIZES=NM_001005484.1:918;GS=205;PH=probably-damaging:0.999;EA_AGE=.;AA_AGE=.";

            var sa = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(69428));

            var dbsnpReader = new DbSnpReader(_renamer);
            var dbSnpItem   = dbsnpReader.ExtractItem(vcfLine1)[0];

            dbSnpItem.SetSupplementaryAnnotations(sa);

            var oneKGenItem = _oneKGenReader.ExtractItems(vcfLine2)[0];

            oneKGenItem.SetSupplementaryAnnotations(sa);

            var evsReader = new EvsReader(_renamer);
            var evsItem   = evsReader.ExtractItems(vcfLine3)[0];

            evsItem.SetSupplementaryAnnotations(sa);
            sa.FinalizePositionalAnnotations();

            var dbSnp = sa.SaPosition.AlleleSpecificAnnotations["G"].Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.DbSnp)] as DbSnpAnnotation;

            Assert.NotNull(dbSnp);

            Assert.Equal(new List <long> {
                140739101
            }, dbSnp.DbSnp);
            Assert.Equal(true, sa.SaPosition.IsRefMinorAllele);
        }
Пример #2
0
        public void DeletionAndSnvMerge()
        {
            // NIR-906
            const string vcfLine1 =
                "2	193187631	rs774176075	TGTTG	T	.	.	RS=774176075;RSPOS=193187632;dbSNPBuildID=144;SSR=0;SAO=0;VP=0x050000000005000002000200;WGT=1;VC=DIV;ASP";
            const string vcfLine2 = "2	193187632	rs2592266	G	T	.	.	RS=2592266;RSPOS=193187632;dbSNPBuildID=100;SSR=0;SAO=0;VP=0x050000000005150026000100;WGT=1;VC=SNV;ASP;VLD;G5;KGPhase3;CAF=0.01937,0.9806;COMMON=1";

            var dbsnpReader = new DbSnpReader(_renamer);
            var dbSnpEntry1 = dbsnpReader.ExtractItem(vcfLine1)[0];
            var dbSnpEntry2 = dbsnpReader.ExtractItem(vcfLine2)[0];

            var sa = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(193187632));
            var additionalEntry = dbSnpEntry1.SetSupplementaryAnnotations(sa);

            additionalEntry.SetSupplementaryAnnotations(sa);


            var sa2 = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(193187632));

            dbSnpEntry2.SetSupplementaryAnnotations(sa2);

            sa.MergeSaCreator(sa2);
            sa.FinalizePositionalAnnotations();

            Assert.Equal("T", sa.SaPosition.GlobalMajorAllele);
            Assert.Equal("0.9806", sa.SaPosition.GlobalMajorAlleleFrequency);
            Assert.Equal("G", sa.SaPosition.GlobalMinorAllele);
            Assert.Equal("0.01937", sa.SaPosition.GlobalMinorAlleleFrequency);
        }
Пример #3
0
        private void CreateDbsnpGaTsv(string fileName)
        {
            if (fileName == null)
            {
                return;
            }

            var benchMark = new Benchmark();

            var version = DataSourceVersionReader.GetSourceVersion(fileName);

            var dbsnpWriter = new SaTsvWriter(_outputDirectory, version, _genomeAssembly.ToString(),
                                              SaTsvCommon.DbSnpSchemaVersion, InterimSaCommon.DbsnpTag, null, true, new ReferenceSequenceProvider(FileUtilities.GetReadStream(_compressedReferencePath)));

            var globalAlleleWriter = new SaTsvWriter(_outputDirectory, version, _genomeAssembly.ToString(),
                                                     SaTsvCommon.DbSnpSchemaVersion, InterimSaCommon.GlobalAlleleTag, "GMAF", false, new ReferenceSequenceProvider(FileUtilities.GetReadStream(_compressedReferencePath)));

            using (var tsvWriter = new DbsnpGaTsvWriter(dbsnpWriter, globalAlleleWriter))
            {
                var dbSnpReader = new DbSnpReader(GZipUtilities.GetAppropriateReadStream(fileName), _refNamesDictionary);
                TsvWriterUtilities.WriteSortedItems(dbSnpReader.GetDbSnpItems(), tsvWriter);
            }

            var timeSpan = Benchmark.ToHumanReadable(benchMark.GetElapsedTime());

            TsvWriterUtilities.WriteCompleteInfo("DbSNP", version.Version, timeSpan);
        }
Пример #4
0
        public void MergeDbSnp1Kg()
        {
            //NIR-1262
            const string vcfLine =
                "1	825069	rs4475692	G	A,C	.	.	RS=4475692;RSPOS=825069;dbSNPBuildID=111;SSR=0;SAO=0;VP=0x050100000005170126000100;WGT=1;VC=SNV;SLO;ASP;VLD;G5A;G5;GNO;KGPhase3;CAF=0.3227,.,0.6773;COMMON=1";
            const string vcfLine1Kg =
                "1	825069	rs4475692	G	C	100	PASS	AC=3392;AF=0.677316;AN=5008;NS=2504;DP=22495;EAS_AF=0.754;AMR_AF=0.5692;AFR_AF=0.6127;EUR_AF=0.7286;SAS_AF=0.7096;AA=g|||;VT=SNP;EAS_AN=1008;EAS_AC=760;EUR_AN=1006;EUR_AC=733;AFR_AN=1322;AFR_AC=810;AMR_AN=694;AMR_AC=395;SAS_AN=978;SAS_AC=694\tGT";

            var dbsnpReader = new DbSnpReader(_renamer);
            var sa          = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(825069));

            foreach (var dbSnpEntry in dbsnpReader.ExtractItem(vcfLine))
            {
                dbSnpEntry.SetSupplementaryAnnotations(sa);
            }

            var sa1         = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(825069));
            var onekgReader = new OneKGenReader(_renamer);

            foreach (var onekgItem in onekgReader.ExtractItems(vcfLine1Kg))
            {
                onekgItem.SetSupplementaryAnnotations(sa1);
            }

            sa.MergeSaCreator(sa1);
            sa.FinalizePositionalAnnotations();

            Assert.Equal("C", sa.SaPosition.GlobalMajorAllele);
            Assert.Equal("G", sa.SaPosition.GlobalMinorAllele);
        }
Пример #5
0
        public void MergeSnvAndDeletion()
        {
            // NIR-906
            const string vcfLine1 =
                "1	862389	rs6693546	A	G	.	.	RS=6693546;RSPOS=862389;dbSNPBuildID=116;SSR=0;SAO=0;VP=0x05010008000515013e000100;WGT=1;VC=SNV;SLO;INT;ASP;VLD;G5;GNO;KGPhase1;KGPhase3;CAF=0.3171,0.6829;COMMON=1";
            const string vcfLine2 = "1	862388	rs534606253	GA	G	.	.	RS=534606253;RSPOS=862389;dbSNPBuildID=142;SSR=0;SAO=0;VP=0x050000080005040024000200;WGT=1;VC=DIV;INT;ASP;VLD;KGPhase3;CAF=0.996,0.003994;COMMON=1";

            var dbsnpReader = new DbSnpReader(_renamer);
            var dbSnpEntry1 = dbsnpReader.ExtractItem(vcfLine1)[0];
            var dbSnpEntry2 = dbsnpReader.ExtractItem(vcfLine2)[0];

            var sa = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(862389));

            dbSnpEntry1.SetSupplementaryAnnotations(sa);

            var sa2             = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(862389));
            var additionalEntry = dbSnpEntry2.SetSupplementaryAnnotations(sa2);

            additionalEntry.SetSupplementaryAnnotations(sa2);

            sa.MergeSaCreator(sa2);
            sa.FinalizePositionalAnnotations();

            Assert.Equal("G", sa.SaPosition.GlobalMajorAllele);
            Assert.Equal("0.6829", sa.SaPosition.GlobalMajorAlleleFrequency);
            Assert.Equal("A", sa.SaPosition.GlobalMinorAllele);
            Assert.Equal("0.3171", sa.SaPosition.GlobalMinorAlleleFrequency);
        }
Пример #6
0
        public void MultipleDbsnpMerge()
        {
            // NIR-778, 805. The second dbSNP id is missing from the SA database.
            const string vcfLine1 =
                "17	3616153	rs34081014	C	G	.	.	RS=34081014;RSPOS=3616153;dbSNPBuildID=126;SSR=0;SAO=0;VP=0x050000000005140136000100;WGT=1;VC=SNV;ASP;VLD;GNO;KGPhase1;KGPhase3;CAF=0.9297,0.07029;COMMON=1";

            const string vcfLine2 =
                "17	3616152	rs71362546	GCTG	GCTT,GGTG	.	.	RS=71362546;RSPOS=3616153;dbSNPBuildID=130;SSR=0;SAO=0;VP=0x050100000005000102000810;WGT=1;VC=MNV;SLO;ASP;GNO;NOC";

            var sa1         = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(3616153));
            var sa2         = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(3616153));
            var dbsnpReader = new DbSnpReader(_renamer);
            var dbSnpItem1  = dbsnpReader.ExtractItem(vcfLine1)[0];
            var dbSnpItems  = dbsnpReader.ExtractItem(vcfLine2);

            dbSnpItem1.SetSupplementaryAnnotations(sa1);

            var additionalItems = dbSnpItems.Select(dbSnpItem => dbSnpItem.SetSupplementaryAnnotations(sa1)).ToList();

            foreach (var item in additionalItems)
            {
                item.SetSupplementaryAnnotations(sa2);
            }

            sa1.MergeSaCreator(sa2);

            var dbSnp =
                sa1.SaPosition.AlleleSpecificAnnotations["G"].Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.DbSnp)] as
                DbSnpAnnotation;

            Assert.NotNull(dbSnp);
            Assert.Equal(dbSnp.DbSnp, new List <long> {
                34081014, 71362546
            });
        }
Пример #7
0
        public void MergeDbSnpClinVar()
        {
            const string vcfLine = "1	225592188	rs387906416	TAGAAGA	CTTCTAG	.	.	RS=387906416;RSPOS=225592188;RV;dbSNPBuildID=137;SSR=0;SAO=1;VP=0x050060000605000002110800;GENEINFO=LBR:3930;WGT=1;VC=MNV;PM;NSN;REF;ASP;LSD;OM";

            var dbsnpReader = new DbSnpReader(_renamer);
            var dbSnpItems  = dbsnpReader.ExtractItem(vcfLine);

            var sa = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(225592188));

            foreach (var dbSnpItem in dbSnpItems)
            {
                dbSnpItem.SetSupplementaryAnnotations(sa);
            }

            var xmlReader = new ClinVarXmlReader(new FileInfo(Resources.TopPath("RCV000087262.xml")), _reader, _sequence);

            foreach (var clinVarItem in xmlReader)
            {
                var sa1 = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(225592188));
                clinVarItem.SetSupplementaryAnnotations(sa1);
                sa.MergeSaCreator(sa1);
            }

            Assert.Equal(1, sa.SaPosition.ClinVarItems.Count);

            foreach (var clinVarEntry in sa.SaPosition.ClinVarItems)
            {
                Assert.Equal(clinVarEntry.ID, "RCV000087262.3");
                Assert.Equal(clinVarEntry.MedGenIDs.First(), "C0030779");
                Assert.Equal(clinVarEntry.Phenotypes.First(), "Pelger-Huët anomaly");
            }
        }
Пример #8
0
        public void DuplicateDbsnp()
        {
            // NIR-853: can't reproduce the problem at dbSnp parsing and merging.
            const string vcfLine1 =
                "1	8121167	rs34500567	C	CAAT,CAATAATAAAATAATAATAATAAT,CAATAAT,CAAT	.	.	RS=34500567;RSPOS=8121167;dbSNPBuildID=126;SSR=0;SAO=0;VP=0x050000000005000002000200;WGT=1;VC=DIV;ASP;CAF=0.9726,.,.,.,.,0.9726;COMMON=1";
            const string vcfLine2 =
                "1	8121167	rs566669620	C	CAATAATAAAAT	.	.	RS=566669620;RSPOS=8121175;dbSNPBuildID=142;SSR=0;SAO=0;VP=0x050000000005040024000200;WGT=1;VC=DIV;ASP;VLD;KGPhase3;CAF=0.9726,0.0007987;COMMON=1";
            const string vcfLine3 =
                "1	8121167	rs59792241	C	CAAT,CAATAATAAAATAATAATAATAAT,CAATAAT,CAAT	.	.	RS=59792241;RSPOS=8121205;dbSNPBuildID=137;SSR=0;SAO=0;VP=0x050000000005000002000200;WGT=1;VC=DIV;ASP;CAF=0.9726,.,.,.,.,0.9726;COMMON=1";

            var dbsnpReader = new DbSnpReader(_renamer);
            var dbSnpItems1 = dbsnpReader.ExtractItem(vcfLine1);
            var dbSnpItems2 = dbsnpReader.ExtractItem(vcfLine2);
            var dbSnpItems3 = dbsnpReader.ExtractItem(vcfLine3);


            var sa1 = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(8121168));
            var sa2 = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(8121168));
            var sa3 = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(8121168));

            var additionalItems = dbSnpItems1.Select(dbSnpItem => dbSnpItem.SetSupplementaryAnnotations(sa1)).ToList();

            foreach (var item in additionalItems)
            {
                item.SetSupplementaryAnnotations(sa1);
            }

            additionalItems.Clear();
            additionalItems.AddRange(dbSnpItems2.Select(dbSnpItem => dbSnpItem.SetSupplementaryAnnotations(sa2)));

            foreach (var item in additionalItems)
            {
                item.SetSupplementaryAnnotations(sa2);
            }

            additionalItems.Clear();
            foreach (var dbSnpItem in dbSnpItems3)
            {
                additionalItems.Add(dbSnpItem.SetSupplementaryAnnotations(sa3));
            }

            foreach (var item in additionalItems)
            {
                item.SetSupplementaryAnnotations(sa3);
            }
            sa1.MergeSaCreator(sa2);
            sa1.MergeSaCreator(sa3);

            var dbSnp =
                sa1.SaPosition.AlleleSpecificAnnotations["iAAT"].Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.DbSnp)] as
                DbSnpAnnotation;

            Assert.NotNull(dbSnp);
            Assert.Equal(2, dbSnp.DbSnp.Count);
            Assert.Equal(34500567, dbSnp.DbSnp[0]);
            Assert.Equal(59792241, dbSnp.DbSnp[1]);
        }
Пример #9
0
        public void NoMinorAllele()
        {
            const string vcfLine          = "17	828	rs62053745	T	C	.	.	RS=62053745;RSPOS=828;dbSNPBuildID=129;SSR=0;SAO=0;VP=0x050100080005140136000100;WGT=1;VC=SNV;SLO;INT;ASP;VLD;GNO;KGPhase1;KGPhase3;CAF=.,0.7424;COMMON=1";
            var          sequenceProvider = ParserTestUtils.GetSequenceProvider(828, "T", 'G', ChromosomeUtilities.RefNameToChromosome);
            var          dbsnpReader      = new DbSnpReader(null, sequenceProvider);
            var          dbSnpEntry       = dbsnpReader.ExtractItem(vcfLine).First();

            Assert.Equal("C", dbSnpEntry.AltAllele);
        }
Пример #10
0
        public void DisregardZeroFreq()
        {
            const string vcfLine          = "1	241369	rs11490246	C	T	.	.	RS=11490246;RSPOS=241369;dbSNPBuildID=120;SSR=0;SAO=0;VP=0x050100000005000126000100;WGT=1;VC=SNV;SLO;ASP;GNO;KGPhase3;CAF=0,1;COMMON=0";
            var          sequenceProvider = ParserTestUtils.GetSequenceProvider(241369, "C", 'G', ChromosomeUtilities.RefNameToChromosome);
            var          dbsnpReader      = new DbSnpReader(null, sequenceProvider);
            var          dbSnpEntry       = dbsnpReader.ExtractItem(vcfLine).First();

            Assert.Equal("T", dbSnpEntry.AltAllele);
        }
Пример #11
0
        public void RwDbsnpGlobalAlleles()
        {
            //NIR-1262
            var randomPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            // create our expected data source versions
            var dbSnpVersion = new DataSourceVersion("dbSNP", "147", DateTime.Parse("2016-07-26").Ticks);

            var expectedDataSourceVersions = new List <DataSourceVersion> {
                dbSnpVersion
            };

            const string vcfLine1 =
                "2	141724543	rs112783784	A	C,T	.	.	RS=112783784;RSPOS=141724543;dbSNPBuildID=132;SSR=0;SAO=0;VP=0x050100080015140136000100;WGT=1;VC=SNV;SLO;INT;OTH;ASP;VLD;GNO;KGPhase1;KGPhase3;CAF=0.04113,0.9105,0.04832;COMMON=1";

            const string vcfLine2 =
                "2	141724543	rs4300776	A	C	.	.	RS=4300776;RSPOS=141724543;dbSNPBuildID=111;SSR=0;SAO=0;VP=0x050100080015000102000100;WGT=1;VC=SNV;SLO;INT;OTH;ASP;GNO;CAF=0.04113,0.9105;COMMON=1";

            var sa        = new SupplementaryAnnotationPosition(141724543);
            var saCreator = new SupplementaryPositionCreator(sa);

            var dbsnpReader = new DbSnpReader(_renamer);

            foreach (var dbSnpItem in dbsnpReader.ExtractItem(vcfLine1))
            {
                dbSnpItem.SetSupplementaryAnnotations(saCreator);
            }

            foreach (var dbSnpItem in dbsnpReader.ExtractItem(vcfLine2))
            {
                dbSnpItem.SetSupplementaryAnnotations(saCreator);
            }

            // write the supplementary annotation file
            using (var writer = new SupplementaryAnnotationWriter(randomPath, "chr1", expectedDataSourceVersions))
            {
                saCreator.FinalizePositionalAnnotations();
                writer.Write(saCreator, sa.ReferencePosition);
            }

            using (var reader = new SupplementaryAnnotationReader(randomPath))
            {
                // extract the three annotations
                var observedAnnotation = reader.GetAnnotation(141724543) as SupplementaryAnnotationPosition;
                Assert.NotNull(observedAnnotation);

                Assert.Equal("C", observedAnnotation.GlobalMajorAllele);
                Assert.Equal("0.9105", observedAnnotation.GlobalMajorAlleleFrequency);

                Assert.Equal("T", observedAnnotation.GlobalMinorAllele);
                Assert.Equal("0.04832", observedAnnotation.GlobalMinorAlleleFrequency);
            }

            File.Delete(randomPath);
            File.Delete(randomPath + ".idx");
        }
Пример #12
0
        public void MissingEntry2()
        {
            const string vcfLine =
                "17	828	rs62053745	T	C	.	.	RS=62053745;RSPOS=828;dbSNPBuildID=129;SSR=0;SAO=0;VP=0x050100080005140136000100;WGT=1;VC=SNV;SLO;INT;ASP;VLD;GNO;KGPhase1;KGPhase3;CAF=0.2576,0.7424;COMMON=1";

            var dbsnpReader = new DbSnpReader(null, _refChromDict);
            var dbSnpEntry  = dbsnpReader.ExtractItem(vcfLine)[0];

            Assert.Equal(62053745, dbSnpEntry.RsId);
        }
Пример #13
0
        public void MissingEntry()
        {
            const string vcfLine =
                "1	241369	rs11490246	C	T	.	.	RS=11490246;RSPOS=241369;dbSNPBuildID=120;SSR=0;SAO=0;VP=0x050000000005000126000100;WGT=1;VC=SNV;ASP;GNO;KGPhase3;CAF=0,1;COMMON=0";

            var sequenceProvider = ParserTestUtils.GetSequenceProvider(241369, "C", 'A', _refChromDict);
            var dbsnpReader      = new DbSnpReader(null, sequenceProvider);
            var dbSnpEntry       = dbsnpReader.ExtractItem(vcfLine).First();

            Assert.Equal(11490246, dbSnpEntry.RsId);
        }
Пример #14
0
        public void DisregardZeroFreq()
        {
            const string vcfLine =
                "1	241369	rs11490246	C	T	.	.	RS=11490246;RSPOS=241369;dbSNPBuildID=120;SSR=0;SAO=0;VP=0x050100000005000126000100;WGT=1;VC=SNV;SLO;ASP;GNO;KGPhase3;CAF=0,1;COMMON=0";
            var dbsnpReader = new DbSnpReader(null, _refChromDict);
            var dbSnpEntry  = dbsnpReader.ExtractItem(vcfLine)[0];

            Assert.Equal("T", dbSnpEntry.AlternateAllele);
            Assert.Equal(1, dbSnpEntry.AltAlleleFreq);
            Assert.Equal(double.MinValue, dbSnpEntry.RefAlleleFreq);
        }
Пример #15
0
        public void MissingEntry()
        {
            const string vcfLine =
                "1	241369	rs11490246	C	T	.	.	RS=11490246;RSPOS=241369;dbSNPBuildID=120;SSR=0;SAO=0;VP=0x050000000005000126000100;WGT=1;VC=SNV;ASP;GNO;KGPhase3;CAF=0,1;COMMON=0";

            var dbsnpReader = new DbSnpReader(null, _refChromDict);
            var dbSnpEntry  = dbsnpReader.ExtractItem(vcfLine)[0];

            Assert.Equal(11490246, dbSnpEntry.RsId);
            Assert.Equal(1, dbSnpEntry.AltAlleleFreq);
        }
Пример #16
0
        public void NoMinorAllele()
        {
            const string vcfLine =
                "17	828	rs62053745	T	C	.	.	RS=62053745;RSPOS=828;dbSNPBuildID=129;SSR=0;SAO=0;VP=0x050100080005140136000100;WGT=1;VC=SNV;SLO;INT;ASP;VLD;GNO;KGPhase1;KGPhase3;CAF=.,0.7424;COMMON=1";

            var dbsnpReader = new DbSnpReader(null, _refChromDict);
            var dbSnpEntry  = dbsnpReader.ExtractItem(vcfLine)[0];

            Assert.Equal("C", dbSnpEntry.AlternateAllele);
            Assert.Equal(0.7424, dbSnpEntry.AltAlleleFreq);
            Assert.Equal(double.MinValue, dbSnpEntry.RefAlleleFreq);
        }
Пример #17
0
        public void MergeDbSnpCosmic1Kg()
        {
            const string vcfLine1 = "1	10228	rs143255646	TA	T	.	.	RS=143255646;RSPOS=10229;dbSNPBuildID=134;SSR=0;SAO=0;VP=0x050000020005000002000200;WGT=1;VC=DIV;R5;ASP";
            const string vcfLine2 = "1	10228	.	TA	T	100	PASS	AC=2130;AF=0.425319;AN=5008;NS=2504;DP=103152;EAS_AF=0.3363;AMR_AF=0.3602;AFR_AF=0.4909;EUR_AF=0.4056;SAS_AF=0.4949;AA=|||unknown(NO_COVERAGE)";

            var sa              = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(10229));
            var dbsnpReader     = new DbSnpReader(_renamer);
            var dbSnpItem1      = dbsnpReader.ExtractItem(vcfLine1)[0];
            var additionalItems = new List <SupplementaryDataItem>
            {
                dbSnpItem1.SetSupplementaryAnnotations(sa)
            };


            var cosmicItem1 = new CosmicItem("1", 10229, "COSM1000", "TA", "T", "TP53",
                                             new HashSet <CosmicItem.CosmicStudy> {
                new CosmicItem.CosmicStudy(null, "carcinoma", "oesophagus")
            }, null);

            additionalItems.Add(cosmicItem1.SetSupplementaryAnnotations(sa));

            var oneKGenItem = _oneKGenReader.ExtractItems(vcfLine2)[0];

            additionalItems.Add(oneKGenItem.SetSupplementaryAnnotations(sa));

            //sa.Clear();
            foreach (var item in additionalItems)
            {
                item.SetSupplementaryAnnotations(sa);
            }

            var asa   = sa.SaPosition.AlleleSpecificAnnotations["1"];
            var dbSnp = asa.Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.DbSnp)] as DbSnpAnnotation;
            var oneKg = asa.Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.OneKg)] as OneKGenAnnotation;

            Assert.NotNull(oneKg);

            var oneKgAc = oneKg.OneKgAllAc;
            var oneKgAn = oneKg.OneKgAllAn;

            Assert.NotNull(oneKgAc);
            Assert.NotNull(oneKgAn);

            Assert.NotNull(dbSnp);
            Assert.NotNull(oneKg);
            Assert.Equal(dbSnp.DbSnp, new List <long> {
                143255646
            });
            Assert.Equal("0.425319", (oneKgAc.Value / (double)oneKgAn.Value).ToString(JsonCommon.FrequencyRoundingFormat));

            Assert.True(sa.SaPosition.ContainsCosmicId("COSM1000"));
        }
Пример #18
0
        public void GetItems_test()
        {
            var sequence = new SimpleSequence(new string('A', VariantUtils.MaxUpstreamLength) + "T" + new string('G', 10329 - 10285) + "AC", 10284 - VariantUtils.MaxUpstreamLength);

            var sequenceProvider = new SimpleSequenceProvider(GenomeAssembly.GRCh37, sequence, ChromosomeUtilities.RefNameToChromosome);

            var reader = new DbSnpReader(GetStream(), sequenceProvider);

            var items = reader.GetItems().ToList();

            Assert.Equal(3, items.Count);
            Assert.Equal("\"rs866375379\"", items[0].GetJsonString());
        }
Пример #19
0
        public void MissingDbsnpId()
        {
            const string vcfLine =
                "X	21505833	rs12395602	G	A,C,T	.	.	RS=12395602;RSPOS=21505833;dbSNPBuildID=120;SSR=0;SAO=0;VP=0x05010008000505051f000101;WGT=1;VC=SNV;SLO;INT;ASP;VLD;G5;HD;GNO;KGPhase1";

            var dbsnpReader  = new DbSnpReader(null, _refChromDict);
            var dbSnpEntries = dbsnpReader.ExtractItem(vcfLine);

            Assert.Equal(3, dbSnpEntries.Count);
            Assert.Equal("A", dbSnpEntries[0].AlternateAllele);
            Assert.Equal(12395602, dbSnpEntries[0].RsId);
            Assert.Equal("C", dbSnpEntries[1].AlternateAllele);
            Assert.Equal(12395602, dbSnpEntries[1].RsId);
            Assert.Equal("T", dbSnpEntries[2].AlternateAllele);
            Assert.Equal(12395602, dbSnpEntries[2].RsId);
        }
Пример #20
0
        private static ExitCodes ProgramExecution()
        {
            var referenceProvider = new ReferenceSequenceProvider(FileUtilities.GetReadStream(_compressedReference));
            var version           = DataSourceVersionReader.GetSourceVersion(_inputFile + ".version");

            string outFileName = $"{version.Name}_{version.Version}";

            using (var dbSnpReader = new DbSnpReader(GZipUtilities.GetAppropriateReadStream(_inputFile), referenceProvider))
                using (var nsaStream = FileUtilities.GetCreateStream(Path.Combine(_outputDirectory, outFileName + SaCommon.SaFileSuffix)))
                    using (var indexStream = FileUtilities.GetCreateStream(Path.Combine(_outputDirectory, outFileName + SaCommon.SaFileSuffix + SaCommon.IndexSufix)))
                        using (var nsaWriter = new NsaWriter(nsaStream, indexStream, version, referenceProvider, SaCommon.DbsnpTag, true, true, SaCommon.SchemaVersion, false))
                        {
                            nsaWriter.Write(dbSnpReader.GetItems());
                        }

            return(ExitCodes.Success);
        }
Пример #21
0
        public void MissingDbsnpId()
        {
            const string vcfLine =
                "X	21505833	rs12395602	G	A,C,T	.	.	RS=12395602;RSPOS=21505833;dbSNPBuildID=120;SSR=0;SAO=0;VP=0x05010008000505051f000101;WGT=1;VC=SNV;SLO;INT;ASP;VLD;G5;HD;GNO;KGPhase1";

            var sequenceProvider = ParserTestUtils.GetSequenceProvider(21505833, "G", 'G', ChromosomeUtilities.RefNameToChromosome);
            var dbsnpReader      = new DbSnpReader(null, sequenceProvider);

            var dbSnpEntries = dbsnpReader.ExtractItem(vcfLine).ToList();

            Assert.Equal(3, dbSnpEntries.Count);
            Assert.Equal("A", dbSnpEntries[0].AltAllele);
            Assert.Equal(12395602, dbSnpEntries[0].RsId);
            Assert.Equal("C", dbSnpEntries[1].AltAllele);
            Assert.Equal(12395602, dbSnpEntries[1].RsId);
            Assert.Equal("T", dbSnpEntries[2].AltAllele);
            Assert.Equal(12395602, dbSnpEntries[2].RsId);
        }
Пример #22
0
        public void RefGlobalMajor()
        {
            // NIR-942
            const string vcfLine =
                "1	1242707	rs2274262	A	G,T	.	.	RS=2274262;RSPOS=1242707;RV;dbSNPBuildID=100;SSR=0;SAO=0;VP=0x0501004a000507013e000100;WGT=1;VC=SNV;SLO;U5;INT;R5;ASP;VLD;G5A;G5;GNO;KGPhase1;KGPhase3;CAF=0.4,0.4,0.2;COMMON=1";

            var dbsnpReader = new DbSnpReader(_renamer);
            var dbSnpEntry  = dbsnpReader.ExtractItem(vcfLine)[0];

            var sa        = new SupplementaryAnnotationPosition(1242707);
            var saCreator = new SupplementaryPositionCreator(sa);

            dbSnpEntry.SetSupplementaryAnnotations(saCreator);

            saCreator.FinalizePositionalAnnotations();

            Assert.Equal("A", sa.GlobalMajorAllele);
            Assert.Equal("G", sa.GlobalMinorAllele);
        }
Пример #23
0
        public void DisregardZeroFreq()
        {
            const string vcfLine =
                "1	241369	rs11490246	C	T	.	.	RS=11490246;RSPOS=241369;dbSNPBuildID=120;SSR=0;SAO=0;VP=0x050100000005000126000100;WGT=1;VC=SNV;SLO;ASP;GNO;KGPhase3;CAF=0,1;COMMON=0";
            var dbsnpReader = new DbSnpReader(_renamer);
            var dbSnpEntry  = dbsnpReader.ExtractItem(vcfLine)[0];

            var sa        = new SupplementaryAnnotationPosition(828);
            var saCreator = new SupplementaryPositionCreator(sa);

            dbSnpEntry.SetSupplementaryAnnotations(saCreator);

            saCreator.FinalizePositionalAnnotations();

            Assert.Equal("T", sa.GlobalMajorAllele);
            Assert.Equal("1", sa.GlobalMajorAlleleFrequency);
            Assert.Null(sa.GlobalMinorAllele);
            Assert.Null(sa.GlobalMinorAlleleFrequency);
        }
Пример #24
0
        public void MergeMultipleDbSnpItems()
        {
            const string vcfLine1 =
                "1	1469597	rs3118506	GCG	GC,GG	.	.	RS=3118506;RSPOS=1469598;RV;dbSNPBuildID=103;SSR=0;SAO=0;VP=0x050000800005000002000110;WGT=1;VC=SNV;U3;ASP;NOC";
            const string vcfLine2 =
                "1	1469598	rs368645009	CG	C	.	.	RS=368645009;RSPOS=1469599;RV;dbSNPBuildID=138;SSR=0;SAO=0;VP=0x050000800005000002000200;WGT=1;VC=DIV;U3;ASP";

            var sa1 = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(1469599));
            var sa2 = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(1469599));

            var dbsnpReader = new DbSnpReader(_renamer);
            var dbSnpItems  = dbsnpReader.ExtractItem(vcfLine1);
            var dbSnpItem2  = dbsnpReader.ExtractItem(vcfLine2)[0];

            var additionalItems = dbSnpItems.Select(dbSnpItem => dbSnpItem.SetSupplementaryAnnotations(sa1)).ToList();

            foreach (var item in additionalItems)
            {
                item.SetSupplementaryAnnotations(sa1);
            }

            additionalItems.Clear();
            additionalItems.Add(dbSnpItem2.SetSupplementaryAnnotations(sa2));

            foreach (var item in additionalItems)
            {
                item.SetSupplementaryAnnotations(sa2);
            }

            sa1.MergeSaCreator(sa2);

            var expectedDbSnp = new List <long> {
                3118506, 368645009
            };

            var dbSnp =
                sa1.SaPosition.AlleleSpecificAnnotations["1"].Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.DbSnp)] as
                DbSnpAnnotation;

            Assert.NotNull(dbSnp);

            Assert.Equal(expectedDbSnp, dbSnp.DbSnp);
        }
Пример #25
0
        public void MissingDbsnpId()
        {
            // refactorSA. Annotation for C is missing in the database. have to debug that.

            const string vcfLine =
                "X	21505833	rs12395602	G	A,C,T	.	.	RS=12395602;RSPOS=21505833;dbSNPBuildID=120;SSR=0;SAO=0;VP=0x05010008000505051f000101;WGT=1;VC=SNV;SLO;INT;ASP;VLD;G5;HD;GNO;KGPhase1";

            var dbsnpReader  = new DbSnpReader(_renamer);
            var dbSnpEntries = dbsnpReader.ExtractItem(vcfLine);

            var sa        = new SupplementaryAnnotationPosition(21505833);
            var saCreator = new SupplementaryPositionCreator(sa);

            foreach (var dbSnpEntry in dbSnpEntries)
            {
                dbSnpEntry.SetSupplementaryAnnotations(saCreator);
            }

            saCreator.FinalizePositionalAnnotations();

            var dbSnpA =
                sa.AlleleSpecificAnnotations["A"].Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.DbSnp)] as
                DbSnpAnnotation;

            Assert.NotNull(dbSnpA);

            var dbSnpC =
                sa.AlleleSpecificAnnotations["C"].Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.DbSnp)] as
                DbSnpAnnotation;

            Assert.NotNull(dbSnpC);

            var dbSnpT =
                sa.AlleleSpecificAnnotations["T"].Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.DbSnp)] as
                DbSnpAnnotation;

            Assert.NotNull(dbSnpT);

            Assert.Equal(12395602, dbSnpA.DbSnp[0]);
            Assert.Equal(12395602, dbSnpC.DbSnp[0]);
            Assert.Equal(12395602, dbSnpT.DbSnp[0]);
        }
Пример #26
0
        public void NoMinorAllele1()
        {
            const string vcfLine =
                "17	828	rs62053745	T	C	.	.	RS=62053745;RSPOS=828;dbSNPBuildID=129;SSR=0;SAO=0;VP=0x050100080005140136000100;WGT=1;VC=SNV;SLO;INT;ASP;VLD;GNO;KGPhase1;KGPhase3;CAF=0.7424,.;COMMON=1";

            var dbsnpReader = new DbSnpReader(_renamer);
            var dbSnpEntry  = dbsnpReader.ExtractItem(vcfLine)[0];

            var sa        = new SupplementaryAnnotationPosition(828);
            var saCreator = new SupplementaryPositionCreator(sa);

            dbSnpEntry.SetSupplementaryAnnotations(saCreator);

            saCreator.FinalizePositionalAnnotations();

            Assert.Equal("T", sa.GlobalMajorAllele);
            Assert.Equal("0.7424", sa.GlobalMajorAlleleFrequency);
            Assert.Null(sa.GlobalMinorAllele);
            Assert.Null(sa.GlobalMinorAlleleFrequency);
        }
Пример #27
0
        public void MergeDbSnpCosmic()
        {
            const string vcfLine1 = "1	10228	rs143255646	TA	T	.	.	RS=143255646;RSPOS=10229;dbSNPBuildID=134;SSR=0;SAO=0;VP=0x050000020005000002000200;WGT=1;VC=DIV;R5;ASP";


            var sa              = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(10229));
            var dbsnpReader     = new DbSnpReader(_renamer);
            var dbSnpItem1      = dbsnpReader.ExtractItem(vcfLine1)[0];
            var additionalItems = new List <SupplementaryDataItem>
            {
                dbSnpItem1.SetSupplementaryAnnotations(sa)
            };

            var cosmicItem1 = new CosmicItem("1", 10229, "COSM1000", "TA", "T", "TP53",
                                             new HashSet <CosmicItem.CosmicStudy> {
                new CosmicItem.CosmicStudy(null, "carcinoma", "oesophagus")
            }, null);
            var cosmicItem2 = new CosmicItem("1", 10229, "COSM1000", "TA", "T", "TP53",
                                             new HashSet <CosmicItem.CosmicStudy> {
                new CosmicItem.CosmicStudy("01", "carcinoma", "large_intestine")
            }, null);

            additionalItems.Add(cosmicItem1.SetSupplementaryAnnotations(sa));
            additionalItems.Add(cosmicItem2.SetSupplementaryAnnotations(sa));

            //sa.Clear();
            foreach (var item in additionalItems)
            {
                item.SetSupplementaryAnnotations(sa);
            }

            var dbSnpAnnotation =
                sa.SaPosition.AlleleSpecificAnnotations["1"].Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.DbSnp)] as
                DbSnpAnnotation;

            Assert.NotNull(dbSnpAnnotation);
            Assert.Equal(dbSnpAnnotation.DbSnp, new List <long> {
                143255646
            });
            Assert.True(sa.SaPosition.ContainsCosmicId("COSM1000"));
        }
Пример #28
0
        public void MergeDbSnpItems()
        {
            const string vcfLine1 = "1	10228	rs143255646	TA	T	.	.	RS=143255646;RSPOS=10229;dbSNPBuildID=134;SSR=0;SAO=0;VP=0x050000020005000002000200;WGT=1;VC=DIV;R5;ASP";
            const string vcfLine2 = "1	10228	rs200462216	TAACCCCTAACCCTAACCCTAAACCCTA	T	.	.	RS=200462216;RSPOS=10229;dbSNPBuildID=137;SSR=0;SAO=0;VP=0x050000020005000002000200;WGT=1;VC=DIV;R5;ASP";

            var sa          = new SupplementaryPositionCreator(new SupplementaryAnnotationPosition(10229));
            var dbsnpReader = new DbSnpReader(_renamer);
            var dbSnpItem1  = dbsnpReader.ExtractItem(vcfLine1)[0];
            var dbSnpItem2  = dbsnpReader.ExtractItem(vcfLine2)[0];

            var additionalItems = new List <SupplementaryDataItem>
            {
                dbSnpItem1.SetSupplementaryAnnotations(sa),
                dbSnpItem2.SetSupplementaryAnnotations(sa)
            };

            //sa.Clear();
            foreach (var item in additionalItems)
            {
                item.SetSupplementaryAnnotations(sa);
            }

            var dbSnp1 =
                sa.SaPosition.AlleleSpecificAnnotations["1"].Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.DbSnp)] as
                DbSnpAnnotation;

            Assert.NotNull(dbSnp1);

            var dbSnp27 =
                sa.SaPosition.AlleleSpecificAnnotations["27"].Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.DbSnp)] as
                DbSnpAnnotation;

            Assert.NotNull(dbSnp27);

            Assert.Equal(dbSnp1.DbSnp, new List <long> {
                143255646
            });
            Assert.Equal(dbSnp27.DbSnp, new List <long> {
                200462216
            });
        }
Пример #29
0
        public void ReadWriteDbSnpCosmic()
        {
            var randomPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            // create our expected data source versions
            var dbSnpVersion  = new DataSourceVersion("dbSNP", "142", DateTime.Parse("2015-01-02").Ticks);
            var cosmicVersion = new DataSourceVersion("COSMIC", "GRCh37_v71", DateTime.Parse("2014-10-21").Ticks);

            var expectedDataSourceVersions = new List <DataSourceVersion> {
                dbSnpVersion, cosmicVersion
            };

            // create our expected supplementary annotations
            const string vcfLine1 = "1	10228	rs143255646	TA	T	.	.	RS=143255646;RSPOS=10229;dbSNPBuildID=134;SSR=0;SAO=0;VP=0x050000020005000002000200;WGT=1;VC=DIV;R5;ASP";

            var sa        = new SupplementaryAnnotationPosition(10229);
            var saCreator = new SupplementaryPositionCreator(sa);

            var dbsnpReader     = new DbSnpReader(_renamer);
            var dbSnpItem1      = dbsnpReader.ExtractItem(vcfLine1)[0];
            var additionalItems = new List <SupplementaryDataItem>
            {
                dbSnpItem1.SetSupplementaryAnnotations(saCreator)
            };

            var cosmicItem1 = new CosmicItem("1", 10229, "COSM1000", "TA", "T", "TP53",
                                             new HashSet <CosmicItem.CosmicStudy> {
                new CosmicItem.CosmicStudy("", "carcinoma", "oesophagus")
            }, null);
            var cosmicItem2 = new CosmicItem("1", 10229, "COSM1000", "TA", "T", "TP53",
                                             new HashSet <CosmicItem.CosmicStudy> {
                new CosmicItem.CosmicStudy("01", "carcinoma", "large_intestine")
            }, null);

            additionalItems.Add(cosmicItem1.SetSupplementaryAnnotations(saCreator));
            additionalItems.Add(cosmicItem2.SetSupplementaryAnnotations(saCreator));

            //sa.Clear();
            foreach (var item in additionalItems)
            {
                item.SetSupplementaryAnnotations(saCreator);
            }

            Assert.Equal(1, sa.CosmicItems.Count);
            // the preceeding code has been unit tested in  MergeDbSnpCosmic()

            // write the supplementary annotation file
            using (var writer = new SupplementaryAnnotationWriter(randomPath, "chr1", expectedDataSourceVersions))
            {
                writer.Write(saCreator, sa.ReferencePosition);
            }

            // read the supplementary annotation file
            using (var reader = new SupplementaryAnnotationReader(randomPath))
            {
                // extract the three annotations
                var observedAnnotation1 = reader.GetAnnotation(10229) as SupplementaryAnnotationPosition;
                Assert.NotNull(observedAnnotation1);

                var expDbSnp =
                    sa.AlleleSpecificAnnotations["1"].Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.DbSnp)] as
                    DbSnpAnnotation;
                Assert.NotNull(expDbSnp);
                var obsDbSnp =
                    observedAnnotation1.AlleleSpecificAnnotations["1"].Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.DbSnp)] as
                    DbSnpAnnotation;
                Assert.NotNull(obsDbSnp);

                Assert.Equal(expDbSnp.DbSnp, obsDbSnp.DbSnp);
                Assert.True(observedAnnotation1.ContainsCosmicId(sa.CosmicItems[0].ID));
                Assert.Equal(1, observedAnnotation1.CosmicItems.Count);
            }

            File.Delete(randomPath);
            File.Delete(randomPath + ".idx");
        }
Пример #30
0
        public void ReadWriteExacDbsnp()
        {
            var randomPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            // create our expected data source versions
            var dbSnpVersion  = new DataSourceVersion("dbSNP", "142", DateTime.Parse("2015-01-02").Ticks);
            var cosmicVersion = new DataSourceVersion("COSMIC", "GRCh37_v71", DateTime.Parse("2014-10-21").Ticks);

            var expectedDataSourceVersions = new List <DataSourceVersion> {
                dbSnpVersion, cosmicVersion
            };

            // create our expected supplementary annotations
            const string vcfLine1 = "2	48010488	rs1042821	G	A	.	.	RS=1042821;RSPOS=48010488;RV;dbSNPBuildID=86;SSR=0;SAO=1;VP=0x050168420a05150136100100;GENEINFO=MSH6:2956;WGT=1;VC=SNV;PM;PMC;SLO;NSM;REF;U5;R5;ASP;VLD;G5;GNO;KGPhase1;KGPhase3;LSD;CAF=0.7991,0.2009;COMMON=1";
            const string vcfLine2 =
                "2	48010488	rs1042821	G	A,C	14068898.15	PASS	AC=21019,1;AC_AFR=1700,0;AC_AMR=1015,1;AC_Adj=19510,1;AC_EAS=1973,0;AC_FIN=743,0;AC_Het=15722,1,0;AC_Hom=1894,0;AC_NFE=10593,0;AC_OTH=147,0;AC_SAS=3339,0;AF=0.178,8.487e-06;AN=117830;AN_AFR=6388;AN_AMR=9014;AN_Adj=91130;AN_EAS=6792;AN_FIN=5078;AN_NFE=48404;AN_OTH=664;AN_SAS=14790;BaseQRankSum=-4.850e-01;ClippingRankSum=-1.400e-01;DB;DP=1206681;FS=0.000;GQ_MEAN=129.86;GQ_STDDEV=221.88;Het_AFR=1322,0,0;Het_AMR=931,1,0;Het_EAS=1511,0,0;Het_FIN=665,0,0;Het_NFE=8585,0,0;Het_OTH=111,0,0;Het_SAS=2597,0,0;Hom_AFR=189,0;Hom_AMR=42,0;Hom_EAS=231,0;Hom_FIN=39,0;Hom_NFE=1004,0;Hom_OTH=18,0;Hom_SAS=371,0;InbreedingCoeff=0.0376;MQ=60.00;MQ0=0;MQRankSum=0.00;NCC=3737;POSITIVE_TRAIN_SITE;QD=17.46;ReadPosRankSum=0.181;VQSLOD=5.87;culprit=MQ;DP_HIST=3051|9435|11318|5521|9711|11342|4131|1270|615|404|328|266|264|262|196|186|126|115|97|277,133|968|2180|3402|3564|2815|1772|954|551|389|321|263|261|261|196|186|126|115|97|277,0|0|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0;GQ_HIST=949|2966|347|492|15135|1435|1335|854|421|526|590|416|13672|1951|445|462|255|174|211|16279,24|79|81|124|135|96|110|118|97|180|228|137|182|191|126|171|180|151|192|16229,0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|1";

            var sa        = new SupplementaryAnnotationPosition(48010488);
            var saCreator = new SupplementaryPositionCreator(sa);

            var dbsnpReader = new DbSnpReader(_renamer);
            var dbSnpItem1  = dbsnpReader.ExtractItem(vcfLine1)[0];

            dbSnpItem1.SetSupplementaryAnnotations(saCreator);

            var exacReader = new ExacReader(_renamer);

            foreach (var exacItem in exacReader.ExtractItems(vcfLine2))
            {
                exacItem.SetSupplementaryAnnotations(saCreator);
            }


            // write the supplementary annotation file
            using (var writer = new SupplementaryAnnotationWriter(randomPath, "chr2", expectedDataSourceVersions))
            {
                writer.Write(saCreator, sa.ReferencePosition);
            }

            // read the supplementary annotation file
            using (var reader = new SupplementaryAnnotationReader(randomPath))
            {
                // extract the three annotations
                var observedAnnotation1 = reader.GetAnnotation(48010488) as SupplementaryAnnotationPosition;
                Assert.NotNull(observedAnnotation1);


                var expDbSnpA =
                    sa.AlleleSpecificAnnotations["A"].Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.DbSnp)] as DbSnpAnnotation;
                var obsDbSnpA =
                    observedAnnotation1.AlleleSpecificAnnotations["A"].Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.DbSnp)] as DbSnpAnnotation;
                Assert.NotNull(expDbSnpA);
                Assert.NotNull(obsDbSnpA);

                // we want to make sure we are reading the values we have written
                Assert.Equal(expDbSnpA.DbSnp, obsDbSnpA.DbSnp);


                var expExacA =
                    sa.AlleleSpecificAnnotations["A"].Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.Exac)] as ExacAnnotation;
                var obsExacA =
                    observedAnnotation1.AlleleSpecificAnnotations["A"].Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.Exac)] as ExacAnnotation;

                Assert.NotNull(expExacA);
                Assert.NotNull(obsExacA);

                Assert.Equal(expExacA.ExacAllAn, obsExacA.ExacAllAn);
                Assert.Equal(expExacA.ExacCoverage, obsExacA.ExacCoverage);
                Assert.Equal(Convert.ToDouble(expExacA.ExacAllAc), Convert.ToDouble(obsExacA.ExacAllAc));
                Assert.Equal(Convert.ToDouble(expExacA.ExacAfrAc), Convert.ToDouble(obsExacA.ExacAfrAc));
                Assert.Equal(Convert.ToDouble(expExacA.ExacAmrAc), Convert.ToDouble(obsExacA.ExacAmrAc));
                Assert.Equal(Convert.ToDouble(expExacA.ExacEasAc), Convert.ToDouble(obsExacA.ExacEasAc));
                Assert.Equal(Convert.ToDouble(expExacA.ExacFinAc), Convert.ToDouble(obsExacA.ExacFinAc));
                Assert.Equal(Convert.ToDouble(expExacA.ExacNfeAc), Convert.ToDouble(obsExacA.ExacNfeAc));
                Assert.Equal(Convert.ToDouble(expExacA.ExacOthAc), Convert.ToDouble(obsExacA.ExacOthAc));
                Assert.Equal(Convert.ToDouble(expExacA.ExacSasAc), Convert.ToDouble(obsExacA.ExacSasAc));


                var expExacC =
                    sa.AlleleSpecificAnnotations["C"].Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.Exac)] as ExacAnnotation;
                var obsExacC =
                    observedAnnotation1.AlleleSpecificAnnotations["C"].Annotations[DataSourceCommon.GetIndex(DataSourceCommon.DataSource.Exac)] as ExacAnnotation;

                Assert.NotNull(expExacC);
                Assert.NotNull(obsExacC);

                Assert.Equal(expExacC.ExacCoverage, obsExacC.ExacCoverage);
                Assert.Equal(Convert.ToDouble(expExacC.ExacAllAc), Convert.ToDouble(obsExacC.ExacAllAc));
                Assert.Equal(Convert.ToDouble(expExacC.ExacAfrAc), Convert.ToDouble(obsExacC.ExacAfrAc));
                Assert.Equal(Convert.ToDouble(expExacC.ExacAmrAc), Convert.ToDouble(obsExacC.ExacAmrAc));
                Assert.Equal(Convert.ToDouble(expExacC.ExacEasAc), Convert.ToDouble(obsExacC.ExacEasAc));
                Assert.Equal(Convert.ToDouble(expExacC.ExacFinAc), Convert.ToDouble(obsExacC.ExacFinAc));
                Assert.Equal(Convert.ToDouble(expExacC.ExacNfeAc), Convert.ToDouble(obsExacC.ExacNfeAc));
                Assert.Equal(Convert.ToDouble(expExacC.ExacOthAc), Convert.ToDouble(obsExacC.ExacOthAc));
                Assert.Equal(Convert.ToDouble(expExacC.ExacSasAc), Convert.ToDouble(obsExacC.ExacSasAc));
            }

            File.Delete(randomPath);
            File.Delete(randomPath + ".idx");
        }