Skip to content

Commit

Permalink
Add threads argument to the _run_hmmsearch function.
Browse files Browse the repository at this point in the history
  • Loading branch information
chtsai0105 committed Sep 8, 2023
1 parent dd4e16d commit f6d6294
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/dbcanlight/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .utils import check_db
from .config import db_path
from dbcanlight.utils import check_db
from dbcanlight.config import db_path

check_db(*[x for x in vars(db_path).values()])
8 changes: 4 additions & 4 deletions src/dbcanlight/dbcanlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ def _load_input(self) -> None:
if f.is_pressed():
self._hmms.rewind()

def _run_hmmsearch(self, sequences, evalue, coverage) -> dict[list]:
def _run_hmmsearch(self, sequences, evalue, coverage, threads) -> dict[list]:
results = {}
logging.debug("Start hmmsearch")
for hits in pyhmmer.hmmsearch(self._hmms, sequences):
for hits in pyhmmer.hmmsearch(self._hmms, sequences, cpus=threads):
cog = hits.query_name.decode()
cog_length = self._hmms_length[cog]
for hit in hits:
Expand All @@ -75,9 +75,9 @@ def _run_hmmsearch(self, sequences, evalue, coverage) -> dict[list]:
logging.info(f"Found {len(results)} genes have hits")
return results

def run(self, evalue: float, coverage: float) -> dict[list]:
def run(self, evalue: float, coverage: float, threads: int) -> dict[list]:
self._load_input()
return self._run_hmmsearch(self._sequences, evalue, coverage)
return self._run_hmmsearch(self._sequences, evalue, coverage, threads)


def cazyme_finder(input: str, output, evalue: float, coverage: float, **kwargs):
Expand Down
5 changes: 4 additions & 1 deletion src/dbcanlight/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ def check_db(*dbs: Path) -> None:
for db in dbs:
dbmissingList.append(db) if not db.exists() else None
if dbmissingList:
print(f"Database file {*dbmissingList,} missing. \nAborted")
print(
f"Database file {*dbmissingList,} missing. "
"Please follow the instructions in https://github.com/chtsai0105/dbcanLight#requirements and download the required database."
)
sys.exit(1)


Expand Down

0 comments on commit f6d6294

Please sign in to comment.