-
Notifications
You must be signed in to change notification settings - Fork 0
/
subsample.sh
23 lines (19 loc) · 921 Bytes
/
subsample.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
# Get the current directory where the script is located
folder="$(dirname "$(readlink -f "$0")")"
# Prompt user for the value after -p option
read -p "Enter the value for -p option (default is 0.05): " p_value
p_value=${p_value:-0.05} # Set default value to 0.05 if user input is empty
# Iterate through files ending with ".fastq.gz"
for file in "$folder"/*_1.fastq.gz; do
# Extract prefix from the file name
prefix=$(basename "${file}" _1.fastq.gz)
# Check if corresponding "_2.fastq.gz" file exists
if [ -e "$folder/${prefix}_2.fastq.gz" ]; then
# Run sequit on paired-end files
zcat ${prefix}_1.fastq.gz | seqkit sample -p ${p_value} -s 80 -o sub_${prefix}_1.fastq.gz
zcat ${prefix}_2.fastq.gz | seqkit sample -p ${p_value} -s 80 -o sub_${prefix}_2.fastq.gz
else
echo "Error: ${prefix}_2.fastq.gz not found for ${prefix}_1.fastq.gz"
fi
done