|
| 1 | +rule initiate: |
| 2 | + input: |
| 3 | + rules.setup_maker.output |
| 4 | + params: |
| 5 | + prefix = "{sample}" |
| 6 | + output: |
| 7 | + "results/{sample}/{sample}.ok" |
| 8 | + shell: |
| 9 | + """ |
| 10 | + if [[ ! -d results/{params.prefix} ]] |
| 11 | + then |
| 12 | + mkdir results/{params.prefix} |
| 13 | + fi |
| 14 | + touch {output} |
| 15 | + """ |
| 16 | + |
| 17 | +rule split: |
| 18 | + input: |
| 19 | + fasta = get_assembly_path, |
| 20 | + ok = rules.initiate.output |
| 21 | + params: |
| 22 | + prefix = "{sample}", |
| 23 | + len = n, |
| 24 | + min = min |
| 25 | + log: |
| 26 | + stdout = "results/{sample}/logs/split.{sample}.stdout.txt", |
| 27 | + stderr = "results/{sample}/logs/split.{sample}.stderr.txt" |
| 28 | + output: |
| 29 | + ok = "results/{sample}/GENOME_PARTITIONS/splitting.ok", |
| 30 | + fasta = "results/{sample}/GENOME_PARTITIONS/{sample}.min"+str(min)+".fasta" |
| 31 | + shell: |
| 32 | + """ |
| 33 | + echo -e "\n$(date)\tStarting on host: $(hostname) ...\n" |
| 34 | + basedir=$(pwd) |
| 35 | +
|
| 36 | + cd results/{params.prefix}/GENOME_PARTITIONS/ |
| 37 | + bash $basedir/bin/count_length.sh ../../../{input.fasta} {params.len} {params.min} split |
| 38 | +
|
| 39 | + retVal=$? |
| 40 | +
|
| 41 | + if [ ! $retVal -eq 0 ] |
| 42 | + then |
| 43 | + echo "Splitting ended in an error" |
| 44 | + exit $retVal |
| 45 | + else |
| 46 | + touch ../../../{output.ok} |
| 47 | + cat *.fasta > ../../../{output.fasta} |
| 48 | + fi |
| 49 | +
|
| 50 | + echo -e "\n$(date)\tFinished!\n" |
| 51 | + """ |
| 52 | + |
| 53 | +rule genemark: |
| 54 | + input: |
| 55 | + ok = rules.initiate.output, |
| 56 | + fasta = rules.split.output.fasta |
| 57 | + params: |
| 58 | + prefix = "{sample}", |
| 59 | + genemark_dir = config["genemark"]["genemark_dir"], |
| 60 | + gmes_petap_params = config["genemark"]["gmes_petap_params"] |
| 61 | + threads: config["threads"]["genemark"] |
| 62 | + singularity: |
| 63 | + "docker://chrishah/premaker-plus:18" |
| 64 | + log: |
| 65 | + stdout = "results/{sample}/logs/GENEMARK.{sample}.stdout.txt", |
| 66 | + stderr = "results/{sample}/logs/GENEMARK.{sample}.stderr.txt" |
| 67 | + output: |
| 68 | + ok = "results/{sample}/GENEMARK/genemark.status.ok", |
| 69 | + model = "results/{sample}/GENEMARK/gmhmm.mod" |
| 70 | + shell: |
| 71 | + """ |
| 72 | + echo -e "\n$(date)\tStarting on host: $(hostname) ...\n" |
| 73 | + basedir=$(pwd) |
| 74 | +
|
| 75 | + if [[ ! -d results/{params.prefix}/GENEMARK ]] |
| 76 | + then |
| 77 | + mkdir results/{params.prefix}/GENEMARK |
| 78 | + else |
| 79 | + if [ "$(ls -1 results/{params.prefix}/GENEMARK/ | wc -l)" -gt 0 ] |
| 80 | + then |
| 81 | + echo -e "Cleaning up remnants of previous run first" 1> {log.stdout} 2> {log.stderr} |
| 82 | + rm results/{params.prefix}/GENEMARK |
| 83 | + mkdir results/{params.prefix}/GENEMARK |
| 84 | + fi |
| 85 | + fi |
| 86 | + cd results/{params.prefix}/GENEMARK |
| 87 | +
|
| 88 | + ln -sf $basedir/{params.genemark_dir}/gm_key .gm_key |
| 89 | +
|
| 90 | + if [ "{params.gmes_petap_params}" == "None" ] |
| 91 | + then |
| 92 | + gmes_petap.pl -ES -cores {threads} -sequence ../../../{input.fasta} 1> ../../../{log.stdout} 2> ../../../{log.stderr} |
| 93 | + else |
| 94 | + gmes_petap.pl -ES {params.gmes_petap_params} -cores {threads} -sequence ../../../{input.fasta} 1> ../../../{log.stdout} 2> ../../../{log.stderr} |
| 95 | + fi |
| 96 | +
|
| 97 | + retVal=$? |
| 98 | +
|
| 99 | + if [ ! $retVal -eq 0 ] |
| 100 | + then |
| 101 | + echo "Genemark ended in an error" |
| 102 | + exit $retVal |
| 103 | + else |
| 104 | + touch ../../../{output.ok} |
| 105 | + fi |
| 106 | + echo -e "\n$(date)\tFinished!\n" |
| 107 | + |
| 108 | + """ |
| 109 | + |
| 110 | +rule busco: |
| 111 | + input: |
| 112 | + ok = rules.initiate.output, |
| 113 | + fasta = rules.split.output.fasta |
| 114 | + params: |
| 115 | + prefix = "{sample}", |
| 116 | + busco_path = "data/BUSCO", |
| 117 | + busco_set = config["busco"]["set"], |
| 118 | + augustus_species = config["busco"]["species"] |
| 119 | + threads: config["threads"]["busco"] |
| 120 | + singularity: |
| 121 | + "docker://chrishah/busco-docker:v3.1.0" |
| 122 | + log: |
| 123 | + stdout = "results/{sample}/logs/BUSCO.{sample}.stdout.txt", |
| 124 | + stderr = "results/{sample}/logs/BUSCO.{sample}.stderr.txt" |
| 125 | + output: |
| 126 | + "results/{sample}/BUSCO/run_{sample}/single_copy_busco_sequences/{sample}.BUSCOs.fasta" |
| 127 | + shell: |
| 128 | + """ |
| 129 | + echo -e "\n$(date)\tStarting on host: $(hostname) ...\n" |
| 130 | +
|
| 131 | + if [[ ! -d results/{params.prefix}/BUSCO ]] |
| 132 | + then |
| 133 | + mkdir results/{params.prefix}/BUSCO |
| 134 | + fi |
| 135 | + cd results/{params.prefix}/BUSCO |
| 136 | +
|
| 137 | + if [[ ! -d tmp ]] |
| 138 | + then |
| 139 | + mkdir tmp |
| 140 | + fi |
| 141 | +
|
| 142 | + cp -rf /usr/share/augustus/config tmp/config |
| 143 | + AUGUSTUS_CONFIG_PATH=$(pwd)/tmp/config |
| 144 | +
|
| 145 | + #run BUSCO |
| 146 | + run_BUSCO.py \ |
| 147 | + --in ../../../{input.fasta} --out {params.prefix} -l ../../../{params.busco_path}/{params.busco_set} --mode genome -c {threads} -f \ |
| 148 | + -sp {params.augustus_species} --long --augustus_parameters='--progress=true' 1> ../../../{log.stdout} 2> ../../../{log.stderr} |
| 149 | +
|
| 150 | + #collect predicted BUSCOs |
| 151 | + cat run_{params.prefix}/single_copy_busco_sequences/*.faa | sed 's/:.*//' > run_{params.prefix}/single_copy_busco_sequences/{params.prefix}.BUSCOs.fasta |
| 152 | +
|
| 153 | + echo -e "\n$(date)\tFinished!\n" |
| 154 | + """ |
| 155 | + |
| 156 | +rule cegma: |
| 157 | + input: |
| 158 | + ok = rules.initiate.output, |
| 159 | + fasta = rules.split.output.fasta |
| 160 | + params: |
| 161 | + prefix = "{sample}" |
| 162 | + threads: config["threads"]["cegma"] |
| 163 | + singularity: |
| 164 | + "docker://chrishah/cegma:2.5" |
| 165 | + log: |
| 166 | + stdout = "results/{sample}/logs/CEGMA.{sample}.stdout.txt", |
| 167 | + stderr = "results/{sample}/logs/CEGMA.{sample}.stderr.txt" |
| 168 | + output: |
| 169 | + ok = "results/{sample}/CEGMA/cegma.status.ok", |
| 170 | + cegma_gff = "results/{sample}/CEGMA/{sample}.cegma.gff" |
| 171 | + shell: |
| 172 | + """ |
| 173 | + echo -e "\n$(date)\tStarting on host: $(hostname) ...\n" |
| 174 | +
|
| 175 | + if [[ ! -d results/{params.prefix}/CEGMA ]] |
| 176 | + then |
| 177 | + mkdir results/{params.prefix}/CEGMA |
| 178 | + fi |
| 179 | + cd results/{params.prefix}/CEGMA |
| 180 | +
|
| 181 | + #run CEGMA |
| 182 | + cegma -g ../../../{input.fasta} -T {threads} -o {params.prefix} 1> ../../../{log.stdout} 2> ../../../{log.stderr} |
| 183 | +
|
| 184 | + retVal=$? |
| 185 | +
|
| 186 | + if [ ! $retVal -eq 0 ] |
| 187 | + then |
| 188 | + echo "Cegma ended in an error" |
| 189 | + exit $retVal |
| 190 | + else |
| 191 | + touch ../../../{output.ok} |
| 192 | + fi |
| 193 | + echo -e "\n$(date)\tFinished!\n" |
| 194 | +
|
| 195 | + """ |
| 196 | + |
| 197 | +rule snap_pass1: |
| 198 | + input: |
| 199 | + ok = rules.cegma.output.ok, |
| 200 | + cegma_gff = rules.cegma.output.cegma_gff, |
| 201 | + fasta = rules.split.output.fasta |
| 202 | + params: |
| 203 | + prefix = "{sample}", |
| 204 | + script = "bin/snap.p1.sh" |
| 205 | + singularity: |
| 206 | + "docker://chrishah/premaker-plus:18" |
| 207 | + log: |
| 208 | + stdout = "results/{sample}/logs/SNAP.PASS1.{sample}.stdout.txt", |
| 209 | + stderr = "results/{sample}/logs/SNAP.PASS1.{sample}.stderr.txt" |
| 210 | + output: |
| 211 | + ok = "results/{sample}/SNAP.PASS1/snap.status.ok", |
| 212 | + hmm = "results/{sample}/SNAP.PASS1/{sample}.cegma.snap.hmm" |
| 213 | + shell: |
| 214 | + """ |
| 215 | + echo -e "\n$(date)\tStarting on host: $(hostname) ...\n" |
| 216 | + basedir=$(pwd) |
| 217 | + |
| 218 | + export PATH="$(pwd)/bin/maker/bin:$PATH" |
| 219 | +
|
| 220 | + if [[ ! -d results/{params.prefix}/SNAP.PASS1 ]] |
| 221 | + then |
| 222 | + mkdir results/{params.prefix}/SNAP.PASS1 |
| 223 | + fi |
| 224 | + cd results/{params.prefix}/SNAP.PASS1 |
| 225 | +
|
| 226 | + bash $basedir/{params.script} \ |
| 227 | + {params.prefix} \ |
| 228 | + $basedir/{input.cegma_gff} \ |
| 229 | + $basedir/{input.fasta} \ |
| 230 | + 1> $basedir/{log.stdout} 2> $basedir/{log.stderr} |
| 231 | +
|
| 232 | + retVal=$? |
| 233 | +
|
| 234 | + if [ ! $retVal -eq 0 ] |
| 235 | + then |
| 236 | + echo "SNAP ended in an error" |
| 237 | + exit $retVal |
| 238 | + else |
| 239 | + touch $basedir/{output.ok} |
| 240 | + fi |
| 241 | + echo -e "\n$(date)\tFinished!\n" |
| 242 | + """ |
| 243 | + |
0 commit comments