This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Python error for variant call

Dear all,

I got a error when output VCF file.

"in VCFoutput
  i.INFO['AC'][index] += 1
  IndexError: list index out of range"                          

Here is the part where error from:
  for x in xrange(len(variant[3])):
                                if variant[3][x] in i.ALT and variant[1][x] in i.REF:
                                    index=i.REF.index(variant[1][x])
                                    **i.INFO['AC'][index] += 1**
                                    i.INFO['AN']+=1
                                    aplotype=index+1
                                    genotype=[aplotype]

Anyone knows how to fix it? Thanks ahead

assembly

I added code markup to your post for increased readability. You can do this by selecting the text and clicking the 101010 button. When you compose or edit a post that button is in your toolbar, see image below:

101010 Button

The obvious answer is that it is telling you that the position in the list does not exist. Is this your script? Or taken from somewhere else? Without more of the code, or a brief description in pseudocode explaining what you're doing, it's hard to tell what everything is.

1 answer

It is not possible to answer this question withouth knowing what i.REF.index and the variant object contains.

Do note that the AC field is the allele count and ensure that there is a reason that i.REF.index(variant[1][x]) returns values that are within the range of i.INFO['AC']

Log in to answer this question.