我正在用Python开发一个简单的生物信息学包。我已经定义了一个用于处理FASTA文件的类,但是解释器在“def”关键字第8行引发了语法错误,表面上是构造函数。
第8行没有“def”关键字,我无法在我编写的代码中检测到语法错误 - 我能否对此另有启发?或者也许是关于如何修复解释器的建议?
class FastaToolbox:
def __init__(self, inputPath, seqType):
self.input = inputPath
self.seqType = seqType
self.validNucleic = ['a','g','c','t','u','r','y','k','m','s','w','b','d','h','v','n','-']
self.validAmino = ['A','B','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S'
'T','U','V','W','Y','Z','X','*','-']
self.warnings = []
for char in self.validNucleic:
if char != '-':
self.validNucleic.append(upper(char))
for char in self.validNucleic:
if char != '-' and char != '*':
self.validAmino.append(lower(char))
def validateFasta(self):
if self.seqType == 'nucleic':
for char in range (0, len(self.seq) - 1):
if seq[char] not in validNucleic:
print("ERR! Seq %s has invalid read at pos %i", self.seqHeader, char)
self.warnings.append(self.seq)
else:
for char in range (0, len(self.seq) - 1):
if seq[char] not in validAmino:
print("ERR! Seq %s has invalid read at pos %i", self.seqHeader, char)
self.warnings.append(self.seq)