Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
377641b
1
Parent(s):
b186be8
fix requirements
Browse files- ntv3_tracks_pipeline.py +0 -38
ntv3_tracks_pipeline.py
CHANGED
|
@@ -9,11 +9,6 @@ import torch
|
|
| 9 |
from transformers import AutoConfig, AutoModel, AutoTokenizer
|
| 10 |
from transformers.pipelines import Pipeline
|
| 11 |
|
| 12 |
-
try:
|
| 13 |
-
from pyfaidx import Fasta
|
| 14 |
-
except Exception:
|
| 15 |
-
Fasta = None
|
| 16 |
-
|
| 17 |
try:
|
| 18 |
import requests
|
| 19 |
except Exception:
|
|
@@ -211,39 +206,6 @@ def _get_dna_sequence(assembly: str, chrom: str, start: int, end: int) -> str:
|
|
| 211 |
return seq
|
| 212 |
|
| 213 |
|
| 214 |
-
def _ensure_fasta_for_assembly(assembly: str, cache_dir: str | Path) -> Path:
|
| 215 |
-
"""
|
| 216 |
-
Download <assembly>.fa.gz, decompress to <assembly>.fa, return the .fa path.
|
| 217 |
-
pyfaidx works reliably on uncompressed FASTA.
|
| 218 |
-
"""
|
| 219 |
-
cache_dir = Path(cache_dir).expanduser().resolve()
|
| 220 |
-
cache_dir.mkdir(parents=True, exist_ok=True)
|
| 221 |
-
|
| 222 |
-
fa_path = cache_dir / f"{assembly}.fa"
|
| 223 |
-
gz_path = cache_dir / f"{assembly}.fa.gz"
|
| 224 |
-
|
| 225 |
-
if fa_path.exists():
|
| 226 |
-
return fa_path
|
| 227 |
-
|
| 228 |
-
# This function is deprecated - use _get_dna_sequence with API instead
|
| 229 |
-
raise ValueError(
|
| 230 |
-
f"FASTA file download is no longer supported for assembly='{assembly}'. "
|
| 231 |
-
f"Please use _get_dna_sequence() with API-based sequence fetching instead."
|
| 232 |
-
)
|
| 233 |
-
|
| 234 |
-
import gzip
|
| 235 |
-
|
| 236 |
-
print(f"Decompressing {gz_path} -> {fa_path}")
|
| 237 |
-
with gzip.open(gz_path, "rb") as fin, open(fa_path, "wb") as fout:
|
| 238 |
-
while True:
|
| 239 |
-
chunk = fin.read(1024 * 1024)
|
| 240 |
-
if not chunk:
|
| 241 |
-
break
|
| 242 |
-
fout.write(chunk)
|
| 243 |
-
|
| 244 |
-
return fa_path
|
| 245 |
-
|
| 246 |
-
|
| 247 |
def _pick_device(device: str | int | torch.device) -> torch.device:
|
| 248 |
# Handle torch.device objects
|
| 249 |
if isinstance(device, torch.device):
|
|
|
|
| 9 |
from transformers import AutoConfig, AutoModel, AutoTokenizer
|
| 10 |
from transformers.pipelines import Pipeline
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
try:
|
| 13 |
import requests
|
| 14 |
except Exception:
|
|
|
|
| 206 |
return seq
|
| 207 |
|
| 208 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
def _pick_device(device: str | int | torch.device) -> torch.device:
|
| 210 |
# Handle torch.device objects
|
| 211 |
if isinstance(device, torch.device):
|