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")); }
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")); }
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"); }