pyfaidx 0.9.2__tar.gz → 0.9.2.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 (61) hide show
  1. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/PKG-INFO +8 -3
  2. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/README.rst +7 -1
  3. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/pyfaidx/__init__.py +4 -6
  4. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/pyfaidx.egg-info/PKG-INFO +8 -3
  5. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/pyfaidx.egg-info/SOURCES.txt +1 -0
  6. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/pyfaidx.egg-info/scm_file_list.json +1 -0
  7. pyfaidx-0.9.2.2/pyfaidx.egg-info/scm_version.json +8 -0
  8. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/pyproject.toml +1 -2
  9. pyfaidx-0.9.2.2/tests/test_sequence_integer_coordinates.py +46 -0
  10. pyfaidx-0.9.2/pyfaidx.egg-info/scm_version.json +0 -8
  11. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/.coveragerc +0 -0
  12. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/.github/dependabot.yml +0 -0
  13. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/.github/workflows/main.yml +0 -0
  14. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/.github/workflows/pypi.yml +0 -0
  15. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/.gitignore +0 -0
  16. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/CODE_OF_CONDUCT.md +0 -0
  17. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/LICENSE +0 -0
  18. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/MANIFEST.in +0 -0
  19. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/dev-requirements.txt +0 -0
  20. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/pyfaidx/cli.py +0 -0
  21. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/pyfaidx.egg-info/dependency_links.txt +0 -0
  22. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/pyfaidx.egg-info/entry_points.txt +0 -0
  23. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/pyfaidx.egg-info/requires.txt +0 -0
  24. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/pyfaidx.egg-info/top_level.txt +0 -0
  25. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/scripts/benchmark.py +0 -0
  26. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/setup.cfg +0 -0
  27. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/__init__.py +0 -0
  28. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/data/chr17.hg19.part.fa +0 -0
  29. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/data/download_gene_fasta.py +0 -0
  30. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/data/gene.bed12 +0 -0
  31. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/data/gene.bed12.fasta +0 -0
  32. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/data/issue_83.fasta +0 -0
  33. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/data/malformed.bed +0 -0
  34. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/data/regions.bed +0 -0
  35. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_FastaRecord.py +0 -0
  36. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_FastaRecord_iter.py +0 -0
  37. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_FastaVariant.py +0 -0
  38. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_Fasta_bgzip.py +0 -0
  39. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_Fasta_integer_index.py +0 -0
  40. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_Fasta_synchronization.py +0 -0
  41. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_Path.py +0 -0
  42. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_bed_non_data.py +0 -0
  43. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_bgzf_first_access.py +0 -0
  44. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_bgzfblock.py +0 -0
  45. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_bio_seqio.py +0 -0
  46. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_faidx.py +0 -0
  47. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_feature_bounds_check.py +0 -0
  48. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_feature_comments.py +0 -0
  49. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_feature_default_seq.py +0 -0
  50. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_feature_indexing.py +0 -0
  51. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_feature_key_function.py +0 -0
  52. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_feature_read_ahead_buffer.py +0 -0
  53. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_feature_sequence_as_raw.py +0 -0
  54. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_feature_spliced_seq.py +0 -0
  55. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_feature_split_char.py +0 -0
  56. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_fsspec.py +0 -0
  57. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_long_fasta_entry.py +0 -0
  58. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_reverse_record_slices.py +0 -0
  59. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_reverse_sequence_coordinates.py +0 -0
  60. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_sequence_class.py +0 -0
  61. {pyfaidx-0.9.2 → pyfaidx-0.9.2.2}/tests/test_wrap_sequence_newline.py +0 -0
@@ -1,13 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyfaidx
3
- Version: 0.9.2
3
+ Version: 0.9.2.2
4
4
  Summary: pyfaidx: efficient pythonic random access to fasta subsequences
5
5
  Author-email: Matthew Shirley <mdshw5@gmail.com>
6
6
  License: BSD-3-Clause
7
7
  Project-URL: Homepage, https://github.com/mdshw5/pyfaidx/
8
8
  Project-URL: Author homepage, http://mattshirley.com
9
9
  Classifier: Development Status :: 5 - Production/Stable
10
- Classifier: License :: OSI Approved :: BSD License
11
10
  Classifier: Environment :: Console
12
11
  Classifier: Intended Audience :: Science/Research
13
12
  Classifier: Natural Language :: English
@@ -80,7 +79,7 @@ Usage
80
79
  >>> genes
81
80
  Fasta("tests/data/genes.fasta") # set strict_bounds=True for bounds checking
82
81
 
83
- Acts like a dictionary.
82
+ Acts like a dictionary. Record names are always strings, so dictionary-style lookups need a ``str`` key.
84
83
 
85
84
  .. code:: python
86
85
 
@@ -121,6 +120,12 @@ Indexes like a list:
121
120
  >AB821309.1:1-50
122
121
  ATGGTCAGCTGGGGTCGTTTCATCTGCCTGGTCGTGGTCACCATGGCAAC
123
122
 
123
+ An ``int`` key is always a position in the file, never a record name. If your
124
+ record names are numbers (for example chromosomes ``1``, ``2``, ... in Ensembl
125
+ or TAIR10 genomes), convert the key first: ``genes[str(chrom)]``. This is easy
126
+ to miss when names come from a table, since pandas reads a numeric ``chrom``
127
+ column as integers.
128
+
124
129
  Slices just like a string:
125
130
 
126
131
  .. code:: python
@@ -52,7 +52,7 @@ Usage
52
52
  >>> genes
53
53
  Fasta("tests/data/genes.fasta") # set strict_bounds=True for bounds checking
54
54
 
55
- Acts like a dictionary.
55
+ Acts like a dictionary. Record names are always strings, so dictionary-style lookups need a ``str`` key.
56
56
 
57
57
  .. code:: python
58
58
 
@@ -93,6 +93,12 @@ Indexes like a list:
93
93
  >AB821309.1:1-50
94
94
  ATGGTCAGCTGGGGTCGTTTCATCTGCCTGGTCGTGGTCACCATGGCAAC
95
95
 
96
+ An ``int`` key is always a position in the file, never a record name. If your
97
+ record names are numbers (for example chromosomes ``1``, ``2``, ... in Ensembl
98
+ or TAIR10 genomes), convert the key first: ``genes[str(chrom)]``. This is easy
99
+ to miss when names come from a table, since pandas reads a numeric ``chrom``
100
+ column as integers.
101
+
96
102
  Slices just like a string:
97
103
 
98
104
  .. code:: python
@@ -134,7 +134,7 @@ class Sequence(object):
134
134
  >chr1
135
135
  AC
136
136
  >>> x[-2]
137
- >chr1
137
+ >chr1:4-5
138
138
  T
139
139
  """
140
140
  if self.start is None or self.end is None or len(self.seq) == 0:
@@ -182,11 +182,9 @@ class Sequence(object):
182
182
  elif isinstance(n, int):
183
183
  if n < 0:
184
184
  n = len(self) + n
185
- if self.start:
186
- return self.__class__(self.name, self.seq[n], self.start + n,
187
- self.start + n, self.comp)
188
- else:
189
- return self.__class__(self.name, self.seq[n], self.comp)
185
+ if not 0 <= n < len(self):
186
+ raise IndexError('String index out of range')
187
+ return self[n:n + 1]
190
188
 
191
189
  def __str__(self):
192
190
  return self.seq
@@ -1,13 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyfaidx
3
- Version: 0.9.2
3
+ Version: 0.9.2.2
4
4
  Summary: pyfaidx: efficient pythonic random access to fasta subsequences
5
5
  Author-email: Matthew Shirley <mdshw5@gmail.com>
6
6
  License: BSD-3-Clause
7
7
  Project-URL: Homepage, https://github.com/mdshw5/pyfaidx/
8
8
  Project-URL: Author homepage, http://mattshirley.com
9
9
  Classifier: Development Status :: 5 - Production/Stable
10
- Classifier: License :: OSI Approved :: BSD License
11
10
  Classifier: Environment :: Console
12
11
  Classifier: Intended Audience :: Science/Research
13
12
  Classifier: Natural Language :: English
@@ -80,7 +79,7 @@ Usage
80
79
  >>> genes
81
80
  Fasta("tests/data/genes.fasta") # set strict_bounds=True for bounds checking
82
81
 
83
- Acts like a dictionary.
82
+ Acts like a dictionary. Record names are always strings, so dictionary-style lookups need a ``str`` key.
84
83
 
85
84
  .. code:: python
86
85
 
@@ -121,6 +120,12 @@ Indexes like a list:
121
120
  >AB821309.1:1-50
122
121
  ATGGTCAGCTGGGGTCGTTTCATCTGCCTGGTCGTGGTCACCATGGCAAC
123
122
 
123
+ An ``int`` key is always a position in the file, never a record name. If your
124
+ record names are numbers (for example chromosomes ``1``, ``2``, ... in Ensembl
125
+ or TAIR10 genomes), convert the key first: ``genes[str(chrom)]``. This is easy
126
+ to miss when names come from a table, since pandas reads a numeric ``chrom``
127
+ column as integers.
128
+
124
129
  Slices just like a string:
125
130
 
126
131
  .. code:: python
@@ -48,6 +48,7 @@ tests/test_long_fasta_entry.py
48
48
  tests/test_reverse_record_slices.py
49
49
  tests/test_reverse_sequence_coordinates.py
50
50
  tests/test_sequence_class.py
51
+ tests/test_sequence_integer_coordinates.py
51
52
  tests/test_wrap_sequence_newline.py
52
53
  tests/data/chr17.hg19.part.fa
53
54
  tests/data/download_gene_fasta.py
@@ -49,6 +49,7 @@
49
49
  "tests/test_reverse_record_slices.py",
50
50
  "tests/test_reverse_sequence_coordinates.py",
51
51
  "tests/test_sequence_class.py",
52
+ "tests/test_sequence_integer_coordinates.py",
52
53
  "tests/test_wrap_sequence_newline.py"
53
54
  ]
54
55
  }
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "0.9.2.2",
3
+ "distance": 0,
4
+ "node": "ged79e4bfe04e5d62847d2b12de82e5a29cd14de3",
5
+ "dirty": false,
6
+ "branch": "HEAD",
7
+ "node_date": "2026-10-29"
8
+ }
@@ -13,7 +13,6 @@ requires-python = ">=3.7"
13
13
  license = {text = "BSD-3-Clause"}
14
14
  classifiers = [
15
15
  "Development Status :: 5 - Production/Stable",
16
- "License :: OSI Approved :: BSD License",
17
16
  "Environment :: Console",
18
17
  "Intended Audience :: Science/Research",
19
18
  "Natural Language :: English",
@@ -44,4 +43,4 @@ local_scheme = "no-local-version"
44
43
 
45
44
  [tool.pytest.ini_options]
46
45
  minversion = "6.0"
47
- addopts = "--doctest-modules pyfaidx/__init__.py tests"
46
+ addopts = "--doctest-modules pyfaidx/__init__.py tests"
@@ -0,0 +1,46 @@
1
+ import pytest
2
+
3
+ from pyfaidx import Sequence
4
+
5
+
6
+ @pytest.mark.parametrize('one_based', [False, True])
7
+ @pytest.mark.parametrize('reverse', [False, True])
8
+ @pytest.mark.parametrize('comp', [False, True])
9
+ @pytest.mark.parametrize('index', [0, 2, -1, -5])
10
+ def test_integer_coordinates_match_selected_base(one_based, reverse, comp, index):
11
+ start = 1 if one_based else 0
12
+ sequence = Sequence('chr1', 'ACGTA', start=start, end=5)
13
+ labels = [(i, i + int(not one_based)) for i in range(start, start + 5)]
14
+ if reverse:
15
+ sequence = sequence.reverse
16
+ labels = [pair[::-1] for pair in labels[::-1]]
17
+ if comp:
18
+ sequence = sequence.complement
19
+ selected = sequence[index]
20
+ assert selected.seq == sequence.seq[index]
21
+ assert (selected.start, selected.end) == labels[index]
22
+ assert selected.comp is comp
23
+ assert selected[:].fancy_name == selected.fancy_name
24
+
25
+
26
+ @pytest.mark.parametrize('comp', [False, True])
27
+ def test_integer_without_coordinates_preserves_complement(comp):
28
+ sequence = Sequence('chr1', 'ACGTA', comp=comp)
29
+ selected = sequence[-1]
30
+ assert selected.seq == 'A'
31
+ assert selected.start is None
32
+ assert selected.end is None
33
+ assert selected.comp is comp
34
+
35
+
36
+ @pytest.mark.parametrize('index', [-6, -10, 5, 10])
37
+ def test_integer_outside_sequence_raises(index):
38
+ sequence = Sequence('chr1', 'ACGTA', start=1, end=5)
39
+ with pytest.raises(IndexError):
40
+ sequence[index]
41
+
42
+
43
+ @pytest.mark.parametrize('index', [-1, 0])
44
+ def test_integer_empty_sequence_raises(index):
45
+ with pytest.raises(IndexError):
46
+ Sequence('chr1', '')[index]
@@ -1,8 +0,0 @@
1
- {
2
- "tag": "0.9.2",
3
- "distance": 0,
4
- "node": "g98ad0718ddc8048656da42baf5731232d0072eea",
5
- "dirty": false,
6
- "branch": "HEAD",
7
- "node_date": "2026-10-25"
8
- }
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