forked from erkutilaslan/sra_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreplace_srx_to_sample.sh
More file actions
executable file
·39 lines (27 loc) · 1.15 KB
/
replace_srx_to_sample.sh
File metadata and controls
executable file
·39 lines (27 loc) · 1.15 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
#!/bin/bash
# file containing SRR to sample name mappings
table_file="srx_sample_name_v0.2.2.csv"
# loop through each line in the table file
while IFS=',' read -r srx_name sample_name; do
# find and rename R1 fastq.gz files
find . -type f -name "${srx_name}_*_1.fastq.gz" | while read -r file; do
file_dir=$(dirname "$file")
srx_srr=$(basename "$file")
mv $file ${file_dir}/${sample_name}.${srx_srr}
echo "Renamed $file to ${sample_name}.${srx_srr}"
done
# find and rename R2 fastq.gz files if they exist
find . -type f -name "${srx_name}_*_2.fastq.gz" | while read -r file; do
file_dir=$(dirname "$file")
srx_srr=$(basename "$file")
mv $file ${file_dir}/${sample_name}.${srx_srr}
echo "Renamed $file to ${sample_name}.${srx_srr}"
done
# find and rename non-paired files if they exist
find . -type f -name "${srx_name}*.fastq.gz" | while read -r file; do
file_dir=$(dirname "$file")
srx_srr=$(basename "$file")
mv $file ${file_dir}/${sample_name}.${srx_srr}
echo "Renamed $file to ${sample_name}.${srx_srr}"
done
done <"$table_file"