Last active
August 29, 2015 14:12
-
-
Save smondet/4beec3cbd7c6a3a922bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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` | |
echo "$curl -f -F file=@$VCF_PATH $CYCLEDASH_URL/upload > $tmp_file" | |
$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 | |
echo "$curl -H 'Content-Type: application/json' -f $CYCLEDASH_URL/api/runs --data @$tmp_json -o $WITNESS" | |
$curl -H 'Content-Type: application/json' -f $CYCLEDASH_URL/api/runs --data @$tmp_json -o $WITNESS | |
else | |
echo "Seems like upload failed, exiting" | |
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