pybcf 1.3.0__tar.gz → 1.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pybcf-1.3.0/src/pybcf.egg-info → pybcf-1.3.2}/PKG-INFO +1 -1
- {pybcf-1.3.0 → pybcf-1.3.2}/setup.py +1 -1
- {pybcf-1.3.0 → pybcf-1.3.2}/src/bcf.cpp +3 -3
- {pybcf-1.3.0 → pybcf-1.3.2}/src/index.cpp +4 -0
- {pybcf-1.3.0 → pybcf-1.3.2/src/pybcf.egg-info}/PKG-INFO +1 -1
- {pybcf-1.3.0 → pybcf-1.3.2}/test/test_indexed.py +47 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/LICENSE.txt +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/MANIFEST.in +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/README.md +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/pyproject.toml +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/setup.cfg +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/bcf.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/gzstream.cpp +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/gzstream.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/header.cpp +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/header.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/index.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/info.cpp +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/info.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/pybcf/__init__.py +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/pybcf/reader.cpp +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/pybcf/reader.pyx +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/pybcf.egg-info/SOURCES.txt +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/pybcf.egg-info/dependency_links.txt +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/pybcf.egg-info/requires.txt +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/pybcf.egg-info/top_level.txt +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/sample_data.cpp +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/sample_data.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/types.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/variant.cpp +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/variant.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/adler32.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/adler32_p.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/arch_functions.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/chunkset_tpl.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/compare256_rle.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/compress.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/cpu_features.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/cpu_features.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/crc32.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/crc32.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/crc32_braid_comb.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/crc32_braid_comb_p.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/crc32_braid_p.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/crc32_braid_tbl.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/deflate.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/deflate.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/deflate_fast.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/deflate_huff.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/deflate_medium.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/deflate_p.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/deflate_quick.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/deflate_rle.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/deflate_slow.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/deflate_stored.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/fallback_builtins.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/functable.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/functable.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/gzguts.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/gzlib.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/gzwrite.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/infback.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/inffast_tpl.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/inffixed_tbl.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/inflate.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/inflate.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/inflate_p.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/inftrees.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/inftrees.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/insert_string.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/insert_string_roll.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/insert_string_tpl.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/match_tpl.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/trees.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/trees.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/trees_emit.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/trees_tbl.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/uncompr.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/zbuild.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/zendian.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/zutil.c +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/zutil.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/zutil_p.h +0 -0
- {pybcf-1.3.0 → pybcf-1.3.2}/test/test_pybcf.py +0 -0
|
@@ -131,7 +131,7 @@ setup(name='pybcf',
|
|
|
131
131
|
description='Package for loading data from bcf files',
|
|
132
132
|
long_description=io.open('README.md', encoding='utf-8').read(),
|
|
133
133
|
long_description_content_type='text/markdown',
|
|
134
|
-
version='1.3.
|
|
134
|
+
version='1.3.2',
|
|
135
135
|
author='Jeremy McRae',
|
|
136
136
|
author_email='jmcrae@illumina.com',
|
|
137
137
|
license="MIT",
|
|
@@ -62,12 +62,12 @@ void BCF::set_region(std::string chrom, std::uint32_t start, std::uint32_t end)
|
|
|
62
62
|
|
|
63
63
|
std::uint32_t contig_id = header.get_contig_id(chrom);
|
|
64
64
|
|
|
65
|
+
Offsets offset = idxfile.query(contig_id, start, end);
|
|
66
|
+
infile.seek(offset);
|
|
67
|
+
|
|
65
68
|
query_chrom = chrom;
|
|
66
69
|
query_start = start;
|
|
67
70
|
query_end = end;
|
|
68
|
-
|
|
69
|
-
Offsets offset = idxfile.query(contig_id, start, end);
|
|
70
|
-
infile.seek(offset);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
}
|
|
@@ -166,6 +166,10 @@ std::uint32_t get_width(std::int32_t depth, std::int32_t min_shift) {
|
|
|
166
166
|
/// @param end end position of region
|
|
167
167
|
/// @return file offsets for the bin as struct with u_offset and c_offset members.
|
|
168
168
|
Offsets IndexFile::query(std::uint32_t contig_id, std::int64_t beg, std::int64_t end) {
|
|
169
|
+
if (end < beg) {
|
|
170
|
+
throw std::invalid_argument("start is after end: " + std::to_string(beg) + " > " + std::to_string(end));
|
|
171
|
+
}
|
|
172
|
+
|
|
169
173
|
// find the bins which could overlap a position
|
|
170
174
|
auto bins = reg2bins(beg, end);
|
|
171
175
|
|
|
@@ -3,6 +3,7 @@ import unittest
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
|
|
5
5
|
from pybcf import BcfReader
|
|
6
|
+
from pysam import VariantFile
|
|
6
7
|
|
|
7
8
|
class TestIndexed(unittest.TestCase):
|
|
8
9
|
''' class to make sure BcfReader works correctly
|
|
@@ -16,7 +17,40 @@ class TestIndexed(unittest.TestCase):
|
|
|
16
17
|
'''
|
|
17
18
|
bcf = BcfReader(self.hapmap)
|
|
18
19
|
self.assertTrue(hasattr(bcf, 'fetch') and callable(getattr(bcf, 'fetch')))
|
|
20
|
+
|
|
21
|
+
def test_matches_pysam(self):
|
|
22
|
+
''' check this fetch gets the same variants as pysam fetch
|
|
23
|
+
'''
|
|
24
|
+
bcf = BcfReader(self.hapmap)
|
|
25
|
+
vcf = VariantFile(self.hapmap)
|
|
26
|
+
|
|
27
|
+
sites = [(x.chrom, x.pos) for x in bcf]
|
|
28
|
+
chroms = set(x[0] for x in sites)
|
|
29
|
+
self.assertTrue(len(chroms) == 1)
|
|
30
|
+
chrom = next(iter(chroms))
|
|
31
|
+
|
|
32
|
+
_, pos_50th = sites[len(sites) // 2]
|
|
33
|
+
_, pos_75th = sites[(len(sites) // 4) * 3]
|
|
34
|
+
|
|
35
|
+
# check that we get variants restricted to a region after fetching
|
|
36
|
+
pybcf_fetched = [(x.chrom, x.pos) for x in bcf.fetch(chrom, pos_50th, pos_75th)]
|
|
37
|
+
pysam_fetched = [(x.chrom, x.pos) for x in vcf.fetch(chrom, pos_50th-1, pos_75th)]
|
|
38
|
+
self.assertEqual(pybcf_fetched, pysam_fetched)
|
|
39
|
+
|
|
40
|
+
def test_fetch_after_bcf_iterated(self):
|
|
41
|
+
''' check that we can fetch variants after we reach the end of the bcf
|
|
42
|
+
'''
|
|
43
|
+
bcf = BcfReader(self.hapmap)
|
|
44
|
+
chrom = next(bcf).chrom
|
|
45
|
+
for x in bcf:
|
|
46
|
+
pass
|
|
47
|
+
|
|
48
|
+
# if we try to iterate now, there are no more variants
|
|
49
|
+
self.assertEqual(list(bcf), [])
|
|
19
50
|
|
|
51
|
+
# but we can still fetch variants even after hitting the end of the bcf
|
|
52
|
+
self.assertTrue(len(list(bcf.fetch(chrom))) > 0)
|
|
53
|
+
|
|
20
54
|
def test_fetch_one_chrom(self):
|
|
21
55
|
''' check that if we fetch one chrom, none of the other chroms are included
|
|
22
56
|
'''
|
|
@@ -101,6 +135,19 @@ class TestIndexed(unittest.TestCase):
|
|
|
101
135
|
with self.assertRaises(ValueError):
|
|
102
136
|
bcf.fetch(missing_chrom)
|
|
103
137
|
|
|
138
|
+
def test_raise_error_for_swapped_coordinates(self):
|
|
139
|
+
''' check we raise error if the start position is after the end
|
|
140
|
+
'''
|
|
141
|
+
bcf = BcfReader(self.test_cases)
|
|
142
|
+
chrom = next(bcf).chrom
|
|
143
|
+
|
|
144
|
+
with self.assertRaises(ValueError):
|
|
145
|
+
bcf.fetch(chrom, 10, 9)
|
|
146
|
+
|
|
147
|
+
# but we can still iterate, since the fetch didn't succeed
|
|
148
|
+
iterated = list(bcf)
|
|
149
|
+
self.assertTrue(len(iterated) > 0)
|
|
150
|
+
|
|
104
151
|
def test_fetch_chrom_without_variants(self):
|
|
105
152
|
''' check we don't raise an error if fetching for a chrom that exist
|
|
106
153
|
'''
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|