title: Split large .gz files with prefixes
body: <p>Each of my fastq files is about 20 millions reads (or 20 millions lines). Now I need to split the big fastq files into chunks, each with only 1 million reads (or 1 million lines), for the ease of further analysis. fastq file is just like .txt.</p>
  
  <p>My thought is, just count the line, and print out the lines after counting every 1 million lines. But the input file is .gz compressed form (fastq.gz), do I need to unzip first?</p>
  
  <p>How can I do this with python?</p>
  
  <p>I tried the following command:</p>
  
  <pre><code>zless XXX.fastq.gz |split -l 4000000 prefix
  </code></pre>
  
  <p>(gzip first then split the file)</p>
  
  <p>However, seems it doesn't work with prefix (I tried) "-prefix", still it doesn't work. Also, with split command the output is like:</p>
  
  <pre><code>prefix-aa, prefix-ab...
  </code></pre>
  
  <p>If my prefix is <code>XXX.fastq.gz</code>, then the output will be <code>XXX.fastq.gzab</code>, which will destroy the .fastq.gz format.</p>
  
  <p>So what I need is XXX_aa.fastq.gz, XXX_ab.fastq.gz (ie. suffix). How can I do that?</p>