Skip to content

Commit 2218621

Browse files
committed
removed bio.applications
1 parent 1b7b930 commit 2218621

File tree

2 files changed

+23
-26
lines changed

2 files changed

+23
-26
lines changed

fdog/libs/blast.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import os
1919
import sys
20-
from Bio.Blast.Applications import NcbiblastpCommandline
2120
import xml.etree.ElementTree as ET
2221
import subprocess
2322

@@ -29,21 +28,21 @@ def do_blastsearch(
2928
""" Perform blastp search for a query fasta file
3029
Return an XML string contains blast result
3130
"""
32-
filter = 'no'
33-
if lowComplexityFilter == True:
34-
filter = 'yes'
31+
filter_value = "yes" if lowComplexityFilter else "no"
3532
try:
36-
blastp_cline = NcbiblastpCommandline(
37-
query = query, db = blast_db, evalue = evalBlast, seg = filter,
38-
max_target_seqs = 10, outfmt = 5)
39-
stdout, stderr = blastp_cline()
40-
return(stdout)
41-
except:
42-
sys.exit(
43-
'ERROR: Error running blastp search for %s against %s\n%s'
44-
% (query, blast_db, NcbiblastpCommandline(
45-
query = query, db = blast_db, evalue = evalBlast, seg = filter,
46-
max_target_seqs = 10, outfmt = 5)))
33+
cmd = [
34+
"blastp",
35+
"-query", query,
36+
"-db", blast_db,
37+
"-evalue", str(evalBlast),
38+
"-seg", filter_value,
39+
"-max_target_seqs", "10",
40+
"-outfmt", "5"
41+
]
42+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
43+
return result.stdout
44+
except subprocess.CalledProcessError as e:
45+
sys.exit(f"ERROR: Error running BLASTP search for {query} against {blast_db}\n{e.stderr}")
4746

4847

4948
def parse_blast_xml(blast_output):

fdog/libs/preparation.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
import sys
1919
import os
20+
import subprocess
2021
from pathlib import Path
2122
from Bio import SeqIO
22-
from Bio.Blast.Applications import NcbiblastpCommandline
2323
from ete3 import NCBITaxa
2424

2525
import fdog.libs.zzz as general_fn
@@ -107,17 +107,15 @@ def check_input(args):
107107

108108
def check_blast_version(corepath, refspec):
109109
""" Check if blast DBs in corepath is compatible with blastp version """
110-
fdog_path = os.path.realpath(__file__).replace('/libs/preparation.py','')
111-
query = fdog_path + '/data/infile.fa'
112-
blast_db = '%s/%s/%s' % (corepath, refspec, refspec)
110+
fdog_path = os.path.realpath(__file__).replace('/libs/preparation.py', '')
111+
query = os.path.join(fdog_path, 'data', 'infile.fa')
112+
blast_db = os.path.join(corepath, refspec, refspec)
113113
try:
114-
blastp_cline = NcbiblastpCommandline(
115-
query = query, db = blast_db)
116-
stdout, stderr = blastp_cline()
117-
except:
118-
sys.exit(
119-
'ERROR: Error running blast (probably conflict with BLAST DBs versions)\n%s'
120-
% (NcbiblastpCommandline(query = query, db = blast_db)))
114+
cmd = ["blastp", "-query", query, "-db", blast_db]
115+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
116+
except subprocess.CalledProcessError as e:
117+
sys.exit(f"ERROR: Error running BLAST (probably conflict with BLAST DB versions)\n{e.stderr}")
118+
121119

122120
def check_ranks_core_taxa(corepath, refspec, minDist, maxDist):
123121
""" Check if refspec (or all core taxa) have a valid minDist and maxDist tax ID

0 commit comments

Comments
 (0)