列表对象没有属性

时间:2018-10-20 17:29:46

标签: list object attributes

这是我上的课。我正在尝试将我的类对象中的所有x和y染色体替换为数字23和24。我以为我可以使用cReadRefSeq的getChrID方法,但是它一直在说列表对象不是可归因的。

class cRefSeq:
    def __init__(self):
        self.sGenesym=  'NULL'
        self.sNMID=     'NULL'
        self.nChrID=    0
        self.sStrand=   'NULL' 
        self.nExons=    0
        self.nExonSP=   0
        self.nExonEP=   0
    def parse_refflat_line(self,sReadLine):
        instanceList=[]
        instanceList=sReadLine.split('\t')
        self.sGenesym=  instanceList[0]
        self.sNMID=     instanceList[1]
        self.nChrID=    instanceList[2]
        self.sStrand=   instanceList[3]
        self.nExons=    instanceList[8]
        self.nExonSP=   instanceList[9]
        self.nExonEP=   instanceList[10]
    def getGenesym(self):
        return self.sGenesym
    def getNMID(self):
        return self.sNMID
    def getChrID(self):
        return self.nChrID
    def getStrand(self):
        return self.sStrand
    def getExons(self):
        return self.nExons
    def getExonSP(self):
        return self.nExonSP
    def getExonEP(self):
        return self.nExonEP

    def ClassList():
        Direct='C:\\Users\\user\\Desktop\\Bioinformatics\\refFlat'
        fname=input('enter a filename:')
        infile=open(Direct+'\\'+fname,'r')
        cRefSeqList=[]
        print(time.ctime())  
        for sReadLine in infile.readlines():
            cReadRefSeq=cRefSeq()
            cReadRefSeq.parse_refflat_line(sReadLine)
            cRefSeqList.append(cReadRefSeq)
        return cRefSeqList,Direct

    def ChrIDconvert(cRefSeqList):
        for cReadRefSeq in cRefSeqList:
            if cReadRefSeq.getChrID== 'X':
                cReadRefSeq.getChrID.replace('X',23)
            elif cReadRefSeq.getChrID== 'Y':
                cReadRefSeq.getChrID.replace('Y',24)
            else: pass
        return cRefSeqList

0 个答案:

没有答案