RahmanTeam / CAVA

CAVA (Clinical Annotation of VAriants)
MIT License
14 stars 9 forks source link

Annotate vcf with no records #5

Open dariober opened 7 years ago

dariober commented 7 years ago

Hello- It seems that CAVA throws an exception if the input VCF file has no records. This is what I get:

cava.py -i in.vcf -c cava.config

-----------------------------------------------------------------------
CAVA (Clinical Annotation of VAriants) v1.2.2 is now running.
Started:  2017-08-14 09:25:16.991644 

Configuration file:  cava.config
Input file (VCF):    in.vcf
Output file (VCF):   output.vcf
Log file:            output.log

Input file contains 0 records to annotate.

Traceback (most recent call last):
  File "/home/db291g/applications/cava/CAVA/cava.py", line 420, in <module>
    breaks = findFileBreaks(copts.input, copts.threads)
  File "/home/db291g/applications/cava/CAVA/cava.py", line 134, in findFileBreaks
    delta = int((counter - first + 1) / threads)
UnboundLocalError: local variable 'first' referenced before assignment

I think a vcf with no records is a legitimate input so I fixed this on my local copy by adding this check just after https://github.com/RahmanTeam/CAVA/blob/master/cava.py#L416 :

if numOfRecords == 0:
   sys.stderr.write('Done. Nothing to be annotated.\n')
   sys.exit(0)

In this way cava writes out the VCF header and exits clean.

Maybe it should be fixed in the master as well?

marton-munz commented 7 years ago

Hi, thanks very much for this. You are absolutely right and your suggested fix looks perfect. We are going to add this to the next stable CAVA release. If next time you have a feedback/suggestion, could you please post it to the CAVA User Group so that all users registered there would be able to see it?: https://groups.google.com/forum/#!forum/cava-user-group Many thanks again for your feedback.