diff --git a/unknowntags.sh b/unknowntags.sh index d62d26ef6c999d56e9338e01f0da0965a1cda997..1f4cf57ec9e8084e6b19077935c125784fcdc83a 100755 --- a/unknowntags.sh +++ b/unknowntags.sh @@ -1,22 +1,48 @@ #!/bin/bash if (( $# < 1 )); then - echo "Print number of unique unknowntags" - echo "Usage: $0 ./block-I/02-inspect/dataFile" + echo "Usage:" + echo "1. Print Tag/Detection-Info" + echo "$0 ./block-I/02-inspect/dataFile" + echo "" + echo "2. Print list of unknown tags" + echo "$0 ./block-I/02-inspect/dataFile list" exit fi -grep X $1 | cut -d',' -f8 | sort | uniq | wc -l +COL_TAG=9 +HEADER_SIZE=`grep "#" "$1" | wc -l` +function printList(){ + echo "Unknown Tags VVV" + grep -v '#' "$1" | cut -d',' -f"$COL_TAG"- "$1" | grep "NA" | cut -d',' -f1 | sort | uniq + echo "Unknown Tags /\\/\\" +} -# if (( "$#" < 2 )); then -# echo "Usage: this data.csv newtagFile" -# echo "1. searches for unkown tags ('X') and saves them in a list named unknownTags" -# echo "2. compares these tags, with the tags from tagFile" -# echo "If anything matches, the beetle/tag must've been in the unit!" -# exit 1 -# fi - -# while IFS= read -r line -# do -# grep "$line" $unknownTags -# done < "$2" +function printInfo() { + echo "## Tags" + tag_total=`cut -d',' -f"$COL_TAG" "$1" | sort | uniq | wc -l` + tag_total=$(($tag_total-$HEADER_SIZE)) + tag_known=`cut -d',' -f"$COL_TAG"- "$1" | grep -v "NA" | cut -d',' -f1 | sort | uniq | wc -l` + tag_unknown=$(($tag_total-$tag_known)) + + echo " total: $tag_total" + echo " known: $tag_known" + echo "unknown: $tag_unknown" + echo "" + + echo "## Detections" + detection_total=`wc -l "$1" | cut -d" " -f1` + detection_total=$(($detection_total-$HEADER_SIZE)) + detection_known=`cut -d',' -f"$COL_TAG"- "$1" | grep -v "NA" | cut -d',' -f1 | wc -l` + detection_unknown=$(($detection_total-$detection_known)) + + echo " total: $detection_total" + echo " known: $detection_known" + echo "unknown: $detection_unknown" +} + +if (( $# == 1 )); then + printInfo $1 +else + printList $1 +fi