KarchinLab / open-cravat

A modular annotation tool for genomic variants
MIT License
110 stars 27 forks source link

KeyError in sample_id with multiple VCF files #210

Closed meyerkm closed 4 months ago

meyerkm commented 5 months ago

Came across a small bug on L453 of cravat_convert.py. When running with multiple VCF files that have empty sample ids, L453 throws a KeyError: 'sample_id', before the else statement can execute.

[https://github.com/KarchinLab/open-cravat/blob/6c0c7ce283eb568afeb9f9360ef20cf89fdbc518/cravat/cravat_convert.py#L453] if wdict["sample_id"]:

Simple fix to change L453 to the following: if "sample_id" in wdict:

This will eliminate the KeyError, by correctly checking if the key is present in the dictionary and allow the if-statement block to execute the else-statement correctly.

skanderson commented 4 months ago

@meyerkm Thanks for catching this. I put in the fix as suggested, hopefully it will make the next release. Also, we'll plan on adding some unit tests for cravat_convert in the near future.