spacer
spacer

cURL

Fetching database entries using a basic POST request to dbfetch:

#!/bin/sh
url='http://www.ebi.ac.uk/Tools/dbfetch/dbfetch'
curl --silent --data 'db=uniprot' --data 'id=WAP_RAT,WAP_MOUSE' --data 'format=default' --data 'style=raw' "$url"

Submitting a job to NCBI BLAST (REST) using a database entry identifier for the query sequence:

#!/bin/sh
 
baseUrl='http://www.ebi.ac.uk/Tools/services/rest/ncbiblast'
 
# Submit job.
url="$baseUrl/run"
email='support@ebi.ac.uk'
jobId=`curl -s -d "email=$email" \
-d 'stype=protein' \
-d 'program=blastp' \
-d 'database=uniprotkb_swissprot' \
-d 'sequence=UNIPROT:WAP_RAT' \
$url`
echo "JobId: $jobId"
 
# Job status polling.
url="$baseUrl/status/$jobId"
status='PENDING'
while [ "$status" = 'PENDING' -o "$status" = 'RUNNING' ]; do
    sleep 3
    status=`curl -s "$url"`
    echo "$status"
done
 
# Get available result types.
url="$baseUrl/resulttypes/$jobId"
resultTypeXml=`curl -s "$url"`
resultTypeList=`echo "$resultTypeXml" | xpath -e '//identifier' 2> /dev/null | sed 's#<[^>]*>##g'`
 
# Get results.
for resultType in $resultTypeList; do
    url="$baseUrl/result/$jobId/$resultType"
    curl -s "$url"
done

Submitting a job to MUSCLE (REST) using input data from a file:

#!/bin/sh
 
baseUrl='http://www.ebi.ac.uk/Tools/services/rest/muscle'
 
# Submit job.
url="$baseUrl/run"
email='support@ebi.ac.uk'
jobId=`curl -s -d "email=$email" \
--data-urlencode "sequence@$HOME/test/data/sequence/prot_test_multi_1433.tfa" \
$url`
echo "JobId: $jobId"
 
# Job status polling.
url="$baseUrl/status/$jobId"
status='PENDING'
while [ "$status" = 'PENDING' -o "$status" = 'RUNNING' ]; do
    sleep 3
    status=`curl -s "$url"`
    echo "$status"
done
 
# Get available result types.
url="$baseUrl/resulttypes/$jobId"
resultTypeXml=`curl -s "$url"`
resultTypeList=`echo "$resultTypeXml" | xpath -e '//identifier' 2> /dev/null | sed 's#<[^>]*>##g'`
 
# Get results.
for resultType in $resultTypeList; do
    url="$baseUrl/result/$jobId/$resultType"
    curl -s "$url"
done
 
tutorials/06_programming/tools/curl.txt · Last modified: 2012/09/19 10:45 by hpm
spacer
spacer