Mercurial > repos > fubar > egapx_runner
comparison nf/subworkflows/ncbi/rnaseq_short/main.nf @ 0:d9c5c5b87fec draft
planemo upload for repository https://github.com/ncbi/egapx commit 8173d01b08d9a91c9ec5f6cb50af346edc8020c4
author | fubar |
---|---|
date | Sat, 03 Aug 2024 11:16:53 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d9c5c5b87fec |
---|---|
1 #!/usr/bin/env nextflow | |
2 // rnaseq short EGAPx execution | |
3 // route data to tasks | |
4 | |
5 nextflow.enable.dsl=2 | |
6 | |
7 include { sra_query } from './sra_qry/main' | |
8 include { fetch_sra_fasta } from './fetch_sra_fasta/main' | |
9 include { star_index } from './star_index/main' | |
10 include { star_wnode as star } from './star_wnode/main' | |
11 include { bam_strandedness } from './bam_strandedness/main' | |
12 include { bam_bin_and_sort } from './bam_bin_and_sort/main' | |
13 include { bam2asn } from './convert_from_bam/main' | |
14 include { rnaseq_collapse } from './rnaseq_collapse/main' | |
15 | |
16 params.intermediate = false | |
17 | |
18 | |
19 workflow rnaseq_short_plane { | |
20 take: | |
21 genome_asn | |
22 scaffolds | |
23 unpacked_genome_fasta | |
24 | |
25 // Alternative groups of parameters, one of them should be set | |
26 // reads_query - SRA query in the form accepted by NCBI | |
27 // reads_ids - list of SRA IDs | |
28 // reads, reads_metadata - path to reads accompanied by metadata | |
29 reads_query // SRA query | |
30 reads_ids // list of SRA IDs | |
31 reads // path to reads | |
32 reads_metadata // path to reads metadata 13 tab-delimited fields, 1-st - SRA ID, 3-rd paired or unpaired, everything else - not used, but must be present | |
33 // 4, 5, 13 - numbers, 5 - non zero number | |
34 organelles // path to organelle list | |
35 // Alternative parameters, one of them should be set | |
36 // tax_id - NCBI tax id of the closest taxon to the genome | |
37 // hmm_params - HMM parameters | |
38 tax_id // NCBI tax id of the closest taxon to the genome | |
39 max_intron // max intron length | |
40 task_params // task parameters for every task | |
41 main: | |
42 // Satisfy quirks of Nextflow compiler | |
43 def reads_query1 = reads_query | |
44 def reads_ids1 = reads_ids | |
45 def ch_reads = Channel.fromList(reads) | |
46 // Conditional code on SRA reads source | |
47 if (reads_query || reads_ids || reads) { | |
48 def index = star_index(unpacked_genome_fasta, task_params.get('star_index', [:])) | |
49 def ch_align, ch_align_index, sra_metadata, sra_run_list | |
50 if (reads_query || reads_ids) { | |
51 def query = reads_query1 ? reads_query1 : reads_ids1.join("[Accession] OR ") + "[Accession]" | |
52 (sra_metadata, sra_run_list) = sra_query(query, task_params.get('sra_qry', [:])) | |
53 def reads_fasta_pairs = fetch_sra_fasta(sra_run_list, task_params.get('fetch_sra_fasta', [:])) | |
54 (ch_align, ch_align_index) = star(scaffolds, reads_fasta_pairs, genome_asn, index, max_intron, task_params.get('star_wnode', [:])) | |
55 } else { | |
56 sra_metadata = reads_metadata | |
57 (ch_align, ch_align_index) = star(scaffolds, ch_reads, genome_asn, index, max_intron, task_params.get('star_wnode', [:])) | |
58 } | |
59 // | |
60 | |
61 bam_strandedness(ch_align.collect(), sra_metadata, task_params.get('bam_strandedness', [:])) | |
62 def strandedness = bam_strandedness.out.strandedness | |
63 | |
64 // Run bam_bin_and_sort | |
65 bam_bin_and_sort(ch_align, ch_align_index, unpacked_genome_fasta, organelles, task_params.get('bam_bin_and_sort', [:])) | |
66 def bam_bins = bam_bin_and_sort.out.sorted | |
67 | |
68 // Run BAM2ASN | |
69 bam2asn(bam_bins, strandedness, genome_asn, task_params.get('convert_from_bam', [:])) | |
70 def asn_align = bam2asn.out.align.collect() | |
71 def keylist = bam2asn.out.keylist.collect() | |
72 | |
73 rnaseq_collapse(genome_asn, keylist, asn_align, sra_metadata, 10, task_params.get('rnaseq_collapse', [:])) | |
74 } | |
75 | |
76 emit: | |
77 rnaseq_alignments = rnaseq_collapse.out.alignments | |
78 } |