text: user13885: Hi I am trying to convert bam files generated from Ion Torrent Proton sequencing to fastq format so that I can upload them to KBase for analysis.
  The files are named as follows:
  01_thu159_IX_RNA_001.bam 01_thu163_IX_RNA_001.bam 01_thu164_IX_RNA_001.bam 01_thu190_IX_RNA_001.bam
  So I tried:
  samtools fastq *.bam > *.fastq
  However, that did not work. But, I know it is possible to use a placeholder for the name in code by using something like $f or I have also seen %N%. I am just not sure how to basically use those placeholders to be able to quickly apply a for loop, which will convert the files to fastq format without having to do each one individually. I have 28 samples each containing 4 bam files. Any advice on how I can do this would be greatly appreciated.
  
  user-1: Using GNU parallel:
  ls *.bam | parallel -j 2 "samtools fastq {} > {.}.fastq"
  
  Use -j to control the number of parallel jobs. That only works for single-end data though as paired-end data must first be sorted or collated by name.
  
original_text: 13885: <p>Hi I am trying to convert <code>bam</code> files generated from Ion Torrent Proton sequencing to <code>fastq</code> format so that I can upload them to KBase for analysis.</p>
  <p>The files are named as follows:
  <code>01_thu159_IX_RNA_001.bam 01_thu163_IX_RNA_001.bam 01_thu164_IX_RNA_001.bam 01_thu190_IX_RNA_001.bam</code></p>
  <p>So I tried:</p>
  <p><code>samtools fastq *.bam &gt; *.fastq</code></p>
  <p>However, that did not work. But, I know it is possible to use a placeholder for the name in code by using something like <code>$f</code> or I have also seen <code>%N%</code>. I am just not sure how to basically use those placeholders to be able to quickly apply a <code>for</code> loop, which will convert the files to fastq format without having to do each one individually. I have 28 samples each containing 4 <code>bam</code> files. Any advice on how I can do this would be greatly appreciated.</p>
   -1: <p>Using GNU parallel:</p>
  <pre><code>ls *.bam | parallel -j 2 &quot;samtools fastq {} &gt; {.}.fastq&quot;
  </code></pre>
  <p>Use <code>-j</code> to control the number of parallel jobs. That only works for single-end data though as paired-end data must first be sorted or collated by name.</p>
  