You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<h3>Reading multi-FASTA Files<aclass="headerlink" href="#reading-multi-fasta-files" title="Link to this heading">#</a></h3>
1315
+
<p>Suppose you have a multi-FASTA file and want to read each sequence into a <codeclass="docutils literal notranslate"><spanclass="pre">DNA</span></code>
1316
+
object in a list. We’ll be using <codeclass="docutils literal notranslate"><spanclass="pre">io.StringIO</span></code> to make a mock FASTA file in
<spanclass="gp">... </span><spanclass="s2">">seq3 H. Sapiens</span><spanclass="se">\n</span><spanclass="s2">"</span><spanclass="o">+</span>\
<p>The following code will read the sequences into scikit-bio. In practice, <codeclass="docutils literal notranslate"><spanclass="pre">mock_fl</span></code>
1339
+
may be replaced with an opened file handle, or the path to the file.</p>
<liclass="toc-h3 nav-item toc-entry"><aclass="reference internal nav-link" href="#reading-and-writing-fasta-files">Reading and Writing FASTA Files</a></li>
1420
1479
<liclass="toc-h3 nav-item toc-entry"><aclass="reference internal nav-link" href="#reading-and-writing-fasta-qual-files">Reading and Writing FASTA/QUAL Files</a></li>
Copy file name to clipboardExpand all lines: docs/dev/io.html
+13Lines changed: 13 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -983,6 +983,18 @@ <h3>Writing files from scikit-bio<a class="headerlink" href="#writing-files-from
983
983
not know how you want to serialize an object. OO interfaces define a default
984
984
<codeclass="docutils literal notranslate"><spanclass="pre">format</span></code>, so it may not be necessary to include it.</p>
985
985
</section>
986
+
<sectionid="streaming-files-with-read-and-write">
987
+
<h3>Streaming files with read and write<aclass="headerlink" href="#streaming-files-with-read-and-write" title="Link to this heading">#</a></h3>
988
+
<p>If you are working with particularly large files, streaming them might be preferable.
989
+
Scikit-bio’s <codeclass="docutils literal notranslate"><spanclass="pre">io</span></code> module offers the ability to contruct a streaming interface from
990
+
the <codeclass="docutils literal notranslate"><spanclass="pre">read</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">write</span></code> functions.</p>
991
+
<p><codeclass="docutils literal notranslate"><spanclass="pre">skbio.io.read</span></code> returns a generator, which can then be passed to <codeclass="docutils literal notranslate"><spanclass="pre">skbio.io.write</span></code>
992
+
to write only one chunk from the generator at a time.</p>
0 commit comments