seqmat 0.1.53__tar.gz → 0.1.55__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.
- {seqmat-0.1.53/seqmat.egg-info → seqmat-0.1.55}/PKG-INFO +92 -104
- {seqmat-0.1.53 → seqmat-0.1.55}/README.md +91 -103
- {seqmat-0.1.53 → seqmat-0.1.55}/seqmat/__init__.py +1 -1
- {seqmat-0.1.53 → seqmat-0.1.55}/seqmat/cli.py +11 -1
- {seqmat-0.1.53 → seqmat-0.1.55}/seqmat/config.py +32 -3
- {seqmat-0.1.53 → seqmat-0.1.55}/seqmat/gene.py +6 -2
- {seqmat-0.1.53 → seqmat-0.1.55}/seqmat/sqlite_store.py +3 -2
- {seqmat-0.1.53 → seqmat-0.1.55}/seqmat/utils.py +216 -50
- {seqmat-0.1.53 → seqmat-0.1.55/seqmat.egg-info}/PKG-INFO +92 -104
- {seqmat-0.1.53 → seqmat-0.1.55}/setup.py +1 -1
- {seqmat-0.1.53 → seqmat-0.1.55}/LICENSE +0 -0
- {seqmat-0.1.53 → seqmat-0.1.55}/MANIFEST.in +0 -0
- {seqmat-0.1.53 → seqmat-0.1.55}/examples/basic_usage.py +0 -0
- {seqmat-0.1.53 → seqmat-0.1.55}/examples/data_inspection.py +0 -0
- {seqmat-0.1.53 → seqmat-0.1.55}/requirements.txt +0 -0
- {seqmat-0.1.53 → seqmat-0.1.55}/seqmat/lmdb_store.py +0 -0
- {seqmat-0.1.53 → seqmat-0.1.55}/seqmat/seqmat.py +0 -0
- {seqmat-0.1.53 → seqmat-0.1.55}/seqmat/transcript.py +0 -0
- {seqmat-0.1.53 → seqmat-0.1.55}/seqmat.egg-info/SOURCES.txt +0 -0
- {seqmat-0.1.53 → seqmat-0.1.55}/seqmat.egg-info/dependency_links.txt +0 -0
- {seqmat-0.1.53 → seqmat-0.1.55}/seqmat.egg-info/entry_points.txt +0 -0
- {seqmat-0.1.53 → seqmat-0.1.55}/seqmat.egg-info/requires.txt +0 -0
- {seqmat-0.1.53 → seqmat-0.1.55}/seqmat.egg-info/top_level.txt +0 -0
- {seqmat-0.1.53 → seqmat-0.1.55}/setup.cfg +0 -0
- {seqmat-0.1.53 → seqmat-0.1.55}/tests/__init__.py +0 -0
- {seqmat-0.1.53 → seqmat-0.1.55}/tests/test_gene.py +0 -0
- {seqmat-0.1.53 → seqmat-0.1.55}/tests/test_seqmat.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: seqmat
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.55
|
|
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
|
|
@@ -69,6 +69,14 @@ SeqMat is a comprehensive Python library for genomic sequence analysis, providin
|
|
|
69
69
|
pip install seqmat
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
+
After installing, to use genes and transcripts you need to fetch organism data once (see [Data Setup and Configuration](#data-setup-and-configuration)):
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
seqmat setup
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
This downloads prebuilt data (genes.db + FASTA) from SeqMat's S3 bucket into a dedicated directory on your machine. No config file is required: the installer can add `SEQMAT_DATA_DIR` to your shell config so SeqMat finds the data in future sessions.
|
|
79
|
+
|
|
72
80
|
### With Bioinformatics Features
|
|
73
81
|
```bash
|
|
74
82
|
# For protein translation
|
|
@@ -177,8 +185,9 @@ print(f"Spliced: {spliced.seq}")
|
|
|
177
185
|
```python
|
|
178
186
|
from seqmat import Gene, setup_genomics_data
|
|
179
187
|
|
|
180
|
-
# One-time setup
|
|
181
|
-
|
|
188
|
+
# One-time setup: downloads prebuilt genes.db + FASTA from SeqMat's S3 bucket (no rebuild)
|
|
189
|
+
# Uses a dedicated data dir on your machine (default: platform user data dir)
|
|
190
|
+
setup_genomics_data("/path/to/data", organism="hg38") # or omit path to use default location
|
|
182
191
|
|
|
183
192
|
# Load a gene
|
|
184
193
|
kras = Gene.from_file("KRAS", organism="hg38")
|
|
@@ -235,44 +244,45 @@ genomic_seq.apply_mutations([
|
|
|
235
244
|
|
|
236
245
|
## Data Setup and Configuration
|
|
237
246
|
|
|
238
|
-
|
|
247
|
+
**Typical workflow:** `pip install seqmat` → run `seqmat setup` once (or `setup_genomics_data()` with optional path) → data is downloaded to a dedicated directory; SeqMat can add `SEQMAT_DATA_DIR` to your shell so future use is config-less. No manual config or rebuild needed.
|
|
248
|
+
|
|
249
|
+
SeqMat uses a flexible configuration system. When `SEQMAT_DATA_DIR` is set, all paths are derived from it (config-less). Otherwise paths are read from a config file (written by setup if needed).
|
|
239
250
|
|
|
240
251
|
### Quick Setup for Supported Organisms
|
|
241
252
|
|
|
242
|
-
For the built-in organisms (hg38, mm39)
|
|
253
|
+
For ordinary **pip install** users, setup **downloads prebuilt data** (genes.db and FASTA) from the SeqMat S3 bucket into a dedicated location on your machine. **No rebuild is required.** Default data location is the platform user data dir (e.g. `~/Library/Application Support/seqmat` on macOS). For the built-in organisms (hg38, mm39):
|
|
243
254
|
|
|
244
255
|
```python
|
|
245
256
|
from seqmat import setup_genomics_data
|
|
246
257
|
|
|
247
|
-
#
|
|
258
|
+
# Default: download prebuilt genes.db + FASTA from S3 (fast)
|
|
248
259
|
setup_genomics_data("/path/to/your/data", organism="hg38")
|
|
249
|
-
|
|
250
|
-
# Optional: limit or set parallel workers (faster on multi-core machines)
|
|
251
|
-
setup_genomics_data("/path/to/your/data", organism="hg38", n_jobs=8) # or n_jobs=1 for serial
|
|
252
|
-
|
|
253
|
-
# Download and setup mouse genome data
|
|
254
260
|
setup_genomics_data("/path/to/your/data", organism="mm39")
|
|
261
|
+
|
|
262
|
+
# Optional: build from sources (GTF + FASTA) instead of using prebuilt data
|
|
263
|
+
setup_genomics_data("/path/to/your/data", organism="hg38", from_prebuilt=False, n_jobs=8)
|
|
255
264
|
```
|
|
256
265
|
|
|
257
266
|
Or via command line:
|
|
258
267
|
```bash
|
|
259
|
-
#
|
|
260
|
-
|
|
268
|
+
# Default: download prebuilt data from S3
|
|
269
|
+
seqmat setup --path /path/to/your/data --organism hg38
|
|
261
270
|
|
|
262
|
-
#
|
|
263
|
-
seqmat setup --path /path/to/your/data --organism
|
|
271
|
+
# Build from GTF/FASTA sources instead
|
|
272
|
+
seqmat setup --path /path/to/your/data --organism hg38 --build-from-sources
|
|
264
273
|
```
|
|
265
274
|
|
|
266
275
|
### Configuration System
|
|
267
276
|
|
|
268
|
-
**Config-less mode (
|
|
269
|
-
|
|
277
|
+
**Config-less mode (recommended):**
|
|
278
|
+
When you run `seqmat setup` (or `setup_genomics_data()`), SeqMat can append to your shell config (e.g. `.zshrc` or `.bashrc`):
|
|
270
279
|
|
|
271
280
|
```bash
|
|
272
|
-
export SEQMAT_DATA_DIR=/path/to/seqmat_base
|
|
281
|
+
export SEQMAT_DATA_DIR=/path/to/seqmat_base
|
|
282
|
+
export SEQMAT_DEFAULT_ORGANISM=hg38
|
|
273
283
|
```
|
|
274
284
|
|
|
275
|
-
SeqMat
|
|
285
|
+
After you open a new terminal (or run `source ~/.zshrc`), SeqMat uses only these environment variables. All paths are derived: `{SEQMAT_DATA_DIR}/{organism}/genes.db`, `{organism}.fa`, etc. You do not need to create or edit any config file.
|
|
276
286
|
|
|
277
287
|
**Config file mode** (when `SEQMAT_DATA_DIR` is not set):
|
|
278
288
|
|
|
@@ -301,43 +311,41 @@ The config file (when used) contains:
|
|
|
301
311
|
},
|
|
302
312
|
"hg38": {
|
|
303
313
|
"BASE": "/path/to/data/hg38",
|
|
304
|
-
"CHROM_SOURCE": "/path/to/data/hg38
|
|
305
|
-
"MRNA_PATH": "/path/to/data/hg38
|
|
306
|
-
"
|
|
314
|
+
"CHROM_SOURCE": "/path/to/data/hg38",
|
|
315
|
+
"MRNA_PATH": "/path/to/data/hg38",
|
|
316
|
+
"genes_db": "/path/to/data/hg38/genes.db",
|
|
317
|
+
"fasta_full_genome": "/path/to/data/hg38/hg38.fa"
|
|
307
318
|
},
|
|
308
319
|
"mm39": {
|
|
309
320
|
"BASE": "/path/to/data/mm39",
|
|
310
|
-
"CHROM_SOURCE": "/path/to/data/mm39
|
|
311
|
-
"MRNA_PATH": "/path/to/data/mm39
|
|
312
|
-
"
|
|
321
|
+
"CHROM_SOURCE": "/path/to/data/mm39",
|
|
322
|
+
"MRNA_PATH": "/path/to/data/mm39",
|
|
323
|
+
"genes_db": "/path/to/data/mm39/genes.db",
|
|
324
|
+
"fasta_full_genome": "/path/to/data/mm39/mm39.fa"
|
|
313
325
|
}
|
|
314
326
|
}
|
|
315
327
|
```
|
|
316
328
|
|
|
317
329
|
### Directory Structure
|
|
318
330
|
|
|
319
|
-
When you run `setup_genomics_data`,
|
|
331
|
+
When you run `setup_genomics_data`, each organism directory contains a single **genes.db** (SQLite) and a full-genome FASTA:
|
|
320
332
|
|
|
321
333
|
```
|
|
322
334
|
/your/data/path/
|
|
323
335
|
├── hg38/ # Organism directory
|
|
324
|
-
│ ├──
|
|
325
|
-
│
|
|
326
|
-
│
|
|
327
|
-
│
|
|
328
|
-
│
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
│ ├── temp/ # Temporary download files
|
|
333
|
-
│ ├── conservation.pkl # Conservation scores
|
|
334
|
-
│ └── gtex_expression.gct.gz # Expression data (human only)
|
|
335
|
-
└── mm39/ # Mouse data (similar structure)
|
|
336
|
-
├── chromosomes/
|
|
337
|
-
├── annotations/
|
|
336
|
+
│ ├── genes.db # Gene annotations (SQLite; from prebuilt or built from GTF)
|
|
337
|
+
│ ├── hg38.fa # Full genome FASTA
|
|
338
|
+
│ ├── temp/ # Temporary files (when building from sources)
|
|
339
|
+
│ ├── missplicing/
|
|
340
|
+
│ └── oncosplice/
|
|
341
|
+
└── mm39/ # Mouse (same layout)
|
|
342
|
+
├── genes.db
|
|
343
|
+
├── mm39.fa
|
|
338
344
|
└── ...
|
|
339
345
|
```
|
|
340
346
|
|
|
347
|
+
Prebuilt data is downloaded from SeqMat's S3 bucket (default: `seqmat-prebuilt-public`). To upload or update prebuilt assets, use layout: `{bucket}/{organism}/genes.db`, `{bucket}/{organism}/{organism}.fa.gz`, and optionally `{bucket}/{organism}/conservation.db` or `conservation.pkl`.
|
|
348
|
+
|
|
341
349
|
### Adding Support for New Organisms
|
|
342
350
|
|
|
343
351
|
To add a new organism (e.g., dm6 for Drosophila), you have several options:
|
|
@@ -389,73 +397,44 @@ DEFAULT_ORGANISM_DATA = {
|
|
|
389
397
|
|
|
390
398
|
#### Option 3: Manual Setup for Custom Data
|
|
391
399
|
|
|
392
|
-
For completely custom data
|
|
400
|
+
For completely custom data: create the organism directory, place `genes.db` (SQLite, same schema as built by setup) and a full-genome FASTA (e.g. `custom.fa`), then point config at that directory:
|
|
393
401
|
|
|
394
402
|
```python
|
|
395
|
-
# 1. Create directory structure manually
|
|
396
|
-
import os
|
|
397
403
|
from pathlib import Path
|
|
404
|
+
from seqmat.config import load_config, save_config
|
|
398
405
|
|
|
399
406
|
base_path = Path("/path/to/data/custom_genome")
|
|
400
|
-
base_path.mkdir(exist_ok=True)
|
|
401
|
-
|
|
402
|
-
(base_path / "annotations").mkdir(exist_ok=True)
|
|
403
|
-
|
|
404
|
-
# 2. Place your FASTA files in chromosomes/ directory
|
|
405
|
-
# Your files: chr1.fasta, chr2.fasta, etc.
|
|
406
|
-
|
|
407
|
-
# 3. Update configuration
|
|
408
|
-
from seqmat.config import load_config, save_config
|
|
407
|
+
base_path.mkdir(parents=True, exist_ok=True)
|
|
408
|
+
# Place genes.db and e.g. custom_genome.fa in base_path, then:
|
|
409
409
|
|
|
410
410
|
config = load_config()
|
|
411
411
|
config['custom_genome'] = {
|
|
412
412
|
'BASE': str(base_path),
|
|
413
|
-
'CHROM_SOURCE': str(base_path
|
|
414
|
-
'MRNA_PATH': str(base_path
|
|
415
|
-
'
|
|
413
|
+
'CHROM_SOURCE': str(base_path),
|
|
414
|
+
'MRNA_PATH': str(base_path),
|
|
415
|
+
'genes_db': str(base_path / 'genes.db'),
|
|
416
|
+
'fasta_full_genome': str(base_path / 'custom_genome.fa')
|
|
416
417
|
}
|
|
417
418
|
save_config(config)
|
|
418
|
-
|
|
419
|
-
# 4. Process your GTF file (if you have gene annotations)
|
|
420
|
-
from seqmat.utils import process_gtf_annotations
|
|
421
|
-
process_gtf_annotations(
|
|
422
|
-
gtf_file="/path/to/your.gtf",
|
|
423
|
-
output_dir=str(base_path / 'annotations'),
|
|
424
|
-
organism="custom_genome"
|
|
425
|
-
)
|
|
426
419
|
```
|
|
427
420
|
|
|
428
|
-
### Data Sources
|
|
429
|
-
|
|
430
|
-
SeqMat downloads data from these default sources:
|
|
421
|
+
### Data Sources
|
|
431
422
|
|
|
432
|
-
**
|
|
433
|
-
|
|
434
|
-
- Annotations: Ensembl release-111 GTF
|
|
435
|
-
- Conservation: Pre-computed conservation scores
|
|
436
|
-
- Expression: GTEx v8 median TPM data
|
|
423
|
+
**Default (prebuilt download):**
|
|
424
|
+
SeqMat downloads prebuilt `genes.db` and FASTA from the SeqMat S3 bucket (default: `seqmat-prebuilt-public`). No rebuild; data is ready to use.
|
|
437
425
|
|
|
438
|
-
**
|
|
439
|
-
-
|
|
440
|
-
-
|
|
426
|
+
**Build-from-sources** (when you pass `from_prebuilt=False` or `--build-from-sources`):
|
|
427
|
+
- GTF: Ensembl (e.g. release-111 for hg38, release-112 for mm39)
|
|
428
|
+
- FASTA: UCSC Genome Browser (hg38, mm39)
|
|
429
|
+
- Conservation: same prebuilt bucket, per organism (`conservation.db` or `.pkl`)
|
|
430
|
+
- Expression (human only): GTEx v8 median TPM data
|
|
441
431
|
|
|
442
|
-
###
|
|
432
|
+
### Overriding the prebuilt data source
|
|
443
433
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
```python
|
|
447
|
-
from seqmat.config import load_config, save_config
|
|
448
|
-
|
|
449
|
-
config = load_config()
|
|
450
|
-
config['directory_structure'] = {
|
|
451
|
-
'chromosomes': 'genomes', # Custom name for FASTA directory
|
|
452
|
-
'annotations': 'gene_data' # Custom name for annotation directory
|
|
453
|
-
}
|
|
454
|
-
save_config(config)
|
|
434
|
+
By default, prebuilt data is downloaded from SeqMat's S3 bucket. To use a different bucket or mirror, set one of:
|
|
455
435
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
```
|
|
436
|
+
- **Environment:** `export SEQMAT_PREBUILT_DATA_BASE_URL=https://your-bucket.s3.region.amazonaws.com`
|
|
437
|
+
- **Config file:** add `"prebuilt_data_base_url": "https://..."` to your seqmat config (see `get_config_file()`).
|
|
459
438
|
|
|
460
439
|
### Configuration Management
|
|
461
440
|
|
|
@@ -483,6 +462,13 @@ config['default_organism'] = 'mm39' # Switch default to mouse
|
|
|
483
462
|
save_config(config)
|
|
484
463
|
```
|
|
485
464
|
|
|
465
|
+
### Rebuilding data from sources
|
|
466
|
+
|
|
467
|
+
If you need to regenerate `genes.db` from a GTF (e.g. a different Ensembl release or custom annotations), use build-from-sources. This downloads the GTF and FASTA from Ensembl/UCSC, fetches conservation from the prebuilt bucket, parses the GTF, and writes `genes.db` locally.
|
|
468
|
+
|
|
469
|
+
- **CLI:** `seqmat setup --path /path/to/data --organism hg38 --build-from-sources`
|
|
470
|
+
- **Python:** `setup_genomics_data("/path/to/data", organism="hg38", from_prebuilt=False, n_jobs=8)`
|
|
471
|
+
|
|
486
472
|
### Troubleshooting Setup
|
|
487
473
|
|
|
488
474
|
**Common issues:**
|
|
@@ -536,11 +522,10 @@ with open('seqmat_config_template.json', 'w') as f:
|
|
|
536
522
|
json.dump(config, f, indent=2)
|
|
537
523
|
```
|
|
538
524
|
|
|
539
|
-
|
|
540
|
-
- **
|
|
541
|
-
- **
|
|
542
|
-
- **
|
|
543
|
-
- **Expression data** → organism root directory (human only)
|
|
525
|
+
When building from sources, setup produces per organism:
|
|
526
|
+
- **genes.db** (SQLite) in the organism directory
|
|
527
|
+
- **Full-genome FASTA** (e.g. `hg38.fa`) in the organism directory
|
|
528
|
+
- **Expression data** (human only) merged into gene records
|
|
544
529
|
|
|
545
530
|
## Data Inspection and Management
|
|
546
531
|
|
|
@@ -585,12 +570,14 @@ print_data_summary() # Formatted overview of all data
|
|
|
585
570
|
SeqMat provides a comprehensive CLI for data management. The CLI automatically detects available organisms from your configuration:
|
|
586
571
|
|
|
587
572
|
```bash
|
|
588
|
-
#
|
|
573
|
+
# Default: download prebuilt data (no rebuild)
|
|
574
|
+
seqmat setup
|
|
589
575
|
seqmat setup --path /your/data/path --organism hg38
|
|
590
|
-
seqmat setup --path /your/data/path --organism mm39 --force
|
|
591
576
|
|
|
592
|
-
#
|
|
593
|
-
seqmat setup --
|
|
577
|
+
# Build from GTF/FASTA instead (for custom or updated annotations)
|
|
578
|
+
seqmat setup --path /your/data/path --organism hg38 --build-from-sources
|
|
579
|
+
|
|
580
|
+
seqmat setup --help # Shows path default and --organism choices
|
|
594
581
|
|
|
595
582
|
# Check what organisms are supported/configured
|
|
596
583
|
seqmat organisms
|
|
@@ -683,12 +670,13 @@ $ seqmat summary
|
|
|
683
670
|
**Core Functions:**
|
|
684
671
|
- `load_config()`: Load configuration (file path from `get_config_file()`)
|
|
685
672
|
- `get_config_file()`: Return the active config file path
|
|
673
|
+
- `get_data_base()`: Return `SEQMAT_DATA_DIR` path if set (config-less mode), else None
|
|
686
674
|
- `save_config(config)`: Save configuration to file
|
|
687
|
-
- `get_default_organism()`: Get default organism from config
|
|
688
|
-
- `get_available_organisms()`: Get list of
|
|
675
|
+
- `get_default_organism()`: Get default organism (from env in config-less mode, else config)
|
|
676
|
+
- `get_available_organisms()`: Get list of configured organisms (from data dir in config-less mode)
|
|
689
677
|
- `get_organism_config(organism=None)`: Get file paths for organism (uses default if None)
|
|
690
|
-
- `get_organism_info(organism)`: Get organism metadata
|
|
691
|
-
- `
|
|
678
|
+
- `get_organism_info(organism)`: Get organism metadata
|
|
679
|
+
- `get_prebuilt_data_base_url()`: Base URL for prebuilt downloads (env > config > default bucket)
|
|
692
680
|
|
|
693
681
|
**Configuration Examples:**
|
|
694
682
|
```python
|
|
@@ -711,7 +699,7 @@ save_config(config)
|
|
|
711
699
|
- `list_supported_organisms()`: Get all supported organisms (dynamic from config)
|
|
712
700
|
- `list_available_organisms()`: Get configured organisms
|
|
713
701
|
- `get_organism_info(organism)`: Detailed organism information
|
|
714
|
-
- `setup_genomics_data(basepath, organism=None, force=False, pickup=False, n_jobs=None)`:
|
|
702
|
+
- `setup_genomics_data(basepath, organism=None, force=False, pickup=False, n_jobs=None, from_prebuilt=True)`: Set up data. By default downloads prebuilt genes.db and FASTA from S3; use `from_prebuilt=False` to build from GTF/FASTA. `n_jobs` controls GTF parsing workers when building from sources.
|
|
715
703
|
|
|
716
704
|
**Gene Discovery:**
|
|
717
705
|
- `list_gene_biotypes(organism)`: Get available gene types
|
|
@@ -726,7 +714,7 @@ save_config(config)
|
|
|
726
714
|
### Command Line Interface
|
|
727
715
|
|
|
728
716
|
**Setup Commands:**
|
|
729
|
-
- `seqmat setup --path PATH --organism {dynamic_list} [--force]`:
|
|
717
|
+
- `seqmat setup --path PATH --organism {dynamic_list} [--force] [--build-from-sources]`: Default: download prebuilt data from S3; use `--build-from-sources` to build genes.db from GTF/FASTA
|
|
730
718
|
- `seqmat organisms`: List organism status and availability
|
|
731
719
|
|
|
732
720
|
**Exploration Commands:**
|