public void GenerateVcfStrings_IncludeHeaders() { if (MiscUtils.IsRunningAnyLinux) { return; // currently failing on linux :( } var parser = VcfVariantParserSettings.Create(ImmutableList.Create(SampleName)); var variants = VcfVariant.TryParse(Bnd1, parser).FollowedBy(VcfVariant.TryParse(Bnd2, parser)).EnumerateSuccesses().ToList(); var wittyerVariant = WittyerBndInternal.Create(variants[0], variants[0].ToTryOfGenotypedVcfVariant(VariantNormalizer.TrimCommonBases).GetOrThrow().Samples.Values.First(), WittyerType.IntraChromosomeBreakend, new List <uint>(), uint.MinValue, null, variants[1]); var headerLines = WittyerVcfWriter.GenerateVcfStrings( WittyerResult.Create(VcfHeader.CreateBuilder(VcfVersion.FourPointOne).Build(), SampleName, variants.Select(v => v.Contig).Distinct().ToList(), false, new Dictionary <WittyerType, IReadOnlyList <IWittyerVariant> >(), new Dictionary <WittyerType, IReadOnlyList <IWittyerBnd> > { { WittyerType.IntraChromosomeBreakend, new List <IWittyerBnd> { wittyerVariant } } }, new List <IVcfVariant>()), null, null) .TakeWhile(line => line.StartsWith(VcfConstants.Header.Prefix)).ToList(); // 11 = VcfVersion, WHO, WHAT, WHERE, WHY, WIT, WIN, WOW, date, version, column names Assert.Equal(11, headerLines.Count); }
public void CnvWorksWithCrossType() { if (MiscUtils.IsRunningAnyLinux) { return; // currently failing on linux :( } var outputDirectory = Path.GetRandomFileName().ToDirectoryInfo(); var wittyerSettings = WittyerSettings.Create(outputDirectory, CnvTruth, CnvQuery, ImmutableList <ISamplePair> .Empty, EvaluationMode.CrossTypeAndSimpleCounting, InputSpecs); var results = MainLauncher.GenerateResults(wittyerSettings).EnumerateSuccesses().ToList(); var(_, query, truth) = results.First(); var testStrings = WittyerVcfWriter.GenerateVcfStrings(query, null, null).Where(line => !line.StartsWith(VcfConstants.Header.Prefix)); MultiAssert.True(testStrings.All(s => ParseVariantGetTag(s, WitDecision.FalsePositive))); testStrings = WittyerVcfWriter.GenerateVcfStrings(null, truth, null).Where(line => !line.StartsWith(VcfConstants.Header.Prefix)); MultiAssert.True(testStrings.All(s => ParseVariantGetTag(s, WitDecision.FalseNegative))); var stats = MainLauncher .GenerateJson(wittyerSettings, results, EmptyCmd).GetOrThrow().PerSampleStats.First(); // make sure to check for null MultiAssert.True(stats.QuerySampleName != null); MultiAssert.True(stats.TruthSampleName != null); var expectedStats = JsonConvert.DeserializeObject <GeneralStats>(File.ReadAllText(CnvJsonCts.FullName)) .PerSampleStats.First(); var expectedOverallEventStats = expectedStats.OverallStats.Single(x => x.StatsType.Equals(StatsType.Event)); var actualOverallEventStats = stats.OverallStats.Single(x => x.StatsType.Equals(StatsType.Event)); MultiAssert.Equal(expectedOverallEventStats.QueryFpCount, actualOverallEventStats.QueryFpCount); MultiAssert.Equal(expectedOverallEventStats.QueryTpCount, actualOverallEventStats.QueryTpCount); MultiAssert.Equal(expectedOverallEventStats.QueryTotalCount, actualOverallEventStats.QueryTotalCount); MultiAssert.Equal(expectedOverallEventStats.TruthTpCount, actualOverallEventStats.TruthTpCount); MultiAssert.Equal(expectedOverallEventStats.TruthFnCount, actualOverallEventStats.TruthFnCount); MultiAssert.Equal(expectedOverallEventStats.TruthTotalCount, actualOverallEventStats.TruthTotalCount); MultiAssert.AssertAll(); }
public void SvWorksWithSimpleCount() { if (MiscUtils.IsRunningAnyLinux) { return; // currently failing on linux :( } //var insertionSpec = InputSpecs[WittyerVariantType.Insertion]; var insertionSpec = InputSpec.Create(WittyerType.Insertion, WittyerConstants.DefaultBins.SetItem(0, (50, false)), WittyerConstants.DefaultBpOverlap, 0.05, WittyerConstants.DefaultExcludeFilters, WittyerConstants.DefaultIncludeFilters, null); var outputDirectory = Path.GetRandomFileName().ToDirectoryInfo(); var wittyerSettings = WittyerSettings.Create(outputDirectory, SomaticTruth, SomaticQuery, ImmutableList <ISamplePair> .Empty, EvaluationMode.SimpleCounting, InputSpecs.SetItem(WittyerType.Insertion, insertionSpec)); var results = MainLauncher.GenerateResults(wittyerSettings).Select(i => i.GetOrThrow()).ToList(); var(_, query, truth) = results.First(); MultiAssert.Equal(((IMutableWittyerResult)query).NumEntries, (uint)WittyerVcfWriter.ProcessVariants(query, false).Count()); MultiAssert.Equal(((IMutableWittyerResult)truth).NumEntries, (uint)WittyerVcfWriter.ProcessVariants(truth, true).Count()); var testStrings = WittyerVcfWriter.GenerateVcfStrings(query, null, null).Where(line => !line.StartsWith(VcfConstants.Header.Prefix)); MultiAssert.True(testStrings.All(s => ParseVariantGetTag(s, WitDecision.FalsePositive))); testStrings = WittyerVcfWriter.GenerateVcfStrings(null, truth, null).Where(line => !line.StartsWith(VcfConstants.Header.Prefix)); MultiAssert.True(testStrings.All(s => ParseVariantGetTag(s, WitDecision.FalseNegative))); var actualStats = GeneralStats.Create(results, wittyerSettings.Mode == EvaluationMode.Default, wittyerSettings.InputSpecs, EmptyCmd).PerSampleStats .First(); var expectedStats = JsonConvert.DeserializeObject <GeneralStats>(File.ReadAllText(SvJsonSc.FullName)) .PerSampleStats.First(); var expectedOverallEventStats = expectedStats.OverallStats.Single(x => x.StatsType.Equals(StatsType.Event)); var actualOverallEventStats = actualStats.OverallStats.Single(x => x.StatsType.Equals(StatsType.Event)); MultiAssert.Equal(expectedOverallEventStats.QueryFpCount, actualOverallEventStats.QueryFpCount); MultiAssert.Equal(expectedOverallEventStats.QueryTpCount, actualOverallEventStats.QueryTpCount); MultiAssert.Equal(expectedOverallEventStats.QueryTotalCount, actualOverallEventStats.QueryTotalCount); MultiAssert.Equal(expectedOverallEventStats.TruthTpCount, actualOverallEventStats.TruthTpCount); MultiAssert.Equal(expectedOverallEventStats.TruthFnCount, actualOverallEventStats.TruthFnCount); MultiAssert.Equal(expectedOverallEventStats.TruthTotalCount, actualOverallEventStats.TruthTotalCount); var expectedInsertionStats = expectedStats.DetailedStats .Single(s => s.VariantType == WittyerType.Insertion.Name).PerBinStats; var actualInsertionStats = actualStats.DetailedStats .Single(s => s.VariantType == WittyerType.Insertion.Name).PerBinStats; foreach (var(expectedInsBinStat, actualInsBinStat) in expectedInsertionStats.Zip(actualInsertionStats, (a, b) => (a, b))) { var expectedSingleStat = expectedInsBinStat.Stats.Single(); var actualSingleStat = actualInsBinStat.Stats.Single(); if (!expectedSingleStat.Equals(actualSingleStat)) { MultiAssert.Equal(string.Empty, expectedInsBinStat.Bin); } MultiAssert.Equal(expectedSingleStat, actualSingleStat); } MultiAssert.AssertAll(); }