#!/bin/bash

LENGTHS="/cvmfs/data.galaxyproject.org/managed/len/ucsc"
LOCATION="/cvmfs/data.galaxyproject.org/managed/location"


echo "Regenerating ${LOCATION}/dbkeys_ucsc.loc"
echo '# this file is automatically generated by update_ucsc.sh' > ${LOCATION}/dbkeys_ucsc.loc
while read build display; do
    [ -f ${LENGTHS}/${build}.len ] && echo -e "${build}\t${display}\t${LENGTHS}/${build}.len" >> ${LOCATION}/dbkeys_ucsc.loc
done < <(awk -F'\t' '$1 !~ "^ *[?#]" {print $1"\t"$2}' ${LOCATION}/builds.txt)
