seqmat 0.1.53__tar.gz → 0.1.54__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.53/seqmat.egg-info → seqmat-0.1.54}/PKG-INFO +1 -1
  2. {seqmat-0.1.53 → seqmat-0.1.54}/seqmat/__init__.py +1 -1
  3. {seqmat-0.1.53 → seqmat-0.1.54}/seqmat/config.py +7 -1
  4. {seqmat-0.1.53 → seqmat-0.1.54}/seqmat/gene.py +6 -2
  5. {seqmat-0.1.53 → seqmat-0.1.54}/seqmat/utils.py +42 -0
  6. {seqmat-0.1.53 → seqmat-0.1.54/seqmat.egg-info}/PKG-INFO +1 -1
  7. {seqmat-0.1.53 → seqmat-0.1.54}/setup.py +1 -1
  8. {seqmat-0.1.53 → seqmat-0.1.54}/LICENSE +0 -0
  9. {seqmat-0.1.53 → seqmat-0.1.54}/MANIFEST.in +0 -0
  10. {seqmat-0.1.53 → seqmat-0.1.54}/README.md +0 -0
  11. {seqmat-0.1.53 → seqmat-0.1.54}/examples/basic_usage.py +0 -0
  12. {seqmat-0.1.53 → seqmat-0.1.54}/examples/data_inspection.py +0 -0
  13. {seqmat-0.1.53 → seqmat-0.1.54}/requirements.txt +0 -0
  14. {seqmat-0.1.53 → seqmat-0.1.54}/seqmat/cli.py +0 -0
  15. {seqmat-0.1.53 → seqmat-0.1.54}/seqmat/lmdb_store.py +0 -0
  16. {seqmat-0.1.53 → seqmat-0.1.54}/seqmat/seqmat.py +0 -0
  17. {seqmat-0.1.53 → seqmat-0.1.54}/seqmat/sqlite_store.py +0 -0
  18. {seqmat-0.1.53 → seqmat-0.1.54}/seqmat/transcript.py +0 -0
  19. {seqmat-0.1.53 → seqmat-0.1.54}/seqmat.egg-info/SOURCES.txt +0 -0
  20. {seqmat-0.1.53 → seqmat-0.1.54}/seqmat.egg-info/dependency_links.txt +0 -0
  21. {seqmat-0.1.53 → seqmat-0.1.54}/seqmat.egg-info/entry_points.txt +0 -0
  22. {seqmat-0.1.53 → seqmat-0.1.54}/seqmat.egg-info/requires.txt +0 -0
  23. {seqmat-0.1.53 → seqmat-0.1.54}/seqmat.egg-info/top_level.txt +0 -0
  24. {seqmat-0.1.53 → seqmat-0.1.54}/setup.cfg +0 -0
  25. {seqmat-0.1.53 → seqmat-0.1.54}/tests/__init__.py +0 -0
  26. {seqmat-0.1.53 → seqmat-0.1.54}/tests/test_gene.py +0 -0
  27. {seqmat-0.1.53 → seqmat-0.1.54}/tests/test_seqmat.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: seqmat
3
- Version: 0.1.53
3
+ Version: 0.1.54
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.53"
8
+ __version__ = "0.1.54"
9
9
  __author__ = "Nicolas Lynn Vila"
10
10
  __email__ = "nicolasalynn@gmail.com"
11
11
 
@@ -165,7 +165,13 @@ def get_organism_config(organism: Optional[str] = None) -> Dict[str, Path]:
165
165
  raise ValueError(f"Invalid configuration for organism '{organism}'. Expected dictionary.")
166
166
  if not isinstance(org_config, dict):
167
167
  raise ValueError(f"Invalid configuration for organism '{organism}'.")
168
- return {k: Path(v) for k, v in org_config.items() if isinstance(v, str)}
168
+ out = {k: Path(v) for k, v in org_config.items() if isinstance(v, str)}
169
+ # Prefer genes.db when it exists: if not in config, infer from BASE or MRNA_PATH (same dir as setup)
170
+ if "genes_db" not in out:
171
+ base_or_mrna = out.get("BASE") or out.get("MRNA_PATH")
172
+ if base_or_mrna is not None:
173
+ out["genes_db"] = Path(base_or_mrna) / "genes.db"
174
+ return out
169
175
 
170
176
  def get_directory_config() -> Dict[str, str]:
171
177
  """Return directory_structure (e.g. chromosomes, annotations folder names)."""
@@ -78,11 +78,15 @@ class Gene:
78
78
  def from_file(cls, gene_name: str, organism: Optional[str] = None) -> Optional['Gene']:
79
79
  """
80
80
  Load gene data from file.
81
-
81
+
82
+ Load order: LMDB (if installed) → SQLite (genes.db) → per-gene pickle files.
83
+ To use the DB, ensure genes.db exists in your organism data dir (run setup_genomics_data,
84
+ or set SEQMAT_DATA_DIR to a path whose organism subdirs contain genes.db).
85
+
82
86
  Args:
83
87
  gene_name: Name of the gene to load
84
88
  organism: Organism reference build
85
-
89
+
86
90
  Returns:
87
91
  Gene object or None if not found
88
92
  """
@@ -1,6 +1,7 @@
1
1
  """Utility functions for SeqMat package"""
2
2
  from __future__ import annotations
3
3
 
4
+ import os
4
5
  import pickle
5
6
  import json
6
7
  import re
@@ -520,6 +521,45 @@ def download_genome_data(organism: str, base_path: Path, skip_existing: bool = F
520
521
  return files
521
522
 
522
523
 
524
+ def _shell_config_path() -> Optional[Path]:
525
+ """Path to the user's shell config file (~/.zshrc or ~/.bashrc). Prefer zsh if SHELL contains zsh."""
526
+ home = Path.home()
527
+ shell = os.environ.get("SHELL", "")
528
+ if "zsh" in shell:
529
+ rc = home / ".zshrc"
530
+ else:
531
+ rc = home / ".bashrc"
532
+ if rc.exists():
533
+ return rc
534
+ # If preferred rc doesn't exist, try the other
535
+ other = home / ".zshrc" if rc.name == ".bashrc" else home / ".bashrc"
536
+ return other if other.exists() else rc
537
+
538
+
539
+ def _append_seqmat_env_to_shell(data_root: Path, organism: str) -> None:
540
+ """Append SEQMAT_DATA_DIR and SEQMAT_DEFAULT_ORGANISM to the user's shell config if not already set."""
541
+ rc = _shell_config_path()
542
+ if not rc or not rc.is_file():
543
+ return
544
+ try:
545
+ text = rc.read_text()
546
+ except OSError:
547
+ return
548
+ if "SEQMAT_DATA_DIR" in text:
549
+ return
550
+ block = (
551
+ "\n# SeqMat config-less data root (added by seqmat setup)\n"
552
+ f"export SEQMAT_DATA_DIR=\"{data_root}\"\n"
553
+ f"export SEQMAT_DEFAULT_ORGANISM=\"{organism}\"\n"
554
+ )
555
+ try:
556
+ with open(rc, "a") as f:
557
+ f.write(block)
558
+ print(f"Added SEQMAT_DATA_DIR and SEQMAT_DEFAULT_ORGANISM to {rc}. Restart your shell or run: source {rc}")
559
+ except OSError:
560
+ pass
561
+
562
+
523
563
  def setup_genomics_data(
524
564
  basepath: str,
525
565
  organism: Optional[str] = None,
@@ -615,6 +655,8 @@ def setup_genomics_data(
615
655
  print(f"Configuration saved to: {CONFIG_FILE}")
616
656
  else:
617
657
  print("SEQMAT_DATA_DIR is set; no config file written. Point it at this path to use the data.")
658
+ # Append SEQMAT_DATA_DIR (and default organism) to shell config so it persists
659
+ _append_seqmat_env_to_shell(Path(basepath).resolve(), organism)
618
660
  print(f"Successfully set up genomics data for {organism} in {basepath}")
619
661
  print("You can now use Gene.from_file() to load gene data.")
620
662
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: seqmat
3
- Version: 0.1.53
3
+ Version: 0.1.54
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.53",
11
+ version="0.1.54",
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