-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsam_bam.sh
31 lines (23 loc) · 1021 Bytes
/
sam_bam.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
#SBATCH --job-name=sam_to_bam # you can give your job a name
#SBATCH --ntasks=24 # the number of processors or tasks
#SBATCH --account=itcga # our account
#SBATCH --reservation=ITCGA2025 # this gives us special access during the workshop
#SBATCH --time=10:00:00 # the maximum time for the job
#SBATCH --mem=32gb # the amount of RAM
#SBATCH --partition=itcga # the specific server in chimera we are using
#SBATCH --error=log/%x-%A.err # a filename to save error messages into
#SBATCH --output=log/%x-%A.out # a filename to save any printed output into
module load samtools-1.10-gcc-9.3.0-flukja5
# Define the input directory and output directory
input_dir=$1
output_dir=$2
# Loop through .sam files in the input directory
for file in "$input_dir"/*.sam; do
# Extract the base name without the suffix (e.g., "C1_S4_L001")
base=$(basename "$file" .sam)
# Convert SAM to BAM using samtools
samtools view -S -b "$file" > "$output_dir/${base}.bam"
done
echo "Finish Run"
echo "End time: $(date)"