-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_consensus_test.array.sh
More file actions
33 lines (28 loc) · 1.11 KB
/
Copy pathrun_consensus_test.array.sh
File metadata and controls
33 lines (28 loc) · 1.11 KB
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
30
31
32
33
#!/bin/bash
#SBATCH --job-name=consensus_sequence # Job name
#SBATCH --ntasks=1 # Run one tasks
#SBATCH --mem=16G # Job Memory
#SBATCH --time=23:00:00 # Time limit hrs:min:sec
#SBATCH --output=tmp/logs/consensus_sequence_%A_%a.log # Standard output and error log
#SBATCH --array=0-25 #Number of tasks to run
ml purge
module load MAFFT/7.505-GCC-11.3.0-with-extensions
# Generate TMP and OUT_DIRs if not yet present
TMP_DIR=$1
OUT_DIR=$2
mkdir -p ${TMP_DIR}
mkdir -p ${OUT_DIR}
# Generate an array of samples
SAMPLES_ARRAY=($(ls ${TMP_DIR} | tr '\n' ' '))
# Divide the array into more manageable chunks
CHUNK_START=$((SLURM_ARRAY_TASK_ID * 1000))
CHUNK_END=$((CHUNK_START + 999))
ARRAY_CHUNK=(${SAMPLES_ARRAY[@]:${CHUNK_START}:${CHUNK_END}})
# Run through the fasta files in the chunk
for THIS_FILE in ${ARRAY_CHUNK[@]}; do
INS_ID=$(echo ${THIS_FILE} | cut -d '.' -f 1)
python consensus_insert_sequence.py -i ${TMP_DIR}/${THIS_FILE} -n ${INS_ID} -o ${OUT_DIR}
done
if [ $? -eq 0 ]; then
echo "DONE"
fi