generated from nextstrain/pathogen-repo-guide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from nextstrain/james/dedup-segments
Group segments by strains
- Loading branch information
Showing
29 changed files
with
5,423 additions
and
2,347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
- strain: TRVL9760 | ||
accession: KP026181 # matches the metadata for the other segments for this strain | ||
segment: S | ||
- strain: BeAn19991 | ||
accession: KP052851 | ||
segment: M | ||
- strain: BeAn19991 | ||
accession: KP052852 | ||
segment: S | ||
- strain: BeAn_626990 | ||
accession: MG747521 | ||
segment: S | ||
- strain: BeH_543629 | ||
accession: MG747572 | ||
segment: S | ||
- strain: BeH_543857 | ||
accession: MG747578 | ||
segment: S | ||
- strain: BeAn_206119 | ||
accession: MG747539 | ||
segment: S | ||
- strain: BeH_543760 | ||
accession: MG747575 | ||
segment: S | ||
- strain: BeAn_208402 | ||
accession: MG747542 | ||
segment: S | ||
- strain: BeAn_208819 | ||
accession: MG747545 | ||
segment: S | ||
- strain: PPS_523_H_669315 | ||
accession: MG747584 | ||
segment: S | ||
- strain: PPS_522_H_669314 | ||
accession: MG747581 | ||
segment: S | ||
- strain: PMOH_682426 | ||
accession: MG747587 | ||
segment: S | ||
- strain: PMOH_682431 | ||
accession: MG747590 | ||
segment: S | ||
- strain: BeH505764 # Note: strain is dropped by phylo exclude rule | ||
accession: PP357050 | ||
segment: S |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
rule group_segments: | ||
input: | ||
metadata="data/metadata_merged.tsv", | ||
resolutions=config["grouping"]["resolutions"], | ||
output: | ||
metadata="results/metadata.tsv" | ||
params: | ||
common_strain_fields = config["grouping"]["common_strain_fields"], | ||
segments = segments, | ||
shell: | ||
r""" | ||
python3 scripts/group_segments.py \ | ||
--metadata {input.metadata} \ | ||
--common-strain-fields {params.common_strain_fields} \ | ||
--segments {params.segments} \ | ||
--resolutions {input.resolutions} \ | ||
--output-metadata {output.metadata} | ||
""" | ||
|
||
rule subset_sequences_by_segment: | ||
input: | ||
metadata = "results/metadata.tsv", | ||
sequences = "data/sequences.fasta", | ||
output: | ||
kv_map = temp("data/kv-map_{segment}.tsv"), | ||
sequences = "results/{segment}/sequences.fasta", | ||
params: | ||
columns = lambda w: f"accession_{w.segment},strain", | ||
filter_exp = lambda w: f"len($accession_{w.segment})>0", | ||
drop_key = "__DROP__", | ||
shell: | ||
r""" | ||
cat results/metadata.tsv \ | ||
| csvtk cut -t -f {params.columns} \ | ||
| csvtk filter2 -t -U -f {params.filter_exp:q} \ | ||
> {output.kv_map} && \ | ||
seqkit replace \ | ||
-p "(.*)" --replacement "{{kv}}" --kv-file {output.kv_map} -m {params.drop_key} \ | ||
{input.sequences} \ | ||
| seqkit grep -v -r -p '^{params.drop_key}$' \ | ||
> {output.sequences} | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.