@@ -402,12 +402,19 @@ def parse_mutations(refseq, features_dict, mutations_list):
402
402
one dict per variant. format of subdict varies by variant type
403
403
"""
404
404
variant_list = []
405
+ problematic = []
405
406
406
407
for mutation in mutations_list :
407
408
record = variant_to_variant_record (mutation , refseq , features_dict )
408
409
if record != {}:
409
410
variant_list .append (record )
411
+ else :
412
+ problematic .append (mutation )
410
413
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 )
411
418
return variant_list
412
419
413
420
@@ -588,12 +595,12 @@ def generate_barcode(record_seq, variant_list, ref_char=None, ins_char="?", oth_
588
595
589
596
590
597
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 ):
592
599
reference_seq , features_dict = load_feature_coordinates (reference_json )
593
600
594
601
constellation_dict = {}
595
602
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 )
597
604
if not constellation :
598
605
continue
599
606
if constellation_names and constellation not in constellation_names :
@@ -612,6 +619,7 @@ def type_constellations(in_fasta, list_constellation_files, constellation_names,
612
619
else :
613
620
new_mutations_list .append (entry )
614
621
mutations_list = new_mutations_list
622
+ print ("Typing provided mutations %s" % "," .join (mutations_list ))
615
623
mutation_variants = parse_mutations (reference_seq , features_dict , mutations_list )
616
624
if len (constellation_dict ) == 1 and "mutations" not in constellation_dict :
617
625
constellation = list (constellation_dict )[0 ]
@@ -622,8 +630,11 @@ def type_constellations(in_fasta, list_constellation_files, constellation_names,
622
630
else :
623
631
constellation_dict ["mutations" ] = mutation_variants
624
632
633
+ if dry_run :
634
+ return
635
+
625
636
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 ) :
627
638
variants_out = open (out_csv , "w" )
628
639
variants_out .write ("query,%s\n " % "," .join (list (constellation_dict .keys ())))
629
640
@@ -672,7 +683,7 @@ def type_constellations(in_fasta, list_constellation_files, constellation_names,
672
683
673
684
674
685
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 ):
676
687
677
688
reference_seq , features_dict = load_feature_coordinates (reference_json )
678
689
@@ -710,6 +721,9 @@ def classify_constellations(in_fasta, list_constellation_files, constellation_na
710
721
mutations_list = new_mutations_list
711
722
mutation_variants = parse_mutations (reference_seq , features_dict , mutations_list )
712
723
724
+ if dry_run :
725
+ return
726
+
713
727
variants_out = open (out_csv , "w" )
714
728
columns = ["query" ,"constellations" ,"mrca_lineage" ]
715
729
if list_incompatible :
0 commit comments