Вот класс, который я определил в python3.
class BlastHit():
'''
instance attributes:
entry: one line from blast output file
transID: transcript ID
SPID: SwissProt ID (without the version number)
ID: identity
MM: mismatch
methods:
constructor
__repr__
goodMatchCheck:
method that returns whether the hit is a really good match (e.g. >95 identity)
'''
def __init__(self, entry):
self.entry = entry
splited_line = entry.rstrip().split("\t")
# Find transcript ID (transID)
qseqid = splited_line[0]
self.transID = qseqid.split("|")[0]
# Find SwissProt ID (SPID)
sseqid = splited_line[1]
sp = sseqid.split("|")[3]
self.SPID = sp.split(".")[0]
# Find identity (ID)
self.ID = splited_line[2]
# Find mismatch (MM)
self.MM = splited_line[4]
def __repr__(self):
return f"BlastHit('{self.entry}')"
def goodMatchCheck(self):
return float(self.MM) >= 95.0
def list_results(self):
results = list()
results += self.transID
return results
И я попытался запустить следующее:
if __name__ == "__main__":
BlastHit.list_results("c0_g1_i1|m.1 gi|74665200|sp|Q9HGP0.1|PVG4_SCHPO 100.00 372 0 0 1 372 1 372 0.0 754")
Однако система продолжала выдавать мне ту же ошибку сообщение:
AttributeError: у объекта 'str' нет атрибута 'transID'
У кого есть идеи, пожалуйста, поделитесь со мной. Спасибо!