Skip to content

Commit b87875a

Browse files
committed
mltree: Separate iqtree from preparing iqtree input. This is now done in a new rule prepare_iqtree
1 parent 16e79fa commit b87875a

4 files changed

+45
-29
lines changed

data/cluster-config-SGE.yaml.template

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ modeltest:
8787
raxmlng:
8888
N: raxmlng
8989
h_vmem: 8G
90+
prepare_iqtree:
91+
N: prepiqt
9092
iqtree:
9193
N: iqtree
9294
h_vmem: 16G

data/cluster-config-SLURM.yaml.template

+2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ modeltest:
9999
raxmlng:
100100
job-name: raxmlng
101101
mem: 94G
102+
prepare_iqtree:
103+
job-name: prepiqt
102104
iqtree:
103105
job-name: iqtree
104106
mem: 94G

data/cluster-config-TORQUE.yaml.template

+2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ modeltest:
8888
raxmlng:
8989
N: raxmlng
9090
h_vmem: 8gb
91+
prepare_iqtree:
92+
N: prepiqt
9193
iqtree:
9294
N: iqtree
9395
mem: 94gb

rules/tree.smk

+39-29
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,46 @@ rule raxmlng:
6969
echo -e $statistics_string > {params.wd}/{output.statistics}
7070
touch {params.wd}/{output.checkpoint}
7171
"""
72-
rule iqtree:
72+
73+
rule prepare_iqtree:
7374
input:
74-
# "results/statistics/filter-{aligner}-{alitrim}/alignment_filter_information_{alitrim}_{aligner}.txt"
75-
# "results/checkpoints/modes/modeltest.done"
7675
"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
77112
output:
78113
checkpoint = "results/checkpoints/iqtree_{aligner}_{alitrim}_{bootstrap}.done",
79114
statistics = "results/statistics/mltree/mltree_iqtree_{aligner}_{alitrim}_{bootstrap}_statistics.txt"
@@ -95,36 +130,11 @@ rule iqtree:
95130
config["iqtree"]["threads"]
96131
shell:
97132
"""
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
100133
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
122134
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
124135
statistics_string="iqtree\t{wildcards.aligner}\t{wildcards.alitrim}\t{params.bb}\t{wildcards.bootstrap}\t$(ls algn | wc -l)\t$(cat concat.contree)"
125136
echo -e $statistics_string > {params.wd}/{output.statistics}
126-
cd {params.wd}
127-
touch {output.checkpoint}
137+
touch {params.wd}/{output.checkpoint}
128138
"""
129139

130140
if "phylobayes" in config["tree"]["method"]:

0 commit comments

Comments
 (0)