-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path05_map_parallel.sh
More file actions
42 lines (34 loc) · 1.06 KB
/
Copy path05_map_parallel.sh
File metadata and controls
42 lines (34 loc) · 1.06 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
34
35
36
37
38
39
40
41
42
#!/bin/bash
#############
## written by RMPeery 2025
## Doesn't always work well - if fail use alt_map_loop.sh
## USE: ./map_parallel.sh
#############
set -eou pipefail
# Define dir
# change to match dir structure
DIR="/home/user/path"
RDS="$DIR/reads/Pcin_trimRds"
REF="$DIR/ref/Phyci1_bwaRef"
OUT="$DIR/bam"
mkdir -p "$OUT"
# function to map reads started by ChatGPT4 from loop version (alt_map_loop.sh)
# modified by RMPeery to use paths and streamline
mapping() {
FWDRDS="$1"
# grab reverse reads; check file extensions
REVRDS="${FWDRDS/_1P.fastq.gz/_2P.fastq.gz}"
# grab sample ID
ID=$(basename "$FWDRDS" _1P.fastq.gz)
# check in on processing
echo "Processing sample: $ID"
# run mapping and sorting
bwa-mem2 mem -M -t 24 "$REF" "$FWDRDS" "$REVRDS" | \
samtools sort -@ 16 -o "$OUT/${ID}.mapSort.bam"
# check in on processing
echo "Mapping for $ID completed."
}
export -f mapping
# run in parallel (j = no. concurrent jobs)
find "$RDS" -name "*_1P.fastq.gz" | parallel -j 3 mapping {}
echo "Mapping complete for all files."