November 2018
Intermediate to advanced
360 pages
9h 36m
English
Let's take a look at the following steps:
from Bio import SeqIOw_hdl = open('example.fasta', 'w')w_seq = seq[11:5795]SeqIO.write([w_seq], w_hdl, 'fasta')w_hdl.close()
The SeqIO.write function takes a list of sequences to write (not just a single one). Be careful with this idiom. If you want to write many sequences (and you could easily write millions with NGS), do not use a list (as shown in the preceding code), because this will allocate massive amounts of memory. Either use an iterator, or use the SeqIO.write function several times with a subset of the sequence on each write.