FAA File Sequence
2
I used this sequence of codes to print the sequences with a header:
but now that I'm trying to print without a header (the lines with > in the start) using this other code, I'm not getting it
Is there any other code that can do this, a more direct one or using the same sequence with sth different?
faa
python
• 1.1k views
I managed to solve it with this code:
openFile = open('genoma9.faa', 'r')
writeFile = open('updatedFile.txt', 'w')
for txtLine in openFile .readlines():
if not (txtLine.startswith('>WP')):
print(txtLine)
writeFile.write(txtLine)
writeFile.close()
openFile.close()
The read() method returns the specified number of bytes from the file. Default is -1 which means the whole file.
here you read the whole file. If the file is too large, it won't fit in memory.
Is there any other code that can do this
iterate over each line, fill the name and the sequence of the current sequence.
see Correct Way To Parse A Fasta File In Python
Login before adding your answer.
Traffic: 1972 users visited in the last hour