public void Write_and_read_back() { var index = new JasixIndex(); index.Add("chr1", 100, 101, 100000, "1"); index.Add("chr1", 105, 109, 100050, "1"); index.Add("chr1", 150, 1000, 100075, "1");//large variant index.Add("chr1", 160, 166, 100100, "1"); index.Add("chr2", 100, 100, 100150, "2"); index.Add("chr2", 102, 105, 100200, "2"); var writeStream = new MemoryStream(); using (writeStream) { index.Write(writeStream); } var readStream = new MemoryStream(writeStream.ToArray()); readStream.Seek(0, SeekOrigin.Begin); JasixIndex readBackIndex; using (readStream) { readBackIndex = new JasixIndex(readStream); } Assert.Equal(100000, readBackIndex.GetFirstVariantPosition("chr1", 100, 102)); Assert.Equal(100000, readBackIndex.GetFirstVariantPosition("chr1", 103, 104)); Assert.Equal(100000, readBackIndex.GetFirstVariantPosition("chr1", 120, 124)); Assert.Equal(100000, readBackIndex.GetFirstVariantPosition("chr1", 158, 160)); Assert.Equal(100150, readBackIndex.GetFirstVariantPosition("chr2", 103, 105)); //checking large variants Assert.Null(readBackIndex.LargeVariantPositions("chr1", 100, 149)); var largeVariants = readBackIndex.LargeVariantPositions("chr1", 100, 201); Assert.NotNull(largeVariants); Assert.Single(largeVariants); Assert.Equal(100075, largeVariants[0]); }
public void FindLargeVaritants_method_does_not_return_small_variants() { var index = new JasixIndex(); index.Add("chr1", 100, 101, 100_000); index.Add("chr1", 105, 109, 100_050); index.Add("chr1", 160, 166, 100_100); index.Add("chr1", 200, 1000, 100_075);//large variant index.Add("chr2", 100, 100, 100_150); index.Add("chr2", 102, 105, 100_200); index.Flush(); //checking large variants Assert.Null(index.LargeVariantPositions("chr1", 100, 199)); var largeVariants = index.LargeVariantPositions("chr1", 100, 201); Assert.NotNull(largeVariants); Assert.Single(largeVariants); Assert.Equal(100075, largeVariants[0]); }
public void IndexWriteRead() { var index = new JasixIndex(); index.Add("chr1", 100, 101, 100000); index.Add("chr1", 105, 109, 100050); index.Add("chr1", 150, 1000, 100075);//large variant index.Add("chr1", 160, 166, 100100); index.Add("chr2", 100, 100, 100150); index.Add("chr2", 102, 105, 100200); var tempFile = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); using (var writer = FileUtilities.GetCreateStream(tempFile)) { index.Write(writer); } JasixIndex readBackIndex; using (var stream = FileUtilities.GetReadStream(tempFile)) { readBackIndex = new JasixIndex(stream); } File.Delete(tempFile); Assert.Equal(100000, readBackIndex.GetFirstVariantPosition("chr1", 100, 102)); Assert.Equal(100000, readBackIndex.GetFirstVariantPosition("chr1", 103, 104)); Assert.Equal(100000, readBackIndex.GetFirstVariantPosition("chr1", 120, 124)); Assert.Equal(100000, readBackIndex.GetFirstVariantPosition("chr1", 158, 160)); Assert.Equal(100150, readBackIndex.GetFirstVariantPosition("chr2", 103, 105)); //checking large variants Assert.Null(readBackIndex.LargeVariantPositions("chr1", 100, 149)); var largeVariants = readBackIndex.LargeVariantPositions("chr1", 100, 201); Assert.NotNull(largeVariants); Assert.Single(largeVariants); Assert.Equal(100075, largeVariants[0]); }
public void Combination_of_large_and_small_variants() { var index = new JasixIndex(); //query range 10,000- 10,020 index.Add("chr1", 8_000, 9_900, 90_000); //SV not overlapping the query index.Add("chr1", 9_000, 10_005, 90_100); // partially overlapping index.Add("chr1", 9_500, 10_050, 90_200); //completely overlapping index.Add("chr1", 10_000, 10_001, 100_000); index.Add("chr1", 10_004, 10_006, 100_100); index.Add("chr1", 10_009, 10_550, 100_200);//SV starting from the middle of the range index.Add("chr1", 10_008, 10_010, 100_300); index.Add("chr1", 10_011, 10_020, 100_400); index.Add("chr1", 10_039, 10_550, 100_200);//SV past the range index.Flush(); var firstSmallVarLocation = index.GetFirstVariantPosition("chr1", 10_000, 10_020); var largeVariantLocations = index.LargeVariantPositions("chr1", 10_000, 10_020); Assert.Equal(90_000, firstSmallVarLocation); Assert.True(largeVariantLocations.SequenceEqual(new List <long> { 90_100, 90_200, 100_200 }));