[Tutor] IndexError: list index out of range

Myunggyo Lee somrsaltt at gmail.com
Thu Jun 26 10:18:14 CEST 2014


Hi all
I just started to learn python language.
I'm trying to figure out the reason of error but i couldn't find it.
first imports short.txt(is attached to this mail)
and read in dictionary named gpdic1


Traceback (most recent call last):
  File "/home/ercsb/test.py", line 11, in <module>
    hgene = lines[1]
IndexError: list index out of range


-------------------------------------------------------------------------------------------
# -*- coding: utf-8 -*-
import string, os, sys, time, glob

inf2 =open('short.txt','r')

gpdic1={}
while 1:
        line= inf2.readline()
        if not line: break
        lines = line[:-1].split(',')

        hgene = lines[1]
        chr1 = lines[4]
        hgstart = lines[5]
        hgstop = lines[6]
        tgene = lines[7]
        chr2 = lines[10]
        tgstart = lines[11]
        tgstop = lines[12]

        gpdic1["hgene"] = hgene
        gpdic1["chr1"] = chr1
        gpdic1["hgstart"] = hgstart
        gpdic1["hgstop"] = hgstop
        gpdic1["tgene"] = tgene
        gpdic1["chr2"] = chr2
        gpdic1["tgstart"] = tgstart
        gpdic1["tgstop"] = tgstop
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140626/558c1f6d/attachment.html>
-------------- next part --------------
BF766250,TMEM151B,1,121,6,44273393,44273512,MT1A,118,329,16,56672578,56673816
CV351576,SNRNP70,1,116,19,49611334,49611448,GALT,110,377,9,34648372,34649047
AF487906,AFF1,1,211,4,87968543,87968752,MLL,203,435,11,118359327,118360590
DA403287,ARL16,1,163,17,79650564,79650824,LPIN1,161,542,2,11905658,11911581
BQ027739,RPLP2,19,216,11,812551,812874,HLA-DPA1,212,264,6,4513297,4513349
BF732578,PLD6,1,64,17,17109569,17109632,TNS1,58,729,2,218677091,218682697
DA168843,UQCRH,1,217,1,46769402,46775925,WASF1,217,524,6,110500775,110501082
BC040830,XPO5,121,374,6,43506503,43506758,RNF11,368,431,1,51716222,51716308
BI060051,abParts,13,122,14,106208368,106208477,DDB1,115,226,11,61094327,61096907

BG491331,PMM2,2,666,16,8891714,8906963,FDPS,667,899,1,155287732,155288485
BF800892,HNRNPA2B1,23,136,7,26236477,26236589,AATF,132,346,17,35310229,35310443
BE161420,BCYRN1,1,69,X,70516825,70516893,LMBR1,63,171,7,156473902,156474010
BG015191,MEG3,1,84,14,101301719,101301803,PPM1G,78,395,2,27604463,27605349
DW446667,BTN2A1,16,81,6,26458176,26458241,LAMP1,78,216,13,113977580,113977718
BF931405,MLL2,1,58,12,49445846,49445903,HLA-DPA1,59,122,6,4517371,4517434
DA869870,Unknown,1,293,1,12678018,12678310,COL6A2,292,524,21,47550288,47550520
AF362886,TPM3,12,220,1,154142876,154144580,ALK,212,308,2,29446307,29446402
DA819158,ARHGAP24,1,357,4,86396556,86491874,BANK1,357,561,4,102942670,102946482
BE835134,MPHOSPH10,7,123,2,71362676,71362793,AES,124,223,19,3053161,3053260
AI087196,TAGLN,6,72,11,117075433,117075498,BCORL1,65,396,X,129147106,129147437



More information about the Tutor mailing list