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