Skip to content

Commit

Permalink
separate individual query into own file
Browse files Browse the repository at this point in the history
  • Loading branch information
mchowdh200 committed Jul 7, 2022
1 parent ec6f22f commit d737365
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 14 deletions.
32 changes: 32 additions & 0 deletions scripts/stix_cmd.sh
Original file line number Diff line number Diff line change
@@ -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}"
28 changes: 14 additions & 14 deletions scripts/stix_query.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

0 comments on commit d737365

Please sign in to comment.