R/openGraph.R

Defines functions openGraph

Documented in openGraph

#' openGraph
#'
#' Send the JSONFile to http://labpib.fmrp.usp.br/ web server and
#' to visualize a dynamic graph in the web browser. 
#'
#' @param JSONFile a file generated by createJSONToCytoscape function. 
#' @param classTable classification table generated by export.class.table function. 
#' @param openBrowser logical if FALSE, returns a URL link, if TRUE opens
#' the web browser to access graph visualization.
#'
#' @export

openGraph <- function(JSONFile, classTable=NULL, openBrowser=FALSE){
 # require(RCurl)

 
  if(is.null(classTable)){
    r = postForm("http://labpib.fmrp.usp.br:8888/upload", a="Test", fileUpload(filename=JSONFile) )
  }
  else{
 	for(i in 1:nrow(classTable)) if(classTable[i,1]=="") classTable[i,c(1,4,6,7)] <- classTable[i-1,c(1,4,6,7)]
	msel <- as.matrix(classTable[,1:7])
	msel <- cbind(msel[,6], msel[,-6])
	colnames(msel)[1] <- "Id"
	msel[,1] <- as.numeric(sub("^\\s+","", msel[,1]))
	if(sum(colnames(msel)=="none") ) msel <- msel[,-which(colnames(msel)=="none")] 
	write.csv(msel, file="att2.csv") 
    r = postForm("http://labpib.fmrp.usp.br:8888/upload", a="Test", fileUpload(filename=JSONFile), fileUpload(filename="att2.csv")  )
    file.remove("att2.csv") 
  }
  if(openBrowser){
    browseURL(r[[1]]);
  }else{return(paste("Your Graph URL is: ", r[[1]], sep="")) }
}
rsilvabioinfo/ProbMetab documentation built on May 28, 2019, 3:32 a.m.