-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrun_tools.sh
More file actions
69 lines (55 loc) · 1.89 KB
/
run_tools.sh
File metadata and controls
69 lines (55 loc) · 1.89 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
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
#!/bin/bash
set -e
# Check if the correct number of arguments is provided
if [ "$#" -lt 2 ]; then
echo "Usage: $0 <input_json_file> <output_directory>"
exit 1
fi
INPUT_JSON=$1 # Path to the input JSON file
OUTPUT_DIR=$2 # Directory where the results will be stored
PYTHON_SCRIPT="scripts/parse_index.py" # Python script to parse the JSON file
NUM_THREADS_CHECKM2_RUN=20
# Ensure the output directory exists
mkdir -p "$OUTPUT_DIR"
# Check if Python script exists
if [ ! -f "$PYTHON_SCRIPT" ]; then
echo "Error: Python script $PYTHON_SCRIPT not found."
exit 1
fi
# Parse the JSON file and capture the output
PARSED_PATHS=$(python3 "$PYTHON_SCRIPT" "$INPUT_JSON" fna)
if [ $? -ne 0 ]; then
echo "Error parsing JSON file."
exit 1
fi
# Convert the parsed paths into a comma-separated list
IFS=$'\n' read -r -d '' -a PATHS_ARRAY < <(printf '%s\0' "$PARSED_PATHS")
PATHS_COMMA=$(IFS=,; echo "${PATHS_ARRAY[*]}")
# Check if there are paths to process
if [ -z "$PATHS_COMMA" ]; then
echo "No paths found in the JSON file."
exit 1
fi
# ensure conda environment is active and checkm2 db is downloaded
conda env create -f env.yml
conda activate genome_loader_env
checkm2 database --download
# Generate output file paths
STATS_OUTPUT="$OUTPUT_DIR/stats.json"
CHECKM2_OUTPUT="$OUTPUT_DIR/checkm2/"
mkdir -p "$CHECKM2_OUTPUT"
# Run statswrapper.sh and save the results to the output directory
echo "Running statswrapper.sh..."
statswrapper.sh in="$PATHS_COMMA" --format=8 > "$STATS_OUTPUT"
if [ $? -ne 0 ]; then
echo "Error running statswrapper.sh."
exit 1
fi
# Run checkm2 and save the results to the output directory
echo "Running checkm2..."
checkm2 predict --threads $NUM_THREADS_CHECKM2_RUN --input "${PATHS_ARRAY[@]}" -o "$CHECKM2_OUTPUT"
if [ $? -ne 0 ]; then
echo "Error running checkm2."
exit 1
fi
echo "Process completed successfully. Results saved to $OUTPUT_DIR."