-
Notifications
You must be signed in to change notification settings - Fork 96
/
add_to_lineages.sh
executable file
·40 lines (32 loc) · 1.08 KB
/
add_to_lineages.sh
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
# This script takes a lineage (e.g., XBB.1.5.34) as an argument and performs the following tasks:
# 1. Select the first field from TSV files in ~/Downloads/nextstrain_fetch*.
# 2. Remove the 'hCoV-19/' prefix from the selected field.
# 3. Remove everything after the first '|' character.
# 4. Append the provided lineage to the end of each line.
# 5. Skip the first line (header) and append the result to lineages.csv.
# 6. Run the deduplicate_keeping_last.py Python script.
# 7. Remove all files matching the ~/Downloads/nextstrain_fetch* pattern.
usage() {
echo "Usage: $0 <lineage> [--keep-first]"
echo "Example: $0 XBB.1.5.34"
}
lineage=$1
if [ -z "$lineage" ]; then
echo "Error: Please provide a lineage as an argument."
usage
exit 1
fi
tsv-select -f1 ~/Downloads/nextstrain_fetch* \
| sed 's/hCoV-19\///g' \
| sed 's/|.*//g' \
| sed "s/\$/,${lineage}/" \
| tail -n +2 \
>>lineages.csv
if [ "$2" != "--keep-first" ]; then
python deduplicate_keeping_last.py
else
echo "Keeping first"
python deduplicate_keeping_first.py
fi
rm ~/Downloads/nextstrain_fetch*