Skip to content

Commit e574e79

Browse files
authored
Merge pull request #24 from NBISweden/develop
Merge develop **Changelog**: - Update sourmash and contigtax versions - Update and make sourmash database link configurable - Add sourmash kmer size to config - Update normalization in R scripts to handle one-sample data
2 parents 9fd801a + db3ed6b commit e574e79

11 files changed

Lines changed: 168 additions & 123 deletions

File tree

.test/config/annotate.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ taxonomy:
140140
# hash fraction to use for sourmash when computing signatures for contigs
141141
# this is evaluated as 1/<sourmash_fraction>
142142
sourmash_fraction: 100
143+
# kmer size to use when computing signatures
144+
sourmash_kmer_size: 31
145+
# sourmash database to use
146+
# see https://sourmash.readthedocs.io/en/latest/databases.html
147+
# and choose an LCA database link matching the sourmash_kmer_size
148+
sourmash_database_url: https://osf.io/ypsjq/download
143149
# ranks to report taxonomy for
144150
ranks:
145151
- "superkingdom"

config/config.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,18 @@ taxonomy:
139139
# modify assignments without having to rerun the search step
140140
search_params: "--evalue 0.01 --top 10"
141141
# parameters for contigtax assign
142-
assign_params: "--evalue 0.001 --top 5"
142+
# by default the lowest common ancestor is assigned from the list of top hits
143+
# to instead use a voting strategy set --mode rank_vote
144+
assign_params: "--evalue 0.001 --top 5 --mode rank_lca"
143145
# hash fraction to use for sourmash when computing signatures for contigs
144146
# this is evaluated as 1/<sourmash_fraction>
145147
sourmash_fraction: 100
148+
# kmer size to use when computing signatures
149+
sourmash_kmer_size: 31
150+
# sourmash database to use
151+
# see https://sourmash.readthedocs.io/en/latest/databases.html
152+
# and choose an LCA database link matching the sourmash_kmer_size
153+
sourmash_database_url: https://osf.io/ypsjq/download
146154
# ranks to report taxonomy for
147155
ranks:
148156
- "superkingdom"

workflow/envs/sourmash.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: sourmash
2+
channels:
3+
- bioconda
4+
- conda-forge
5+
- defaults
6+
dependencies:
7+
- python=3.9.6
8+
- sourmash=4.2.2

workflow/envs/taxonomy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
name: taxonomy
12
channels:
23
- conda-forge
34
- bioconda
45
- defaults
56
dependencies:
67
- python=3.7.6
7-
- contigtax=0.5.9
8+
- contigtax=0.5.10
89
- diamond=0.9.24
9-
- sourmash=3.3.0

workflow/rules/annotation.smk

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ if config["runOnUppMax"]:
301301
params:
302302
resource_dir=lambda wildcards, input: os.path.dirname(input[1]),
303303
tmpdir=temppath+"/{assembly}-eggnog",
304-
out=temppath+"/annotation/{assembly}/{assembly}",
304+
out=results+"/annotation/{assembly}/{assembly}",
305305
flags="--no_file_comments"
306306
log:
307307
results+"/annotation/{assembly}/{assembly}.emapper.annotations.log"
@@ -313,6 +313,7 @@ if config["runOnUppMax"]:
313313
runtime=lambda wildcards, attempt: attempt**2*60
314314
shell:
315315
"""
316+
if [ -z ${{SLURM_JOB_ID+x}} ]; then SLURM_JOB_ID="emapper_annotate_hits_uppmax"; fi
316317
#Copy eggnog.db
317318
mkdir -p /dev/shm/$SLURM_JOB_ID
318319
cp {params.resource_dir}/eggnog.db {params.resource_dir}/eggnog_proteins.dmnd /dev/shm/$SLURM_JOB_ID
@@ -351,6 +352,8 @@ rule parse_emapper:
351352
input:
352353
annotations = results+"/annotation/{assembly}/{assembly}.emapper.annotations",
353354
info = "resources/kegg/kegg_{db}.tsv"
355+
wildcard_constraints:
356+
db="enzymes|pathways|kos|modules"
354357
output:
355358
results+"/annotation/{assembly}/{db}.parsed.tsv"
356359
script:

workflow/rules/classification.smk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ from scripts.common import classify_input, krona_input, metaphlan_krona_string
22

33
localrules:
44
classify,
5+
krona_taxonomy,
56
download_kraken_build,
67
download_centrifuge_build,
78
centrifuge_kreport,

workflow/rules/quantification.smk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ localrules:
1313

1414
rule quantify:
1515
input:
16-
expand(results+"/annotation/{assembly}/gene_{counts_type}.tsv",
17-
assembly=assemblies.keys(), counts_type=["counts", "rpkm"])
16+
expand("{results}/annotation/{assembly}/gene_{counts_type}.tsv",
17+
results=[config["paths"]["results"]], assembly=assemblies.keys(),
18+
counts_type=["counts", "rpkm"])
1819

1920

2021
rule write_featurefile:

workflow/rules/taxonomy.smk

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,17 @@ rule contigtax_assign:
201201

202202
rule download_sourmash_db:
203203
output:
204-
"resources/sourmash/genbank-k31.lca.json"
204+
lca="resources/sourmash/sourmash_db.lca.json",
205+
version="resources/sourmash/version.txt"
205206
log:
206207
"resources/sourmash/download.log"
207208
params:
208-
url="https://osf.io/4f8n3/download"
209+
url=config["taxonomy"]["sourmash_database_url"]
209210
shell:
210211
"""
211-
curl -L -o {output}.gz {params.url} > {log} 2>&1
212-
gunzip {output}.gz
212+
curl -L -v -o {output.lca}.gz {params.url} > {log} 2>&1
213+
grep filename {log} | cut -f2 -d ';' > {output.version}
214+
gunzip {output.lca}.gz
213215
"""
214216

215217
rule sourmash_compute:
@@ -220,19 +222,20 @@ rule sourmash_compute:
220222
log:
221223
results+"/assembly/{assembly}/sourmash_compute.log"
222224
conda:
223-
"../envs/taxonomy.yml"
225+
"../envs/sourmash.yml"
224226
params:
225-
frac=config["taxonomy"]["sourmash_fraction"]
227+
frac=config["taxonomy"]["sourmash_fraction"],
228+
k=config["taxonomy"]["sourmash_kmer_size"]
226229
shell:
227230
"""
228231
sourmash compute --singleton --scaled {params.frac} \
229-
-k 31 -o {output} {input} > {log} 2>&1
232+
-k {params.k} -o {output} {input} > {log} 2>&1
230233
"""
231234

232235
rule sourmash_classify:
233236
input:
234237
sig=results+"/assembly/{assembly}/final_contigs.fa.sig",
235-
db="resources/sourmash/genbank-k31.lca.json"
238+
db="resources/sourmash/sourmash_db.lca.json"
236239
output:
237240
csv=results+"/annotation/{assembly}/taxonomy/sourmash.taxonomy.csv"
238241
log:
@@ -243,7 +246,7 @@ rule sourmash_classify:
243246
resources:
244247
runtime=lambda wildcards, attempt: attempt**2*30
245248
conda:
246-
"../envs/taxonomy.yml"
249+
"../envs/sourmash.yml"
247250
shell:
248251
"""
249252
sourmash lca classify --db {input.db} --scaled {params.frac} \

0 commit comments

Comments
 (0)