UCSF-Costello-Lab / LG3_Pipeline

The original LG3 pipeline
https://github.com/UCSF-Costello-Lab/LG3_Pipeline
0 stars 0 forks source link

ROBUSTNESS: Validate correctness of TSV file content #100

Open HenrikBengtsson opened 6 years ago

HenrikBengtsson commented 6 years ago

From https://github.com/UCSF-Costello-Lab/LG3_Pipeline/issues/98#issuecomment-433174059;

HenrikBengtsson commented 6 years ago

On tedious proposal in Bash:


## Validate tab-delimited CONV file
ntabs=($(grep -vE "^[ ]*#" "${CONV}" | while IFS=$'\t' read -r -a dummy; do echo "${#dummy[@]}"; done | sort -u))
if [[ ${#ntabs[@]} != 1 ]]; then
    echo "ERROR: Tab-delimited file '${CONV}' has different number of TABs on different lines: ${ntabs[*]} (should only be a single unique value)"
    exit 1
elif [[ ${ntabs[0]} != 4 ]]; then
    echo "ERROR: Tab-delimited file '${CONV}' should have exactly 4 TABs on each lines: ${ntabs[*]}"
    exit 1
fi