From 5fdbaca23bc108a01afc8829e65500fa90df7857 Mon Sep 17 00:00:00 2001 From: Rachel Colquhoun Date: Mon, 6 Dec 2021 15:47:22 +0000 Subject: [PATCH 1/5] add a different way of handling deletions --- scorpio/scripts/type_constellations.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scorpio/scripts/type_constellations.py b/scorpio/scripts/type_constellations.py index c5ae18b..b8d15ed 100755 --- a/scorpio/scripts/type_constellations.py +++ b/scorpio/scripts/type_constellations.py @@ -479,7 +479,7 @@ def call_variant_from_fasta(record_seq, var, ins_char="?", oth_char=None, codon= elif var["type"] == "aa": try: query = record_seq.upper()[var["ref_start"] - 1:var["ref_start"] - 1 + 3 * len(var["ref_allele"])] - query_allele = query.translate() + query_allele = query.translate(gap = "-") #query_allele_minus = record_seq.upper()[var["ref_start"] - 2:var["ref_start"] + 1].translate() #query_allele_plus = record_seq.upper()[var["ref_start"]:var["ref_start"] + 3].translate() #print("Found", query_allele, query_allele_minus, query_allele_plus) @@ -532,15 +532,15 @@ def call_variant_from_fasta(record_seq, var, ins_char="?", oth_char=None, codon= if query_allele == var["ref_allele"]: call = 'ref' query_allele = 0 + elif query_allele == "-" * var["length"] or query_allele == "N" * var["length"]: + call = 'alt' + query_allele = max(int(var["length"] / 3), 1) elif "N" in query_allele: call = 'ambig' if not oth_char: query_allele = "X" else: query_allele = "N" - elif query_allele == "-" * var["length"]: - call = 'alt' - query_allele = int(var["length"] / 3) else: call = 'oth' if not oth_char: From 92d19a9330278f20a342e590d476a5e14144bb1b Mon Sep 17 00:00:00 2001 From: Rachel Colquhoun Date: Mon, 6 Dec 2021 15:52:04 +0000 Subject: [PATCH 2/5] add option for interspersion, but not currently supported --- scorpio/__main__.py | 4 ++++ scorpio/subcommands/haplotype.py | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/scorpio/__main__.py b/scorpio/__main__.py index acc686b..4477815 100644 --- a/scorpio/__main__.py +++ b/scorpio/__main__.py @@ -113,6 +113,10 @@ def main(sysargs = sys.argv[1:]): "--combination", dest="combination", action="store_true", help="Combines the mutations for the specified constellations, and outputs a string across them all, with counts per found constellation" ) + subparser_haplotype.add_argument( + "--interspersion", dest="interspersion", action="store_true", + help="Evaluates an interspersion score" + ) subparser_haplotype.set_defaults(func=scorpio.subcommands.haplotype.run) # _______________________________ report __________________________________# diff --git a/scorpio/subcommands/haplotype.py b/scorpio/subcommands/haplotype.py index 8ce5831..8e72a87 100644 --- a/scorpio/subcommands/haplotype.py +++ b/scorpio/subcommands/haplotype.py @@ -15,4 +15,5 @@ def run(options): options.append_genotypes, options.mutations, options.dry_run, - options.combination) + options.combination, + options.interspersion) From da438362d178a29953ca71b047bf7398d31bf9d0 Mon Sep 17 00:00:00 2001 From: Rachel Colquhoun Date: Mon, 6 Dec 2021 16:17:07 +0000 Subject: [PATCH 3/5] allow comments within the variant strings using \# #36 --- scorpio/scripts/type_constellations.py | 7 ++++++- scorpio/tests/data/type_constellations/lineage_X.json | 7 ++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/scorpio/scripts/type_constellations.py b/scorpio/scripts/type_constellations.py index b8d15ed..2fc5c88 100755 --- a/scorpio/scripts/type_constellations.py +++ b/scorpio/scripts/type_constellations.py @@ -133,9 +133,14 @@ def variant_to_variant_record(l, refseq, features_dict, ignore_fails=False): to a dict """ #print("Parsing variant %s" %l) - lsplit = l.split(":") info = {} + if "#" in l: + l = l.split("#")[0].strip() + if l == "": + return info + lsplit = l.split(":") + if "+" in l: m = re.match(r'[aa:]*(?P\w+):(?P\d+)\+(?P[a-zA-Z]+)', l) if not m: diff --git a/scorpio/tests/data/type_constellations/lineage_X.json b/scorpio/tests/data/type_constellations/lineage_X.json index 358ddc7..60d0392 100644 --- a/scorpio/tests/data/type_constellations/lineage_X.json +++ b/scorpio/tests/data/type_constellations/lineage_X.json @@ -20,7 +20,7 @@ "s:Y144-", "s:E484K", "s:N501Y", - "s:A570D", + "s:A570D # spike ", "s:P681H", "s:T716I", "s:S982A", @@ -29,11 +29,12 @@ "8:R52I", "8:Y73C", "N:D3L", - "N:S235F" + "N:S235F", + "#s:T777I" ], "rules": { "min_alt": 4, "max_ref": 6, "s:E484K": "alt" } -} \ No newline at end of file +} From af98400e260c8557cbb314103f35a448c39eb97b Mon Sep 17 00:00:00 2001 From: Rachel Colquhoun Date: Tue, 7 Dec 2021 08:50:14 +0000 Subject: [PATCH 4/5] fix test where result changed because of deletion handling --- scorpio/tests/type_constellations_test.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scorpio/tests/type_constellations_test.py b/scorpio/tests/type_constellations_test.py index b1f4e54..36d4bf1 100644 --- a/scorpio/tests/type_constellations_test.py +++ b/scorpio/tests/type_constellations_test.py @@ -217,8 +217,13 @@ def test_call_variant_from_fasta(): for var in variants: call, query_allele = call_variant_from_fasta(Seq(ambig_string), var) - assert call == "ambig" - assert query_allele in ["X", "N", "NN", "--"] + print(var, call, query_allele) + if var["type"] == "del": + assert call == "alt" or call == "ambig" + assert query_allele in [2, "X"] + else: + assert call == "ambig" or call == "alt" + assert query_allele in ["X", "N", "NN", "--"] for var in variants: call, query_allele = call_variant_from_fasta(Seq(oth_string), var, oth_char="X") From 1dfb55a981a744edb559c2548923b28470ef6b73 Mon Sep 17 00:00:00 2001 From: Rachel Colquhoun Date: Wed, 8 Dec 2021 12:07:17 +0000 Subject: [PATCH 5/5] update for release --- scorpio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scorpio/__init__.py b/scorpio/__init__.py index 3cb3ecd..66960aa 100644 --- a/scorpio/__init__.py +++ b/scorpio/__init__.py @@ -1,2 +1,2 @@ _program = "scorpio" -__version__ = "0.3.14" +__version__ = "0.3.15"