|
20 | 20 |
|
21 | 21 | from micall.core.project_config import ProjectConfig
|
22 | 22 |
|
23 |
| -IVA = "iva" |
| 23 | +SPAdes = "Spades/bin/spades.py" |
24 | 24 | DEFAULT_DATABASE = os.path.join(os.path.dirname(__file__),
|
25 | 25 | '..',
|
26 | 26 | 'blast_db',
|
@@ -201,34 +201,33 @@ def denovo(fastq1_path: str,
|
201 | 201 | '--interleave',
|
202 | 202 | '-o', joined_path],
|
203 | 203 | 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 |
232 | 231 |
|
233 | 232 | os.chdir(start_dir)
|
234 | 233 | duration = datetime.now() - start_time
|
|
0 commit comments