Thanks, Colin. That worked OK for the json-formatted tables but the HDF5 are still non-human readable. This command does turn up human-readable "HDF" as part of the string, so at first I was using grep "HDF" to check if a file is hdf5 or json. However, it seems possible, however unlikely, that a taxonomic string somewhere might contain HDF for some reason. So now I have switched the code to check for json by grepping "Biological Observation Matrix" which almost certainly won't wind up in a non-human readable string by accident.
## Trap function on exit.
function finish {
if [[ -f $jsontemp ]]; then
rm $jsontemp
fi
}
trap finish EXIT
## Test if input is properly formatted and correct if necessary
randcode=`cat /dev/urandom |tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1` 2>/dev/null
jsontemp="$tempdir/${randcode}_json.biom"
jsontest=$(grep "Biological Observation Matrix" $input)
if [[ -z "$jsontest" ]]; then
## convert biom for processing
echo "Converting input table (HDF5 format) to JSON for processing."
biom convert -i $input -o $jsontemp --to-json
wait
table="$jsontemp"
else
table="$input"
fi
wait
## Execute R slaves
#Call separate R scripts here...