Skip to content

Commit

Permalink
draft of tstv
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmeaton committed Aug 24, 2021
1 parent 5280263 commit 9b80539
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
1 change: 1 addition & 0 deletions workflow/rules/phylogeny.smk
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ rule iqtree_stats:
tree = results_dir + "/iqtree/{reads_origin}/{locus_name}/{prune}/filter{missing_data}/filter-taxa/iqtree.treefile",
tsv = results_dir + "/iqtree/{reads_origin}/{locus_name}/{prune}/filter{missing_data}/filter-taxa/metadata.tsv",
dnds = results_dir + "/dnds_collect/{reads_origin}/{locus_name}/dnds.txt",
tstv = results_dir + "/tstv_collect/{reads_origin}/{locus_name}/tstv.txt",
output:
constraints = results_dir + "/iqtree/{reads_origin}/{locus_name}/{prune}/filter{missing_data}/filter-taxa/temporal_constraints.txt",
log:
Expand Down
22 changes: 21 additions & 1 deletion workflow/rules/qc.smk
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ rule tstv:
vcf = results_dir + "/snippy_pairwise/{reads_origin}/{sample}/{sample}.subs.vcf",
output:
vcf = results_dir + "/tstv/{reads_origin}/{locus_name}/{sample}.vcf",
tstv = results_dir + "/tstv/{reads_origin}/{locus_name}/{sample}.tstv",
tstv = results_dir + "/tstv/{reads_origin}/{locus_name}/{sample}.txt",
params:
locus = config["reference_locus"],
shell:
Expand All @@ -174,3 +174,23 @@ rule tstv:
{scripts_dir}/vcf_tstv.sh {output.tstv}.raw > {output.tstv}
rm -f {output.tstv}.raw
"""

rule tstv_collect:
"""
Collect tStV statistics.
"""
input:
files = lambda wildcards: remove_duplicates([
os.path.join(
os.path.dirname(os.path.dirname(path)),
config["reference_locus_name"],
os.path.basename(os.path.dirname(path)) + ".txt")
for path in identify_paths(outdir="tstv", reads_origin=wildcards.reads_origin)]),
output:
df = results_dir + "/tstv_collect/{reads_origin}/{locus_name}/tstv.txt",

shell:
"""
echo -e "sample\ttstv" > {output.df};
for file in {input.files}; do head -n1 $file; done >> {output.df};
"""
27 changes: 27 additions & 0 deletions workflow/rules/targets.smk
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,33 @@ rule dnds_collect_local:
input:
dnds_collect_local_input

#------------------------------------------------------------------------------#
# TsTv
#------------------------------------------------------------------------------#

tstv_collect_all_input = results_dir + expand("/tstv_collect/all/{locus_name}/tstv.txt",
locus_name=config["reference_locus_name"])[0]
tstv_collect_local_input = tstv_collect_all_input.replace("all", "local")
tstv_collect_assembly_input = tstv_collect_all_input.replace("all", "assembly")
tstv_collect_sra_input = tstv_collect_all_input.replace("all", "sra")

rule tstv_collect_all:
input:
tstv_collect_all_input

rule tstv_collect_assembly:
input:
tstv_collect_assembly_input

rule tstv_collect_sra:
input:
tstv_collect_sra_input,

rule tstv_collect_local:
input:
tstv_collect_local_input


#------------------------------------------------------------------------------#
# Filtering
#------------------------------------------------------------------------------#
Expand Down

0 comments on commit 9b80539

Please sign in to comment.