seqmat 0.1.58__tar.gz → 0.1.59__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-0.1.59}/PKG-INFO +1 -1
  2. {seqmat-0.1.58 → seqmat-0.1.59}/seqmat/__init__.py +1 -1
  3. {seqmat-0.1.58 → seqmat-0.1.59}/seqmat/config.py +2 -1
  4. {seqmat-0.1.58 → seqmat-0.1.59}/seqmat/utils.py +49 -0
  5. {seqmat-0.1.58 → seqmat-0.1.59/seqmat.egg-info}/PKG-INFO +1 -1
  6. {seqmat-0.1.58 → seqmat-0.1.59}/setup.py +1 -1
  7. {seqmat-0.1.58 → seqmat-0.1.59}/LICENSE +0 -0
  8. {seqmat-0.1.58 → seqmat-0.1.59}/MANIFEST.in +0 -0
  9. {seqmat-0.1.58 → seqmat-0.1.59}/README.md +0 -0
  10. {seqmat-0.1.58 → seqmat-0.1.59}/examples/basic_usage.py +0 -0
  11. {seqmat-0.1.58 → seqmat-0.1.59}/examples/data_inspection.py +0 -0
  12. {seqmat-0.1.58 → seqmat-0.1.59}/requirements.txt +0 -0
  13. {seqmat-0.1.58 → seqmat-0.1.59}/seqmat/cli.py +0 -0
  14. {seqmat-0.1.58 → seqmat-0.1.59}/seqmat/gene.py +0 -0
  15. {seqmat-0.1.58 → seqmat-0.1.59}/seqmat/lmdb_store.py +0 -0
  16. {seqmat-0.1.58 → seqmat-0.1.59}/seqmat/seqmat.py +0 -0
  17. {seqmat-0.1.58 → seqmat-0.1.59}/seqmat/sqlite_store.py +0 -0
  18. {seqmat-0.1.58 → seqmat-0.1.59}/seqmat/transcript.py +0 -0
  19. {seqmat-0.1.58 → seqmat-0.1.59}/seqmat.egg-info/SOURCES.txt +0 -0
  20. {seqmat-0.1.58 → seqmat-0.1.59}/seqmat.egg-info/dependency_links.txt +0 -0
  21. {seqmat-0.1.58 → seqmat-0.1.59}/seqmat.egg-info/entry_points.txt +0 -0
  22. {seqmat-0.1.58 → seqmat-0.1.59}/seqmat.egg-info/requires.txt +0 -0
  23. {seqmat-0.1.58 → seqmat-0.1.59}/seqmat.egg-info/top_level.txt +0 -0
  24. {seqmat-0.1.58 → seqmat-0.1.59}/setup.cfg +0 -0
  25. {seqmat-0.1.58 → seqmat-0.1.59}/tests/__init__.py +0 -0
  26. {seqmat-0.1.58 → seqmat-0.1.59}/tests/test_gene.py +0 -0
  27. {seqmat-0.1.58 → seqmat-0.1.59}/tests/test_seqmat.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: seqmat
3
- Version: 0.1.58
3
+ Version: 0.1.59
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
@@ -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__ = "0.1.59"
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,11 +662,21 @@ 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)
@@ -646,6 +688,13 @@ def download_prebuilt_data(
646
688
  files["fasta_file"] = _download_or_raise(fasta_plain_url, base_path, is_gz=False)
647
689
  else:
648
690
  raise
691
+ _validate_prebuilt_file(
692
+ files["fasta_file"],
693
+ min_size=1_000_000,
694
+ kind="FASTA",
695
+ url=f"{base_url}/{organism}/",
696
+ allow_fasta_header=True,
697
+ )
649
698
  files["cons_file"] = None # Conservation only downloaded during build-from-sources
650
699
  return files
651
700
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: seqmat
3
- Version: 0.1.58
3
+ Version: 0.1.59
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
@@ -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="0.1.59",
12
12
  author="Nicolas Lynn Vila",
13
13
  author_email="nicolasalynn@gmail.com",
14
14
  description="Lightning-fast gene manipulation and analysis library.",
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