Issue
Seq = []
Head = []
for line in range (0, len(text)):
if line in '>':
Head.append(line)
else:
Seq.append(line)
I am trying to append the header of FASTA sequences and the nucleotide sequence and separate them on a list. I don't know how to say that if line has '>', add to Head, else add to Seq
Solution
The line: line in '>'
is testing whether line
can be found inside the string '>'
. You need to swap them around to '>' in line
. This will test if the string '>'
can be found inside line
. If you are trying t test if the first character of line is '>'
, use 'line[0] == '>'
.
Also when using range the start will default to zero so you could say for x in range(len(text))
Final code:
Seq = []
Head = []
for line in range (len(text)):
if '>' in line:
Head.append(line)
else:
Seq.append(line)
Answered By - Joyal Mathew
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.