Skip to content

Commit

Permalink
Save SPAdes report and correct Trimmomatic option
Browse files Browse the repository at this point in the history
Allways save SPAdes report;
Correct Trimmomatic -phred option parsing.
  • Loading branch information
miguelpmachado committed Sep 26, 2016
1 parent 8fc414e commit 4f32233
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion INNUca.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def run_INNUca(sampleName, outdir, fastq_files, args, script_path, scheme):

# Run SPAdes
if not args.skipSPAdes:
run_successfully, pass_qc, time_taken, failing, contigs = spades.runSpades(sampleName, outdir, threads, fastq_files, args.spadesNotUseCareful, args.spadesMaxMemory, args.spadesMinCoverageAssembly, args.spadesMinContigsLength, genomeSize, args.spadesKmers, maximumReadsLength, args.spadesSaveReport, args.spadesDefaultKmers, args.spadesMinCoverageContigs)
run_successfully, pass_qc, time_taken, failing, contigs = spades.runSpades(sampleName, outdir, threads, fastq_files, args.spadesNotUseCareful, args.spadesMaxMemory, args.spadesMinCoverageAssembly, args.spadesMinContigsLength, genomeSize, args.spadesKmers, maximumReadsLength, args.spadesDefaultKmers, args.spadesMinCoverageContigs)
runs['SPAdes'] = [run_successfully, pass_qc, time_taken, failing]

if run_successfully:
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ Usage
[--spadesNotUseCareful] [--spadesMinContigsLength N]
[--spadesKmers 55 77 | --spadesDefaultKmers]
[--spadesMaxMemory N] [--spadesMinCoverageAssembly 10]
[--spadesMinCoverageContigs N] [--spadesSaveReport]
[--pilonKeepFiles] [--pilonKeepSPAdesAssembly]
[--spadesMinCoverageContigs N] [--pilonKeepFiles]
[--pilonKeepSPAdesAssembly]

INNUca - Reads Control and Assembly

Expand Down Expand Up @@ -152,8 +152,6 @@ Usage
Minimum contigs coverage. After assembly only keep
contigs with reported coverage equal or above this
value (default: 5)
--spadesSaveReport Tells INNUca to store the number of contigs and
assembled nucleotides for each sample
SPAdes k-mers options (one of the following):
--spadesKmers 55,77 Manually sets SPAdes k-mers lengths (all values must
be odd, less than 128) (default: 55, 77, 99, 113,
Expand Down
11 changes: 5 additions & 6 deletions modules/spades.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def define_kmers(kmers, maximumReadsLength):

# Run SPAdes procedure
@spades_timer
def runSpades(sampleName, outdir, threads, fastq_files, notUseCareful, maxMemory, minCoverageAssembly, minContigsLength, estimatedGenomeSizeMb, kmers, maximumReadsLength, saveReport, defaultKmers, minCoverageContigs):
def runSpades(sampleName, outdir, threads, fastq_files, notUseCareful, maxMemory, minCoverageAssembly, minContigsLength, estimatedGenomeSizeMb, kmers, maximumReadsLength, defaultKmers, minCoverageContigs):
pass_qc = False
failing = {}
failing['sample'] = False
Expand Down Expand Up @@ -110,11 +110,10 @@ def runSpades(sampleName, outdir, threads, fastq_files, notUseCareful, maxMemory
if number_contigs == 0:
run_successfully = False

if saveReport:
report_file = os.path.join(outdir, 'spades_report.txt')
with open(report_file, 'wt') as writer:
writer.write('#contigs' + '\n' + str(number_contigs) + '\n' + '#bp' + '\n' + str(number_bases) + '\n')
writer.flush()
report_file = os.path.join(outdir, 'spades_report.txt')
with open(report_file, 'wt') as writer:
writer.write('#contigs' + '\n' + str(number_contigs) + '\n' + '#bp' + '\n' + str(number_bases) + '\n')
writer.flush()

if failing['sample'] is False:
if number_bases >= estimatedGenomeSizeMb * 1000000 * 0.8 and number_bases <= estimatedGenomeSizeMb * 1000000 * 1.5:
Expand Down
6 changes: 3 additions & 3 deletions modules/trimmomatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def trimmomatic(sampleName, trimmomatic_folder, threads, adaptersFasta, script_p
fastq = sorted(fastq_files)[0]

# Run Trimmomatic
command = ['trimmomatic-0.36.jar', 'PE', '-threads', str(threads), '-basein', fastq, '-baseout', os.path.join(trimmomatic_folder, str(sampleName + '.fastq.gz')), '', '', '', str('SLIDINGWINDOW:' + slidingWindow), str('LEADING:' + str(leading)), str('TRAILING:' + str(trailing)), str('MINLEN:' + str(minLength)), 'TOPHRED33']
command = ['trimmomatic-0.36.jar', 'PE', '-threads', str(threads), '-basein', fastq, '-baseout', os.path.join(trimmomatic_folder, str(sampleName + '.fastq.gz')), '', '', '', str('SLIDINGWINDOW:' + slidingWindow), str('LEADING:' + str(leading)), str('TRAILING:' + str(trailing)), str('MINLEN:' + str(minLength)), 'TOPHRED33', '']

if not doNotTrimCrops:
if maxReadsLength is not None:
Expand Down Expand Up @@ -47,11 +47,11 @@ def trimmomatic(sampleName, trimmomatic_folder, threads, adaptersFasta, script_p

if not run_successfully:
print 'Trimmomatic fail! Trying run with Phred+33 enconding defined...'
command.append('-phred33')
command[16] = '-phred33'
run_successfully, stdout, stderr = utils.runCommandPopenCommunicate(command, False, None)
if not run_successfully:
print 'Trimmomatic fail again! Trying run with Phred+64 enconding defined...'
command[18] = '-phred64'
command[16] = '-phred64'
run_successfully, stdout, stderr = utils.runCommandPopenCommunicate(command, False, None)

return run_successfully
Expand Down
1 change: 0 additions & 1 deletion modules/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def parseArguments(version):
spades_options.add_argument('--spadesMaxMemory', type=int, metavar='N', help='The maximum amount of RAM Gb for SPAdes to use', required=False, default=25)
spades_options.add_argument('--spadesMinCoverageAssembly', type=spades_cov_cutoff, metavar='10', help='The minimum number of reads to consider an edge in the de Bruijn graph (or path I am not sure). Can also be auto or off', required=False, default='off')
spades_options.add_argument('--spadesMinCoverageContigs', type=int, metavar='N', help='Minimum contigs coverage. After assembly only keep contigs with reported coverage equal or above this value', required=False, default=5)
spades_options.add_argument('--spadesSaveReport', action='store_true', help='Tells INNUca to store the number of contigs and assembled nucleotides for each sample')

spades_kmers_options = parser.add_mutually_exclusive_group()
spades_kmers_options.add_argument('--spadesKmers', nargs='+', type=int, metavar='55 77', help='Manually sets SPAdes k-mers lengths (all values must be odd, lower than 128)', required=False, default=[55, 77, 99, 113, 127])
Expand Down

0 comments on commit 4f32233

Please sign in to comment.