-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSnakefile
84 lines (75 loc) · 2.54 KB
/
Snakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
BUSCO_IDs, = glob_wildcards("data/busco_nt_merged/{busco_id}_nt.fasta")
## Run this script using the command: snakemake --cores 4 --use-conda --keep-going --printshellcmds
rule all:
input:
"results/astral/astral_species_tree.tre",
"results/iq_tree_gcf/concord.cf.tree.nex",
"results/amas/trimmed_alignment_summary.txt",
"results/amas/raw_alignment_summary.txt"
#MAFFT -> Create an alignment for every BUSCO
rule mafft_allignment:
input:
"data/busco_nt_merged/{busco_id}_nt.fasta"
output:
"results/mafft/{busco_id}.mafft.fa"
conda:
"conda_yamls/mafft.yml"
shell:
"mafft --auto {input} > {output}"
# Remove Special Characters from FASTA headers (RAxML will choke on |'s)
rule clean_fasta_header:
input:
"results/mafft/{busco_id}.mafft.fa"
output:
"results/mafft/{busco_id}.cleaned"
shell:
"sed 's/|.*//g' {input} > {output}"
# Trim the mafft alignments
rule trimal_trimming:
input:
"results/mafft/{busco_id}.cleaned"
output:
"results/trimal/{busco_id}.trim"
conda:
"conda_yamls/trimal.yml"
shell:
"trimal -in {input} -out {output} -automated1"
# Create summary statistics for both trimmed and untrimmed alignments
rule amas_summaries:
input:
trimmed_alignments = expand("results/trimal/{busco_id}.trim", busco_id=BUSCO_IDs),
raw_alignments = expand("results/mafft/{busco_id}.cleaned", busco_id=BUSCO_IDs)
output:
trimmed_alignment_summary = "results/amas/trimmed_alignment_summary.txt",
raw_alignment_summary = "results/amas/raw_alignment_summary.txt"
conda:
"conda_yamls/amas.yml"
shell:
'''
AMAS.py summary -c 2 -f fasta -d dna -i results/trimal/*trim -o {output.trimmed_alignment_summary}
AMAS.py summary -c 2 -f fasta -d dna -i results/mafft/*cleaned -o {output.raw_alignment_summary}
'''
# Create Gene Trees for every trimmed alignment using RAxML
rule raxml_gene_trees:
input:
"results/trimal/{busco_id}.trim"
output:
"results/raxml/RAxML_bestTree.{busco_id}"
conda:
"conda_yamls/raxml.yml"
shell:
"raxmlHPC -f a -m GTRGAMMA -# 100 -p 12345 -x 12345 -s {input} -w ${{PWD}}/results/raxml -n {wildcards.busco_id}"
# Create a species tree from the RAxML gene trees
rule astral_species_tree:
input:
expand("results/raxml/RAxML_bestTree.{busco_id}", busco_id=BUSCO_IDs)
output:
species_tree = "results/astral/astral_species_tree.tre",
concat_gene_trees = "results/astral/astral_input.tre"
log:
"logs/astral.log"
shell:
'''
cat results/raxml/RAxML_bestTree.* >> results/astral/astral_input.tre
java -jar tools/Astral/astral.5.7.5.jar -i results/astral/astral_input.tre -o {output.species_tree}
'''