psathyrella / partis

B- and T-cell receptor sequence annotation, simulation, clonal family and germline inference, and affinity prediction
GNU General Public License v3.0
57 stars 34 forks source link

KeyError when using --extra-annotation-columns #321

Closed m-vieira closed 1 year ago

m-vieira commented 1 year ago

I've been successfully running the following command (on a Linux cluster, commit 27d22b6622e0fec747f66134fc4e7d09f4dc974c):

partis partition --n-procs 15 --species mouse --infname '$temp_fasta_file' --outfname '$output_file' --extra-annotation-columns regional_bounds:cdr3_seqs:seqs_aa:naive_seq_aa:consensus_seq:consensus_seq_aa

But now that I've updated to commit 5197bace790ab056fd30c7f023f5b7525d6a49ee, I get the following KeyError with the same input data (even with a fresh parameter cache directory):

Error in sys.excepthook:
Traceback (most recent call last):
  File "/home/mvieira/.local/lib/python2.7/site-packages/colored_traceback/colored_traceback.py", line 27, in colorize_traceback
    tb_colored = pygments.highlight(tb_text, lexer, self.formatter)
  File "/home/mvieira/.local/lib/python2.7/site-packages/colored_traceback/colored_traceback.py", line 32, in formatter
    colors = _get_term_color_support()
  File "/home/mvieira/.local/lib/python2.7/site-packages/colored_traceback/colored_traceback.py", line 66, in _get_term_color_support
    curses.setupterm()
_curses.error: setupterm: could not find terminfo database

Original exception was:
Traceback (most recent call last):
  File "/project2/cobey/partis/bin/partis", line 1583, in <module>
    args.func(args)
  File "/project2/cobey/partis/bin/partis", line 323, in run_partitiondriver
    parter.run(actions)
  File "/project2/cobey/partis/python/partitiondriver.py", line 129, in run
    self.action_fcns[tmpaction]()
  File "/project2/cobey/partis/python/partitiondriver.py", line 644, in partition
    self.get_annotations_for_partitions(cpath)
  File "/project2/cobey/partis/python/partitiondriver.py", line 1017, in get_annotations_for_partitions
    self.write_output(all_annotations.values(), hmm_failures, cpath=cpath)
  File "/project2/cobey/partis/python/partitiondriver.py", line 2401, in write_output
    utils.write_annotations(outfname, self.glfo, annotation_list, headers, failed_queries=failed_queries, partition_lines=partition_lines, use_pyyaml=self.args.write_full_yaml_output, dont_write_git_info=self.args.dont_write_git_info)
  File "/project2/cobey/partis/python/utils.py", line 6774, in write_annotations
    write_yaml_output(fname, headers, glfo=glfo, annotation_list=annotation_list, synth_single_seqs=synth_single_seqs, failed_queries=failed_queries, partition_lines=partition_lines, use_pyyaml=use_pyyaml, dont_write_git_info=dont_write_git_info)
  File "/project2/cobey/partis/python/utils.py", line 6828, in write_yaml_output
    yaml_annotations = [get_yamlfo_for_output(l, headers, glfo=glfo) for l in annotation_list]
  File "/project2/cobey/partis/python/utils.py", line 6809, in get_yamlfo_for_output
    add_extra_column(key, line, yamlfo, glfo=glfo)
  File "/project2/cobey/partis/python/utils.py", line 4270, in add_extra_column
    outfo[key] = cons_seq_of_line(info, aa=True)
  File "/project2/cobey/partis/python/utils.py", line 2349, in cons_seq_of_line
    aligned_seqfos = seqfos_from_line(line, aa=aa, use_input_seqs=use_input_seqs)
  File "/project2/cobey/partis/python/utils.py", line 2333, in seqfos_from_line
    for uid, seq, mtp in zip(line['unique_ids'], line[skey+tstr], get_multiplicities(line)):
KeyError: 'seqs_aa'

stdout looks normal, ends with:

getting annotations for final partition
  subcluster annotating 9322 clusters with steps:  (84.6s) (44.8s) (26.2s) (17.1s) (11.0s) (7.4s) (4.9s) (2.3s) 
    subcluster annotation time 307.9

and an empty yaml file is written.

I don't get this error if I remove --extra-annotation-columns entirely, but I still get it if I remove seqs_aa from the list of required extra annotations but keep the others.

Any thoughts?

Thanks for all the hard work maintaining partis!

psathyrella commented 1 year ago

whoops, sorry/thanks for finding! Should be fixed here. Let me know if that doesn't do it though.

m-vieira commented 1 year ago

It worked. Thanks for getting to it so quickly!