This is a test version of Biostars. For the public version, visit https://www.biostars.org.
cravat.us web services, unable to understand what to do

I am following this website to get help regarding connection to cravat.us

with this website I have to connect so that I can submit job without opening my browser. in this website I am looking for web services section.

http://www.cravat.us/help.jsp?chapter=how_to_cite&article=

See the Image to understand the instructions :

https://drive.google.com/file/d/0B6DXP2pIxiX7R01JbmZtQ2RoMlk/edit?usp=sharing

They said create JSON object and all, I have create JSON object:

{
    "analysis": "CHASM",
    "analysistype" : "driver",
    "chasmclassifier" : "Head and Neck",
    "email" : "dokadya@gmail.com"
    "functionalannotation" : "on",
    "hg18" : "off",
    "inputfile" : "/media/storage1/SAMPLE_NAME_1.cravat",
    "mupitinput" : "on",
    "tsvreport" : "on"
}

How can i upload file ? Can I use just path to upload ?

What kind of script I have to write ? HTML form? PERL ?

See the link for my perl file:

https://drive.google.com/file/d/0B6DXP2pIxiX7eF9tWTZ5VDBoTzg/edit?usp=sharing

Like this I have created file but its not working. Please guide me.

Waiting for positive reply.

Thank You.

Chetan

cravat cravat.us web web services

7 answers

Hi, this is Rick from In Silico Solutions, which maintains CRAVAT. Please see the following examples in Perl:

use LWP;
use URI;

my $browser = LWP::UserAgent->new();

#
# Job submission example, when the mutations are in a string
#
print "\n###### Submitting through GET #####\n";
my $urlSubmitGet = URI->new("http://www.cravat.us/rest/service/submit");
$urlSubmitGet->query_form(
        'analyses' => 'CHASM',
        'analysistype' => 'driver',
        'chasmclassifier' => 'Ovary',
        'email' => 'testUser@testemailservice.com',
        'functionalannotation' => 'off',
        'hg18' => 'off',
        'mutations' => 'TR1 chr22 30421786 + A T',
        'mupitinput' => 'off',
        'tsvreport' => 'off');
my $responseSubmitGet = $browser->get($urlSubmitGet);
print $responseSubmitGet->content, "\n";

#
# Job submission example, when the mutations are in a file
#
print "\n###### Submitting through POST #####\n";
my $urlSubmitPost = "http://www.cravat.us/rest/service/submit";
my $responseSubmitPost = $browser->post($urlSubmitPost,
        Content_Type => 'form-data',
        Content => [
        'analyses' => 'CHASM',
        'analysistype' => 'driver',
        'chasmclassifier' => 'Ovary',
        'email' => 'testUser@testemailservice.com',
        'functionalannotation' => 'off',
        'hg18' => 'off',
        'mupitinput' => 'off',
        'tsvreport' => 'off',
        'inputfile' => ['/home/testUser/mutations.txt']]);
print $responseSubmitPost->content, "\n";

#
# Job status checking example
#
print "##### Job Status Checking #####\n";
my $urlStatus = URI->new('http://www.cravat.us/rest/service/status');
$urlStatus->query_form('jobid' => 'testUser_20140430_110005');
my $responseStatus = $browser->get($urlStatus);
print $responseStatus->content, "\n";

Hope this helps and if you have any question, please let me know.

Thank You for kind reply.

I have got following error:

I am also using proxy setting in your script.

###### Submitting through POST #####

{"email":"user@domain.in","classifier":"Head and Neck","hg18":"off","mutations":"","status":"submissionfailed","success":0,"runtimeinsecond":0,"chasm":false,"vest":false,"snvget":false,"geneannot":false,"server":null,"jobid":"chetan_20140501_003611","resultfileurl":"","analysistype":"driver","analyses":"CHASM;","tsvreport":"on","functionalannot":"off","mupitinput":"off","mutationbasename":"BVJ.somatic.cravat","noinputline":1891,"clientip":"128.220.76.161","errormsg":"Job submission failed at method retUploadNSyscall.","webservicesubmission":"on","mutationfilename":"/export/karchin-web02/CRAVAT/tomcat/webapps/CRAVAT_RESULT/chetan_20140501_003611/BVJ.somatic.cravat","submittime":null,"starttime":null,"stoptime":null,"inputcoordinate":null,"logurl":null,"mutationfileurl":null,"infoerrorfileurl":null,"chasmerrorfileurl":null,"snvgeterrorfileurl":null,"vesterrorfileurl":null}

Hi Chetan,

I looked at your perl script. The classifier name should be "Head-and-Neck" (as shown in http://www.cravat.us) instead of "Head and Neck" and I could run the script only by removing the proxy setup command.

Rick

You can use my Python wrappers:

https://github.com/saketkc/galaxy_tools/tree/master/chasm_webservice

Thank You for kind reply.

i incorporated into galaxy, i got following error:

Traceback (most recent call last):
  File "/home/ganit/galaxy_work/galaxy-dist/tools/chasm_webservice/chasm_webservice.py", line 279, in <module>
    main(sys.argv[1:])
  File "/home/ganit/galaxy_work/galaxy-dist/tools/chasm_webservice/chasm_webservice.py", line 263, in main
    job_id = chasm_web.make_request()
  File "/home/ganit/galaxy_work/galaxy-dist/tools/chasm_webservice/chasm_webservice.py", line 149, in make_request
    __URL__, data=stripped_data, files=file_payload)
  File "/usr/lib/python2.7/dist-packages/requests/api.py", line 111, in post
    return request('post', url, data=data, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/api.py", line 65, in request
    prefetch=prefetch
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 191, in request
    r.send(prefetch=prefetch)
  File "/usr/lib/python2.7/dist-packages/requests/models.py", line 453, in send
    raise ConnectionError(e)
requests.exceptions.ConnectionError: Max retries exceeded for url: /rest/service/submit

you need to use a web client like curl. Something like:

$ curl -F analyses=VEST -F analysistype=functional -F email=me@nowhere.com -F inputfile=@input.txt "http://www.cravat.us/rest/service/submit" | python -m json.tool

returns:

{
    "logurl": null,
    "mupitinput": "off",
    "mutationbasename": "",
    "mutationfilename": null,
    "mutationfileurl": null,
    "mutations": "",
    "noinputline": 0,
    "resultfileurl": "",
    "runtimeinsecond": 0,
    "server": null,
    "snvget": false,
    "snvgeterrorfileurl": null,
    "starttime": null,
    "status": "submissionfailed",
    "stoptime": null,
    "submittime": null,
    "success": 0,
    "tsvreport": "off",
    "vest": false,
    "vesterrorfileurl": null,
    "webservicesubmission": null
}

I don't have the time to check all the parameters, but you get the idea .

Thank for the idea. I have to add @ before the input.txt for it to work. Otherwise, it shows errormsg as "there is no input mutation"

Thank You for your kind reply,

I have tried your method, firstly I don't understand what is json.tool hence i wrote following text in json.tool:

{
"analysis" : "CHASM",
"analysistype" : "driver",
"chasmclassifier" : "Head and Neck",
"email" : "dokadya@gmail.com",
"functionalannotation": "on",
"hg18": "off",
"inputfile" : "/media/storage1/chetan/Ganit/Galaxy/cravat/somaticCravat/BVJ.somatic.cravat",
"mupitinput" : "on",
"tsvreport" : "on"
}

And my command is :

$ curl -F analyses=CHASM -F analysistype=driver -F chasmclassifier="Head and Neck" -F email=user@domain.in -F functionalannotation=on -F hg18=off   -F inputfile=somaticCravat/BVJ.somatic.cravat   "http://www.cravat.us/rest/service/submit" -F   mupitinput=on -F  tsvreport=on  | python -m json.tool


  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1766    0   744  100  1022    598    821  0:00:01  0:00:01 --:--:--   822
{
    "analyses": "CHASM", 
    "analysistype": "driver", 
    "chasm": false, 
    "chasmerrorfileurl": null, 
    "classifier": "Head and Neck", 
    "clientip": "128.220.76.162", 
    "email": "user@domain.in", 
    "errormsg": "There is no input mutation.", 
    "functionalannot": "off", 
    "geneannot": false, 
    "hg18": "off", 
    "infoerrorfileurl": null, 
    "inputcoordinate": null, 
    "jobid": "chetan_20140430_042120", 
    "logurl": null, 
    "mupitinput": "on", 
    "mutationbasename": "", 
    "mutationfilename": null, 
    "mutationfileurl": null, 
    "mutations": "", 
    "noinputline": 0, 
    "resultfileurl": "", 
    "runtimeinsecond": 0, 
    "server": null, 
    "snvget": false, 
    "snvgeterrorfileurl": null, 
    "starttime": null, 
    "status": "submissionfailed", 
    "stoptime": null, 
    "submittime": null, 
    "success": 0, 
    "tsvreport": "on", 
    "vest": false, 
    "vesterrorfileurl": null, 
    "webservicesubmission": null
}

Now,

After adding @ before path of input file

$ curl -F analyses=CHASM -F analysistype=driver -F chasmclassifier="Head and Neck" -F email=user@domain.in -F functionalannotation=on -F hg18=off   -F inputfile=@/media/storage1/chetan/Ganit/Galaxy/cravat/somaticCravat/BVJ.somatic.cravat  -F   mupitinput=on -F  tsvreport=on -F chasm=true "http://www.cravat.us/rest/service/submit" | python -mjson.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 58244    0   886  100 57358    257  16673  0:00:03  0:00:03 --:--:-- 16678
{
    "analyses": "CHASM;", 
    "analysistype": "driver", 
    "chasm": false, 
    "chasmerrorfileurl": null, 
    "classifier": "Head and Neck", 
    "clientip": "128.220.76.162", 
    "email": "user@domain.in", 
    "errormsg": "Job submission failed at method retUploadNSyscall.", 
    "functionalannot": "off", 
    "geneannot": false, 
    "hg18": "off", 
    "infoerrorfileurl": null, 
    "inputcoordinate": null, 
    "jobid": "chetan_20140501_020418", 
    "logurl": null, 
    "mupitinput": "on", 
    "mutationbasename": "BVJ.somatic.cravat", 
    "mutationfilename": "/export/karchin-web02/CRAVAT/tomcat/webapps/CRAVAT_RESULT/chetan_20140501_020418/BVJ.somatic.cravat", 
    "mutationfileurl": null, 
    "mutations": "", 
    "noinputline": 1891, 
    "resultfileurl": "", 
    "runtimeinsecond": 0, 
    "server": null, 
    "snvget": false, 
    "snvgeterrorfileurl": null, 
    "starttime": null, 
    "status": "submissionfailed", 
    "stoptime": null, 
    "submittime": null, 
    "success": 0, 
    "tsvreport": "on", 
    "vest": false, 
    "vesterrorfileurl": null, 
    "webservicesubmission": "on"
}

Waiting for Positive reply.

Thank You.

The JSON object in your question is malformed:

{
    "analysis": "CHASM",
    "analysistype" : "driver",
    "chasmclassifier" : "Head and Neck",
    "email" : "dokadya@gmail.com"
    "functionalannotation" : "on",
    "hg18" : "off",
    "inputfile" : "/media/storage1/SAMPLE_NAME_1.cravat",
    "mupitinput" : "on",
    "tsvreport" : "on"
}

Note the lack of a comma after the email key-value pair. Try using a website like JSONLint or a similar tool to validate your JSON object, before using it as input.

Thank You for your kind reply. I validated json.tool file and its correct now. Still having same error as above. Please check command, its output and json.tool file:

curl -F analyses=CHASM -F analysistype=driver -F chasmclassifier="Head and Neck" -F email=dokadya@gmail.com -F functionalannotation=on -F hg18=off   -F inputfile=@/media/storage1/chetan/Ganit/Galaxy/cravat/somaticCravat/BVJ.somatic.cravat  -F   mupitinput=on -F  tsvreport=on -F chasm=true "http://www.cravat.us/rest/service/submit" | python -mjson.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 58246    0   887  100 57359    274  17742  0:00:03  0:00:03 --:--:-- 17741
{
    "analyses": "CHASM;", 
    "analysistype": "driver", 
    "chasm": false, 
    "chasmerrorfileurl": null, 
    "classifier": "Head and Neck", 
    "clientip": "128.220.76.162", 
    "email": "dokadya@gmail.com", 
    "errormsg": "Job submission failed at method retUploadNSyscall.", 
    "functionalannot": "off", 
    "geneannot": false, 
    "hg18": "off", 
    "infoerrorfileurl": null, 
    "inputcoordinate": null, 
    "jobid": "chetan_20140501_023343", 
    "logurl": null, 
    "mupitinput": "on", 
    "mutationbasename": "BVJ.somatic.cravat", 
    "mutationfilename": "/export/karchin-web02/CRAVAT/tomcat/webapps/CRAVAT_RESULT/chetan_20140501_023343/BVJ.somatic.cravat", 
    "mutationfileurl": null, 
    "mutations": "", 
    "noinputline": 1891, 
    "resultfileurl": "", 
    "runtimeinsecond": 0, 
    "server": null, 
    "snvget": false, 
    "snvgeterrorfileurl": null, 
    "starttime": null, 
    "status": "submissionfailed", 
    "stoptime": null, 
    "submittime": null, 
    "success": 0, 
    "tsvreport": "on", 
    "vest": false, 
    "vesterrorfileurl": null, 
    "webservicesubmission": "on"
}

json.tool file:

{
"analysis" : "CHASM",
"analysistype" : "driver",
"chasmclassifier" : "Head and Neck",
"email" : "dokadya@gmail.com",
"functionalannotation": "on",
"hg18": "off",
"inputfile" : "/media/storage1/chetan/Ganit/Galaxy/cravat/somaticCravat/BVJ.somatic.cravat",
"mupitinput" : "on",
"tsvreport" : "on"
}

Waiting for positive reply.

First, please check your input file. Here's an example input (cravatinput.txt)

#UID / Transcript / AA change / Sample ID (optional)
TR1     NM_001126116.1  D127Y   TCGA-02-0231
TR2     NM_001144919.1  R162Q   TCGA-02-3512
TR3     NM_000321.2     Q702K   TCGA-02-3532
TR4     NM_000245.2     A1108S  TCGA-02-1523
TR5     NM_004333.4     V600E   TCGA-02-0023
TR6     NM_001005862.1  G746V   TCGA-02-0252

Here's my command line:

curl -F analyses=CHASM -F analysistype=driver -F email=me@nowhere.com -F inputfile=@cravatinput.txt "http://www.cravat.us/rest/service/submit" | python -m json.tool

Output:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1590    0   802  100   788    538    529  0:00:01  0:00:01 --:--:--   607
{
    "analyses": "CHASM;",
    "analysistype": "driver",
    "chasm": false,
    "chasmerrorfileurl": null,
    "classifier": "Other",
    "clientip": "128.220.76.162",
    "email": "me@nowhere.com",
    "errormsg": "",
    "functionalannot": "off",
    "geneannot": false,
    "hg18": "off",
    "infoerrorfileurl": null,
    "inputcoordinate": null,
    "jobid": "me_20140501_113024",
    "logurl": null,
    "mupitinput": "off",
    "mutationbasename": "cravatinput.txt",
    "mutationfilename": "/export/karchin-web02/CRAVAT/tomcat/webapps/CRAVAT_RESULT/me_20140501_113024/cravatinput.txt",
    "mutationfileurl": null,
    "mutations": "",
    "noinputline": 7,
    "resultfileurl": "",
    "runtimeinsecond": 0,
    "server": null,
    "snvget": false,
    "snvgeterrorfileurl": null,
    "starttime": null,
    "status": "submitted",
    "stoptime": null,
    "submittime": null,
    "success": 0,
    "tsvreport": "off",
    "vest": false,
    "vesterrorfileurl": null,
    "webservicesubmission": "on"
}

Then, you can check job status by jobid

curl http://www.cravat.us/rest/service/status?jobid=me_20140501_113024 | python -m json.tool

Second, json.tool is from Json python module for pretty printing. You don't need to have json.tool file.

this is same question as in seqanswer.com

http://seqanswers.com/forums/showthread.php?p=139107#post139107

Use this tool to validate JSON: JSON Parser

I am in fact Thankful to the owner of this site who has shared this impressive article. CheatHacker

Log in to answer this question.