Skip to content

Commit 89809e9

Browse files
committed
1 parent 0f8a6dc commit 89809e9

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

docs/dev/io.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,26 @@ <h3>Streaming files with read and write<a class="headerlink" href="#streaming-fi
10051005
</pre></div>
10061006
</div>
10071007
</section>
1008+
<section id="support-for-stdin">
1009+
<h3>Support for stdin<a class="headerlink" href="#support-for-stdin" title="Link to this heading">#</a></h3>
1010+
<p>You may stream files in scikit-bio through stdin. To do this, you must set the
1011+
<code class="docutils literal notranslate"><span class="pre">verify</span></code> parameter of the <code class="docutils literal notranslate"><span class="pre">read</span></code> function to <code class="docutils literal notranslate"><span class="pre">False</span></code>. This will bypass
1012+
scikit-bio’s sniffers, which is what enables piping to function. However, the cost is
1013+
that scikit-bio is no longer checking that your file formats are correct, so the user
1014+
must be confident that they know the file format they are working with.</p>
1015+
<p>For example, if you wanted to pipe a FASTA file into a python script, your script could
1016+
look like this.</p>
1017+
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">skbio</span>
1018+
<span class="kn">import</span><span class="w"> </span><span class="nn">sys</span>
1019+
<span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">skbio</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">stdin</span><span class="p">,</span> <span class="nb">format</span><span class="o">=</span><span class="s1">&#39;fasta&#39;</span><span class="p">,</span> <span class="n">verify</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
1020+
<span class="nb">print</span><span class="p">(</span><span class="n">r</span><span class="o">.</span><span class="n">metadata</span><span class="p">[</span><span class="s1">&#39;id&#39;</span><span class="p">])</span>
1021+
</pre></div>
1022+
</div>
1023+
<p>This would then enable you to do the following.</p>
1024+
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$<span class="w"> </span>cat<span class="w"> </span>some_file.fna<span class="w"> </span><span class="p">|</span><span class="w"> </span>python<span class="w"> </span>script.py
1025+
</pre></div>
1026+
</div>
1027+
</section>
10081028
</section>
10091029
</section>
10101030

@@ -1066,6 +1086,7 @@ <h3>Streaming files with read and write<a class="headerlink" href="#streaming-fi
10661086
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#reading-files-into-scikit-bio">Reading files into scikit-bio</a></li>
10671087
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#writing-files-from-scikit-bio">Writing files from scikit-bio</a></li>
10681088
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#streaming-files-with-read-and-write">Streaming files with read and write</a></li>
1089+
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#support-for-stdin">Support for stdin</a></li>
10691090
</ul>
10701091
</li>
10711092
</ul>

docs/dev/searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)