From b1f10599313b78954da8f3b1894e412a75624225 Mon Sep 17 00:00:00 2001 From: Rachel Colquhoun Date: Tue, 26 Oct 2021 10:21:38 +0100 Subject: [PATCH 1/6] update defaults for scorpio define --- scorpio/scripts/extract_definitions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scorpio/scripts/extract_definitions.py b/scorpio/scripts/extract_definitions.py index 0977f09..2a5d5f3 100755 --- a/scorpio/scripts/extract_definitions.py +++ b/scorpio/scripts/extract_definitions.py @@ -237,7 +237,7 @@ def subtract_outgroup(common, outgroup_common): def write_constellation(prefix, group, list_variants, list_intermediates, list_ancestral): group_dict = {"name": group, "sites": list_variants, "intermediate": list_intermediates, - "rules": {"min_alt": max(len(list_variants) - 3, min(len(list_variants), 3)), "max_ref": 3}} + "rules": {"min_alt": max(len(list_variants) - 8, min(len(list_variants), 3)), "max_ref": 3}} if list_ancestral: group_dict["ancestral"] = list_ancestral with open('%s/%s.json' % (prefix, group), 'w') as outfile: From 9789628af9297ef3b653d4e39ab090d681d57626 Mon Sep 17 00:00:00 2001 From: Rachel Colquhoun Date: Tue, 26 Oct 2021 11:49:02 +0100 Subject: [PATCH 2/6] fix print in define --- scorpio/scripts/extract_definitions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scorpio/scripts/extract_definitions.py b/scorpio/scripts/extract_definitions.py index 2a5d5f3..8da848f 100755 --- a/scorpio/scripts/extract_definitions.py +++ b/scorpio/scripts/extract_definitions.py @@ -66,7 +66,7 @@ def get_group_dict(in_variants, group_column, index_column, subset): if subset and row[group_column] not in subset: continue if row[index_column] in group_dict: - logging.warning("%s is a duplicate in group CSV, keeping first") + logging.warning("%s is a duplicate in group CSV, keeping first" % row[index_column]) else: group_dict[row[index_column]] = row[group_column] groups.add(row[group_column]) From 22088a7b4745f7d843782d3340a96923744877d2 Mon Sep 17 00:00:00 2001 From: Rachel Colquhoun Date: Tue, 26 Oct 2021 22:04:02 +0100 Subject: [PATCH 3/6] remove deep copy bug in haplotype --- scorpio/scripts/type_constellations.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/scorpio/scripts/type_constellations.py b/scorpio/scripts/type_constellations.py index 6bce390..68b0122 100755 --- a/scorpio/scripts/type_constellations.py +++ b/scorpio/scripts/type_constellations.py @@ -8,6 +8,7 @@ import json import re import logging +import copy import math if sys.version_info[0] < 3: @@ -868,7 +869,7 @@ def type_constellations(in_fasta, list_constellation_files, constellation_names, out_list = [record.id] for constellation in constellation_dict: - barcode_list, counts, constellation_count_dict, sorted_alt_sites = generate_barcode(record.seq, constellation_dict[constellation], ref_char, constellation_count_dict=constellation_count_dict) + barcode_list, counts, sample_constellation_count_dict, sorted_alt_sites = generate_barcode(record.seq, constellation_dict[constellation], ref_char, constellation_count_dict=copy.deepcopy(constellation_count_dict)) if output_counts or append_genotypes: columns = [record.id] if output_counts: @@ -878,15 +879,15 @@ def type_constellations(in_fasta, list_constellation_files, constellation_names, columns.extend(barcode_list) if combination: scores = {} - for candidate in constellation_count_dict: - if constellation_count_dict[candidate]["alt"] > 0: + for candidate in sample_constellation_count_dict: + if sample_constellation_count_dict[candidate]["alt"] > 0: summary = "%s:%i|%i|%i|%i" % ( - candidate, constellation_count_dict[candidate]["ref"], - constellation_count_dict[candidate]["alt"], - constellation_count_dict[candidate]["ambig"], - constellation_count_dict[candidate]["oth"]) - score = float(constellation_count_dict[candidate]["alt"]) / \ - constellation_count_dict[candidate]["total"] + candidate, sample_constellation_count_dict[candidate]["ref"], + sample_constellation_count_dict[candidate]["alt"], + sample_constellation_count_dict[candidate]["ambig"], + sample_constellation_count_dict[candidate]["oth"]) + score = float(sample_constellation_count_dict[candidate]["alt"]) / \ + sample_constellation_count_dict[candidate]["total"] scores[score] = summary sorted_scores = sorted(scores, key=lambda x: float(x), reverse=True) columns.append("; ".join([scores[score] for score in sorted_scores])) From a0c0c4539664bcd42c5cd56b5696c04924e77ddc Mon Sep 17 00:00:00 2001 From: Rachel Colquhoun Date: Tue, 26 Oct 2021 22:04:33 +0100 Subject: [PATCH 4/6] fix bug reporting intermediate frequencies --- scorpio/scripts/extract_definitions.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scorpio/scripts/extract_definitions.py b/scorpio/scripts/extract_definitions.py index 8da848f..9a5896a 100755 --- a/scorpio/scripts/extract_definitions.py +++ b/scorpio/scripts/extract_definitions.py @@ -208,8 +208,8 @@ def define_mutations(list_variants, feature_dict, reference_seq, include_protein current[3] = new[3] elif current[0] != "": var = translate_if_possible(current[1], current[0], current[2], feature_dict, reference_seq, include_protein) - if freq: - merged_list.append("%s:%s" % (var, freq)) + if current[3]: + merged_list.append("%s:%s" % (var, current[3])) else: merged_list.append(var) current = new @@ -217,8 +217,8 @@ def define_mutations(list_variants, feature_dict, reference_seq, include_protein current = new if current[0] != "": var = translate_if_possible(current[1], current[0], current[2], feature_dict, reference_seq, include_protein) - if freq: - merged_list.append("%s:%s" % (var, freq)) + if current[3]: + merged_list.append("%s:%s" % (var, current[3])) else: merged_list.append(var) return merged_list From 4014c1369627ceee141b5e140ee69e55a902c6ac Mon Sep 17 00:00:00 2001 From: Rachel Colquhoun Date: Wed, 27 Oct 2021 10:51:09 +0100 Subject: [PATCH 5/6] fix bug in scorpio list which could relate to cov-lineages/pango-designation/issues/163 --- scorpio/__main__.py | 2 +- scorpio/scripts/type_constellations.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scorpio/__main__.py b/scorpio/__main__.py index cfe9804..acc686b 100644 --- a/scorpio/__main__.py +++ b/scorpio/__main__.py @@ -251,7 +251,7 @@ def main(sysargs = sys.argv[1:]): if not args.reference_json: args.reference_json = reference_json logging.info("Found reference %s" %args.reference_json) - if not args.constellations and args.command in ['haplotype', 'classify']: + if not args.constellations and args.command in ['haplotype', 'classify', 'list']: args.constellations = list_constellation_files logging.info("Found constellations:") for c in args.constellations: diff --git a/scorpio/scripts/type_constellations.py b/scorpio/scripts/type_constellations.py index 68b0122..c5ae18b 100755 --- a/scorpio/scripts/type_constellations.py +++ b/scorpio/scripts/type_constellations.py @@ -294,8 +294,8 @@ def parse_json_in(refseq, features_dict, variants_file, constellation_names=None in_json.close() sorted_variants = sorted(variant_list, key=lambda x: int(x["ref_start"])) - for var in sorted_variants: - print(var) + #for var in sorted_variants: + # print(var) return sorted_variants, name, output_name, rules, mrca_lineage, incompatible_lineage_calls, parent_lineage, lineage_name @@ -1087,6 +1087,7 @@ def list_constellations(list_constellation_files, constellation_names, reference list_of_constellations.add(mrca_lineage) elif len(variants) > 0: list_of_constellations.add(output_name) + print("\n".join(list_of_constellations)) def parse_args(): parser = argparse.ArgumentParser(description="""Type an alignment at specific sites and classify with a barcode.""", From 00a5e560e5b245b860f44572c34a86330a0e9464 Mon Sep 17 00:00:00 2001 From: Rachel Colquhoun Date: Wed, 27 Oct 2021 11:32:18 +0100 Subject: [PATCH 6/6] update version --- scorpio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scorpio/__init__.py b/scorpio/__init__.py index 8bd5127..3cb3ecd 100644 --- a/scorpio/__init__.py +++ b/scorpio/__init__.py @@ -1,2 +1,2 @@ _program = "scorpio" -__version__ = "0.3.13" +__version__ = "0.3.14"