Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-activate parallel pyrodigal gene prediction #252

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions bakta/features/cds.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import concurrent.futures as cf
import copy
import logging
import subprocess as sp
Expand Down Expand Up @@ -60,9 +61,10 @@ def predict(genome: dict):
else:
gene_finder = pyrodigal.GeneFinder(trainings_info, meta=False, closed=True, mask=True)
sequences = [contig['sequence'] for contig in linear_contigs]
for contig, genes in zip(linear_contigs, map(gene_finder.find_genes, sequences)):
cdss_per_sequence = create_cdss(genes, contig)
cdss.extend(cdss_per_sequence)
with cf.ThreadPoolExecutor(max_workers=cfg.threads) as tpe:
for contig, genes in zip(linear_contigs, tpe.map(gene_finder.find_genes, sequences)):
cdss_per_sequence = create_cdss(genes, contig)
cdss.extend(cdss_per_sequence)

# predict genes on circular replicons (chromosomes/plasmids)
circular_contigs = [c for c in genome['contigs'] if c['topology'] == bc.TOPOLOGY_CIRCULAR]
Expand All @@ -72,9 +74,10 @@ def predict(genome: dict):
else:
gene_finder = pyrodigal.GeneFinder(trainings_info, meta=False, closed=False, mask=True)
sequences = [contig['sequence'] for contig in circular_contigs]
for contig, genes in zip(circular_contigs, map(gene_finder.find_genes, sequences)):
cdss_per_sequence = create_cdss(genes, contig)
cdss.extend(cdss_per_sequence)
with cf.ThreadPoolExecutor(max_workers=cfg.threads) as tpe:
for contig, genes in zip(circular_contigs, tpe.map(gene_finder.find_genes, sequences)):
cdss_per_sequence = create_cdss(genes, contig)
cdss.extend(cdss_per_sequence)

log.info('predicted=%i', len(cdss))
return cdss
Expand Down
Loading