@@ -69,11 +69,46 @@ rule raxmlng:
69
69
echo -e $statistics_string > {params.wd}/{output.statistics}
70
70
touch {params.wd}/{output.checkpoint}
71
71
"""
72
- rule iqtree :
72
+
73
+ rule prepare_iqtree :
73
74
input :
74
- # "results/statistics/filter-{aligner}-{alitrim}/alignment_filter_information_{alitrim}_{aligner}.txt"
75
- # "results/checkpoints/modes/modeltest.done"
76
75
"results/checkpoints/modeltest/aggregate_best_models_{aligner}_{alitrim}.done"
76
+ output :
77
+ algn = directory ("results/phylogeny-{bootstrap}/iqtree/{aligner}-{alitrim}/algn" ),
78
+ nexus = "results/phylogeny-{bootstrap}/iqtree/{aligner}-{alitrim}/concat.nex"
79
+ singularity :
80
+ containers ["iqtree" ]
81
+ params :
82
+ wd = os .getcwd (),
83
+ models = "results/modeltest/best_models_{aligner}_{alitrim}.txt" ,
84
+ genes = get_input_genes
85
+ shell :
86
+ """
87
+ mkdir {output.algn}
88
+ echo "$(date) - prepare_iqtree {wildcards.aligner}-{wildcards.alitrim}: Will use bootstrap cutoff ({wildcards.bootstrap}) before creating concatenated alignment" >> {params.wd}/results/statistics/runlog.txt
89
+ for gene in $(echo "{params.genes}")
90
+ do
91
+ cp {params.wd}/results/alignments/filtered/{wildcards.aligner}-{wildcards.alitrim}/"$gene"_aligned_trimmed.fas {output.algn}/
92
+ done
93
+
94
+ echo "Will create NEXUS partition file with model information now." >> {params.wd}/results/statistics/runlog.txt
95
+ echo "#nexus" > {output.nexus}
96
+ echo "begin sets;" >> {output.nexus}
97
+ i=1
98
+ charpart=""
99
+ for gene in $(echo "{params.genes}")
100
+ do
101
+ cat {params.wd}/{params.models} | grep $gene | awk -v i=$i '{{print "charset part"i" = algn/"$1"_aligned_trimmed.fas:*;"}}' >> {output.nexus}
102
+ charpart=$charpart$(cat {params.wd}/{params.models} | grep $gene | awk -v i=$i '{{printf($2":part"i", ")}}' | sed 's/\\ (.*\\ ), /\\ 1, /')
103
+ i=$((++i))
104
+ done
105
+ echo "charpartition mine = "$charpart";" >> {output.nexus}
106
+ echo "end;" >> {output.nexus} concat.nex
107
+ echo "$(date) - nexus file for iqtree written." >> {params.wd}/results/statistics/runlog.txt
108
+ """
109
+ rule iqtree :
110
+ input :
111
+ rules .prepare_iqtree .output
77
112
output :
78
113
checkpoint = "results/checkpoints/iqtree_{aligner}_{alitrim}_{bootstrap}.done" ,
79
114
statistics = "results/statistics/mltree/mltree_iqtree_{aligner}_{alitrim}_{bootstrap}_statistics.txt"
@@ -95,36 +130,11 @@ rule iqtree:
95
130
config ["iqtree" ]["threads" ]
96
131
shell :
97
132
"""
98
- rm -rf results/phylogeny-{wildcards.bootstrap}/iqtree/{wildcards.aligner}-{wildcards.alitrim}/algn
99
- if [[ ! -d results/phylogeny-{wildcards.bootstrap}/iqtree/{wildcards.aligner}-{wildcards.alitrim} ]]; then mkdir -p results/phylogeny-{wildcards.bootstrap}/iqtree/{wildcards.aligner}-{wildcards.alitrim}; fi
100
133
cd results/phylogeny-{wildcards.bootstrap}/iqtree/{wildcards.aligner}-{wildcards.alitrim}/
101
- mkdir algn
102
- echo "$(date) - iqtree {wildcards.aligner}-{wildcards.alitrim}: Will use bootstrap cutoff ({wildcards.bootstrap}) before creating concatenated alignment" >> {params.wd}/results/statistics/runlog.txt
103
- for gene in $(echo "{params.genes}")
104
- do
105
- cp {params.wd}/results/alignments/filtered/{wildcards.aligner}-{wildcards.alitrim}/"$gene"_aligned_trimmed.fas algn
106
- done
107
- # here we decide how iqtree should be run. In case modeltesting was run before, this will not be repeated here.
108
- echo "Will create NEXUS partition file with model information now."
109
- echo "#nexus" > concat.nex
110
- echo "begin sets;" >> concat.nex
111
- i=1
112
- charpart=""
113
- for gene in $(echo "{params.genes}")
114
- do
115
- cat {params.wd}/{params.models} | grep $gene | awk -v i=$i '{{print "charset part"i" = algn/"$1"_aligned_trimmed.fas:*;"}}' >> concat.nex
116
- charpart=$charpart$(cat {params.wd}/{params.models} | grep $gene | awk -v i=$i '{{printf($2":part"i", ")}}' | sed 's/\\ (.*\\ ), /\\ 1, /')
117
- i=$((++i))
118
- done
119
- echo "charpartition mine = "$charpart";" >> concat.nex
120
- echo "end;" >> concat.nex
121
- echo "$(date) - nexus file for iqtree written." >> {params.wd}/results/statistics/runlog.txt
122
134
iqtree -p concat.nex --prefix concat -bb {params.bb} -nt {threads} $(if [[ "{params.seed}" != "None" ]]; then echo "-seed {params.seed}"; fi) {params.additional_params}
123
- #rm -r algn
124
135
statistics_string="iqtree\t {wildcards.aligner}\t {wildcards.alitrim}\t {params.bb}\t {wildcards.bootstrap}\t $(ls algn | wc -l)\t $(cat concat.contree)"
125
136
echo -e $statistics_string > {params.wd}/{output.statistics}
126
- cd {params.wd}
127
- touch {output.checkpoint}
137
+ touch {params.wd}/{output.checkpoint}
128
138
"""
129
139
130
140
if "phylobayes" in config ["tree" ]["method" ]:
0 commit comments