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.
Files changed (84) hide show
  1. {pybcf-1.3.0/src/pybcf.egg-info → pybcf-1.3.2}/PKG-INFO +1 -1
  2. {pybcf-1.3.0 → pybcf-1.3.2}/setup.py +1 -1
  3. {pybcf-1.3.0 → pybcf-1.3.2}/src/bcf.cpp +3 -3
  4. {pybcf-1.3.0 → pybcf-1.3.2}/src/index.cpp +4 -0
  5. {pybcf-1.3.0 → pybcf-1.3.2/src/pybcf.egg-info}/PKG-INFO +1 -1
  6. {pybcf-1.3.0 → pybcf-1.3.2}/test/test_indexed.py +47 -0
  7. {pybcf-1.3.0 → pybcf-1.3.2}/LICENSE.txt +0 -0
  8. {pybcf-1.3.0 → pybcf-1.3.2}/MANIFEST.in +0 -0
  9. {pybcf-1.3.0 → pybcf-1.3.2}/README.md +0 -0
  10. {pybcf-1.3.0 → pybcf-1.3.2}/pyproject.toml +0 -0
  11. {pybcf-1.3.0 → pybcf-1.3.2}/setup.cfg +0 -0
  12. {pybcf-1.3.0 → pybcf-1.3.2}/src/bcf.h +0 -0
  13. {pybcf-1.3.0 → pybcf-1.3.2}/src/gzstream.cpp +0 -0
  14. {pybcf-1.3.0 → pybcf-1.3.2}/src/gzstream.h +0 -0
  15. {pybcf-1.3.0 → pybcf-1.3.2}/src/header.cpp +0 -0
  16. {pybcf-1.3.0 → pybcf-1.3.2}/src/header.h +0 -0
  17. {pybcf-1.3.0 → pybcf-1.3.2}/src/index.h +0 -0
  18. {pybcf-1.3.0 → pybcf-1.3.2}/src/info.cpp +0 -0
  19. {pybcf-1.3.0 → pybcf-1.3.2}/src/info.h +0 -0
  20. {pybcf-1.3.0 → pybcf-1.3.2}/src/pybcf/__init__.py +0 -0
  21. {pybcf-1.3.0 → pybcf-1.3.2}/src/pybcf/reader.cpp +0 -0
  22. {pybcf-1.3.0 → pybcf-1.3.2}/src/pybcf/reader.pyx +0 -0
  23. {pybcf-1.3.0 → pybcf-1.3.2}/src/pybcf.egg-info/SOURCES.txt +0 -0
  24. {pybcf-1.3.0 → pybcf-1.3.2}/src/pybcf.egg-info/dependency_links.txt +0 -0
  25. {pybcf-1.3.0 → pybcf-1.3.2}/src/pybcf.egg-info/requires.txt +0 -0
  26. {pybcf-1.3.0 → pybcf-1.3.2}/src/pybcf.egg-info/top_level.txt +0 -0
  27. {pybcf-1.3.0 → pybcf-1.3.2}/src/sample_data.cpp +0 -0
  28. {pybcf-1.3.0 → pybcf-1.3.2}/src/sample_data.h +0 -0
  29. {pybcf-1.3.0 → pybcf-1.3.2}/src/types.h +0 -0
  30. {pybcf-1.3.0 → pybcf-1.3.2}/src/variant.cpp +0 -0
  31. {pybcf-1.3.0 → pybcf-1.3.2}/src/variant.h +0 -0
  32. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/adler32.c +0 -0
  33. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/adler32_p.h +0 -0
  34. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/arch_functions.h +0 -0
  35. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/chunkset_tpl.h +0 -0
  36. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/compare256_rle.h +0 -0
  37. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/compress.c +0 -0
  38. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/cpu_features.c +0 -0
  39. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/cpu_features.h +0 -0
  40. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/crc32.c +0 -0
  41. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/crc32.h +0 -0
  42. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/crc32_braid_comb.c +0 -0
  43. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/crc32_braid_comb_p.h +0 -0
  44. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/crc32_braid_p.h +0 -0
  45. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/crc32_braid_tbl.h +0 -0
  46. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/deflate.c +0 -0
  47. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/deflate.h +0 -0
  48. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/deflate_fast.c +0 -0
  49. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/deflate_huff.c +0 -0
  50. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/deflate_medium.c +0 -0
  51. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/deflate_p.h +0 -0
  52. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/deflate_quick.c +0 -0
  53. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/deflate_rle.c +0 -0
  54. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/deflate_slow.c +0 -0
  55. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/deflate_stored.c +0 -0
  56. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/fallback_builtins.h +0 -0
  57. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/functable.c +0 -0
  58. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/functable.h +0 -0
  59. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/gzguts.h +0 -0
  60. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/gzlib.c +0 -0
  61. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/gzwrite.c +0 -0
  62. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/infback.c +0 -0
  63. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/inffast_tpl.h +0 -0
  64. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/inffixed_tbl.h +0 -0
  65. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/inflate.c +0 -0
  66. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/inflate.h +0 -0
  67. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/inflate_p.h +0 -0
  68. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/inftrees.c +0 -0
  69. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/inftrees.h +0 -0
  70. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/insert_string.c +0 -0
  71. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/insert_string_roll.c +0 -0
  72. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/insert_string_tpl.h +0 -0
  73. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/match_tpl.h +0 -0
  74. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/trees.c +0 -0
  75. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/trees.h +0 -0
  76. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/trees_emit.h +0 -0
  77. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/trees_tbl.h +0 -0
  78. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/uncompr.c +0 -0
  79. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/zbuild.h +0 -0
  80. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/zendian.h +0 -0
  81. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/zutil.c +0 -0
  82. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/zutil.h +0 -0
  83. {pybcf-1.3.0 → pybcf-1.3.2}/src/zlib-ng/zutil_p.h +0 -0
  84. {pybcf-1.3.0 → pybcf-1.3.2}/test/test_pybcf.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pybcf
3
- Version: 1.3.0
3
+ Version: 1.3.2
4
4
  Summary: Package for loading data from bcf files
5
5
  Home-page: https://github.com/jeremymcrae/pybcf
6
6
  Author: Jeremy McRae
@@ -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.0',
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pybcf
3
- Version: 1.3.0
3
+ Version: 1.3.2
4
4
  Summary: Package for loading data from bcf files
5
5
  Home-page: https://github.com/jeremymcrae/pybcf
6
6
  Author: Jeremy McRae
@@ -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