Skip to content

Commit

Permalink
add the new process to the workflow and the datatable
Browse files Browse the repository at this point in the history
  • Loading branch information
MarieLataretu committed Jul 9, 2024
1 parent 53ff114 commit 69b2184
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
6 changes: 6 additions & 0 deletions bin/summary_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,9 @@ def unclass_markup(value):

self.add_col_description(f'Read classification was determined against a database containing only SARS-CoV-2 and human with <a href="https://ccb.jhu.edu/software/kraken2/">Kraken2</a> (v{self.tool_versions["kraken2"]}).')

def add_mixed_sites_results(self, mixed_site_results):
res_data = pd.read_csv(mixed_site_results, index_col='sample', dtype={'sample': str})
self.add_column_raw('num_mixed_sites', res_data['num_mixed_sites'])

def add_coverage_plots(self, coverage_plots):
for coverage_plot in sorted(coverage_plots.split(',')):
Expand Down Expand Up @@ -826,6 +829,7 @@ def get_lineage_status(self, lineage):
parser.add_argument("-n", "--nextclade_results", help="nextclade results")
parser.add_argument("-q", "--president_results", help="president results")
parser.add_argument("-k", "--kraken2_results", help="kraken2 results")
parser.add_argument("-m", "--mixed_sites_results", help="mixed sites statisics")
parser.add_argument("-c", "--coverage_plots", help="coverage plots (comma separated)")
parser.add_argument("-s", "--samples", help="sample ids (comma separated)")
args = parser.parse_args()
Expand All @@ -852,6 +856,8 @@ def get_lineage_status(self, lineage):
report.add_pangolin_results(args.pangolin_results)
if args.nextclade_results:
report.add_nextclade_results(args.nextclade_results)
if args.mixed_sites_results:
report.add_mixed_sites_results(args.mixed_sites_results)
if args.coverage_plots:
report.add_coverage_plots(args.coverage_plots)

Expand Down
12 changes: 11 additions & 1 deletion poreCov.nf
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ include { get_fasta } from './modules/get_fasta_test_data.nf'
include { align_to_reference } from './modules/align_to_reference.nf'
include { split_fasta } from './modules/split_fasta.nf'
include { filter_fastq_by_length } from './modules/filter_fastq_by_length.nf'
include { add_alt_allele_ration_vcf } from './modules/add_alt_allele_ration_vcf.nf'

/**************************
* Workflows
Expand Down Expand Up @@ -405,6 +406,15 @@ workflow {
determine_mutations_wf(fasta_input_ch)
genome_quality_wf(fasta_input_ch, reference_for_qc_input_ch)

// add alternative allele ratio to the VCF
if (params.primerV.toString().contains(".bed")) {
external_primer_schemes = artic_ncov_wf.out.primer_dir
}
else {
external_primer_schemes = file(workflow.projectDir + "/data/external_primer_schemes", checkIfExists: true, type: 'dir' )
}
add_alt_allele_ration_vcf(artic_ncov_wf.out.trimmed_bam.join(artic_ncov_wf.out.vcf).join(artic_ncov_wf.out.failed_vcf), external_primer_schemes)

// 3. Specialised outputs (rki, json)
rki_report_wf(genome_quality_wf.out[0], genome_quality_wf.out[1], extended_input_ch)

Expand Down Expand Up @@ -436,7 +446,7 @@ workflow {
else { samples_table_ch = Channel.from( ['deactivated'] ) }
*/
create_summary_report_wf(determine_lineage_wf.out, genome_quality_wf.out[0], determine_mutations_wf.out,
taxonomic_read_classification_ch, alignments_ch, samples_file_ch)
taxonomic_read_classification_ch, add_alt_allele_ration_vcf.out.stats, alignments_ch, samples_file_ch)

}

Expand Down
6 changes: 4 additions & 2 deletions workflows/create_summary_report.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ workflow create_summary_report_wf {
president
nextclade
kraken2
mixed_sites
alignments
samples_table

Expand All @@ -18,6 +19,7 @@ workflow create_summary_report_wf {
pangolin_results = pangolin.map {it -> it[1]}.collectFile(name: 'pangolin_results.csv', skip: 1, keepHeader: true)
president_results = president.map {it -> it[1]}.collectFile(name: 'president_results.tsv', skip: 1, keepHeader: true)
nextclade_results = nextclade.map {it -> it[1]}.collectFile(name: 'nextclade_results.tsv', skip: 1, keepHeader: true)
mixed_site_results = mixed_sites.map {it -> it[1]}.collectFile(name: 'mixed_sites_results.tsv', skip: 1, keepHeader: true)

alignment_files = alignments.map {it -> it[0]}.collect()
if (params.fasta || workflow.profile.contains('test_fasta')) {
Expand All @@ -30,7 +32,7 @@ workflow create_summary_report_wf {
coverage_plots = plot_coverages(alignments.map{it -> it[0]}.toSortedList({ a, b -> a.simpleName <=> b.simpleName }).flatten().collate(6), \
alignments.map{it -> it[1]}.toSortedList({ a, b -> a.simpleName <=> b.simpleName }).flatten().collate(6)).collect()

if (params.samples) { summary_report(version_ch, variants_table_ch, pangolin_results, president_results, nextclade_results, kraken2_results, coverage_plots, samples_table) }
else { summary_report_default(version_ch, variants_table_ch, pangolin_results, president_results, nextclade_results, kraken2_results, coverage_plots) }
if (params.samples) { summary_report(version_ch, variants_table_ch, pangolin_results, president_results, nextclade_results, kraken2_results, mixed_site_results, coverage_plots, samples_table) }
else { summary_report_default(version_ch, variants_table_ch, pangolin_results, president_results, nextclade_results, kraken2_results, mixed_site_results, coverage_plots) }
}
}
4 changes: 4 additions & 0 deletions workflows/process/summary_report.nf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ process summary_report {
path(president_results)
path(nextclade_results)
file(kraken2_results)
file(mixed_sites_results)
file(coverage_plots)
file(samples_table)
output:
Expand Down Expand Up @@ -43,6 +44,7 @@ process summary_report {
-q !{president_results} \
-n !{nextclade_results} \
-k kraken2_results.csv \
-m !{mixed_sites_results} \
-c $(echo !{coverage_plots} | tr ' ' ',') \
-s !{samples_table}
'''
Expand All @@ -64,6 +66,7 @@ process summary_report_default {
path(president_results)
path(nextclade_results)
path(kraken2_results)
path(mixed_sites_results)
path(coverage_plots)
output:
path("poreCov_summary_report_*.html")
Expand Down Expand Up @@ -96,6 +99,7 @@ process summary_report_default {
-q !{president_results} \
-n !{nextclade_results} \
-k kraken2_results.csv \
-m !{mixed_sites_results} \
-c $(echo !{coverage_plots} | tr ' ' ',')
'''
stub:
Expand Down

0 comments on commit 69b2184

Please sign in to comment.