[BioC] PostForm() with KEGG

Duncan Temple Lang duncan at wald.ucdavis.edu
Fri Feb 24 22:09:19 CET 2012


Hi Avoks

While the form is provided by KEGG and so bio-relatd,
you might have been better posting this to the more general r-help mailing list.


You are posting the HTTP request to the wrong URL. That is the URL
of the Web page that displays the form, not the URL that processes
the input from the form.
You have to look at the JavaScript that is referenced in the action
attribute of the HTML form element.

The second issue is that you are submitting the name of a local file.
This won't work as is.  You either need to identify this is the name of a file and not the contents
of the file to send, or else send the contents.  In this form, you can send the
contents via the the unclassified parameter.


u = "http://www.genome.jp/kegg-bin/search_pathway_object"
data = postForm(u,
                .params = list(org_name = "hsadd",
                               unclassified = "hsa:7167 hsa:GPI cpd:C00118\nALDOA 1.2.1.12 C00236",
                               file = "", submit = "Exec"))


If your input is in a file, you can use

  unclassified = paste(readLines(file.choose()), collapse = "\n")

as the value for the unclassified parameter.


There are additional parameters that the form accepts that may be relevant for your search.


As for processing the results, you will want to use

  doc = htmlParse(data, asText = TRUE)

and then use getNodeSet()/xpathSApply() or direct tree extraction to access the nodes you want, e.g.

  xpathSApply(doc, "//li/a",  xmlGetAttr, "href")


 D.


On 2/24/12 6:09 AM, Ovokeraye Achinike-Oduaran wrote:
> Hi all,
> 
> I am trying to use postForm() with the KEGG website but I am stuck on
> how to get my results. Is it possible (code below) or am I using
> postForm() wrongly? The code appears to run but I'm not quite sure how
> to read the results assuming there are any. Please help.
> 
> Thanks.
> 
> Avoks
> ____
> 
> data = postForm("http://www.genome.jp/kegg/tool/map_pathway1.html",
> org_name = "hsadd",
> file = file.choose(),
> submit = "Exec")
> 
>> sessionInfo()
> R version 2.14.1 (2011-12-22)
> Platform: i386-pc-mingw32/i386 (32-bit)
> 
> locale:
> [1] LC_COLLATE=English_xxx.1252  LC_CTYPE=English_xxx.1252
> [3] LC_MONETARY=English_xxx.1252 LC_NUMERIC=C
> [5] LC_TIME=English_xxx.1252
> 
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
> 
> other attached packages:
> [1] RHTMLForms_0.5-1 XML_3.9-4.1      RCurl_1.91-1.1   bitops_1.0-4.1
> 
> loaded via a namespace (and not attached):
> [1] tools_2.14.1
> 
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor



More information about the Bioconductor mailing list