0

So I had a number of amino acid sequence strings that I wanted to use as input into a tool that studies its interactions with certain components of the human immune system (http://www.cbs.dtu.dk/services/NetMHCcons/).

I wanted to ask what, if any, would be a way of accessing, inputting data and getting the output, via a script (R or python preferably). My main issue was I had a lot of sequences that need to be queried separately so wanted to automate the whole thing. The website has one field that reads "Submission" which takes in the string input. There is another field "select species/loci" which gives a drop down menu from which an option needs to be selected. Lastly there's a "submit" button. The output simply loads on the page after hitting submit.

I've tentatively poked around with RSelenium and Rcurl but wanted to ask if there was a more efficient method.

Saam_H
  • 11

2 Answers2

1

I took a look at what it'd take to send a POST request to this service from Python, and it looks possible:

  • this form takes in "multipart/form-data" (see: How to send a "multipart/form-data" with requests in python?), you'll need to send your data in this format. You could inspect a request from the browser (using the dev tools) and copy the fields from there as a starting point.
  • once the form is submitted, it doesn't give you the result right away. You'd need to get your job ID from the response, and then poll the URL: http://www.cbs.dtu.dk/cgi-bin/webface2.fcgi?jobid={your_job_id}&wait=20 until it gives you the result
  • the result will then need to be downloaded and parsed

This tool is however available as a portable version for linux/mac: https://services.healthtech.dtu.dk/software.php

Perhaps downloading this version would make it easier?

dcollien
  • 1,394
  • 1
  • 9
  • 6
0

Try this : Submitting to a web form using python This link is an answer to how to send web forms in python, using urllib. Check your source code and extract the necessary data using re module from the source code of the link you have put up, and send the request. save the HTML source code of http://www.cbs.dtu.dk/services/NetMHCcons/ in the python file as

source_code = '''...'''

The HTML can be found by using CTRL+U in firefox.

Roshin Raphel
  • 2,612
  • 4
  • 22
  • 40