I would like to parse an NCBIXML file to obtain a list if the format:
known_results[i]=(query title, (hit_name,hit_name,hit_name....))
However I am having trouble getting the slice operator to work:
knowns = "output.xml" i=0 for record in NCBIXML.parse(open(knowns)): print record.query_id known_results[i] = record.query_id known_results[i] = (align.title for align in i.record.alignment) i+=1
which results in:
list assignment index out of range
since i can do known_results= "sample text" I think the problem is that I cannot use the slice method with a variable.
Can anyone suggest and alternative way to create this list?
thanks zach cp
crossposted with answer at StackOverflowlink text
There are two good answers on stackoverflow. The first uses list.append(), the second uses dictionaries. THe major problem with my construct is that you cannot assign values to parts of a list that have yet to be created.