I have been given the function below and a text file containing a DNA sequence. However, I am a complete beginner and have no idea how to use these two together.
The function:
def load_fasta(f):
seq_title = f.readline()
s =''
while True:
seq_line = f.readline()
# DEBUG print len(seq_line.strip().lower())
if seq_line == '':
break
else:
s += seq_line.strip().lower()
print(seq_title,'n contains %d basesnn' % len(s))
return (seq_title,s)
There also seems to be an issue with line 11 which states:
‘str’ object has no attribute ‘readline’
I have searched for how to fix this but can’t find a solution that works
Source: Python Questions