|
| 1 | +nextflow.enable.dsl=2 |
| 2 | + |
| 3 | +params.results="results" |
| 4 | +params.align="../09_ebola/results_001/aln.ids_subsamp.phylip" |
| 5 | +params.nboot=200 |
| 6 | + |
| 7 | +results=file(params.results) |
| 8 | + |
| 9 | +process Unique { |
| 10 | + publishDir "$results/", mode: 'link' |
| 11 | + |
| 12 | + label 'goalign' |
| 13 | + |
| 14 | + input: |
| 15 | + file msa |
| 16 | + |
| 17 | + output: |
| 18 | + path "*_unique.phy" |
| 19 | + stdout |
| 20 | + |
| 21 | + script: |
| 22 | + """ |
| 23 | + goalign dedup -i $msa -p | goalign clean sites --char GAP --cutoff 1.0 -p > ${msa.baseName}_unique.phy |
| 24 | + goalign stats length -p -i ${msa.baseName}_unique.phy > len.txt |
| 25 | + printf \$(cat len.txt) |
| 26 | + """ |
| 27 | +} |
| 28 | + |
| 29 | +process InferRefTreeRAxML { |
| 30 | + publishDir "$results/", mode: 'link' |
| 31 | + |
| 32 | + label 'raxml' |
| 33 | + |
| 34 | + input: |
| 35 | + file msa |
| 36 | + val nboot |
| 37 | + |
| 38 | + output: |
| 39 | + path "reftree_collapsed_raxml.nw" |
| 40 | + path "reftree_original_raxml.nw" |
| 41 | + |
| 42 | + script: |
| 43 | + """ |
| 44 | + raxml-ng --all --msa ${msa} --model GTR+G4 --threads ${task.cpus} --seed 123456 --bs-trees $nboot --bs-metric fbp |
| 45 | + mv ${msa}.raxml.bestTreeCollapsed reftree_collapsed_raxml.nw |
| 46 | + mv ${msa}.raxml.support reftree_original_raxml.nw |
| 47 | + """ |
| 48 | +} |
| 49 | + |
| 50 | +process InferRefTreeIQTreeCollapse { |
| 51 | + publishDir "$results/", mode: 'link' |
| 52 | + |
| 53 | + label 'iqtree' |
| 54 | + |
| 55 | + input: |
| 56 | + file msa |
| 57 | + val nboot |
| 58 | + |
| 59 | + output: |
| 60 | + path "reftree_collapsed_iqtree.nw" |
| 61 | + |
| 62 | + script: |
| 63 | + """ |
| 64 | + iqtree -s ${msa} -m GTR+G4 --seed 123456789 -T ${task.cpus} -b $nboot -czb |
| 65 | + mv ${msa}.treefile reftree_collapsed_iqtree.nw |
| 66 | + """ |
| 67 | +} |
| 68 | + |
| 69 | +process InferRefTreeIQTreeNoCollapse { |
| 70 | + publishDir "$results/", mode: 'link' |
| 71 | + |
| 72 | + label 'iqtree' |
| 73 | + |
| 74 | + input: |
| 75 | + file msa |
| 76 | + val nboot |
| 77 | + |
| 78 | + output: |
| 79 | + path "reftree_original_iqtree.nw" |
| 80 | + |
| 81 | + script: |
| 82 | + """ |
| 83 | + iqtree -s ${msa} -m GTR+G4 --seed 123456789 -T ${task.cpus} -b $nboot |
| 84 | + mv ${msa}.treefile reftree_original_iqtree.nw |
| 85 | + """ |
| 86 | +} |
| 87 | + |
| 88 | +process InferRefTreePhyML { |
| 89 | + publishDir "$results/", mode: 'link' |
| 90 | + |
| 91 | + label 'phyml' |
| 92 | + |
| 93 | + input: |
| 94 | + path msa |
| 95 | + |
| 96 | + output: |
| 97 | + path "reftree_phyml.nw" |
| 98 | + |
| 99 | + script: |
| 100 | + """ |
| 101 | + phyml -i ${msa} -m GTR -c 4 -a e -f e -d nt -o tlr -b 0 --r_seed 123456 |
| 102 | + mv ${msa}_phyml_tree.txt reftree_phyml.nw |
| 103 | + """ |
| 104 | +} |
| 105 | + |
| 106 | +process SeqBootPhyML { |
| 107 | + publishDir "$results/seqboot/", mode: 'link' |
| 108 | + |
| 109 | + label 'goalign' |
| 110 | + |
| 111 | + input: |
| 112 | + file msa |
| 113 | + val nboot |
| 114 | + |
| 115 | + output: |
| 116 | + file "bootphy_*" |
| 117 | + |
| 118 | + script: |
| 119 | + """ |
| 120 | + goalign build seqboot -S -p -n $nboot -i ${msa} -o bootphy_ --seed 123456789 |
| 121 | + """ |
| 122 | +} |
| 123 | + |
| 124 | +process SeqBootTreesPhyML { |
| 125 | + label 'phyml' |
| 126 | + |
| 127 | + input: |
| 128 | + path msa |
| 129 | + |
| 130 | + output: |
| 131 | + path "${msa}_boottree_phyml.nw" |
| 132 | + |
| 133 | + script: |
| 134 | + """ |
| 135 | + phyml -i ${msa} -m GTR -c 4 -a e -f e -d nt -o tlr -b 0 --r_seed 123456 |
| 136 | + mv ${msa}_phyml_tree.txt ${msa}_boottree_phyml.nw |
| 137 | + """ |
| 138 | +} |
| 139 | + |
| 140 | +process SeqBootSupportsPhyML { |
| 141 | + publishDir "$results/", mode: 'link' |
| 142 | + |
| 143 | + label 'gotree' |
| 144 | + |
| 145 | + input: |
| 146 | + file ref |
| 147 | + file boot |
| 148 | + val length |
| 149 | + |
| 150 | + output: |
| 151 | + file "reftree_phyml_bootsupport.nw" |
| 152 | + file "reftree_phyml_bootsupport_collapse.nw" |
| 153 | + file boot |
| 154 | + |
| 155 | + script: |
| 156 | + """ |
| 157 | + gotree compute support fbp -i ${ref} -b ${boot} -o reftree_phyml_bootsupport.nw |
| 158 | + gotree collapse length -i ${boot} -l ${0.1/length} | gotree compute support fbp -i ${ref} -b - -o reftree_phyml_bootsupport_collapse.nw |
| 159 | + """ |
| 160 | +} |
| 161 | + |
| 162 | +process SeqBootRAxML { |
| 163 | + publishDir "$results/seqboot/", mode: 'link' |
| 164 | + |
| 165 | + label 'goalign' |
| 166 | + |
| 167 | + input: |
| 168 | + file msa |
| 169 | + val nboot |
| 170 | + |
| 171 | + output: |
| 172 | + file "bootrax_*" |
| 173 | + |
| 174 | + script: |
| 175 | + """ |
| 176 | + goalign build seqboot -S -p -n $nboot -i ${msa} -o bootrax_ --seed 987654321 |
| 177 | + """ |
| 178 | +} |
| 179 | + |
| 180 | +process SeqBootTreesRAxML { |
| 181 | + label 'raxmlshort' |
| 182 | + |
| 183 | + input: |
| 184 | + path msa |
| 185 | + |
| 186 | + output: |
| 187 | + path "${msa}_boottree_raxml.nw" |
| 188 | + |
| 189 | + script: |
| 190 | + """ |
| 191 | + raxml-ng --msa ${msa} --model GTR+G4 --threads ${task.cpus} --seed 123456 |
| 192 | + mv ${msa}.raxml.bestTree ${msa}_boottree_raxml.nw |
| 193 | + """ |
| 194 | +} |
| 195 | + |
| 196 | +process SeqBootSupportsRAxML { |
| 197 | + publishDir "$results/", mode: 'link' |
| 198 | + |
| 199 | + label 'gotree' |
| 200 | + |
| 201 | + input: |
| 202 | + file ref |
| 203 | + file boot |
| 204 | + val length |
| 205 | + |
| 206 | + output: |
| 207 | + file "reftree_raxml_bootsupport.nw" |
| 208 | + file "reftree_raxml_bootsupport_collapse.nw" |
| 209 | + file boot |
| 210 | + |
| 211 | + script: |
| 212 | + """ |
| 213 | + gotree compute support fbp -i ${ref} -b ${boot} -o reftree_raxml_bootsupport.nw |
| 214 | + gotree collapse length -i ${boot} -l ${0.1/length} | gotree compute support fbp -i ${ref} -b - -o reftree_raxml_bootsupport_collapse.nw |
| 215 | + """ |
| 216 | +} |
| 217 | + |
| 218 | +workflow{ |
| 219 | + msa = Channel.fromPath(params.align) |
| 220 | + nboot=params.nboot |
| 221 | + uniqueout = Unique(msa) |
| 222 | + dedup=uniqueout[0] |
| 223 | + length=uniqueout[1].map{it -> Integer.parseInt(it.trim()) } |
| 224 | + |
| 225 | + refrax = InferRefTreeRAxML(dedup,nboot) |
| 226 | + refiqtc = InferRefTreeIQTreeCollapse(dedup,nboot) |
| 227 | + refiqtnc = InferRefTreeIQTreeNoCollapse(dedup,nboot) |
| 228 | + |
| 229 | + phybootmsa = SeqBootPhyML(dedup,nboot) |
| 230 | + raxbootmsa = SeqBootRAxML(dedup,nboot) |
| 231 | + |
| 232 | + refraxnocoll = refrax[1] |
| 233 | + raxboottrees = SeqBootTreesRAxML(raxbootmsa.flatten()) |
| 234 | + SeqBootSupportsRAxML(refraxnocoll, raxboottrees.collectFile(name: 'boot_rax.nw'),length) |
| 235 | + |
| 236 | + refphy = InferRefTreePhyML(dedup) |
| 237 | + phyboottrees = SeqBootTreesPhyML(phybootmsa.flatten()) |
| 238 | + SeqBootSupportsPhyML(refphy, phyboottrees.collectFile(name: 'boot_phy.nw'),length) |
| 239 | +} |
0 commit comments