diff --git a/scripts/stix_cmd.sh b/scripts/stix_cmd.sh new file mode 100644 index 0000000..0d1bb6a --- /dev/null +++ b/scripts/stix_cmd.sh @@ -0,0 +1,32 @@ + +set -eu + +while getopts ":q:p:i:d:t:" opt; do + case $opt in + q) queries="$OPTARG" + ;; + p) index_path="$OPTARG" # where the index lives + ;; + i) stix_index="$OPTARG" # no path, just filename for -i, -d options + ;; + d) stix_db="$OPTARG" + ;; + t) threads="$OPTARG" + ;; + \?) "Invalid option -$OPTARG" >&2 + exit 1 + ;; + esac + + case $OPTARG in + -*) echo "Option $opt needs a valid argument" + exit 1 + ;; + esac +done + +cat $queries | gargs -p $threads "bash stix_query.sh \\ + -p $index_path \\ + -d $stix_db \\ + -i $stix_index \\ + -t {2} -l {0} -r {1}" diff --git a/scripts/stix_query.sh b/scripts/stix_query.sh index 22c73b6..4d401e3 100644 --- a/scripts/stix_query.sh +++ b/scripts/stix_query.sh @@ -2,17 +2,19 @@ set -eu -while getopts ":q:p:i:d:t:" opt; do +while getopts ":p:d:i:t:l:r:" opt; do case $opt in - q) queries="$OPTARG" + p) index_path="$OPTARG" + ;; + d) stix_db="$OPTARG" ;; - p) index_path="$OPTARG" # where the index lives + i) stix_index="$OPTARG" ;; - i) stix_index="$OPTARG" # no path, just filename for -i, -d options + t) svtype="$OPTARG" ;; - d) stix_db="$OPTARG" + l) left="$OPTARG" ;; - t) threads="$OPTARG" + r) right="$OPTARG" ;; \?) "Invalid option -$OPTARG" >&2 exit 1 @@ -26,11 +28,9 @@ while getopts ":q:p:i:d:t:" opt; do esac done -# TODO assumes gargs in the PATH, but could provide/download -# the binary instead with the snakemake pipeline. -cat $queries | - gargs -p $threads \ - "cd $index_path && - echo -e QUERY REGION: {} && - stix -d $stix_db -t {2} -s 500 -i $stix_index -l {0} -r {1} && - echo =========================================================" +hit=$(cd $index_path && + stix -d $stix_db -i $stix_index -t $svtype -l $left -r $right | + tail -n+3 | # chomp the two header lines + awk '{print $7+$8}' # columns with counts + ) +printf "$left\t$right\t$hit\n"