text: user10595: I’m using STAR to align fastq files from SMART-seq2. I have raw data folder containing sub-folders with samples names the sub-folders each contain fastq file. How can I make a bash command in order for STAR to go in each of sub-folders and make alignment for the fastq file and retrieve the bam files in one folder?
  Folder structure:
  /plates/plate_1/rawdata/A1/A1_R1.fastq
  /plates/plate_1/rawdata/B1/B1_R1.fastq
  ...
  /plates/plate_1/rawdata/O24/O24_R1.fastq
  /plates/plate_1/rawdata/P24/P24_R1.fastq
  
  It’s 384 sample folders A1, A2, B3, F5,,, so on
  
  user1642: It seems the sequencing is single-end, and there is only one fastq per sample. If so:
  staridx=/path/to/star/genome/index
  
  mkdir /plates/star/
  cd /plates/star/
  
  files=$(find /plates/plate_1/rawdata/ -name "*_R1.fastq")
  
  for i in ${files}
  do
  
    sample=$(basename $i "_R1.fastq")
  
    STAR --genomeDir $staridx --runThreadN 8 --outFileNamePrefix ${sample}. \
      --readFilesIn $i --outSAMtype BAM
  
  done
  
  All fastq files will be mapped individually, and all bam files will be saved to /plates/star/.
  
original_text: 10595: <p>I’m using STAR to align fastq files from SMART-seq2. I have raw data folder containing sub-folders with samples names the sub-folders each contain fastq file. How can I make a bash command in order for STAR to go in each of sub-folders and make alignment for the fastq file and retrieve the bam files in one folder?</p>
  <p>Folder structure:</p>
  <pre><code>/plates/plate_1/rawdata/A1/A1_R1.fastq
  /plates/plate_1/rawdata/B1/B1_R1.fastq
  ...
  /plates/plate_1/rawdata/O24/O24_R1.fastq
  /plates/plate_1/rawdata/P24/P24_R1.fastq
  </code></pre>
  <p>It’s 384 sample folders A1, A2, B3, F5,,, so on</p>
   1642: <p>It seems the sequencing is single-end, and there is only one fastq per sample. If so:</p>
  <pre><code>staridx=/path/to/star/genome/index
  
  mkdir /plates/star/
  cd /plates/star/
  
  files=$(find /plates/plate_1/rawdata/ -name &quot;*_R1.fastq&quot;)
  
  for i in ${files}
  do
  
    sample=<span class="math-container">$(basename $</span>i &quot;_R1.fastq&quot;)
  
    STAR --genomeDir <span class="math-container">$staridx --runThreadN 8 --outFileNamePrefix $</span>{sample}. \
      --readFilesIn $i --outSAMtype BAM
  
  done
  </code></pre>
  <p>All fastq files will be mapped individually, and all bam files will be saved to <code>/plates/star/</code>.</p>
  