Example #1
0
        public void ReaderAndWriterTests()
        {
            var saDataSources = new ISaDataSource[4];

            saDataSources[0] = new SaDataSource("data1", "data1", "A", false, true, "acd", new[] { "\"id\":\"123\"" });
            saDataSources[1] = new SaDataSource("data2", "data2", "T", false, true, "acd", new[] { "\"id\":\"123\"" });
            saDataSources[2] = new SaDataSource("data3", "data3", "A", false, false, "acd", new[] { "\"id\":\"123\"" });
            saDataSources[3] = new SaDataSource("data4", "data4", "T", false, false, "acd", new[] { "\"id\":\"123\"" });

            var saPos = new SaPosition(saDataSources, "A");

            var ms     = new MemoryStream();
            var writer = new ExtendedBinaryWriter(ms);

            saPos.Write(writer);
            ms.Position = 0;

            var reader     = new ExtendedBinaryReader(ms);
            var observedSa = SaPosition.Read(reader);

            Assert.Equal(saPos.GlobalMajorAllele, observedSa.GlobalMajorAllele);
            Assert.Equal(saPos.DataSources.Length, observedSa.DataSources.Length);

            Assert.Equal(saPos.DataSources[3].KeyName, observedSa.DataSources[3].KeyName);

            Assert.Equal(saPos.DataSources[2].JsonStrings, observedSa.DataSources[2].JsonStrings);
            ms.Dispose();
        }
Example #2
0
        public void GetJsonStrings_NullJsonStrings()
        {
            var dataSource            = new SaDataSource("bob", "bobVcf", "A", false, false, null, null);
            var annotatedSaDataSource = new AnnotatedSaDataSource(dataSource, "A");

            var jsonStrings = annotatedSaDataSource.GetJsonStrings();

            Assert.Null(jsonStrings);
        }
Example #3
0
        public void SaReader_And_SaWriter_Tests()
        {
            var saMs    = new MemoryStream();
            var indexMs = new MemoryStream();

            var dataSourceVersions = new[]
            {
                new DataSourceVersion("clinvar", "20", DateTime.Today.Ticks, "clinvar dataset"),
                new DataSourceVersion("dbSnp", "18", DateTime.Parse("12/20/2010").Ticks, "dbSNP")
            };
            var header         = new SupplementaryAnnotationHeader("chr1", DateTime.Now.Ticks, 1, dataSourceVersions, GenomeAssembly.GRCh37);
            var smallIntervals = new List <ISupplementaryInterval>
            {
                new SupplementaryInterval("data1", "chr1", 100, 150, "", ReportFor.SmallVariants)
            };
            var svIntervals = new List <ISupplementaryInterval>
            {
                new SupplementaryInterval("data2", "chr1", 100, 1000, "", ReportFor.StructuralVariants)
            };

            var allIntervals = new List <ISupplementaryInterval>
            {
                new SupplementaryInterval("data3", "chr1", 100, 1000, "", ReportFor.AllVariants)
            };

            var saDataSources = new ISaDataSource[4];

            saDataSources[0] = new SaDataSource("data1", "data1", "A", false, true, "acd", new[] { "\"id\":\"123\"" });
            saDataSources[1] = new SaDataSource("data2", "data2", "T", false, true, "acd", new[] { "\"id\":\"123\"" });
            saDataSources[2] = new SaDataSource("data3", "data3", "A", false, false, "acd", new[] { "\"id\":\"123\"" });
            saDataSources[3] = new SaDataSource("data4", "data4", "T", false, false, "acd", new[] { "\"id\":\"123\"" });

            var saPos = new SaPosition(saDataSources, "A");

            using (var saWriter = new SaWriter(saMs, indexMs, header, smallIntervals, svIntervals, allIntervals, new List <(int, string)>(), true))
            {
                saWriter.Write(saPos, 150);
            }
            saMs.Position    = 0;
            indexMs.Position = 0;
            ISaPosition obseveredPosition, obseveredPosition2;

            using (var saReader = new SaReader(saMs, indexMs))
            {
                obseveredPosition  = saReader.GetAnnotation(150);
                obseveredPosition2 = saReader.GetAnnotation(200);
            }

            Assert.Equal("A", obseveredPosition.GlobalMajorAllele);
            Assert.Equal(4, obseveredPosition.DataSources.Length);
            Assert.Null(obseveredPosition2);
        }
        private static void AddSupplementaryAnnotation(IAnnotatedVariant annotatedVariant)
        {
            var dataSource = new SaDataSource("clinVar", "clinVar", "C", true, false, null,
                                              new[] { "\"good\":\"result\"" });
            var annotatedSaDataSource = new AnnotatedSaDataSource(dataSource, "C");

            var dataSource2 = new SaDataSource("exac", "exac", "G", true, true, null,
                                               new[] { "\"bad\":\"temper\"", "\"brutal\":\"kangaroo\"" });
            var annotatedSaDataSource2 = new AnnotatedSaDataSource(dataSource2, "G");

            annotatedVariant.SupplementaryAnnotations.Add(annotatedSaDataSource);
            annotatedVariant.SupplementaryAnnotations.Add(annotatedSaDataSource2);
        }
Example #5
0
        public void GetJsonStrings_Positional_AlleleSpecific()
        {
            string[] expectedJsonStrings   = { "test1", "test2" };
            var      dataSource            = new SaDataSource("bob", "bobVcf", "A", false, false, null, expectedJsonStrings);
            var      annotatedSaDataSource = new AnnotatedSaDataSource(dataSource, "A");

            var jsonStrings = annotatedSaDataSource.GetJsonStrings();

            Assert.NotNull(jsonStrings);
            Assert.Equal(2, jsonStrings.Count);
            Assert.Contains(expectedJsonStrings[0], jsonStrings[0]);
            Assert.Contains(expectedJsonStrings[1], jsonStrings[1]);
        }