{"id":606,"date":"2018-05-07T20:56:56","date_gmt":"2018-05-07T18:56:56","guid":{"rendered":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/?p=606"},"modified":"2020-08-31T18:34:49","modified_gmt":"2020-08-31T16:34:49","slug":"interleaved-to-deinterleaved-fasta","status":"publish","type":"post","link":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/2018\/05\/07\/interleaved-to-deinterleaved-fasta\/","title":{"rendered":"One-liner: Interleaved to deinterleaved FASTA"},"content":{"rendered":"<p><strong>Quick, de-interleave it!<\/strong><br \/>\nThere are one-liners that never get old. This is one of them.<\/p>\n<div style=\"background-color: #ffebdb\">\n<pre>$ perl -MBio::SeqIO -e \n'my $seqin = Bio::SeqIO-&gt;\n new(-fh =&gt; \\*STDIN, -format =&gt; 'fasta');\n while (my $seq = $seqin-&gt; next_seq)\n { print \"&gt;\", $seq-&gt; id, \"\\n\", $seq-&gt; seq, \"\\n\"; }'\n&lt; interleaved.fasta &gt; deinterleaved.fasta\n<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p><em>Update 28-Jan-2019:<\/em><br \/>\nOver time, I came to find working with BioPerl uncomfortable, as its clean installation is just not well-supported on Linux. Thus, I have found myself relying on this method more and more, assuming that the line breaks of the input file are LF (and not CRLF):<\/p>\n<div style=\"background-color: #ffebdb\">\n<pre>$ INF=interleaved.fasta\nawk '\/^&gt;\/ {printf(\"\\n%s\\n\",$0);next; } \\\n{ printf(\"%s\",$0);}  END {printf(\"\\n\");}' \\\n&lt; $INF | tail -n +2 \\\n&gt; ${INF%.fasta*}_deint.fasta\n<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Quick, de-interleave it! There are one-liners that never get old. This is one of them. $ perl -MBio::SeqIO -e &#8216;my $seqin = Bio::SeqIO-&gt; new(-fh =&gt; \\*STDIN, -format =&gt; &#8216;fasta&#8217;); while (my $seq = $seqin-&gt; next_seq) { print &#8220;&gt;&#8221;, $seq-&gt; id, &#8220;\\n&#8221;, $seq-&gt; seq, &#8220;\\n&#8221;; }&#8217; &lt; interleaved.fasta &gt; deinterleaved.fasta &nbsp; Update 28-Jan-2019: Over time, I [&hellip;]<\/p>\n","protected":false},"author":2306,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[57598,57600],"tags":[],"class_list":["post-606","post","type-post","status-publish","format-standard","hentry","category-bioinformatics","category-one-liners"],"_links":{"self":[{"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/posts\/606","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/users\/2306"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/comments?post=606"}],"version-history":[{"count":11,"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/posts\/606\/revisions"}],"predecessor-version":[{"id":895,"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/posts\/606\/revisions\/895"}],"wp:attachment":[{"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/media?parent=606"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/categories?post=606"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/tags?post=606"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}