public void Add_one_chrom() { var position1 = new Mock <IPosition>(); position1.SetupGet(x => x.Chromosome).Returns(ChromosomeUtilities.Chr1); position1.SetupGet(x => x.Start).Returns(100); position1.SetupGet(x => x.RefAllele).Returns("A"); position1.SetupGet(x => x.AltAlleles).Returns(new [] { "C" }); var memStream = new MemoryStream(); using (var indexCreator = new OnTheFlyIndexCreator(memStream)) { indexCreator.BeginSection("positions", 100); indexCreator.Add(position1.Object, 2588); indexCreator.EndSection("positions", 2699); } var readStream = new MemoryStream(memStream.ToArray()); readStream.Seek(0, SeekOrigin.Begin); var index = new JasixIndex(readStream); Assert.Equal(100, index.GetSectionBegin("positions")); Assert.Equal(2588, index.GetFirstVariantPosition("chr1", 100, 102)); }
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); }
public void WriteJsonEntry(IPosition position, string entry) { if (string.IsNullOrEmpty(entry)) { return; } _jasixIndexCreator?.Add(position, _bgzipTextWriter.Position); if (!_firstEntry) { _writer.WriteLine(","); } else { _jasixIndexCreator?.BeginSection(JasixCommons.PositionsSectionTag, _bgzipTextWriter.Position); } _firstEntry = false; _writer.Write(entry); }