Skip to content

Commit d4e505d

Browse files
authored
Merge pull request #24 from cov-lineages/dev
Dev
2 parents dcbade4 + 12b9e60 commit d4e505d

File tree

5 files changed

+33
-16
lines changed

5 files changed

+33
-16
lines changed

scorpio/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
_program = "scorpio"
2-
__version__ = "0.3.8"
2+
__version__ = "0.3.9"

scorpio/__main__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def main(sysargs = sys.argv[1:]):
5555
help="Specify where you want the temporary stuff to go Default: $TMPDIR")
5656
misc_group.add_argument("--no-temp", action="store_true", help="Output all intermediate files")
5757
misc_group.add_argument("--verbose", action="store_true", help="Print lots of stuff to screen")
58+
misc_group.add_argument("--dry-run", dest="dry_run", action="store_true", help="Quit after checking constellations and variants are AOK")
5859
misc_group.add_argument('-t', '--threads', action='store', dest="threads", type=int, help="Number of threads")
5960

6061
# _______________________________ classify __________________________________#

scorpio/scripts/type_constellations.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,19 @@ def parse_mutations(refseq, features_dict, mutations_list):
402402
one dict per variant. format of subdict varies by variant type
403403
"""
404404
variant_list = []
405+
problematic = []
405406

406407
for mutation in mutations_list:
407408
record = variant_to_variant_record(mutation, refseq, features_dict)
408409
if record != {}:
409410
variant_list.append(record)
411+
else:
412+
problematic.append(mutation)
410413

414+
if len(problematic) > 0:
415+
sys.stderr.write("The following mutations were not provided in an acceptable format: %s\n\n"
416+
% ",".join(problematic))
417+
sys.exit(1)
411418
return variant_list
412419

413420

@@ -588,12 +595,12 @@ def generate_barcode(record_seq, variant_list, ref_char=None, ins_char="?", oth_
588595

589596

590597
def type_constellations(in_fasta, list_constellation_files, constellation_names, out_csv, reference_json, ref_char=None,
591-
output_counts=False, label=None, append_genotypes=False, mutations_list=None):
598+
output_counts=False, label=None, append_genotypes=False, mutations_list=None, dry_run=False):
592599
reference_seq, features_dict = load_feature_coordinates(reference_json)
593600

594601
constellation_dict = {}
595602
for constellation_file in list_constellation_files:
596-
constellation, variants, ignore, mrca_lineage, incompatible_lineage_calls = parse_variants_in(reference_seq, features_dict, constellation_file, label=label)
603+
constellation, variants, ignore, mrca_lineage, incompatible_lineage_calls = parse_variants_in(reference_seq, features_dict, constellation_file, constellation_names, label=label)
597604
if not constellation:
598605
continue
599606
if constellation_names and constellation not in constellation_names:
@@ -612,6 +619,7 @@ def type_constellations(in_fasta, list_constellation_files, constellation_names,
612619
else:
613620
new_mutations_list.append(entry)
614621
mutations_list = new_mutations_list
622+
print("Typing provided mutations %s" % ",".join(mutations_list))
615623
mutation_variants = parse_mutations(reference_seq, features_dict, mutations_list)
616624
if len(constellation_dict) == 1 and "mutations" not in constellation_dict:
617625
constellation = list(constellation_dict)[0]
@@ -622,8 +630,11 @@ def type_constellations(in_fasta, list_constellation_files, constellation_names,
622630
else:
623631
constellation_dict["mutations"] = mutation_variants
624632

633+
if dry_run:
634+
return
635+
625636
variants_out = None
626-
if len(constellation_dict) > 1 or not output_counts:
637+
if len(constellation_dict) > 1 or not (output_counts or append_genotypes):
627638
variants_out = open(out_csv, "w")
628639
variants_out.write("query,%s\n" % ",".join(list(constellation_dict.keys())))
629640

@@ -672,7 +683,7 @@ def type_constellations(in_fasta, list_constellation_files, constellation_names,
672683

673684

674685
def classify_constellations(in_fasta, list_constellation_files, constellation_names, out_csv, reference_json,
675-
output_counts=False, call_all=False, long=False, label=None, list_incompatible=False, mutations_list=None):
686+
output_counts=False, call_all=False, long=False, label=None, list_incompatible=False, mutations_list=None, dry_run=False):
676687

677688
reference_seq, features_dict = load_feature_coordinates(reference_json)
678689

@@ -710,6 +721,9 @@ def classify_constellations(in_fasta, list_constellation_files, constellation_na
710721
mutations_list = new_mutations_list
711722
mutation_variants = parse_mutations(reference_seq, features_dict, mutations_list)
712723

724+
if dry_run:
725+
return
726+
713727
variants_out = open(out_csv, "w")
714728
columns = ["query","constellations","mrca_lineage"]
715729
if list_incompatible:

scorpio/subcommands/classify.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55

66
def run(options):
77
classify_constellations(options.input,
8-
options.constellations,
9-
options.names,
10-
options.output,
11-
options.reference_json,
12-
options.output_counts,
13-
options.call_all,
14-
options.long,
15-
options.label,
16-
options.list_incompatible,
17-
options.mutations)
8+
options.constellations,
9+
options.names,
10+
options.output,
11+
options.reference_json,
12+
options.output_counts,
13+
options.call_all,
14+
options.long,
15+
options.label,
16+
options.list_incompatible,
17+
options.mutations,
18+
options.dry_run)

scorpio/subcommands/haplotype.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ def run(options):
1313
options.output_counts,
1414
options.label,
1515
options.append_genotypes,
16-
options.mutations)
16+
options.mutations,
17+
options.dry_run)

0 commit comments

Comments
 (0)