<p>Hi All,
I need to split my fastq file that is composed of 30 chromosomes into 30 different files containing each the information from one chromosome. Technically, I need to split this kind of file into seperated one:</p>

<pre><code>@chr1
nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnatgctgggtgatctttagtcnnnnnnnnnn
nnnnnnnnnnnnnnnnatggggtcatgtacacacacacattggatannnnnnnnnnnnnn
nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnatgctgggtgatctttagtcnnnnnnnnnn
...
@chr2
nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnatgctgggtgatctttagtcnnnnnnnnnn
nnnnnnnnnnnnnnnnatggggtcatgtacacacacacattggatannnnnnnnnnnnnn
nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnatgctgggtgatctttagtcnnnnnnnnnn
...
</code></pre>

<p>I tried to use :</p>

<pre><code>awk '/^@chr1$/,/^+$/' consensus.fastq | perl -pe "s/@/&gt;/ ; s/\+//" &gt; chr1.fasta
</code></pre>

<p>but that gives me this :</p>

<pre><code>@chr1
nnnnnagtnnnnnnnnnnnnnnnnnnnnnttgcnnnnnnnnnnnnnnnnnnnnnngcnnn
nnnntgaaannnnnnnnnnnntcnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
</code></pre>

<p>Did somebody had already this kind of problems? Could somebody gives me some advices?
Thanks a lot!</p>

<p>Nath</p>

If you have <a href="http://emboss.sourceforge.net/">EMBOSS</a> installed

    seqretsplit -sformat fastq-sanger -osformat fastq file.fastq

will give you one Fastq record per file. The files will be named after the sequence ID, so chr1.fastq, chr2.fastq etc. Note that you should use `-sformat fastq-sanger`, `fastq-illumina` or `fastq-solexa`, depending on which encoding your file uses. See <a href="https://www.biostars.org/p/642/">this question</a> on Fastq format.

To get Fasta output (you don't explicitly ask for it, but your code implies it), simply change the `-osformat` argument.

    seqretsplit -sformat fastq-sanger -osformat fasta file.fastq