---
# System prepended metadata

title: Fastqc.sh

---

# Fastqc.sh 
```
#!/bin/bash
#SBATCH --mail-user=dokwon@ucdavis.edu
#SBATCH --mail-type=ALL
#SBATCH -J fastqc
#SBATCH -e /ocean/projects/bio220019p/davkwon/lncRNA/Code/Slurm_log/03_fastqc.%j.err
#SBATCH -o /ocean/projects/bio220019p/davkwon/lncRNA/Code/Slurm_log/03_fastqc.%j.out
#SBATCH -p RM-shared
#SBATCH -t 48:00:00                                                                                                                                               i=$1                                                                                                                                                               # echo commands to stdout
set -e
set -x                                                                                                                                                             ## Echo test to check the loop works
# interact
# for i in $(ls -d /ocean/projects/bio220019p/davkwon/lncRNA/Data/Barshisetal2012/*/ |cut -d '/' -f9); do echo $i; done

##Running script
# interact
# for i in $(ls -d /ocean/projects/bio220019p/davkwon/lncRNA/Data/Barshisetal2012/*/ |cut -d '/' -f9); do sbatch fastqc.sh $i; done

#### To test the for loop before you run:
#  Use the for loop above but replace sbatch with echo to print the variables first                                                                               # Make variables for directories                                                                                        data_dir="/ocean/projects/bio220019p/davkwon/lncRNA/Data"
set_dir="${data_dir}/Barshisetal2012"

# Load FastQC
module load FastQC

# change to the directory with prefetched data and where you want fastq files downloaded
cd ${set_dir}

# run fastqc
fastqc ${set_dir}/${i%}
```

### Leslie's Version
```
#!/bin/bash
#SBATCH --mail-user=leaguerrero@ucdavis.edu
#SBATCH --mail-type=ALL
#SBATCH -J fastqc
#SBATCH -e /ocean/projects/bio220019p/lherrera/lncRNA/Code/Slurm_log/03_fastqc.%j.err
#SBATCH -o /ocean/projects/bio220019p/lherrera/lncRNA/Code/Slurm_log/03_fastqc.%j.out
#SBATCH -p RM-shared
#SBATCH -t 48:00:00

i=$1
 # echo commands to stdout
set -e
set -x

## Echo test to check the loop works
# interact
# for i in $(ls -d /ocean/projects/bio220019p/lherrera/lncRNA/Data/Barshis/*/ |cut -d '/' -f9); do echo $i; done

##Running script
# interact
# for i in $(ls -d /ocean/projects/bio220019p/lherrera/lncRNA/Data/Barshis/*/ |cut -d '/' -f9); do sbatch 03_fastqc.sh $i; done

#### To test the for loop before you run:
#  Use the for loop above but replace sbatch with echo to print the variables
# Make variables for directories
data_dir="/ocean/projects/bio220019p/lherrera/lncRNA/Data"
set_dir="${data_dir}/Barshis"

# Load FastQC
module load FastQC

# change to the directory with prefetched data and where you want fastq files downloaded
cd ${set_dir}

# Make the directory for the output
mkdir ${set_dir}/${i%}/${i%}_Fastqc_out

# run fastqc on fastq files or zipped fastq files
fastqc -o ${set_dir}/${i%}/${i%}_Fastqc_out ${set_dir}/${i%}/*.fastq

```



