Skip to content

Commit 18d01e0

Browse files
committed
Substituted SPAdes for IVA
1 parent 5074cbb commit 18d01e0

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed

micall/core/denovo.py

+28-29
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
from micall.core.project_config import ProjectConfig
2222

23-
IVA = "iva"
23+
SPAdes = "Spades/bin/spades.py"
2424
DEFAULT_DATABASE = os.path.join(os.path.dirname(__file__),
2525
'..',
2626
'blast_db',
@@ -201,34 +201,33 @@ def denovo(fastq1_path: str,
201201
'--interleave',
202202
'-o', joined_path],
203203
check=True)
204-
iva_out_path = os.path.join(tmp_dir, 'iva_out')
205-
contigs_fasta_path = os.path.join(iva_out_path, 'contigs.fasta')
206-
# iva_args = [IVA, '--fr', joined_path, '-t', '2']
207-
with open(os.path.join(tmp_dir, 'iva.log'), 'w') as log_file:
208-
iva_args = [IVA, '-vv', '--fr', joined_path, '-t', '2']
209-
if merged_contigs_csv is not None:
210-
seeds_fasta_path = os.path.join(tmp_dir, 'seeds.fasta')
211-
with open(seeds_fasta_path, 'w') as seeds_fasta:
212-
SeqIO.write((SeqRecord(Seq(row['contig']), f'seed-{i}', '', '')
213-
for i, row in enumerate(DictReader(merged_contigs_csv))),
214-
seeds_fasta,
215-
'fasta')
216-
seeds_size = seeds_fasta.tell()
217-
if seeds_size > 0:
218-
iva_args.extend(['--contigs', seeds_fasta_path, '--make_new_seeds'])
219-
iva_args.append(iva_out_path)
220-
try:
221-
run(iva_args,
222-
check=True,
223-
stdout=log_file,
224-
stderr=STDOUT)
225-
except CalledProcessError as ex:
226-
output = ex.output and ex.output.decode('UTF8')
227-
if output != 'Failed to make first seed. Cannot continue\n':
228-
logger.warning('iva failed to assemble.', exc_info=True)
229-
logger.warning(output)
230-
with open(contigs_fasta_path, 'a'):
231-
pass
204+
spades_out_path = os.path.join(tmp_dir, 'spades_out')
205+
contigs_fasta_path = os.path.join(spades_out_path, 'contigs.fasta')
206+
spades_args = [SPAdes, '--12', joined_path, '--phred-offset', '33']
207+
# Setting Phred offset manually is only required for microtests
208+
if merged_contigs_csv is not None:
209+
seeds_fasta_path = os.path.join(tmp_dir, 'seeds.fasta')
210+
with open(seeds_fasta_path, 'w') as seeds_fasta:
211+
SeqIO.write((SeqRecord(Seq(row['contig']), f'seed-{i}', '', '')
212+
for i, row in enumerate(DictReader(merged_contigs_csv))),
213+
seeds_fasta,
214+
'fasta')
215+
seeds_size = seeds_fasta.tell()
216+
if seeds_size > 0:
217+
spades_args.extend(['--trusted-contigs', seeds_fasta_path])
218+
spades_args.extend(['-o', spades_out_path])
219+
try:
220+
run(spades_args,
221+
check=True,
222+
stdout=PIPE,
223+
stderr=STDOUT)
224+
except CalledProcessError as ex:
225+
output = ex.output and ex.output.decode('UTF8')
226+
if output != 'Failed to make first seed. Cannot continue\n':
227+
logger.warning('SPAdes failed to assemble.', exc_info=True)
228+
logger.warning(output)
229+
with open(contigs_fasta_path, 'a'):
230+
pass
232231

233232
os.chdir(start_dir)
234233
duration = datetime.now() - start_time

0 commit comments

Comments
 (0)