edgardomortiz / vcf2phylip

Convert SNPs in VCF format to PHYLIP, NEXUS, binary NEXUS, or FASTA alignments for phylogenetic analysis
GNU General Public License v3.0
294 stars 85 forks source link

KeyError: '2' #4

Closed matnguyen closed 6 years ago

matnguyen commented 6 years ago

I'm trying to run vcf2phylip on a VCF obtained from GATK's CombineVariants.

However, when trying to run it I get:

$ python ~/bin/vcf2phylip/vcf2phylip.py --input all_variants.vcf -f -p
    Traceback (most recent call last):
      File "/home/mnguyen/bin/vcf2phylip/vcf2phylip.py", line 387, in <module>
        main()
      File "/home/mnguyen/bin/vcf2phylip/vcf2phylip.py", line 212, in main
        site_tmp = ''.join([(amb[(nuc[broken[i][0]], nuc[broken[i][2]])]) for i in range(9, index_last_sample)])
    KeyError: '2'
edgardomortiz commented 6 years ago

Hi Matthew,

I would need a few thousand lines of your VCF to diagnose the problem. As far as I remember, GATK doesn't have a single VCF format as output.

You can get this fragment of your file with this: head -2000 all_variants.vcf > all_variants_2000.vcf

edgardomortiz commented 6 years ago

Hi again, did you solve the issue?

matnguyen commented 6 years ago

Hi, sorry for the delay. Here is the file

all_variants.zip

edgardomortiz commented 6 years ago

Hello,

I think is fixed, please clone and test again. The problem was caused because your VCF has haploid genotypes (which I never considered before), please confirm that indeed your genotypes were haploid.

Edgardo

On 21. Jul 2018, at 00:27, Matthew Nguyen notifications@github.com wrote:

Hi, sorry for the delay. Here is the file

all_variants.zip https://github.com/edgardomortiz/vcf2phylip/files/2215626/all_variants.zip — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edgardomortiz/vcf2phylip/issues/4#issuecomment-406742212, or mute the thread https://github.com/notifications/unsubscribe-auth/AFgBvARnsiD1YBcSQ99KTW9fk9ZgnJFYks5uIllQgaJpZM4VEsKI.

matnguyen commented 6 years ago

Hello,

Correct, my genotypes are haploid. I will pull and rerun to ensure everything works then close this issue

Thank you for the fix :)

edgardomortiz commented 6 years ago

I guess I will just close this issue