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

            var phylopWriter = new PhylopWriter(wigFixFile.FullName, version, GenomeAssembly.Unknown, Path.GetTempPath(), 50);

            using (phylopWriter)
            {
                phylopWriter.ExtractPhylopScores();
            }

            var phylopReader = new PhylopReader(FileUtilities.GetReadStream(Path.GetTempPath() + Path.DirectorySeparatorChar + "chr1.npd"));

            using (phylopReader)
            {
                Assert.Equal(0.064, phylopReader.GetScore(100)); //first position of first block
                Assert.Equal(0.058, phylopReader.GetScore(101)); // second position
                Assert.Equal(0.064, phylopReader.GetScore(120)); // some internal position
                Assert.Equal(0.058, phylopReader.GetScore(130)); //last position of first block

                //moving on to the next block: should cause reloading from file
                Assert.Equal(0.064, phylopReader.GetScore(175));  //first position of first block
                Assert.Equal(-2.088, phylopReader.GetScore(182)); // some negative value
            }

            File.Delete(Path.GetTempPath() + Path.DirectorySeparatorChar + "chr1.npd");
        }
Beispiel #2
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);
        }
        public void WriteIntervalTest()
        {
            var randShorts = GetRandShorts();
            var randomPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            var writer     = new ExtendedBinaryWriter(FileUtilities.GetCreateStream(randomPath));

            var testInterval = new PhylopInterval(100, 0, 1);
            var version      = new DataSourceVersion("phylop", "0", DateTime.Now.Ticks, "unit test");

            using (var phylopWriter = new PhylopWriter("chr1", version, GenomeAssembly.Unknown, randShorts, writer))
            {
                phylopWriter.WriteInterval(testInterval, writer);
            }

            using (var phylopReader = new PhylopReader(FileUtilities.GetReadStream(randomPath)))
            {
                var scoreCount = phylopReader.ReadIntervalScores(testInterval);
                Assert.Equal(randShorts.Length, scoreCount);
                var observedScores = phylopReader.GetAllScores();
                for (var i = 0; i < randShorts.Length; i++)
                {
                    Assert.Equal(randShorts[i], observedScores[i]);
                }
            }

            File.Delete(randomPath);
        }
        public void ScoreToAndFromByteArray()
        {
            var randShorts = GetRandShorts();

            var scoreBytes = new byte[PhylopCommon.MaxIntervalLength * 2];

            var randomPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            var writer     = new ExtendedBinaryWriter(FileUtilities.GetCreateStream(randomPath));

            var version = new DataSourceVersion("phylop", "0", DateTime.Now.Ticks, "unit test");

            using (var phylopWriter = new PhylopWriter("chr1", version, GenomeAssembly.Unknown, randShorts, writer))
            {
                phylopWriter.ScoresToBytes(scoreBytes, randShorts, randShorts.Length);
            }

            var scores = new short[PhylopCommon.MaxIntervalLength];

            using (var phylopReader = new PhylopReader(FileUtilities.GetReadStream(randomPath)))
            {
                phylopReader.BytesToScores(scoreBytes.Length, scoreBytes, scores);
            }

            for (var i = 0; i < randShorts.Length; i++)
            {
                Assert.Equal(randShorts[i], scores[i]);
            }

            File.Delete(randomPath);
        }
 public ConservationScoreProvider(IEnumerable <string> dirPaths)
 {
     Name                      = "Conservation score provider";
     _phylopReader             = new PhylopReader(dirPaths);
     GenomeAssembly            = _phylopReader.GenomeAssembly;
     DataSourceVersions        = _phylopReader.DataSourceVersions;
     _currentUcscReferenceName = "";
 }
        public IAnnotationSource CreateAnnotationSource(IAnnotatorInfo annotatorInfo, IAnnotatorPaths annotatorPaths)
        {
            var conservationScoreReader = new PhylopReader(annotatorPaths.SupplementaryAnnotation);

            var transcriptStream = FileUtilities.GetReadStream(CacheConstants.TranscriptPath(annotatorPaths.CachePrefix));
            var siftStream       = FileUtilities.GetReadStream(CacheConstants.SiftPath(annotatorPaths.CachePrefix));
            var polyPhenStream   = FileUtilities.GetReadStream(CacheConstants.PolyPhenPath(annotatorPaths.CachePrefix));
            var referenceStream  = FileUtilities.GetReadStream(annotatorPaths.CompressedReference);

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

            var caProvider = annotatorPaths.CustomAnnotation.Any()          ? new CustomAnnotationProvider(annotatorPaths.CustomAnnotation)               : null;
            var ciProvider = annotatorPaths.CustomIntervals.Any()           ? new CustomIntervalProvider(annotatorPaths.CustomIntervals)                  : null;
            var saProvider = annotatorPaths.SupplementaryAnnotation != null ? new SupplementaryAnnotationProvider(annotatorPaths.SupplementaryAnnotation) : null;

            //adding the saPath because OMIM needs it
            var annotationSource = new NirvanaAnnotationSource(streams, saProvider, conservationScoreReader, caProvider, ciProvider, annotatorPaths.SupplementaryAnnotation);

            if (annotatorInfo.BooleanArguments.Contains(AnnotatorInfoCommon.ReferenceNoCall))
            {
                annotationSource.EnableReferenceNoCalls(annotatorInfo.BooleanArguments.Contains(AnnotatorInfoCommon.TranscriptOnlyRefNoCall));
            }

            if (annotatorInfo.BooleanArguments.Contains(AnnotatorInfoCommon.EnableMitochondrialAnnotation))
            {
                annotationSource.EnableMitochondrialAnnotation();
            }

            if (annotatorInfo.BooleanArguments.Contains(AnnotatorInfoCommon.ReportAllSvOverlappingTranscripts))
            {
                annotationSource.EnableReportAllSvOverlappingTranscripts();
            }

            if (annotatorInfo.BooleanArguments.Contains(AnnotatorInfoCommon.EnableLoftee))
            {
                annotationSource.AddPlugin(new Loftee());
            }

            return(annotationSource);
        }
 /// <summary>
 /// constructor
 /// </summary>
 public MockConservationScoreReader(Stream stream)
 {
     _reader       = new PhylopReader(stream);
     IsInitialized = _reader != null;
 }
Beispiel #8
0
 //constructor
 public PhylopGetScoreTests()
 {
     _npdReader = new PhylopReader(ResourceUtilities.GetReadStream(Resources.TopPath("chr1_10918_150000.npd")));
 }
Beispiel #9
0
 /// <summary>
 /// constructor
 /// </summary>
 public PhylopGetScoreTests()
 {
     // TODO: Fix fragile constructor
     _npdReader = new PhylopReader(ResourceUtilities.GetReadStream(Resources.TopPath("chr1_10918_150000.npd")));
 }