Skip to content

Instantly share code, notes, and snippets.

@ihodes
Forked from smondet/upload_and_post_vcf
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ihodes/e0f1342cdf4a044d2650 to your computer and use it in GitHub Desktop.
Save ihodes/e0f1342cdf4a044d2650 to your computer and use it in GitHub Desktop.
#! /bin/sh
SCRIPT_NAME=$(basename $0)
short_usage()
{
echo "Cf : $SCRIPT_NAME [--help]"
}
long_usage()
{
echo "Post VCFs to Cycledash"
echo " Description : "
echo "Usage :"
echo "-----"
echo " $SCRIPT_NAME {--help,-h,}"
echo ""
echo "Options :"
echo "-------"
echo ""
}
if [ "$1" = "--help" ]
then
long_usage ;
exit
fi
if [ $# -eq 0 ]
then
short_usage ;
exit
fi
while getopts hv:V:U:t:n:N:P:w: option
do
case $option in
h ) long_usage ; exit ;;
V ) export VCF_PATH=$OPTARG ;;
v ) export VARIANT_CALLER_NAME=$OPTARG ;;
U ) export CYCLEDASH_URL=$OPTARG ;;
t ) export TUMOR_BAM_URI=$OPTARG ;;
n ) export NORMAL_BAM_URI=$OPTARG ;;
N ) export NOTES=$OPTARG ;;
P ) export PROJECT_NAME=$OPTARG ;;
w ) export WITNESS=$OPTARG ;;
\?) short_usage ; exit 2 ;;
esac
done
curl=curl
tmp_file=`mktemp /tmp/bbXXX`
$curl -f -F file=@$VCF_PATH $CYCLEDASH_URL/upload > $tmp_file
if [ `cat $tmp_file | wc -l` -lt 2 ] ; then
tmp_json=`mktemp /tmp/bbXXX`
cat <<EOF > $tmp_json
{
"uri": "`cat $tmp_file`",
"callerName": "$VARIANT_CALLER_NAME",
"tumorBamUri": "$TUMOR_BAM_URI",
"normalBamUri": "$NORMAL_BAM_URI",
"projectName": "$PROJECT_NAME",
"notes": "
EOF
echo ${NOTES} | sed 's/"/\\"/g' >> $tmp_json
echo '" }' >> $tmp_json
$curl -H 'Content-Type: application/json' -f $CYCLEDASH_URL/runs --data @$tmp_json -o $WITNESS
else
exit 3
fi
shift `expr $OPTIND - 1`
if [ $# -ne 0 ] ; then
for arg in $*; do
echo "Don't know what to do with: $arg"
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment