-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_virulencefinder.sh
155 lines (128 loc) · 4.13 KB
/
run_virulencefinder.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/bash
# run_virulencefinder.sh
# This script runs virulencefinder on a folder
# conda activate FBI_virulencefinder
# bash run_virulencefinder.sh --debug
# Settings
set -e # Stops the scripts if errors happen
debug=false # Initialize debug flag
# Handle command line arguments
parse_args() {
while [[ $# -gt 0 ]]; do
case "$1" in
--debug)
debug=true
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
shift
done
}
parse_args "$@"
# Sourcing the config file from the current working dir
# The config file is a text file with variables and paths
# It is not a yaml file
source ./config
work_dir=$(pwd)
tools_dir=$work_dir"/tools"
results=$work_dir"/results"
genomeslist=$work_dir"/genomes_list.txt"
# Log file
log_file="$work_dir/installation_log.txt"
# Current working dir
$debug && echo "work_dir: $work_dir"
# Functions
run_virulencefinder() {
echo "running virulencefinder on assemblies"
# Iterate over file paths from genomes_list.txt
while IFS= read -r file_path; do
assembly=$file_path
$debug && echo "running virulencefinder on $assembly"
# Get the genome name
genome=$(basename "$file_path" | cut -d "." -f 1)
mkdir -p "$results/virulencefinder/$genome/blastn"
echo "running virulencefinder on $genome"
cmd=("python" "$tools_dir/virulencefinder/virulencefinder.py"
"-i" "$assembly"
"-tmp" "$results/virulencefinder/$genome/blastn"
"-o" "$results/virulencefinder/$genome"
"-p" "$tools_dir/virulencefinder_db"
"-mp" "$conda_env/bin/blastn"
"-l" "$viru_min_cov"
"-t" "$viru_min_id"
"-x"
"-q")
$debug && echo "${cmd[*]}"
"${cmd[@]}"
done < "$genomeslist"
}
run_serotypefinder() {
echo "running serotypefinder on assemblies"
# Iterate over file paths from genomes_list.txt
while IFS= read -r file_path; do
assembly=$file_path
$debug && echo "running serotypefinder on $assembly"
# Get the genome name
genome=$(basename "$file_path" | cut -d "." -f 1)
mkdir -p "$results/serotypefinder/$genome"
echo "running serotypefinder on $genome"
cmd=("python" "$tools_dir/serotypefinder/serotypefinder.py"
"-i" "$assembly"
"-o" "$results/serotypefinder/$genome"
"-p" "$tools_dir/serotypefinder_db"
"-l" "$sero_min_cov"
"-t" "$sero_min_id"
"-x"
"-q")
$debug && echo "${cmd[*]}"
"${cmd[@]}"
done < "$genomeslist"
}
run_virulencefinder_raw() {
echo "running virulencefinder on raw reads"
# Iterate over file paths from genomes_list.txt
while IFS= read -r file_path; do
# Check if the file path matches the pattern
if [[ "$file_path" == *"_R1_"*.fastq.gz ]]; then
# Construct the corresponding R1 and R2 files
R1=$file_path
R2="${file_path/_R1_/_R2_}"
$debug && echo "running virulencefinder on ""$R1"" and ""$R2"
# Get the genome name
genome=$(basename "$R1" "_R1_*.fastq.gz" | cut -d "_" -f 1)
mkdir -p "$results/virulencefinder_raw/$genome/kma"
echo "running virulencefinder on "$genome
cmd=("python" "$tools_dir/virulencefinder/virulencefinder.py"
"-i" "$R1" "$R2"
"-tmp" "$results/virulencefinder/$genome/kma"
"-o" "$results/virulencefinder_raw/$genome"
"-p" "$tools_dir/virulencefinder_db"
"-mp" "$tools_dir/kma/kma"
"-l" "$viru_min_cov"
"-t" "$viru_min_id"
"-x"
"-q")
$debug && echo "${cmd[*]}"
"${cmd[@]}"
fi
done < "$genomeslist"
}
case $program in
0)
run_virulencefinder
run_serotypefinder
;;
1)
run_virulencefinder
;;
2)
run_serotypefinder
;;
3)
run_virulencefinder_raw
;;
esac
echo "Done"