seqmat 0.1.59__tar.gz → 1.1.0__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 (27) hide show
  1. {seqmat-0.1.59/seqmat.egg-info → seqmat-1.1.0}/PKG-INFO +2 -2
  2. {seqmat-0.1.59 → seqmat-1.1.0}/seqmat/__init__.py +1 -1
  3. {seqmat-0.1.59 → seqmat-1.1.0}/seqmat/seqmat.py +15 -0
  4. {seqmat-0.1.59 → seqmat-1.1.0}/seqmat/utils.py +15 -7
  5. {seqmat-0.1.59 → seqmat-1.1.0/seqmat.egg-info}/PKG-INFO +2 -2
  6. {seqmat-0.1.59 → seqmat-1.1.0}/setup.py +2 -2
  7. {seqmat-0.1.59 → seqmat-1.1.0}/LICENSE +0 -0
  8. {seqmat-0.1.59 → seqmat-1.1.0}/MANIFEST.in +0 -0
  9. {seqmat-0.1.59 → seqmat-1.1.0}/README.md +0 -0
  10. {seqmat-0.1.59 → seqmat-1.1.0}/examples/basic_usage.py +0 -0
  11. {seqmat-0.1.59 → seqmat-1.1.0}/examples/data_inspection.py +0 -0
  12. {seqmat-0.1.59 → seqmat-1.1.0}/requirements.txt +0 -0
  13. {seqmat-0.1.59 → seqmat-1.1.0}/seqmat/cli.py +0 -0
  14. {seqmat-0.1.59 → seqmat-1.1.0}/seqmat/config.py +0 -0
  15. {seqmat-0.1.59 → seqmat-1.1.0}/seqmat/gene.py +0 -0
  16. {seqmat-0.1.59 → seqmat-1.1.0}/seqmat/lmdb_store.py +0 -0
  17. {seqmat-0.1.59 → seqmat-1.1.0}/seqmat/sqlite_store.py +0 -0
  18. {seqmat-0.1.59 → seqmat-1.1.0}/seqmat/transcript.py +0 -0
  19. {seqmat-0.1.59 → seqmat-1.1.0}/seqmat.egg-info/SOURCES.txt +0 -0
  20. {seqmat-0.1.59 → seqmat-1.1.0}/seqmat.egg-info/dependency_links.txt +0 -0
  21. {seqmat-0.1.59 → seqmat-1.1.0}/seqmat.egg-info/entry_points.txt +0 -0
  22. {seqmat-0.1.59 → seqmat-1.1.0}/seqmat.egg-info/requires.txt +0 -0
  23. {seqmat-0.1.59 → seqmat-1.1.0}/seqmat.egg-info/top_level.txt +0 -0
  24. {seqmat-0.1.59 → seqmat-1.1.0}/setup.cfg +0 -0
  25. {seqmat-0.1.59 → seqmat-1.1.0}/tests/__init__.py +0 -0
  26. {seqmat-0.1.59 → seqmat-1.1.0}/tests/test_gene.py +0 -0
  27. {seqmat-0.1.59 → seqmat-1.1.0}/tests/test_seqmat.py +0 -0
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: seqmat
3
- Version: 0.1.59
3
+ Version: 1.1.0
4
4
  Summary: Lightning-fast gene manipulation and analysis library.
5
5
  Home-page: https://github.com/nicolasalynn/seqmat
6
6
  Author: Nicolas Lynn Vila
7
7
  Author-email: nicolasalynn@gmail.com
8
- Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Development Status :: 5 - Production/Stable
9
9
  Classifier: Intended Audience :: Science/Research
10
10
  Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
11
11
  Classifier: License :: OSI Approved :: MIT License
@@ -5,7 +5,7 @@ A comprehensive Python library for genomic sequence analysis with full mutation
5
5
  splicing analysis, and sequence manipulation.
6
6
  """
7
7
 
8
- __version__ = "0.1.59"
8
+ __version__ = "1.1.0"
9
9
  __author__ = "Nicolas Lynn Vila"
10
10
  __email__ = "nicolasalynn@gmail.com"
11
11
 
@@ -190,6 +190,21 @@ class SeqMat:
190
190
  """Return the reference sequence as a string (only valid bases)."""
191
191
  return self.seq_array['ref'][self.seq_array['valid']].tobytes().decode()
192
192
 
193
+ def alignment(self) -> Tuple[str, str]:
194
+ """Return gapped reference and mutated sequences aligned to each other.
195
+
196
+ Deletions appear as '-' in the mutated string, insertions appear as '-'
197
+ in the reference string, and SNPs show the differing bases at the same
198
+ position.
199
+
200
+ Returns:
201
+ (reference, mutated) tuple of equal-length strings.
202
+ """
203
+ arr = self.seq_array
204
+ ref = arr['ref'].tobytes().decode()
205
+ mut = np.where(arr['valid'], arr['nt'], b'-').tobytes().decode()
206
+ return ref, mut
207
+
193
208
  @property
194
209
  def index(self) -> np.ndarray:
195
210
  """Return the genomic indices of valid bases."""
@@ -680,14 +680,22 @@ def download_prebuilt_data(
680
680
  else:
681
681
  try:
682
682
  files["fasta_file"] = _download_or_raise(fasta_gz_url, base_path, is_gz=True)
683
- except OSError as e:
684
- if "not a gzipped" in str(e).lower() or "bad gzip" in str(e).lower():
685
- gz_path = base_path / f"{organism}.fa.gz"
686
- if gz_path.exists():
687
- gz_path.unlink()
688
- files["fasta_file"] = _download_or_raise(fasta_plain_url, base_path, is_gz=False)
689
- else:
683
+ except (OSError, requests.HTTPError) as e:
684
+ # Fall back to plain .fa if .fa.gz is missing (404), forbidden (403), or not gzip
685
+ is_404_403 = (
686
+ isinstance(e, requests.HTTPError)
687
+ and e.response is not None
688
+ and e.response.status_code in (403, 404)
689
+ )
690
+ is_not_gzip = isinstance(e, OSError) and (
691
+ "not a gzipped" in str(e).lower() or "bad gzip" in str(e).lower()
692
+ )
693
+ if not (is_404_403 or is_not_gzip):
690
694
  raise
695
+ gz_path = base_path / f"{organism}.fa.gz"
696
+ if gz_path.exists():
697
+ gz_path.unlink()
698
+ files["fasta_file"] = _download_or_raise(fasta_plain_url, base_path, is_gz=False)
691
699
  _validate_prebuilt_file(
692
700
  files["fasta_file"],
693
701
  min_size=1_000_000,
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: seqmat
3
- Version: 0.1.59
3
+ Version: 1.1.0
4
4
  Summary: Lightning-fast gene manipulation and analysis library.
5
5
  Home-page: https://github.com/nicolasalynn/seqmat
6
6
  Author: Nicolas Lynn Vila
7
7
  Author-email: nicolasalynn@gmail.com
8
- Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Development Status :: 5 - Production/Stable
9
9
  Classifier: Intended Audience :: Science/Research
10
10
  Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
11
11
  Classifier: License :: OSI Approved :: MIT License
@@ -8,7 +8,7 @@ long_description = (this_directory / "README.md").read_text()
8
8
 
9
9
  setup(
10
10
  name="seqmat",
11
- version="0.1.59",
11
+ version="1.1.0",
12
12
  author="Nicolas Lynn Vila",
13
13
  author_email="nicolasalynn@gmail.com",
14
14
  description="Lightning-fast gene manipulation and analysis library.",
@@ -17,7 +17,7 @@ setup(
17
17
  url="https://github.com/nicolasalynn/seqmat",
18
18
  packages=find_packages(),
19
19
  classifiers=[
20
- "Development Status :: 3 - Alpha",
20
+ "Development Status :: 5 - Production/Stable",
21
21
  "Intended Audience :: Science/Research",
22
22
  "Topic :: Scientific/Engineering :: Bio-Informatics",
23
23
  "License :: OSI Approved :: MIT License",
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