seqmat 0.1.58__tar.gz → 1.0.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.58/seqmat.egg-info → seqmat-1.0.0}/PKG-INFO +2 -2
  2. {seqmat-0.1.58 → seqmat-1.0.0}/seqmat/__init__.py +1 -1
  3. {seqmat-0.1.58 → seqmat-1.0.0}/seqmat/config.py +2 -1
  4. {seqmat-0.1.58 → seqmat-1.0.0}/seqmat/utils.py +64 -7
  5. {seqmat-0.1.58 → seqmat-1.0.0/seqmat.egg-info}/PKG-INFO +2 -2
  6. {seqmat-0.1.58 → seqmat-1.0.0}/setup.py +2 -2
  7. {seqmat-0.1.58 → seqmat-1.0.0}/LICENSE +0 -0
  8. {seqmat-0.1.58 → seqmat-1.0.0}/MANIFEST.in +0 -0
  9. {seqmat-0.1.58 → seqmat-1.0.0}/README.md +0 -0
  10. {seqmat-0.1.58 → seqmat-1.0.0}/examples/basic_usage.py +0 -0
  11. {seqmat-0.1.58 → seqmat-1.0.0}/examples/data_inspection.py +0 -0
  12. {seqmat-0.1.58 → seqmat-1.0.0}/requirements.txt +0 -0
  13. {seqmat-0.1.58 → seqmat-1.0.0}/seqmat/cli.py +0 -0
  14. {seqmat-0.1.58 → seqmat-1.0.0}/seqmat/gene.py +0 -0
  15. {seqmat-0.1.58 → seqmat-1.0.0}/seqmat/lmdb_store.py +0 -0
  16. {seqmat-0.1.58 → seqmat-1.0.0}/seqmat/seqmat.py +0 -0
  17. {seqmat-0.1.58 → seqmat-1.0.0}/seqmat/sqlite_store.py +0 -0
  18. {seqmat-0.1.58 → seqmat-1.0.0}/seqmat/transcript.py +0 -0
  19. {seqmat-0.1.58 → seqmat-1.0.0}/seqmat.egg-info/SOURCES.txt +0 -0
  20. {seqmat-0.1.58 → seqmat-1.0.0}/seqmat.egg-info/dependency_links.txt +0 -0
  21. {seqmat-0.1.58 → seqmat-1.0.0}/seqmat.egg-info/entry_points.txt +0 -0
  22. {seqmat-0.1.58 → seqmat-1.0.0}/seqmat.egg-info/requires.txt +0 -0
  23. {seqmat-0.1.58 → seqmat-1.0.0}/seqmat.egg-info/top_level.txt +0 -0
  24. {seqmat-0.1.58 → seqmat-1.0.0}/setup.cfg +0 -0
  25. {seqmat-0.1.58 → seqmat-1.0.0}/tests/__init__.py +0 -0
  26. {seqmat-0.1.58 → seqmat-1.0.0}/tests/test_gene.py +0 -0
  27. {seqmat-0.1.58 → seqmat-1.0.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.58
3
+ Version: 1.0.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.58"
8
+ __version__ = "1.0.0"
9
9
  __author__ = "Nicolas Lynn Vila"
10
10
  __email__ = "nicolasalynn@gmail.com"
11
11
 
@@ -35,8 +35,9 @@ DEFAULT_DATA_DIR = Path(user_data_dir("seqmat", appauthor=False))
35
35
 
36
36
  # S3 bucket for prebuilt data (genes.db, FASTA). Used by default for pip installs (no rebuild).
37
37
  # Layout: {base}/{organism}/genes.db, {organism}/{organism}.fa.gz, etc.
38
+ # Bucket region is eu-north-1; use that endpoint to avoid 301 redirect (which returns XML body, not data).
38
39
  # Override via env SEQMAT_PREBUILT_DATA_BASE_URL or config key "prebuilt_data_base_url".
39
- _PREBUILT_DATA_BASE_URL_DEFAULT = "https://seqmat-prebuilt-public.s3.us-east-1.amazonaws.com"
40
+ _PREBUILT_DATA_BASE_URL_DEFAULT = "https://seqmat-prebuilt-public.s3.eu-north-1.amazonaws.com"
40
41
 
41
42
 
42
43
  def get_prebuilt_data_base_url() -> str:
@@ -584,6 +584,38 @@ class PrebuiltDataUnavailableError(Exception):
584
584
  """Raised when prebuilt data cannot be downloaded (e.g. 404). Use build-from-sources instead."""
585
585
 
586
586
 
587
+ def _validate_prebuilt_file(
588
+ path: Path,
589
+ min_size: int,
590
+ kind: str,
591
+ url: str,
592
+ allow_fasta_header: bool = False,
593
+ ) -> None:
594
+ """Raise PrebuiltDataUnavailableError and remove file if it looks like an error page or is too small."""
595
+ size = path.stat().st_size
596
+ if size < min_size:
597
+ path.unlink()
598
+ raise PrebuiltDataUnavailableError(
599
+ f"Prebuilt {kind} from {url} is too small ({size} bytes). "
600
+ "The server may have returned an error page. Check the bucket URL, network, and permissions. "
601
+ "Alternatively run setup with --build-from-sources."
602
+ )
603
+ with open(path, "rb") as f:
604
+ head = f.read(64)
605
+ if head.startswith(b"<?") or head.startswith(b"<!") or b"<html" in head[:32].lower():
606
+ path.unlink()
607
+ raise PrebuiltDataUnavailableError(
608
+ f"Prebuilt {kind} from {url} looks like an HTML/XML error page, not data. "
609
+ "Check the bucket URL and permissions. Alternatively run setup with --build-from-sources."
610
+ )
611
+ if allow_fasta_header and not head.lstrip().startswith(b">"):
612
+ path.unlink()
613
+ raise PrebuiltDataUnavailableError(
614
+ f"Prebuilt {kind} from {url} does not look like a FASTA file. "
615
+ "Check the bucket. Alternatively run setup with --build-from-sources."
616
+ )
617
+
618
+
587
619
  def download_prebuilt_data(
588
620
  organism: str,
589
621
  base_path: Path,
@@ -630,22 +662,47 @@ def download_prebuilt_data(
630
662
  raise
631
663
 
632
664
  files["genes_db"] = _download_or_raise(genes_db_url, base_path, is_gz=False)
665
+ _validate_prebuilt_file(
666
+ files["genes_db"], min_size=100_000, kind="genes.db", url=genes_db_url
667
+ )
633
668
  # FASTA: try .fa.gz then decompress; if not gzip (e.g. S3 has plain .fa), use .fa
634
669
  fasta_plain_path = base_path / f"{organism}.fa"
635
670
  if skip_existing and fasta_plain_path.exists():
636
671
  print(f"✓ Uncompressed FASTA already exists: {fasta_plain_path.name}")
637
672
  files["fasta_file"] = fasta_plain_path
673
+ _validate_prebuilt_file(
674
+ files["fasta_file"],
675
+ min_size=1_000_000,
676
+ kind="FASTA",
677
+ url=f"{base_url}/{organism}/",
678
+ allow_fasta_header=True,
679
+ )
638
680
  else:
639
681
  try:
640
682
  files["fasta_file"] = _download_or_raise(fasta_gz_url, base_path, is_gz=True)
641
- except OSError as e:
642
- if "not a gzipped" in str(e).lower() or "bad gzip" in str(e).lower():
643
- gz_path = base_path / f"{organism}.fa.gz"
644
- if gz_path.exists():
645
- gz_path.unlink()
646
- files["fasta_file"] = _download_or_raise(fasta_plain_url, base_path, is_gz=False)
647
- 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):
648
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)
699
+ _validate_prebuilt_file(
700
+ files["fasta_file"],
701
+ min_size=1_000_000,
702
+ kind="FASTA",
703
+ url=f"{base_url}/{organism}/",
704
+ allow_fasta_header=True,
705
+ )
649
706
  files["cons_file"] = None # Conservation only downloaded during build-from-sources
650
707
  return files
651
708
 
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: seqmat
3
- Version: 0.1.58
3
+ Version: 1.0.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.58",
11
+ version="1.0.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