Skip to content

Commit

Permalink
Define params and envs to follow lint format guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmig committed Aug 8, 2023
1 parent 0c0c18d commit ff018be
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 12 deletions.
1 change: 1 addition & 0 deletions workflow/envs/fetch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ channels:
- anaconda
dependencies:
- entrez-direct==16.2
- curl==8.2.1
8 changes: 5 additions & 3 deletions workflow/rules/asr.smk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ rule reconstruct_ancestral_sequence:
params:
seqtype = "DNA",
name = OUTPUT_NAME,
etc = ETC_TREE_PARAMS
etc = ETC_TREE_PARAMS,
outgroup = config["ALIGNMENT_REFERENCE"],
model = config["TREE_MODEL"]
input:
fasta = OUTDIR/"nextalign"/f"{OUTPUT_NAME}.aligned.masked.fasta"
output:
Expand All @@ -17,8 +19,8 @@ rule reconstruct_ancestral_sequence:
mkdir -p {output.folder}
iqtree2 \
{params.etc} -asr \
-o {config[ALIGNMENT_REFERENCE]} -T AUTO --threads-max {threads} -s {input.fasta} \
--seqtype {params.seqtype} -m {config[TREE_MODEL]} --prefix {output.folder}/{params.name} >{log} 2>&1
-o {params.outgroup} -T AUTO --threads-max {threads} -s {input.fasta} \
--seqtype {params.seqtype} -m {params.model} --prefix {output.folder}/{params.name} >{log} 2>&1
"""


Expand Down
8 changes: 5 additions & 3 deletions workflow/rules/context.smk
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ rule ml_context_tree:
seqtype = "DNA",
name = OUTPUT_NAME,
etc = ETC_TREE_PARAMS,
bootstrap = 1000
bootstrap = 1000,
outgroup = config["ALIGNMENT_REFERENCE"],
model = config["TREE_MODEL"]
input:
fasta = OUTDIR/"nextalign"/f"{OUTPUT_NAME}.aligned.masked.fasta",
outgroup_aln = OUTDIR/"context"/"nextalign"/"context_sequences.aligned.masked.fasta"
Expand All @@ -93,6 +95,6 @@ rule ml_context_tree:
mkdir -p {output.folder}
iqtree2 \
{params.etc} -B {params.bootstrap} \
-o {config[ALIGNMENT_REFERENCE]} -T AUTO --threads-max {threads} -s aln.fasta \
--seqtype {params.seqtype} -m {config[TREE_MODEL]} --prefix {output.folder}/{params.name}
-o {params.outgroup} -T AUTO --threads-max {threads} -s aln.fasta \
--seqtype {params.seqtype} -m {params.model} --prefix {output.folder}/{params.name}
"""
3 changes: 1 addition & 2 deletions workflow/rules/fasta.smk
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ rule rename_fastas:
LOGDIR / "rename_fastas" / "{sample}.log.txt"
shell:
"sed 's/>.*/>'{wildcards.sample}'/g' {input.fasta} > {output.renamed} 2> {log}"




rule concat_fasta:
threads: 1
Expand Down
13 changes: 10 additions & 3 deletions workflow/rules/fetch.smk
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
rule fetch_alignment_reference:
threads: 1
conda: "../envs/fetch.yaml"
params:
ref = config["ALIGNMENT_REFERENCE"]
output:
fasta = OUTDIR/"reference.fasta"
log:
LOGDIR / "fetch_alignment_reference" / "log.txt"
shell:
"esearch -db nucleotide -query {config[ALIGNMENT_REFERENCE]} | efetch -format fasta > {output.fasta} 2> {log}"
"esearch -db nucleotide -query {params.ref} | efetch -format fasta > {output.fasta} 2> {log}"


rule fetch_mapping_references:
threads: 1
conda: "../envs/fetch.yaml"
params:
refs = config["MAPPING_REFERENCES"]
output:
fasta = OUTDIR/"mapping_references.fasta"
log:
Expand All @@ -21,17 +25,20 @@ rule fetch_mapping_references:
# Create empty file
echo -n > {output.fasta}
# Download and concatenate each reference
echo {config[MAPPING_REFERENCES]} | while read -r ref_id; do
echo {params.refs} | while read -r ref_id; do
esearch -db nucleotide -query "$ref_id" | efetch -format fasta >> {output.fasta} 2>> {log}
done
"""


rule fetch_alignment_annotation:
threads: 1
conda: "../envs/fetch.yaml"
params:
ref = config["ALIGNMENT_REFERENCE"]
output:
OUTDIR/"reference.gff3"
log:
LOGDIR / "fetch_alignment_annotation" / "log.txt"
shell:
"curl 'https://www.ncbi.nlm.nih.gov/sviewer/viewer.cgi?db=nuccore&report=gff3&id={config[ALIGNMENT_REFERENCE]}' -o {output} -s 2>{log}"
"curl 'https://www.ncbi.nlm.nih.gov/sviewer/viewer.cgi?db=nuccore&report=gff3&id={params.ref}' -o {output} -s 2>{log}"
4 changes: 3 additions & 1 deletion workflow/rules/report.smk
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ rule report:
stats_lm = rules.phylo_plots.output.stats_lm,
table = rules.summary_table.output.table,
sum_nv = rules.general_NV_description.output.summary_nv
params:
workflow_version = __version__
output:
html = report(OUTDIR/f"{OUTPUT_NAME}.report.html")
log:
Expand All @@ -163,7 +165,7 @@ rule report:
set +o pipefail
Rscript -e 'library(quarto)' -e \"quarto_render(input = '{input.qmd}',\
execute_params=list( \
workflow_version='{__version__}',\
workflow_version='{params.workflow_version}',\
div='{input.diversity}',\
freyja ='{input.freyja}',\
tree = '{input.tree}',\
Expand Down

0 comments on commit ff018be

Please sign in to comment.