示例#1
0
        public void LoopbackTest()
        {
            var wigFixFile = Resources.TopPath("mini.WigFix");
            var version    = new DataSourceVersion("phylop", "0", DateTime.Now.Ticks, "unit test");

            using (var reader = new PhylopParser(FileUtilities.GetReadStream(wigFixFile), GenomeAssembly.GRCh37, ChromosomeUtilities.RefNameToChromosome))
                using (var npdStream = new MemoryStream())
                    using (var indexStream = new MemoryStream())
                        using (var npdWriter = new NpdWriter(npdStream, indexStream, version, GenomeAssembly.GRCh37, SaCommon.PhylopTag, SaCommon.SchemaVersion))
                        {
                            npdWriter.Write(reader.GetItems());

                            npdStream.Position   = 0;
                            indexStream.Position = 0;

                            using (var phylopReader = new NpdReader(npdStream, indexStream))
                            {
                                Assert.Equal(0.1, phylopReader.GetAnnotation(ChromosomeUtilities.Chr1, 100)); //first position of first block
                                Assert.Equal(0.1, phylopReader.GetAnnotation(ChromosomeUtilities.Chr1, 101)); // second position
                                Assert.Equal(0.1, phylopReader.GetAnnotation(ChromosomeUtilities.Chr1, 120)); // some internal position
                                Assert.Equal(0.1, phylopReader.GetAnnotation(ChromosomeUtilities.Chr1, 130)); //last position of first block

                                //moving on to the next block: should cause reloading from file
                                Assert.Equal(0.1, phylopReader.GetAnnotation(ChromosomeUtilities.Chr1, 175));  //first position of second block
                                Assert.Equal(-2.1, phylopReader.GetAnnotation(ChromosomeUtilities.Chr1, 182)); // some negative value

                                //chrom 2
                                Assert.Null(phylopReader.GetAnnotation(ChromosomeUtilities.Chr2, 400));//values past the last phylop positions should return null
                            }
                        }
        }
示例#2
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 phylopParser = new PhylopParser(GZipUtilities.GetAppropriateReadStream(_inputFile), referenceProvider.Assembly, referenceProvider.RefNameToChromosome))
                using (var nsaStream = FileUtilities.GetCreateStream(Path.Combine(_outputDirectory, outFileName + SaCommon.PhylopFileSuffix)))
                    using (var indexStream = FileUtilities.GetCreateStream(Path.Combine(_outputDirectory, outFileName + SaCommon.PhylopFileSuffix + SaCommon.IndexSufix)))
                        using (var writer = new NpdWriter(nsaStream, indexStream, version, referenceProvider.Assembly, SaCommon.PhylopTag, SaCommon.SchemaVersion))
                        {
                            writer.Write(phylopParser.GetItems());
                        }

            return(ExitCodes.Success);
        }