diff --git a/CacheUtils/CacheUtils.csproj b/CacheUtils/CacheUtils.csproj index 8d25598c..eb21d989 100644 --- a/CacheUtils/CacheUtils.csproj +++ b/CacheUtils/CacheUtils.csproj @@ -12,9 +12,9 @@ - - - + + + diff --git a/Jasix/Jasix.csproj b/Jasix/Jasix.csproj index dc4d8d2c..d4372770 100644 --- a/Jasix/Jasix.csproj +++ b/Jasix/Jasix.csproj @@ -6,7 +6,7 @@ Full - + diff --git a/Nirvana/Nirvana.cs b/Nirvana/Nirvana.cs index 611977b6..0b1f8f1f 100644 --- a/Nirvana/Nirvana.cs +++ b/Nirvana/Nirvana.cs @@ -11,7 +11,9 @@ using Phantom.Workers; using VariantAnnotation; using VariantAnnotation.Interface; +using VariantAnnotation.Interface.AnnotatedPositions; using VariantAnnotation.Interface.GeneAnnotation; +using VariantAnnotation.Interface.IO; using VariantAnnotation.Interface.Plugins; using VariantAnnotation.Interface.Positions; using VariantAnnotation.Interface.Providers; @@ -56,7 +58,7 @@ private ExitCodes ProgramExecution() var plugins = PluginUtilities.LoadPlugins(_pluginDirectory); var annotator = ProviderUtilities.GetAnnotator(transcriptAnnotationProvider, sequenceProvider, saProvider, conservationProvider, geneAnnotationProvider, plugins); var recomposer = _disableRecomposition ? new NullRecomposer() : Recomposer.Create(sequenceProvider, _inputCachePrefix); - var logger = _outputFileName == "" ? (ILogger)new NullLogger() : new ConsoleLogger(); + var logger = _outputFileName == "-" ? (ILogger) new NullLogger() : new ConsoleLogger(); var metrics = new PerformanceMetrics(logger); var dataSourceVersions = GetDataSourceVersions(plugins, transcriptAnnotationProvider, saProvider, @@ -72,7 +74,7 @@ private ExitCodes ProgramExecution() using (var gvcfWriter = _gvcf ? new LiteVcfWriter(ReadWriteUtilities.GetGvcfOutputWriter(_outputFileName), vcfReader.GetHeaderLines(), _annotatorVersionTag, vepDataVersion, dataSourceVersions) : null) using (var jasixIndexCreator = new OnTheFlyIndexCreator(FileUtilities.GetCreateStream(jasixFileName))) { - var bgzipTextWriter = outputWriter as BgzipTextWriter; + if (!(outputWriter is BgzipTextWriter bgzipTextWriter)) throw new NullReferenceException("Unable to create the bgzip text writer."); try { @@ -94,19 +96,10 @@ private ExitCodes ProgramExecution() var annotatedPosition = annotator.Annotate(position); - var jsonOutput = annotatedPosition.GetJsonString(); - if (jsonOutput != null) - { - if (bgzipTextWriter != null) - jasixIndexCreator.Add(annotatedPosition.Position, bgzipTextWriter.Position); - } - jsonWriter.WriteJsonEntry(jsonOutput); + string json = annotatedPosition.GetJsonString(); - if (annotatedPosition.AnnotatedVariants?.Length > 0) vcfWriter?.Write(_conversion.Convert(annotatedPosition)); - - gvcfWriter?.Write(annotatedPosition.AnnotatedVariants?.Length > 0 - ? _conversion.Convert(annotatedPosition) - : string.Join("\t", position.VcfFields)); + if (json != null) WriteOutput(annotatedPosition, bgzipTextWriter.Position, jasixIndexCreator, jsonWriter, vcfWriter, gvcfWriter, json); + else gvcfWriter?.Write(string.Join("\t", position.VcfFields)); metrics.Increment(); } @@ -125,6 +118,20 @@ private ExitCodes ProgramExecution() return ExitCodes.Success; } + private void WriteOutput(IAnnotatedPosition annotatedPosition, long textWriterPosition, + OnTheFlyIndexCreator jasixIndexCreator, IJsonWriter jsonWriter, LiteVcfWriter vcfWriter, + LiteVcfWriter gvcfWriter, string jsonOutput) + { + jasixIndexCreator.Add(annotatedPosition.Position, textWriterPosition); + jsonWriter.WriteJsonEntry(jsonOutput); + + if (vcfWriter == null && gvcfWriter == null || annotatedPosition.Position.IsRecomposed) return; + + string vcfLine = _conversion.Convert(annotatedPosition); + vcfWriter?.Write(vcfLine); + gvcfWriter?.Write(vcfLine); + } + private static List GetDataSourceVersions(IEnumerable plugins, params IProvider[] providers) { diff --git a/Phantom/DataStructures/PositionSet.cs b/Phantom/DataStructures/PositionSet.cs index 5a1c8752..441574a6 100644 --- a/Phantom/DataStructures/PositionSet.cs +++ b/Phantom/DataStructures/PositionSet.cs @@ -122,13 +122,13 @@ internal int[][] GetSampleTagIndexes(string[] tagsToExtract) internal static string ExtractSamplePhaseSet(int phaseSetTagIndex, string[] sampleInfo) { - if (phaseSetTagIndex == -1) return "."; + if (phaseSetTagIndex == -1 || sampleInfo.Length <= phaseSetTagIndex) return "."; if (sampleInfo.Length == 1 && sampleInfo[0] == ".") return "."; var phaseSet = sampleInfo[phaseSetTagIndex]; return phaseSet; } - internal static string ExtractSampleGq(int gqTagIndex, string[] sampleInfo) => (gqTagIndex == -1) ? "." : sampleInfo[gqTagIndex]; + internal static string ExtractSampleGq(int gqTagIndex, string[] sampleInfo) => gqTagIndex == -1 || sampleInfo.Length <= gqTagIndex ? "." : sampleInfo[gqTagIndex]; private static Dictionary<(string Genotypes, int Start), List> GetGenotypeToSampleIndex(PositionSet positionSet) { diff --git a/Phantom/Phantom.csproj b/Phantom/Phantom.csproj index e33334da..18718521 100644 --- a/Phantom/Phantom.csproj +++ b/Phantom/Phantom.csproj @@ -13,7 +13,7 @@ TRACE;RELEASE;NETCOREAPP2_0 - + diff --git a/Phantom/Workers/VariantGenerator.cs b/Phantom/Workers/VariantGenerator.cs index 265c54bd..c31ea44a 100644 --- a/Phantom/Workers/VariantGenerator.cs +++ b/Phantom/Workers/VariantGenerator.cs @@ -82,7 +82,7 @@ private static VariantInfo GetVariantInfo(PositionSet positionSet, AlleleIndexBl string[] psValues = new string[numSamples]; for (int i = 0; i < numSamples; i++) // PS tags are the same in the decomposed variants - psValues[i] = positionSet.PsInfo[i][startIndex]; + psValues[i] = positionSet.PsInfo[i][startIndex]; return new VariantInfo(qual, filter, gqValues, psValues); } @@ -171,7 +171,7 @@ public sealed class VariantInfo public readonly string[] SamplePhaseSets; public readonly Dictionary> AltAlleleToSample = new Dictionary>(); - public VariantInfo(string qual, string filter, string[] sampleGqs, string[]samplePhaseSets) + public VariantInfo(string qual, string filter, string[] sampleGqs, string[] samplePhaseSets) { Qual = qual; Filter = filter; @@ -194,7 +194,6 @@ internal sealed class RecomposedAlleleSet private readonly string _chrName; private const string VariantId = "."; private const string InfoTag = "RECOMPOSED"; - private const string FormatTag = "GT:GQ:PS"; public RecomposedAlleleSet(string chrName, int numSamples) @@ -257,7 +256,7 @@ private void SetGenotypeWithAlleleIndex(List sampleGenotype, byte sampleAll sampleGenotype[sampleAlleleAlleleIndex] = currentGenotypeIndex; } - private string[] GetVcfFields(VariantSite varSite, string altAlleleColumn, string qual, string filter, List[] sampleGenoTypes, string[] sampleGqs, string[] samplePhasesets, string variantId = VariantId, string info = InfoTag, string format = FormatTag) + private string[] GetVcfFields(VariantSite varSite, string altAlleleColumn, string qual, string filter, List[] sampleGenoTypes, string[] sampleGqs, string[] samplePhasesets, string variantId = VariantId, string info = InfoTag) { var vcfFields = new List { @@ -268,20 +267,79 @@ private string[] GetVcfFields(VariantSite varSite, string altAlleleColumn, strin altAlleleColumn, qual, filter, - info, - format + info }; - for (var index = 0; index < sampleGenoTypes.Length; index++) + AddFormatAndSampleColumns(sampleGenoTypes, sampleGqs, samplePhasesets, ref vcfFields); + return vcfFields.ToArray(); + } + + private static void AddFormatAndSampleColumns(List[] sampleGenoTypes, string[] sampleGqs, string[] samplePhasesets, ref List vcfFields) + { + var formatTags = "GT"; + var hasGq = false; + var hasPs = false; + int numSamples = sampleGenoTypes.Length; + + var sampleGenotypeStrings = new string[numSamples]; + for (var index = 0; index < numSamples; index++) + { + sampleGenotypeStrings[index] = GetGenotype(sampleGenoTypes[index]); + if (sampleGenotypeStrings[index] == ".") continue; + if (sampleGqs[index] != ".") hasGq = true; + if (samplePhasesets[index] != ".") hasPs = true; + if (hasGq && hasPs) break; + } + + int numFields = 1; + + if (hasGq) + { + formatTags += ":GQ"; + numFields++; + } + if (hasPs) + { + formatTags += ":PS"; + numFields++; + } + + vcfFields.Add(formatTags); + + for (var index = 0; index < numSamples; index++) { - var sampleGenotypeStr = GetGenotype(sampleGenoTypes[index]); - if (sampleGenotypeStr == ".") vcfFields.Add(".:.:."); + var sampleGenotypeStr = sampleGenotypeStrings[index]; + if (sampleGenotypeStr == ".") vcfFields.Add("."); else { - vcfFields.Add(sampleGenotypeStr + ":" + sampleGqs[index] + ":" + samplePhasesets[index]); + var nonMissingFields = new string[numFields]; + nonMissingFields[0] = sampleGenotypeStr; + var fieldIndex = 1; + if (hasGq) + { + nonMissingFields[fieldIndex] = sampleGqs[index]; + fieldIndex++; + } + if (hasPs) + { + nonMissingFields[fieldIndex] = samplePhasesets[index]; + } + + var sampleColumnStr = string.Join(":", TrimTrailingMissValues(nonMissingFields)); + vcfFields.Add(sampleColumnStr); } } - return vcfFields.ToArray(); + } + + private static string[] TrimTrailingMissValues(string[] values) + { + int indexLastRemainedValue = values.Length - 1; + // Need to have at least one value remained + for (; indexLastRemainedValue > 0; indexLastRemainedValue--) + { + if (values[indexLastRemainedValue] != ".") break; + } + return new ArraySegment(values, 0, indexLastRemainedValue + 1).ToArray(); } private static string GetGenotype(List sampleGenotype) => sampleGenotype.Count == 0 ? "." : string.Join("|", sampleGenotype); diff --git a/UnitTests/Phantom/Workers/PositionProcessorTests.cs b/UnitTests/Phantom/Workers/PositionProcessorTests.cs index 6d0e57ee..b29017e5 100644 --- a/UnitTests/Phantom/Workers/PositionProcessorTests.cs +++ b/UnitTests/Phantom/Workers/PositionProcessorTests.cs @@ -140,7 +140,7 @@ public void GenerateOutput_Return_OriginalAndRecomposed_VcfFieldList() var expectedOutput = new string[4][]; expectedOutput[0] = position1.VcfFields; expectedOutput[1] = new[] - {"chr1", "2", ".", "AGCTG", "AGGTG,TGGTC", ".", "PASS", "RECOMPOSED", "GT:GQ:PS", "1|2:.:."}; + {"chr1", "2", ".", "AGCTG", "AGGTG,TGGTC", ".", "PASS", "RECOMPOSED", "GT", "1|2"}; expectedOutput[2] = position2.VcfFields; expectedOutput[3] = position3.VcfFields; diff --git a/UnitTests/Phantom/Workers/VariantGeneratorTests.cs b/UnitTests/Phantom/Workers/VariantGeneratorTests.cs index 8c75ec0c..bcb4f8e6 100644 --- a/UnitTests/Phantom/Workers/VariantGeneratorTests.cs +++ b/UnitTests/Phantom/Workers/VariantGeneratorTests.cs @@ -56,8 +56,8 @@ public void VariantGenerator_AsExpected() var recomposedPositions = recomposer.Recompose(new List { position1, position2, position3 }, functionBlockRanges).ToList(); Assert.Equal(2, recomposedPositions.Count); - Assert.Equal("chr1 2 . AGC AGA,GGG . PASS RECOMPOSED GT:GQ:PS .:.:. .:.:. 1|2:.:456", string.Join("\t", recomposedPositions[0].VcfFields)); - Assert.Equal("chr1 2 . AGCTG GGATC,GGGTG . PASS RECOMPOSED GT:GQ:PS .:.:. 1|2:.:789 .:.:.", string.Join("\t", recomposedPositions[1].VcfFields)); + Assert.Equal("chr1 2 . AGC AGA,GGG . PASS RECOMPOSED GT:PS . . 1|2:456", string.Join("\t", recomposedPositions[0].VcfFields)); + Assert.Equal("chr1 2 . AGCTG GGATC,GGGTG . PASS RECOMPOSED GT:PS . 1|2:789 .", string.Join("\t", recomposedPositions[1].VcfFields)); } [Fact] @@ -98,7 +98,7 @@ public void VariantGenerator_OverlappingDeletionInTheMiddle_Ignored() var recomposedPositions = recomposer.Recompose(new List { position1, position2, position3 }, functionBlockRanges).ToList(); Assert.Single(recomposedPositions); - Assert.Equal("chr1 2 . AGC AGA,TGA . PASS RECOMPOSED GT:GQ:PS 1|2:.:. .:.:.", string.Join("\t", recomposedPositions[0].VcfFields)); + Assert.Equal("chr1 2 . AGC AGA,TGA . PASS RECOMPOSED GT 1|2 .", string.Join("\t", recomposedPositions[0].VcfFields)); } [Fact] @@ -119,7 +119,7 @@ public void VariantGenerator_OverlappingDeletionAtTheEnd_Ignored() var recomposedPositions = recomposer.Recompose(new List { position1, position2, position3 }, functionBlockRanges).ToList(); Assert.Single(recomposedPositions); - Assert.Equal("chr1 2 . AGC AGA,TGA . PASS RECOMPOSED GT:GQ:PS 1|2:.:. .:.:.", string.Join("\t", recomposedPositions[0].VcfFields)); + Assert.Equal("chr1 2 . AGC AGA,TGA . PASS RECOMPOSED GT 1|2 .", string.Join("\t", recomposedPositions[0].VcfFields)); } [Fact] @@ -140,8 +140,8 @@ public void VariantGenerator_MinQualUsed_DotIgnored() var recomposedPositions = recomposer.Recompose(new List { position1, position2, position3 }, functionBlockRanges).ToList(); Assert.Equal(2, recomposedPositions.Count); - Assert.Equal("chr1 2 . AGC AGA,GGG 45 PASS RECOMPOSED GT:GQ:PS .:.:. .:.:. 1|2:.:456", string.Join("\t", recomposedPositions[0].VcfFields)); - Assert.Equal("chr1 2 . AGCTG GGATC,GGGTG 30.1 PASS RECOMPOSED GT:GQ:PS .:.:. 1|2:.:. .:.:.", string.Join("\t", recomposedPositions[1].VcfFields)); + Assert.Equal("chr1 2 . AGC AGA,GGG 45 PASS RECOMPOSED GT:PS . . 1|2:456", string.Join("\t", recomposedPositions[0].VcfFields)); + Assert.Equal("chr1 2 . AGCTG GGATC,GGGTG 30.1 PASS RECOMPOSED GT . 1|2 .", string.Join("\t", recomposedPositions[1].VcfFields)); } [Fact] @@ -162,8 +162,8 @@ public void VariantGenerator_FailedFilterTagGivenCorrectly_DotTreatedAsPass() var recomposedPositions = recomposer.Recompose(new List { position1, position2, position3 }, functionBlockRanges).ToList(); Assert.Equal(2, recomposedPositions.Count); - Assert.Equal("chr1 2 . AGC AGA,GGG . PASS RECOMPOSED GT:GQ:PS .:.:. .:.:. 1|2:.:456", string.Join("\t", recomposedPositions[0].VcfFields)); - Assert.Equal("chr1 2 . AGCTG GGATC,GGGTG . FilteredVariantsRecomposed RECOMPOSED GT:GQ:PS .:.:. 1|2:.:. .:.:.", string.Join("\t", recomposedPositions[1].VcfFields)); + Assert.Equal("chr1 2 . AGC AGA,GGG . PASS RECOMPOSED GT:PS . . 1|2:456", string.Join("\t", recomposedPositions[0].VcfFields)); + Assert.Equal("chr1 2 . AGCTG GGATC,GGGTG . FilteredVariantsRecomposed RECOMPOSED GT . 1|2 .", string.Join("\t", recomposedPositions[1].VcfFields)); } [Fact] @@ -184,8 +184,50 @@ public void VariantGenerator_MinQGUsed_DotAndNullIgnored() var recomposedPositions = recomposer.Recompose(new List { position1, position2, position3 }, functionBlockRanges).ToList(); Assert.Equal(2, recomposedPositions.Count); - Assert.Equal("chr1 2 . AGC AGA,GGG . PASS RECOMPOSED GT:GQ:PS .:.:. .:.:. 1|2:15.6:456", string.Join("\t", recomposedPositions[0].VcfFields)); - Assert.Equal("chr1 2 . AGCTG GGATC,GGGTG . PASS RECOMPOSED GT:GQ:PS .:.:. 1|2:14.2:. .:.:.", string.Join("\t", recomposedPositions[1].VcfFields)); + Assert.Equal("chr1 2 . AGC AGA,GGG . PASS RECOMPOSED GT:GQ:PS . . 1|2:15.6:456", string.Join("\t", recomposedPositions[0].VcfFields)); + Assert.Equal("chr1 2 . AGCTG GGATC,GGGTG . PASS RECOMPOSED GT:GQ . 1|2:14.2 .", string.Join("\t", recomposedPositions[1].VcfFields)); + } + + [Fact] + public void VariantGenerator_SampleColumnCorrectlyProcessed_WhenTrailingMissingValuesDroped() + { + var mockSequenceProvider = new Mock(); + mockSequenceProvider.SetupGet(x => x.RefNameToChromosome) + .Returns(new Dictionary { { "chr1", new Chromosome("chr1", "1", 0) } }); + mockSequenceProvider.SetupGet(x => x.Sequence).Returns(new SimpleSequence("CAGCTGAA")); + var sequenceProvider = mockSequenceProvider.Object; + + var position1 = SimplePosition.GetSimplePosition("chr1 2 . A T,G . PASS . GT:PS:GQ 0|1:123 2/2:.:14.2 ./.", sequenceProvider.RefNameToChromosome); + var position2 = SimplePosition.GetSimplePosition("chr1 4 . C A,G . PASS . GT:PS:GQ ./. 1|2:.:18 1|2:456:15.6", sequenceProvider.RefNameToChromosome); + var position3 = SimplePosition.GetSimplePosition("chr1 6 . G C . PASS . GT ./. 1|0 ./.", sequenceProvider.RefNameToChromosome); + var functionBlockRanges = new List { 4, 6, 8 }; + + var recomposer = new VariantGenerator(sequenceProvider); + var recomposedPositions = recomposer.Recompose(new List { position1, position2, position3 }, functionBlockRanges).ToList(); + + Assert.Single(recomposedPositions); + Assert.Equal("chr1 2 . AGCTG GGATC,GGGTG . PASS RECOMPOSED GT:GQ . 1|2:14.2 .", string.Join("\t", recomposedPositions[0].VcfFields)); + } + + [Fact] + public void VariantGenerator_AllTrailingMissingValuesDroped() + { + var mockSequenceProvider = new Mock(); + mockSequenceProvider.SetupGet(x => x.RefNameToChromosome) + .Returns(new Dictionary { { "chr1", new Chromosome("chr1", "1", 0) } }); + mockSequenceProvider.SetupGet(x => x.Sequence).Returns(new SimpleSequence("CAGCTGAA")); + var sequenceProvider = mockSequenceProvider.Object; + + var position1 = SimplePosition.GetSimplePosition("chr1 2 . A T,G . PASS . GT:GQ:PS 0|1:.:123 2/2 1|1:17:456", sequenceProvider.RefNameToChromosome); + var position2 = SimplePosition.GetSimplePosition("chr1 4 . C A,G . PASS . GT:GQ:PS ./. 1|2 1|2:15.6:456", sequenceProvider.RefNameToChromosome); + var position3 = SimplePosition.GetSimplePosition("chr1 6 . G C . PASS . GT:GQ:PS ./. 1|0 1|1:13:456", sequenceProvider.RefNameToChromosome); + var functionBlockRanges = new List { 4, 6, 8 }; + + var recomposer = new VariantGenerator(sequenceProvider); + var recomposedPositions = recomposer.Recompose(new List { position1, position2, position3 }, functionBlockRanges).ToList(); + + Assert.Single(recomposedPositions); + Assert.Equal("chr1 2 . AGCTG GGATC,GGGTG,TGATC,TGGTC . PASS RECOMPOSED GT:GQ:PS . 1|2 3|4:13:456", string.Join("\t", recomposedPositions[0].VcfFields)); } } } \ No newline at end of file diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj index 34753a36..26721c11 100644 --- a/UnitTests/UnitTests.csproj +++ b/UnitTests/UnitTests.csproj @@ -5,7 +5,7 @@ true - + diff --git a/UnitTests/VariantAnnotation/IO/VcfWriter/LiteVcfWriterTests.cs b/UnitTests/VariantAnnotation/IO/VcfWriter/LiteVcfWriterTests.cs index a1389a8b..81b29081 100644 --- a/UnitTests/VariantAnnotation/IO/VcfWriter/LiteVcfWriterTests.cs +++ b/UnitTests/VariantAnnotation/IO/VcfWriter/LiteVcfWriterTests.cs @@ -28,16 +28,13 @@ public sealed class LiteVcfWriterTests "##INFO=", "##INFO=", "##INFO=", - "##INFO=", - "##INFO=" + "##INFO=" }; - private const string FilteredVariantsRecomposedHeaderLine = "##FILTER="; - [Fact] public void Vcf_header_write_as_expected() { - var ms = new MemoryStream(); + var ms = new MemoryStream(); var writer = new StreamWriter(ms, Encoding.Default, 1024, true); var currentHeaderLines = new List @@ -46,7 +43,6 @@ public void Vcf_header_write_as_expected() "##FORMAT=", "##source=IsaacVariantCaller", "#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT Mother" - }; var dataSourceVersions = new IDataSourceVersion[] @@ -78,7 +74,6 @@ public void Vcf_header_write_as_expected() expectedLines.AddRange(_infoHeaderLines); expectedLines.Add(CsqtHeaderLine); expectedLines.Add(CsqrHeaderLine); - expectedLines.Add(FilteredVariantsRecomposedHeaderLine); expectedLines.Add("#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT Mother"); expectedLines.Add(vcfLine); @@ -89,10 +84,10 @@ public void Vcf_header_write_as_expected() int i = 0; while ((line = reader.ReadLine()) != null) { - Assert.Equal(expectedLines[i],line); + Assert.Equal(expectedLines[i], line); i++; } - Assert.Equal(22,i); + Assert.Equal(20, i); } } } diff --git a/VariantAnnotation/CommonAssemblyInfo.props b/VariantAnnotation/CommonAssemblyInfo.props index a006a30a..11cefec3 100644 --- a/VariantAnnotation/CommonAssemblyInfo.props +++ b/VariantAnnotation/CommonAssemblyInfo.props @@ -2,9 +2,9 @@ Illumina © 2018 Illumina, Inc. - 2.0.7.0 - 2.0.7.0 - 2.0.7 + 2.0.8.0 + 2.0.8.0 + 2.0.8 Stromberg, Roy, Lajugie, Jiang, Li, and Kang \ No newline at end of file diff --git a/VariantAnnotation/IO/VcfWriter/LiteVcfWriter.cs b/VariantAnnotation/IO/VcfWriter/LiteVcfWriter.cs index 72741d22..553620c7 100644 --- a/VariantAnnotation/IO/VcfWriter/LiteVcfWriter.cs +++ b/VariantAnnotation/IO/VcfWriter/LiteVcfWriter.cs @@ -10,18 +10,15 @@ namespace VariantAnnotation.IO.VcfWriter { public sealed class LiteVcfWriter : IDisposable { - #region members - private readonly StreamWriter _writer; - private const string AnnotatorTag = "##annotator="; - private const string AnnotationServiceUriTag = "##annotationserviceuri="; + private const string AnnotatorTag = "##annotator="; + private const string AnnotationServiceUriTag = "##annotationserviceuri="; private const string AnnotationCollectionVersionTag = "##annotationcollectionversion="; - private const string CsqInfoTag = "##INFO="; private const string CsqrHeaderLine = "##INFO="; @@ -34,12 +31,7 @@ public sealed class LiteVcfWriter : IDisposable "##INFO=\n" + "##INFO=\n" + "##INFO=\n" + - "##INFO=\n" + - "##INFO="; - - private const string FilteredVariantsRecomposedHeaderLine = "##FILTER="; - - #endregion + "##INFO="; #region IDisposable @@ -74,7 +66,6 @@ private void Dispose(bool disposing) } #endregion - public LiteVcfWriter(StreamWriter vcfWriter, IEnumerable headerLines,string nirvanaVersion, string nirvanaDataVersion, IEnumerable dataSourceVersions) { @@ -120,9 +111,7 @@ private static string BuildVcfHeaderLines(string nirvanaVersion,string nirvanaDa // add the CSQT and CSQR header lines sb.Append(CsqtHeaderLine + '\n'); - sb.Append(CsqrHeaderLine + '\n'); - - sb.Append(FilteredVariantsRecomposedHeaderLine); + sb.Append(CsqrHeaderLine); return StringBuilderCache.GetStringAndRelease(sb); } @@ -141,8 +130,7 @@ private void WriteHeader(IEnumerable headerLines, string csqInfoTag) !line.StartsWith(AnnotationServiceUriTag) && !line.StartsWith(CsqInfoTag) && !line.StartsWith(CsqRInfoTag) && - !line.StartsWith(CsqTInfoTag) && - !line.StartsWith(FilteredVariantsRecomposedHeaderLineTag)).ToList(); + !line.StartsWith(CsqTInfoTag)).ToList(); // find where we should place our info field and annotator tags var lastIndex = currentHeaderLines.FindLastIndex(x => x.StartsWith(InfoTag));