コード例 #1
0
        public void AnnotationSourceConstructor()
        {
            var saPath              = Resources.TopPath("DirectoryIntegrity");
            var cacheStub           = Resources.CacheGRCh37("ENST00000579787_chr1_Ensembl84");
            var customAnnoPath      = Resources.TopPath("DirectoryIntegrity");
            var customIntervalsPath = Resources.TopPath("DirectoryIntegrity");

            var conservationScoreReader = new PhylopReader(saPath);

            var transcriptStream = ResourceUtilities.GetReadStream(cacheStub + ".ndb");
            var siftStream       = ResourceUtilities.GetReadStream(cacheStub + ".sift");
            var polyPhenStream   = ResourceUtilities.GetReadStream(cacheStub + ".polyphen");
            var referenceStream  = ResourceUtilities.GetReadStream(cacheStub + ".bases");

            var streams = new AnnotationSourceStreams(transcriptStream, siftStream, polyPhenStream, referenceStream);

            var customAnnotationProvider = new CustomAnnotationProvider(new[] { customAnnoPath });
            var customIntervalProvider   = new CustomIntervalProvider(new[] { customIntervalsPath });
            var saProvider = new SupplementaryAnnotationProvider(saPath);

            var annotationSource = new NirvanaAnnotationSource(streams, saProvider, conservationScoreReader,
                                                               customAnnotationProvider, customIntervalProvider, null);

            Assert.NotNull(annotationSource);
        }
コード例 #2
0
        public void EmptySamplesTest()
        {
            using (var reader = new LiteVcfReader(ResourceUtilities.GetReadStream(Resources.InputFiles("Nirvana_unified_json_format.vcf"))))
            {
                // getting the 4th variant
                VcfUtilities.GetNextVariant(reader, _renamer);
                VcfUtilities.GetNextVariant(reader, _renamer);
                VcfUtilities.GetNextVariant(reader, _renamer);
                var variant = VcfUtilities.GetNextVariant(reader, _renamer);

                // GT:GQ:GQX:DPI:AD
                // 0/1:124:19:5:11,8:PASS:.
                // .
                // 1/2:55:59:.:0,21:LowGQX:20

                // the unified json will call this function to get all the samples and can print them out using GetEntry as shown below
                var sampleVariants = variant.ExtractSampleInfo();

                var expectedEntry =
                    "{\"variantFreq\":0.4211,\"genotypeQuality\":124,\"alleleDepths\":[11,8],\"genotype\":\"0/1\"}";
                var observedEntry = sampleVariants[0].ToString();
                Assert.Equal(expectedEntry, observedEntry);

                expectedEntry = "{\"isEmpty\":true}";
                observedEntry = sampleVariants[1].ToString();
                Assert.Equal(expectedEntry, observedEntry);

                expectedEntry =
                    "{\"variantFreq\":1,\"totalDepth\":20,\"genotypeQuality\":55,\"alleleDepths\":[0,21],\"genotype\":\"1/2\",\"failedFilter\":true}";
                observedEntry = sampleVariants[2].ToString();
                Assert.Equal(expectedEntry, observedEntry);
            }
        }
コード例 #3
0
        public void JsonSamplesOutput()
        {
            using (var reader = new LiteVcfReader(ResourceUtilities.GetReadStream(Resources.InputFiles("Nirvana_unified_json_format.vcf"))))
            {
                // LP2000021	LP2000022	LP2000023
                Assert.Equal("LP2000021", reader.SampleNames[0]);
                Assert.Equal("LP2000022", reader.SampleNames[1]);
                Assert.Equal("LP2000023", reader.SampleNames[2]);

                var variant = VcfUtilities.GetNextVariant(reader, _renamer);

                // chr9	138685463	.	A	C	.	PASS	BaseQRankSum=-1.61165;GQ=120;DP=43;ReadPosRankSum=0;MQ=60;SNVHPOL=3;SNVSB=-65.7;MQRankSum=0	GT:GQX:GQ:DP:DPF:AD	0/0:90:0:31:0:.	0/0:75:0:26:0:.	0/1:161:194:36:0:20,16

                // the unified json will call this function to get all the samples and can print them out using GetEntry as shown below
                var sampleVariants = variant.ExtractSampleInfo();

                Assert.Equal("0/0", sampleVariants[0].Genotype);
                Assert.Equal("0/0", sampleVariants[1].Genotype);
                Assert.Equal("0/1", sampleVariants[2].Genotype);


                const string expectedEntry1 = "{\"totalDepth\":31,\"genotypeQuality\":90,\"genotype\":\"0/0\"}";
                const string expectedEntry2 = "{\"totalDepth\":26,\"genotypeQuality\":75,\"genotype\":\"0/0\"}";
                const string expectedEntry3 = "{\"variantFreq\":0.4444,\"totalDepth\":36,\"genotypeQuality\":161,\"alleleDepths\":[20,16],\"genotype\":\"0/1\"}";

                Assert.Equal(expectedEntry1, sampleVariants[0].ToString());
                Assert.Equal(expectedEntry2, sampleVariants[1].ToString());
                Assert.Equal(expectedEntry3, sampleVariants[2].ToString());
            }
        }
コード例 #4
0
ファイル: IndexTests.cs プロジェクト: wook2014/Nirvana
        public void IndexCreation_multiChromosome()
        {
            var jsonStream = new BlockGZipStream(ResourceUtilities.GetReadStream(Resources.TopPath("cosmicv72.indels.json.gz")), CompressionMode.Decompress);

            var writeStream = new MemoryStream();

            using (var indexCreator = new IndexCreator(jsonStream, writeStream))
            {
                indexCreator.CreateIndex();
            }

            JasixIndex readBackIndex;
            var        readStream = new MemoryStream(writeStream.ToArray());

            readStream.Seek(0, SeekOrigin.Begin);

            using (readStream)
            {
                readBackIndex = new JasixIndex(readStream);
            }

            Assert.Equal(2268, readBackIndex.GetFirstVariantPosition("chr1", 9775924, 9775924));
            Assert.Equal(14035925971, readBackIndex.GetFirstVariantPosition("chr2", 16081096, 16081096));
            Assert.Equal(433156622693, readBackIndex.GetFirstVariantPosition("chr20", 36026164, 36026164));
            Assert.Equal(439602269527, readBackIndex.GetFirstVariantPosition("chrX", 66765044, 66765044));
        }
コード例 #5
0
ファイル: IndexTests.cs プロジェクト: wook2014/Nirvana
        public void GetGeneSection()
        {
            var readStream  = new BlockGZipStream(ResourceUtilities.GetReadStream(Resources.TopPath("Clinvar20150901.json.gz")), CompressionMode.Decompress);
            var indexStream = ResourceUtilities.GetReadStream(Resources.TopPath("Clinvar20150901.json.gz.jsi"));

            var outStream = new MemoryStream();

            using (var writer = new StreamWriter(outStream, Encoding.UTF8, 512, true))
                using (var qp = new QueryProcessor(new StreamReader(readStream), indexStream, writer))
                {
                    writer.NewLine = "\r\n";
                    qp.PrintSection("genes");
                }

            Assert.NotEqual(0, outStream.Length);
            outStream.Position = 0;
            using (var reader = new StreamReader(outStream))
            {
                var count = 0;
                var line  = reader.ReadLine();
                while (line != null)
                {
                    count++;
                    line = reader.ReadLine();
                }

                Assert.Equal(127, count);
            }
        }
コード例 #6
0
 public void NoSamples()
 {
     using (var reader = new LiteVcfReader(ResourceUtilities.GetReadStream(Resources.InputFiles("NoSamples.vcf"))))
     {
         Assert.Null(reader.SampleNames);
     }
 }
コード例 #7
0
        /// <summary>
        /// constructor
        /// </summary>
        public ChromosomeRenamerFixture()
        {
            var referenceStream = ResourceUtilities.GetReadStream(Resources.CacheGRCh37("ENSR00001584270_chr1_Ensembl84_reg.bases"));

            Sequence = new CompressedSequence();
            Reader   = new CompressedSequenceReader(referenceStream, Sequence);
            Renamer  = Sequence.Renamer;
        }
コード例 #8
0
 public void CopyNumberExtractionNormal()
 {
     using (var reader = new LiteVcfReader(ResourceUtilities.GetReadStream(Resources.InputFiles("canvas.vcf"))))
     {
         Assert.Equal(9, VcfCommon.GenotypeIndex);
         Assert.Equal("SAMPLE", reader.SampleNames[0]);
     }
 }
コード例 #9
0
 public void CopyNumberExtractionTumor()
 {
     using (var reader = new LiteVcfReader(ResourceUtilities.GetReadStream(Resources.InputFiles("tumor.vcf"))))
     {
         Assert.Equal(9, VcfCommon.GenotypeIndex);
         Assert.Equal("TUMOR", reader.SampleNames[1]);
     }
 }
コード例 #10
0
        public void GetColumnIndices_missing_column()
        {
            const string header = @"CNV_ID	ID_GENE	gene_name	ID_SAMPLE	ID_TUMOUR	Primary site	Site subtype 1	Site subtype 2	Site subtype 3	Primary histology	Histology subtype 1	Histology subtype 2	Histology subtype 3	SAMPLE_NAME	TOTAL_CN	MINOR_ALLELE	MUT_TYPE	ID_STUDY	Chromosome:G_Start..G_Stop";

            var readStream = ResourceUtilities.GetReadStream(Resources.SaPath("CosmicCNV.tsv"));

            var cnvReader = new CosmicCnvReader(readStream,
                                                ChromosomeUtilities.RefNameToChromosome,
                                                GenomeAssembly.GRCh37);

            Assert.Throws <InvalidDataException>(() => cnvReader.GetColumnIndices(header));
        }
コード例 #11
0
 public void MultiSampleVcf()
 {
     using (var reader = new LiteVcfReader(ResourceUtilities.GetReadStream(Resources.TopPath("OneKMultiSample.vcf"))))
     {
         // HG00096	HG00097	HG00099	HG00100	HG00101	HG00102......
         Assert.Equal("HG00096", reader.SampleNames[0]);
         Assert.Equal("HG00097", reader.SampleNames[1]);
         Assert.Equal("HG00099", reader.SampleNames[2]);
         Assert.Equal("HG00100", reader.SampleNames[3]);
         Assert.Equal("HG00101", reader.SampleNames[4]);
     }
 }
コード例 #12
0
        public void GetEntries()
        {
            var readStream = ResourceUtilities.GetReadStream(Resources.SaPath("CosmicCNV.tsv"));

            var cnvReader = new CosmicCnvReader(readStream,
                                                ChromosomeUtilities.RefNameToChromosome,
                                                GenomeAssembly.GRCh37);

            var cnvItems = cnvReader.GetEntries();

            Assert.Equal(5, cnvItems.Count());
        }
コード例 #13
0
        public void GetColumnIndices_valid_header()
        {
            const string header = @"CNV_ID	ID_GENE	gene_name	ID_SAMPLE	ID_TUMOUR	Primary site	Site subtype 1	Site subtype 2	Site subtype 3	Primary histology	Histology subtype 1	Histology subtype 2	Histology subtype 3	SAMPLE_NAME	TOTAL_CN	MINOR_ALLELE	MUT_TYPE	ID_STUDY	GRCh	Chromosome:G_Start..G_Stop";

            var readStream = ResourceUtilities.GetReadStream(Resources.SaPath("CosmicCNV.tsv"));

            var cnvReader = new CosmicCnvReader(readStream,
                                                ChromosomeUtilities.RefNameToChromosome,
                                                GenomeAssembly.GRCh37);

            cnvReader.GetColumnIndices(header);
            //we do not need an assert because not getting an exception in the last line means pass
        }
コード例 #14
0
        public void GetColumnIndices_missing_column()
        {
            var header = @"CNV_ID	ID_GENE	gene_name	ID_SAMPLE	ID_TUMOUR	Primary site	Site subtype 1	Site subtype 2	Site subtype 3	Primary histology	Histology subtype 1	Histology subtype 2	Histology subtype 3	SAMPLE_NAME	TOTAL_CN	MINOR_ALLELE	MUT_TYPE	ID_STUDY	Chromosome:G_Start..G_Stop";

            var readStream = ResourceUtilities.GetReadStream(Resources.TopPath("SA\\CosmicCNV.tsv"));

            var cnvReader = new CosmicCnvReader(readStream,
                                                new Dictionary <string, IChromosome>()
            {
                { "W", new Chromosome("chrW", "W", 1) }
            },
                                                GenomeAssembly.GRCh37);

            Assert.Throws <InvalidDataException>(() => cnvReader.GetColumnIndices(header));
        }
コード例 #15
0
        public void BasicCustomIntervalOutput()
        {
            var customIntervalProvider = new MockCustomIntervalProvider(ResourceUtilities.GetReadStream(Resources.CustomIntervals("chr1_IcslIntervals_69090_69091.nci")), _renamer);
            var annotationSource       = ResourceUtilities.GetAnnotationSource(DataUtilities.EmptyCachePrefix, null, null, customIntervalProvider);

            var annotatedVariant = DataUtilities.GetVariant(annotationSource,
                                                            "chr1	69092	.	T	C	.	LowGQX;HighDPFRatio	END=10244;BLOCKAVG_min30p3a	GT:GQX:DP:DPF	.:.:0:1");

            Assert.NotNull(annotatedVariant);

            const string expectedJson = "{\"altAllele\":\"C\",\"refAllele\":\"T\",\"begin\":69092,\"chromosome\":\"chr1\",\"end\":69092,\"variantType\":\"SNV\",\"vid\":\"1:69092:C\",\"IcslIntervals\":[{\"Start\":69091,\"End\":70008,\"gene\":\"OR4F5\",\"assesment\":\"Some_evidence_of_constraint\",\"score\":0.0,\"exacScore\":3.60208899915}]}";
            var          observedJson = JsonUtilities.GetFirstAlleleJson(annotatedVariant);

            Assert.Equal(expectedJson, observedJson);
        }
コード例 #16
0
ファイル: IndexTests.cs プロジェクト: wook2014/Nirvana
        public void BgzipTestReader_basic()
        {
            var stream = ResourceUtilities.GetReadStream(Resources.TopPath("TinyAnnotated.json"));

            var lineCount = 0;

            using (var jasixReader = new StreamReader(stream))
            {
                while (jasixReader.ReadLine() != null)
                {
                    lineCount++;
                }
            }

            Assert.Equal(4, lineCount);
        }
コード例 #17
0
        public void ConservationScoreTest2()
        {
            var saReader = ResourceUtilities.GetSupplementaryAnnotationReader(Resources.MiniSuppAnnot("chr1_13528_13529.nsa"));
            var csReader = new MockConservationScoreReader(ResourceUtilities.GetReadStream(Resources.TopPath("chr1_10918_150000.npd")));
            var annotatedVariant = DataUtilities.GetVariant(DataUtilities.EmptyCachePrefix, saReader,
                "1	13528	.	C	G,CT	1771.54	VQSRTrancheSNP99.60to99.80	AC=21,11;AC_AFR=12,0", csReader);
            Assert.NotNull(annotatedVariant);

            var altAllele = JsonUtilities.GetAllele(annotatedVariant);
            Assert.NotNull(altAllele);

            var altAllele2 = JsonUtilities.GetAllele(annotatedVariant, 1);
            Assert.NotNull(altAllele2);

            Assert.Contains("\"phylopScore\":0.81", altAllele);
            Assert.DoesNotContain("\"phylopScore\"", altAllele2);
        }
コード例 #18
0
        public void GetEntries()
        {
            var readStream = ResourceUtilities.GetReadStream(Resources.TopPath("SA\\CosmicCNV.tsv"));

            var cnvReader = new CosmicCnvReader(readStream,
                                                new Dictionary <string, IChromosome>()
            {
                { "17", new Chromosome("chr17", "17", 1) },
                { "Y", new Chromosome("chrY", "Y", 2) },
                { "MT", new Chromosome("chrM", "MT", 3) }
            },
                                                GenomeAssembly.GRCh37);

            var cnvItems = cnvReader.GetEntries();

            Assert.Equal(5, cnvItems.Count());
        }
コード例 #19
0
        public void GetCompressedSequence()
        {
            using (var reader = new CompressedSequenceReader(
                       ResourceUtilities.GetReadStream(Resources.TopPath("TestSeq_reference.dat"))))
            {
                var sequence   = reader.Sequence;
                var chromosome = new Chromosome("chrBob", "Bob", 0);
                reader.GetCompressedSequence(chromosome);

                Assert.Equal(0, sequence.Length);

                chromosome = new Chromosome("chrTestSeq", "TestSeq", 0);
                reader.GetCompressedSequence(chromosome);

                Assert.NotNull(reader.CytogeneticBands);
                Assert.Equal(GenomeAssembly.GRCh37, reader.Assembly);
                Assert.Equal(53, sequence.Length);
            }
        }
コード例 #20
0
        public void MultipleAllelesMultipleSamples()
        {
            using (var reader = new LiteVcfReader(ResourceUtilities.GetReadStream(Resources.InputFiles("Nirvana_unified_json_format.vcf"))))
            {
                // LP2000021	LP2000022	LP2000023
                Assert.Equal("LP2000021", reader.SampleNames[0]);
                Assert.Equal("LP2000022", reader.SampleNames[1]);
                Assert.Equal("LP2000023", reader.SampleNames[2]);

                // skip the first variant
                VcfUtilities.GetNextVariant(reader, _renamer);
                var variant = VcfUtilities.GetNextVariant(reader, _renamer);

                // GT:GQ:GQX:DPI:AD
                // 1/2:46:1:32:0,22,3
                // 1/1:147:4:27:0,12,5
                // 0/0:365:9:29:0,8,10

                // the unified json will call this function to get all the samples and can print them out using GetEntry as shown below
                var sampleVariants = variant.ExtractSampleInfo();

                Assert.Equal("1/2", sampleVariants[0].Genotype);
                Assert.Equal("1/1", sampleVariants[1].Genotype);
                Assert.Equal("0/0", sampleVariants[2].Genotype);


                // 1/2 - A
                var expectedEntry =
                    "{\"variantFreq\":1,\"totalDepth\":32,\"genotypeQuality\":1,\"alleleDepths\":[0,22,3],\"genotype\":\"1/2\"}";
                var observedEntry = sampleVariants[0].ToString();
                Assert.Equal(expectedEntry, observedEntry);

                // 1/1 - T
                expectedEntry = "{\"variantFreq\":1,\"totalDepth\":27,\"genotypeQuality\":4,\"alleleDepths\":[0,12,5],\"genotype\":\"1/1\"}";
                observedEntry = sampleVariants[1].ToString();
                Assert.Equal(expectedEntry, observedEntry);

                // 0/0 - A
                expectedEntry = "{\"variantFreq\":1,\"totalDepth\":29,\"genotypeQuality\":9,\"alleleDepths\":[0,8,10],\"genotype\":\"0/0\"}";
                observedEntry = sampleVariants[2].ToString();
                Assert.Equal(expectedEntry, observedEntry);
            }
        }
コード例 #21
0
        public void SamplesWithFilterAndGq()
        {
            using (var reader = new LiteVcfReader(ResourceUtilities.GetReadStream(Resources.InputFiles("Nirvana_unified_json_format.vcf"))))
            {
                // skip the first two variants
                VcfUtilities.GetNextVariant(reader, _renamer);
                VcfUtilities.GetNextVariant(reader, _renamer);
                var variant = VcfUtilities.GetNextVariant(reader, _renamer);

                // GT:GQ:DP:DPF:AD:FT:DPI
                // 0/1:124:19:5:11,8:PASS:.
                // 2/2:58:55:.:0,23:LowGQX:21
                // 1/2:55:59:.:0,21:LowGQX:20

                // the unified json will call this function to get all the samples and can print them out using GetEntry as shown below
                var sampleVariants = variant.ExtractSampleInfo();

                Assert.Equal("0/1", sampleVariants[0].Genotype);
                Assert.Equal("2/2", sampleVariants[1].Genotype);
                Assert.Equal("1/2", sampleVariants[2].Genotype);



                var expectedEntry =
                    "{\"variantFreq\":0.4211,\"genotypeQuality\":124,\"alleleDepths\":[11,8],\"genotype\":\"0/1\"}";
                var observedEntry = sampleVariants[0].ToString();
                Assert.Equal(expectedEntry, observedEntry);

                // 1/1 - T
                expectedEntry =
                    "{\"variantFreq\":1,\"totalDepth\":21,\"genotypeQuality\":58,\"alleleDepths\":[0,23],\"genotype\":\"2/2\",\"failedFilter\":true}";
                observedEntry = sampleVariants[1].ToString();
                Assert.Equal(expectedEntry, observedEntry);

                // 0/0 - A
                expectedEntry =
                    "{\"variantFreq\":1,\"totalDepth\":20,\"genotypeQuality\":55,\"alleleDepths\":[0,21],\"genotype\":\"1/2\",\"failedFilter\":true}";
                observedEntry = sampleVariants[2].ToString();
                Assert.Equal(expectedEntry, observedEntry);
            }
        }
コード例 #22
0
        public void GetHeaderOnly()
        {
            var readStream  = new BlockGZipStream(ResourceUtilities.GetReadStream(Resources.TopPath("Clinvar20150901.json.gz")), CompressionMode.Decompress);
            var indexStream = ResourceUtilities.GetReadStream(Resources.TopPath("Clinvar20150901.json.gz.jsi"));

            var outStream = new MemoryStream();

            using (var writer = new StreamWriter(outStream, Encoding.UTF8, 512, true))
                using (var qp = new QueryProcessor(new StreamReader(readStream), indexStream, writer))
                {
                    qp.PrintHeaderOnly();
                }

            Assert.NotEqual(0, outStream.Length);
            outStream.Position = 0;
            using (var reader = new StreamReader(outStream))
            {
                string headerLine = reader.ReadToEnd();
                Assert.Equal("{\"header\":{\"annotator\":\"Nirvana 2.0.9.0\",\"creationTime\":\"2018-04-30 17:17:23\",\"genomeAssembly\":\"GRCh37\",\"schemaVersion\":6,\"dataVersion\":\"91.26.45\",\"dataSources\":[{\"name\":\"VEP\",\"version\":\"91\",\"description\":\"Ensembl\",\"releaseDate\":\"2018-03-05\"},{\"name\":\"ClinVar\",\"version\":\"20180129\",\"description\":\"A freely accessible, public archive of reports of the relationships among human variations and phenotypes, with supporting evidence\",\"releaseDate\":\"2018-01-29\"},{\"name\":\"COSMIC\",\"version\":\"84\",\"description\":\"somatic mutation and related details and information relating to human cancers\",\"releaseDate\":\"2018-02-13\"},{\"name\":\"dbSNP\",\"version\":\"150\",\"description\":\"Identifiers for observed variants\",\"releaseDate\":\"2017-04-03\"},{\"name\":\"gnomAD_exome\",\"version\":\"2.0.2\",\"description\":\"Exome allele frequencies from Genome Aggregation Database (gnomAD)\",\"releaseDate\":\"2017-10-05\"},{\"name\":\"gnomAD\",\"version\":\"2.0.2\",\"description\":\"Whole genome allele frequencies from Genome Aggregation Database (gnomAD)\",\"releaseDate\":\"2017-10-05\"},{\"name\":\"MITOMAP\",\"version\":\"20180228\",\"description\":\"Small variants in the MITOMAP human mitochondrial genome database\",\"releaseDate\":\"2018-02-28\"},{\"name\":\"1000 Genomes Project\",\"version\":\"Phase 3 v5a\",\"description\":\"A public catalogue of human variation and genotype data\",\"releaseDate\":\"2013-05-27\"},{\"name\":\"TOPMed\",\"version\":\"freeze_5\",\"description\":\"Allele frequencies from TOPMed data lifted over using dbSNP ids.\",\"releaseDate\":\"2017-08-28\"},{\"name\":\"ClinGen\",\"version\":\"20160414\",\"releaseDate\":\"2016-04-14\"},{\"name\":\"DGV\",\"version\":\"20160515\",\"description\":\"Provides a comprehensive summary of structural variation in the human genome\",\"releaseDate\":\"2016-05-15\"},{\"name\":\"MITOMAP\",\"version\":\"20180228\",\"description\":\"Large structural variants in the MITOMAP human mitochondrial genome database\",\"releaseDate\":\"2018-02-28\"},{\"name\":\"ExAC\",\"version\":\"0.3.1\",\"description\":\"Gene scores from the ExAC project\",\"releaseDate\":\"2016-03-16\"},{\"name\":\"OMIM\",\"version\":\"20180213\",\"description\":\"An Online Catalog of Human Genes and Genetic Disorders\",\"releaseDate\":\"2018-02-13\"},{\"name\":\"phyloP\",\"version\":\"hg19\",\"description\":\"46 way conservation score between humans and 45 other vertebrates\",\"releaseDate\":\"2009-11-10\"}]}}\r\n", headerLine);
            }
        }
コード例 #23
0
        public void GetChromosomeList()
        {
            var readStream  = new BlockGZipStream(ResourceUtilities.GetReadStream(Resources.TopPath("Clinvar20150901.json.gz")), CompressionMode.Decompress);
            var indexStream = ResourceUtilities.GetReadStream(Resources.TopPath("Clinvar20150901.json.gz.jsi"));

            var outStream = new MemoryStream();

            using (var writer = new StreamWriter(outStream, Encoding.UTF8, 512, true))
                using (var qp = new QueryProcessor(new StreamReader(readStream), indexStream, writer))
                {
                    qp.PrintChromosomeList();
                }

            Assert.NotEqual(0, outStream.Length);
            outStream.Position = 0;
            using (var reader = new StreamReader(outStream))
            {
                string chromList = reader.ReadToEnd();
                Assert.Equal("1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\nX\r\nY\r\n", chromList);
            }
        }
コード例 #24
0
        public void GetCompressedSequence()
        {
            using (var reader = new CompressedSequenceReader(ResourceUtilities.GetReadStream(Resources.TopPath("TestSeq_reference.dat"))))
            {
                Assert.Equal(GenomeAssembly.GRCh37, reader.Assembly);
                var sequence = reader.Sequence;

                var chromosome = new Chromosome("chrBob", "Bob", null, null, 1, 1);
                reader.GetCompressedSequence(chromosome);

                Assert.Null(sequence.CytogeneticBands);
                Assert.Equal(0, sequence.Length);

                chromosome = new Chromosome("chrTestSeq", "TestSeq", null, null, 1, 0);
                reader.GetCompressedSequence(chromosome);
                var bases = sequence.Substring(0, 100);

                Assert.NotNull(sequence.CytogeneticBands);
                Assert.Equal(53, sequence.Length);
                Assert.Equal("NNATGTTTCCACTTTCTCCTCATTAGANNNTAACGAATGGGTGATTTCCCTAN", bases);
            }
        }
コード例 #25
0
        public void ReadDataVersionFromFile()
        {
            var versionFile = ResourceUtilities.GetReadStream(Resources.TopPath("dbSNP.version"));

            DataSourceVersion version;

            using (var reader = new DataSourceVersionReader(versionFile))
            {
                version = reader.GetVersion();
            }

            Assert.Equal("dbSNP", version.Name);
            Assert.Equal("147", version.Version);
            Assert.Equal(DateTime.Parse("2016-04-08").Ticks, version.ReleaseDateTicks);
            Assert.True(string.IsNullOrEmpty(version.Description));
            Assert.Contains("dataSource=dbSNP", version.ToString());            //vcf output

            var sb = StringBuilderCache.Acquire();

            version.SerializeJson(sb);

            Assert.Contains("name\":\"dbSNP", StringBuilderCache.GetStringAndRelease(sb));            //json output
        }
コード例 #26
0
        public void TestIndexCreation()
        {
            var readStream = new BlockGZipStream(ResourceUtilities.GetReadStream(Resources.TopPath("cosmicv72.indels.json.gz")), CompressionMode.Decompress);
            var tempFile   = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            using (var indexCreator = new IndexCreator(readStream, FileUtilities.GetCreateStream(tempFile)))
            {
                indexCreator.CreateIndex();
            }
            JasixIndex readBackIndex;

            using (var stream = FileUtilities.GetReadStream(tempFile))
            {
                readBackIndex = new JasixIndex(stream);
            }

            Assert.Equal(1591, readBackIndex.GetFirstVariantPosition("chr1", 9775924, 9775924));
            Assert.Equal(11500956299, readBackIndex.GetFirstVariantPosition("chr2", 16081096, 16081096));
            Assert.Equal(372100991296, readBackIndex.GetFirstVariantPosition("chr20", 36026164, 36026164));
            Assert.Equal(377682846863, readBackIndex.GetFirstVariantPosition("chrX", 66765044, 66765044));

            File.Delete(tempFile);
        }
コード例 #27
0
 public BlockGZipStreamTests()
 {
     // TODO: Fix fragile constructor
     _expectedDecompressedBuffer = GrabBytes(ResourceUtilities.GetReadStream(Resources.TopPath("HelloWorld_original.dat")));
 }
コード例 #28
0
 //constructor
 public PhylopGetScoreTests()
 {
     _npdReader = new PhylopReader(ResourceUtilities.GetReadStream(Resources.TopPath("chr1_10918_150000.npd")));
 }
コード例 #29
0
 /// <summary>
 /// constructor
 /// </summary>
 public PhylopGetScoreTests()
 {
     // TODO: Fix fragile constructor
     _npdReader = new PhylopReader(ResourceUtilities.GetReadStream(Resources.TopPath("chr1_10918_150000.npd")));
 }