-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadd_chrom_num.sh
More file actions
24 lines (19 loc) · 871 Bytes
/
add_chrom_num.sh
File metadata and controls
24 lines (19 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/bash
GENOME=S288C_reference_sequence_R64-4-1_20230823.fsa
awk '/>/{print}' S288C_reference_sequence_R64-4-1_20230823.fsa | awk '{gsub(/\[|\]|=/, " "); print}' | awk '{print $9,$10}' | awk '{gsub(/ /,"_"); print'} > tmp_new.txt
awk '/>/{print}' S288C_reference_sequence_R64-4-1_20230823.fsa | awk '{sub(">","");print}' | awk '{print $1}' > tmp_old.txt
old_chrom=tmp_old.txt
new_chrom=tmp_new.txt
backup_file=ORIGINAL_S288C_reference_sequence_R64-4-1_20230823.fsa
if ! [ -f $backup_file ]; then
echo "Backing up original file..."
cat $GENOME > $backup_file
fi
echo "Changing chromosome location header using the slowest possible method..."
while read -r -u 3 new_name && read -r -u 4 old_name; do
sed -i "s/${old_name}/${new_name}/" "${GENOME}"
done 3<$new_chrom 4<$old_chrom
echo "Removing tmp files..."
rm tmp_old.txt
rm tmp_new.txt
echo "Finished.."