Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -8,34 +8,6 @@ from functools import lru_cache
|
|
8 |
from mtdna_classifier import classify_sample_location
|
9 |
import subprocess
|
10 |
|
11 |
-
import shutil
|
12 |
-
|
13 |
-
# Force reinstall every time (only if missing)
|
14 |
-
if not os.path.exists(f"{os.environ['HOME']}/edirect/esummary"):
|
15 |
-
subprocess.run("yes | sh -c \"$(wget -q https://ftp.ncbi.nlm.nih.gov/entrez/entrezdirect/install-edirect.sh -O -)\"", shell=True)
|
16 |
-
os.environ["PATH"] += f":{os.environ['HOME']}/edirect"
|
17 |
-
print("✅ EDirect installed.")
|
18 |
-
else:
|
19 |
-
print("✅ EDirect already installed.")
|
20 |
-
|
21 |
-
|
22 |
-
# Force PATH to include edirect (again, just to be safe)
|
23 |
-
os.environ["PATH"] += f":{os.environ['HOME']}/edirect"
|
24 |
-
print("Current PATH:", os.environ["PATH"])
|
25 |
-
subprocess.run("which esummary", shell=True)
|
26 |
-
accession = "KU131308"
|
27 |
-
print(accession)
|
28 |
-
test_cmd = f'{os.environ["HOME"]}/edirect/esummary -db nuccore -id KU131308 -format medline | egrep "PUBMED|isolate"'
|
29 |
-
result = subprocess.run(test_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
30 |
-
print("EDirect output:\n", result.stdout)
|
31 |
-
print("EDirect error:\n", result.stderr)
|
32 |
-
|
33 |
-
cmd = f'{os.environ["HOME"]}/edirect/esummary -db nuccore -id {accession} -format medline | egrep "PUBMED|isolate"'
|
34 |
-
result = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
35 |
-
output = result.stdout
|
36 |
-
print(output)
|
37 |
-
print("done")
|
38 |
-
|
39 |
@lru_cache(maxsize=128)
|
40 |
def classify_sample_location_cached(accession):
|
41 |
return classify_sample_location(accession)
|
|
|
8 |
from mtdna_classifier import classify_sample_location
|
9 |
import subprocess
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
@lru_cache(maxsize=128)
|
12 |
def classify_sample_location_cached(accession):
|
13 |
return classify_sample_location(accession)
|