Skip to content

Instantly share code, notes, and snippets.

@ariutta
Last active April 10, 2019 17:33
Show Gist options
  • Save ariutta/8712a1de67d2919e613e17cd112f44ee to your computer and use it in GitHub Desktop.
Save ariutta/8712a1de67d2919e613e17cd112f44ee to your computer and use it in GitHub Desktop.
Issue with creating/updating network on NDEx
# ndexr relies on httr but doesn't handle importing it
library(httr)
library(ndexr)
NDEX_USER <- Sys.getenv("NDEX_USER")
NDEX_PWD <- Sys.getenv("NDEX_PWD")
NETWORK_ID <- '37800bb2-5bb4-11e9-831d-0660b7976219'
ndexcon <- NA
if (NDEX_USER == '' || NDEX_PWD == '') {
message <- 'Error: environment variables NDEX_USER and/or NDEX_PWD not set.'
write(message, stderr())
write('In your terminal, run:', stderr())
write('export NDEX_USER=\'your-ndex-username\'', stderr())
write('export NDEX_PWD=\'your-ndex-password\'', stderr())
stop(message)
} else {
ndexcon <- ndex_connect(username=NDEX_USER, password=NDEX_PWD, host="dev2.ndexbio.org", ndexConf=ndex_config$Version_2.0)
}
tryCatch({
ndex_network_set_systemProperties(ndexcon, NETWORK_ID, readOnly=FALSE)
}, warning = function(w) {
write(paste("Warning making network editable in download_upload.R:", w, sep = '\n'), stderr())
NA
}, error = function(err) {
write(paste("Error making network editable in download_upload.R:", err, sep = '\n'), stderr())
NA
}, finally = {
# Do something
})
rcx <- ndex_get_network(ndexcon, NETWORK_ID)
networkIdCreated <- ndex_create_network(ndexcon, rcx)
print(networkIdCreated)
#networkIdUpdated <- ndex_update_network(ndexcon, rcx, NETWORK_ID)
#print(networkIdUpdated)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment