From 6049d5b5c46aa27184e3e21191bfe64aa04b081f Mon Sep 17 00:00:00 2001 From: Ahmed Mohamed Date: Wed, 27 Nov 2024 22:30:55 +1100 Subject: [PATCH] fixes for R_NO_REMAP --- .github/workflows/check-bioc.yml | 8 +- DESCRIPTION | 2 +- src/handlesegfault.c | 4 +- src/init.h | 4 + src/kgml_interface.cpp | 174 +++++++++++++++---------------- src/methods.cpp | 14 +-- src/sbml_interface.cpp | 120 ++++++++++----------- 7 files changed, 165 insertions(+), 161 deletions(-) diff --git a/.github/workflows/check-bioc.yml b/.github/workflows/check-bioc.yml index d842a0b..def2ce3 100644 --- a/.github/workflows/check-bioc.yml +++ b/.github/workflows/check-bioc.yml @@ -51,10 +51,10 @@ jobs: fail-fast: false matrix: config: - - { os: ubuntu-latest, r: 'devel', bioc: '3.20', cont: "bioconductor/bioconductor_docker:devel", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" } - - { os: ubuntu-latest, r: '4.4', bioc: '3.19', cont: "bioconductor/bioconductor_docker:RELEASE_3_19", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" } - - { os: macOS-latest, r: '4.4', bioc: '3.19'} - - { os: windows-latest, r: '4.4', bioc: '3.19'} + - { os: ubuntu-latest, r: 'devel', bioc: '3.21', cont: "bioconductor/bioconductor_docker:devel", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" } + - { os: ubuntu-latest, r: '4.4', bioc: '3.20', cont: "bioconductor/bioconductor_docker:RELEASE_3_20", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" } + - { os: macOS-latest, r: '4.4', bioc: '3.20'} + - { os: windows-latest, r: '4.4', bioc: '3.20'} env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true RSPM: ${{ matrix.config.rspm }} diff --git a/DESCRIPTION b/DESCRIPTION index a794f4a..e72be25 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: NetPathMiner -Version: 1.43.0 +Version: 1.43.1 Date: 2014 onwards Title: NetPathMiner for Biological Network Construction, Path Mining and Visualization diff --git a/src/handlesegfault.c b/src/handlesegfault.c index 65e285e..92cdfde 100755 --- a/src/handlesegfault.c +++ b/src/handlesegfault.c @@ -6,13 +6,13 @@ #ifndef WIN_COMPILE #ifdef HAVE_XML void segfault_KGML(int signal, siginfo_t *si, void *arg){ - EVAL(lang2(install("registerMemoryErr"), mkString("KGML2igraph"))); + EVAL(Rf_lang2(Rf_install("registerMemoryErr"), Rf_mkString("KGML2igraph"))); error("Critical memory error in KGML2igraph. Please save your work and restart R."); } #endif #ifdef HAVE_SBML void segfault_SBML(int signal, siginfo_t *si, void *arg){ - EVAL(lang2(install("registerMemoryErr"), mkString("SBML2igraph"))); + EVAL(Rf_lang2(Rf_install("registerMemoryErr"), Rf_mkString("SBML2igraph"))); error("Critical memory error in SBML2igraph. Please save your work and restart R."); } #endif diff --git a/src/init.h b/src/init.h index 7f5a902..d5a0be4 100755 --- a/src/init.h +++ b/src/init.h @@ -12,6 +12,10 @@ using namespace std; #endif //__cplusplus +#ifndef R_NO_REMAP +#define R_NO_REMAP +#endif + #include #include #include diff --git a/src/kgml_interface.cpp b/src/kgml_interface.cpp index 3bfeef0..1f3195f 100755 --- a/src/kgml_interface.cpp +++ b/src/kgml_interface.cpp @@ -46,7 +46,7 @@ SEXP readkgmlfile(SEXP FILENAME, SEXP VERBOSE) { /* Load XML document */ doc = xmlParseFile(filename); if (doc == NULL) { - Rf_warningcall(mkChar(filename), "Unable to parse file"); + Rf_warningcall(Rf_mkChar(filename), "Unable to parse file"); if(verbose) Rprintf(": Error.\n"); return(R_NilValue); } @@ -56,7 +56,7 @@ SEXP readkgmlfile(SEXP FILENAME, SEXP VERBOSE) { strcmp( (char *) (doc->intSubset->name), "pathway") != 0 ) //strncmp( (char *) (doc->intSubset->SystemID), "http://www.kegg.jp/kegg/", 24) !=0) { - Rf_warningcall(mkChar(filename), "File is not KEGG pathway file"); + Rf_warningcall(Rf_mkChar(filename), "File is not KEGG pathway file"); xmlFreeDoc(doc); if(verbose) Rprintf(": Error.\n"); return(R_NilValue); @@ -65,14 +65,14 @@ SEXP readkgmlfile(SEXP FILENAME, SEXP VERBOSE) { /* Get pathway information :*/ xmlNodePtr pathway = xmlDocGetRootElement(doc); if(pathway == NULL || strcmp( (char *) (pathway->name), "pathway") != 0){ - Rf_warningcall(mkChar(filename), "No pathways in file"); + Rf_warningcall(Rf_mkChar(filename), "No pathways in file"); xmlFreeDoc(doc); if(verbose) Rprintf(": Error.\n"); return(R_NilValue); } const char* pathwayId = get_attr(pathway, "name"); if(!pathwayId){ - Rf_warningcall(mkChar(filename), "Pathway ID not found in file. Using file name instead."); + Rf_warningcall(Rf_mkChar(filename), "Pathway ID not found in file. Using file name instead."); pathwayId = filename; }else{ pathwayId +=5; //Remove "path:" leading characters// @@ -80,7 +80,7 @@ SEXP readkgmlfile(SEXP FILENAME, SEXP VERBOSE) { const char* pathwayTitle = get_attr(pathway, "title"); if(!pathwayTitle){ - Rf_warningcall(mkChar(pathwayId), "Pathway title not found in file."); + Rf_warningcall(Rf_mkChar(pathwayId), "Pathway title not found in file."); pathwayTitle = ""; } if(verbose) Rprintf(" \"%s\"",pathwayTitle); @@ -88,7 +88,7 @@ SEXP readkgmlfile(SEXP FILENAME, SEXP VERBOSE) { /* Create xpath evaluation context */ xpathCtx = xmlXPathNewContext(doc); if(xpathCtx == NULL) { - Rf_warningcall(mkChar(filename), "Unable to create new XPath context"); + Rf_warningcall(Rf_mkChar(filename), "Unable to create new XPath context"); xmlFreeDoc(doc); if(verbose) Rprintf(": Error.\n"); return(R_NilValue); @@ -97,7 +97,7 @@ SEXP readkgmlfile(SEXP FILENAME, SEXP VERBOSE) { /* Evaluate xpath expression */ nodes = xmlXPathEvalExpression((xmlChar *) "//reaction", xpathCtx); if(nodes == NULL || nodes->nodesetval == NULL || nodes->nodesetval->nodeNr == 0) { - Rf_warningcall(mkChar(pathwayId), "Pathway contains no reactions"); + Rf_warningcall(Rf_mkChar(pathwayId), "Pathway contains no reactions"); xmlXPathFreeContext(xpathCtx); xmlFreeDoc(doc); if(verbose) Rprintf(": Error.\n"); @@ -112,8 +112,8 @@ SEXP readkgmlfile(SEXP FILENAME, SEXP VERBOSE) { size = (nodes->nodesetval) ? nodes->nodesetval->nodeNr : 0; SEXP REACTIONLIST,ID; - PROTECT(REACTIONLIST = allocVector(VECSXP,size)); - PROTECT(ID = allocVector(STRSXP,size)); + PROTECT(REACTIONLIST = Rf_allocVector(VECSXP,size)); + PROTECT(ID = Rf_allocVector(STRSXP,size)); if(verbose) Rprintf(": %d reactions found.\n",size); @@ -123,55 +123,55 @@ SEXP readkgmlfile(SEXP FILENAME, SEXP VERBOSE) { xpathCtx->node = curReaction; const char *name = get_attr(curReaction, "name"); - SET_STRING_ELT(ID,i,mkChar(name)); + SET_STRING_ELT(ID,i,Rf_mkChar(name)); SEXP REACTION,REACTIONNAMES; SEXP NAME, REVERSIBLE, REACTANTS, RSTOIC, PRODUCTS, PSTOIC, GENES, PATHWAY, KEGG_PATHWAY, KEGG_REACTION, KEGG_GENES, NCBI_GENE; - PROTECT(REACTION = allocVector(VECSXP,13)); - PROTECT(REACTIONNAMES = allocVector(STRSXP,13)); + PROTECT(REACTION = Rf_allocVector(VECSXP,13)); + PROTECT(REACTIONNAMES = Rf_allocVector(STRSXP,13)); - PROTECT(NAME = allocVector(STRSXP,1)); - SET_STRING_ELT(NAME,0, mkChar(name)); - SET_VECTOR_ELT(REACTION,0,NAME); SET_STRING_ELT(REACTIONNAMES,0,mkChar("name")); + PROTECT(NAME = Rf_allocVector(STRSXP,1)); + SET_STRING_ELT(NAME,0, Rf_mkChar(name)); + SET_VECTOR_ELT(REACTION,0,NAME); SET_STRING_ELT(REACTIONNAMES,0,Rf_mkChar("name")); - PROTECT(REVERSIBLE = allocVector(LGLSXP,1)); + PROTECT(REVERSIBLE = Rf_allocVector(LGLSXP,1)); LOGICAL(REVERSIBLE)[0] = strcmp(get_attr(curReaction, "type"), "irreversible") != 0; - SET_VECTOR_ELT(REACTION,1,REVERSIBLE); SET_STRING_ELT(REACTIONNAMES,1,mkChar("reversible")); + SET_VECTOR_ELT(REACTION,1,REVERSIBLE); SET_STRING_ELT(REACTIONNAMES,1,Rf_mkChar("reversible")); //cout << (char *) xmlGetProp(curReaction,(const xmlChar *)"type") <nodesetval; int numOfReactants = (reactantNodes) ? reactantNodes->nodeNr : 0; - PROTECT(REACTANTS = allocVector(STRSXP,numOfReactants)); - PROTECT(RSTOIC = allocVector(REALSXP,numOfReactants)); + PROTECT(REACTANTS = Rf_allocVector(STRSXP,numOfReactants)); + PROTECT(RSTOIC = Rf_allocVector(REALSXP,numOfReactants)); for (int r = 0;r < numOfReactants;r++) { temp = get_attr(reactantNodes->nodeTab[r], "name"); - SET_STRING_ELT(REACTANTS,r,mkChar(temp+4)); + SET_STRING_ELT(REACTANTS,r,Rf_mkChar(temp+4)); REAL(RSTOIC)[r] = NA_REAL; } - SET_VECTOR_ELT(REACTION,2,REACTANTS); SET_STRING_ELT(REACTIONNAMES,2,mkChar("reactants")); - SET_VECTOR_ELT(REACTION,3,RSTOIC);SET_STRING_ELT(REACTIONNAMES,3,mkChar("reactant.stoichiometry")); + SET_VECTOR_ELT(REACTION,2,REACTANTS); SET_STRING_ELT(REACTIONNAMES,2,Rf_mkChar("reactants")); + SET_VECTOR_ELT(REACTION,3,RSTOIC);SET_STRING_ELT(REACTIONNAMES,3,Rf_mkChar("reactant.stoichiometry")); //cout << "Reactant level :|" << endl; xmlNodeSetPtr productNodes = xmlXPathEvalExpression( (const xmlChar *) "./product", xpathCtx ) ->nodesetval; int numOfProducts = (productNodes) ? productNodes->nodeNr : 0; - PROTECT(PRODUCTS = allocVector(STRSXP,numOfProducts)); - PROTECT(PSTOIC = allocVector(REALSXP,numOfProducts)); + PROTECT(PRODUCTS = Rf_allocVector(STRSXP,numOfProducts)); + PROTECT(PSTOIC = Rf_allocVector(REALSXP,numOfProducts)); for (int p = 0;p < numOfProducts;p++) { temp = get_attr(productNodes->nodeTab[p], "name"); - SET_STRING_ELT(PRODUCTS,p,mkChar(temp+4)); + SET_STRING_ELT(PRODUCTS,p,Rf_mkChar(temp+4)); REAL(PSTOIC)[p] = NA_REAL; } - SET_VECTOR_ELT(REACTION,4,PRODUCTS); SET_STRING_ELT(REACTIONNAMES,4,mkChar("products")); - SET_VECTOR_ELT(REACTION,5,PSTOIC);SET_STRING_ELT(REACTIONNAMES,5,mkChar("product.stoichiometry")); + SET_VECTOR_ELT(REACTION,4,PRODUCTS); SET_STRING_ELT(REACTIONNAMES,4,Rf_mkChar("products")); + SET_VECTOR_ELT(REACTION,5,PSTOIC);SET_STRING_ELT(REACTIONNAMES,5,Rf_mkChar("product.stoichiometry")); //cout << "Product level :|" << endl; - SET_VECTOR_ELT(REACTION,6,R_NilValue);SET_STRING_ELT(REACTIONNAMES,6,mkChar("kinetics")); + SET_VECTOR_ELT(REACTION,6,R_NilValue);SET_STRING_ELT(REACTIONNAMES,6,Rf_mkChar("kinetics")); string geneXPath = ((string)"//entry[@type='gene' and @reaction='")+((string)name)+((string)"']"); @@ -182,43 +182,43 @@ SEXP readkgmlfile(SEXP FILENAME, SEXP VERBOSE) { for (int m = 0;m < numOfModifiers;m++) genes = split( get_attr(geneNodes->nodeTab[m], "name"), ' ', genes); - PROTECT(GENES = allocVector(STRSXP,genes.size())); - PROTECT(KEGG_GENES = allocVector(STRSXP,genes.size())); - PROTECT(NCBI_GENE = allocVector(STRSXP,genes.size())); + PROTECT(GENES = Rf_allocVector(STRSXP,genes.size())); + PROTECT(KEGG_GENES = Rf_allocVector(STRSXP,genes.size())); + PROTECT(NCBI_GENE = Rf_allocVector(STRSXP,genes.size())); for(size_t g=0; g kegg_reaction = split(name, ' '); - PROTECT(KEGG_REACTION = allocVector(STRSXP, kegg_reaction.size() )); + PROTECT(KEGG_REACTION = Rf_allocVector(STRSXP, kegg_reaction.size() )); for(size_t kr=0; kr genes = split( v_name, ' '); - PROTECT(KEGG_GENES = allocVector(STRSXP,genes.size())); - PROTECT(NCBI_GENE = allocVector(STRSXP,genes.size())); + PROTECT(KEGG_GENES = Rf_allocVector(STRSXP,genes.size())); + PROTECT(NCBI_GENE = Rf_allocVector(STRSXP,genes.size())); for(size_t g=0; gintSubset->name), "pathway") != 0 ) //strncmp( (char *) (doc->intSubset->SystemID), "http://www.kegg.jp/kegg/", 24) !=0) { - Rf_warningcall(mkChar(filename), "File is not KEGG pathway file."); + Rf_warningcall(Rf_mkChar(filename), "File is not KEGG pathway file."); xmlFreeDoc(doc); if(verbose) Rprintf(": Error.\n"); return; @@ -380,7 +380,7 @@ void readkgml_sign_int(const char* filename, /* Get pathway information :*/ xmlNodePtr pathway = xmlDocGetRootElement(doc); if(!pathway || strcmp( (char *) (pathway->name), "pathway") != 0){ - Rf_warningcall(mkChar(filename), "No pathways in file."); + Rf_warningcall(Rf_mkChar(filename), "No pathways in file."); xmlXPathFreeContext(xpathCtx); xmlFreeDoc(doc); if(verbose) Rprintf(": Error.\n"); @@ -390,7 +390,7 @@ void readkgml_sign_int(const char* filename, vector pathway_info; const char* pathwayId = get_attr(pathway, "name"); if(!pathwayId){ - Rf_warningcall(mkChar(filename), "Pathway ID not found in file. Using file name instead."); + Rf_warningcall(Rf_mkChar(filename), "Pathway ID not found in file. Using file name instead."); pathwayId = filename; }else{ pathwayId +=5; //Remove "path:" leading characters// @@ -398,7 +398,7 @@ void readkgml_sign_int(const char* filename, const char* pathwayTitle = get_attr(pathway, "title"); if(!pathwayTitle){ - Rf_warningcall(mkChar(pathwayId), "Pathway title not found in file."); + Rf_warningcall(Rf_mkChar(pathwayId), "Pathway title not found in file."); pathwayTitle = ""; } if(verbose) Rprintf(" \"%s\"",pathwayTitle); @@ -406,7 +406,7 @@ void readkgml_sign_int(const char* filename, /* Create xpath evaluation context */ xpathCtx = xmlXPathNewContext(doc); if(xpathCtx == NULL) { - Rf_warningcall(mkChar(filename), "Unable to create new XPath context."); + Rf_warningcall(Rf_mkChar(filename), "Unable to create new XPath context."); xmlFreeDoc(doc); if(verbose) Rprintf(": Error.\n"); return; @@ -415,7 +415,7 @@ void readkgml_sign_int(const char* filename, /* Evaluate xpath expression */ nodes = xmlXPathEvalExpression((xmlChar *) "//relation", xpathCtx); if(nodes == NULL || nodes->nodesetval == NULL || nodes->nodesetval->nodeNr == 0) { - Rf_warningcall(mkChar(pathwayId), "Pathway contains no Protein-protein relationships."); + Rf_warningcall(Rf_mkChar(pathwayId), "Pathway contains no Protein-protein relationships."); xmlXPathFreeContext(xpathCtx); xmlFreeDoc(doc); if(verbose) Rprintf(": Error.\n"); diff --git a/src/methods.cpp b/src/methods.cpp index e3585da..0073a91 100755 --- a/src/methods.cpp +++ b/src/methods.cpp @@ -175,7 +175,7 @@ SEXP expand_complexes(SEXP ATTR_LS, SEXP EL, SEXP V, SEXP EXPAND, SEXP MISSING){ PROTECT( PARENTS = NEW_LIST(parents.size()) ); for(size_t i=0; igetModel(); if(!model){ if(verbose) Rprintf(": Error.\n"); - Rf_warningcall(mkChar(filename), "No model in file"); + Rf_warningcall(Rf_mkChar(filename), "No model in file"); return(NEW_LIST(2)); } @@ -41,11 +41,11 @@ SEXP readsbmlfile(SEXP FILENAME, SEXP ATTR_TERMS, SEXP VERBOSE) { message<<"line "<< err->getLine() <<": "<< err->getShortMessage() << "\n"; if(err->getErrorId() == NotSchemaConformant ){ if(verbose) Rprintf(": Error.\n"); - Rf_warningcall(mkChar(filename), "%s", message.str().c_str()); + Rf_warningcall(Rf_mkChar(filename), "%s", message.str().c_str()); return(R_NilValue); } }//loop over errors. - Rf_warningcall(mkChar(filename), "%s", message.str().c_str()); + Rf_warningcall(Rf_mkChar(filename), "%s", message.str().c_str()); } @@ -59,10 +59,10 @@ SEXP readsbmlfile(SEXP FILENAME, SEXP ATTR_TERMS, SEXP VERBOSE) { //cout << "C++ returns :|" << endl; PROTECT( OUT = NEW_LIST(2) ); PROTECT( NAMES = NEW_STRING(2) ); - SET_VECTOR_ELT(OUT,0,REACTIONLIST); SET_STRING_ELT(NAMES,0,mkChar("reactions")); - SET_VECTOR_ELT(OUT,1,SPECIESFRAME); SET_STRING_ELT(NAMES,1,mkChar("species")); + SET_VECTOR_ELT(OUT,0,REACTIONLIST); SET_STRING_ELT(NAMES,0,Rf_mkChar("reactions")); + SET_VECTOR_ELT(OUT,1,SPECIESFRAME); SET_STRING_ELT(NAMES,1,Rf_mkChar("species")); - setAttrib(OUT,R_NamesSymbol,NAMES); + Rf_setAttrib(OUT,R_NamesSymbol,NAMES); UNPROTECT(4); @@ -77,12 +77,12 @@ SEXP getReactionList(Model *model, const vector &attr_terms, vectorsize()); SEXP REACTIONLIST,ID; - PROTECT(REACTIONLIST = allocVector(VECSXP, reactions->size())); + PROTECT(REACTIONLIST = Rf_allocVector(VECSXP, reactions->size())); PROTECT(ID = NEW_STRING(reactions->size())); SEXP PATHWAY; PROTECT(PATHWAY = NEW_STRING(1)); - SET_STRING_ELT(PATHWAY,0, mkChar(model->getName().c_str()) ); + SET_STRING_ELT(PATHWAY,0, Rf_mkChar(model->getName().c_str()) ); for (unsigned i = 0;i < reactions->size();i++) { Reaction *ri = reactions->get(i); @@ -99,13 +99,13 @@ SEXP getReactionList(Model *model, const vector &attr_terms, vectorgetId().c_str())); + SET_STRING_ELT(ID,i,Rf_mkChar(ri->getId().c_str())); SEXP REACTION,REACTIONNAMES; SEXP NAME, REVERSIBLE, REACTANTS, RSTOIC, PRODUCTS, PSTOIC, GENES, KINETICS,KNAMES, COMPARTMENT, COMP_NAME; PROTECT( NAME = NEW_STRING(1) ); - SET_STRING_ELT(NAME,0, mkChar(ri->getName().c_str()) ); + SET_STRING_ELT(NAME,0, Rf_mkChar(ri->getName().c_str()) ); PROTECT( REVERSIBLE = NEW_LOGICAL(1) ); LOGICAL(REVERSIBLE)[0] = ri->getReversible(); @@ -117,7 +117,7 @@ SEXP getReactionList(Model *model, const vector &attr_terms, vectorgetReactant(r)->getSpecies(); add_elem( species, sp ); - SET_STRING_ELT(REACTANTS,r,mkChar(sp.c_str())); + SET_STRING_ELT(REACTANTS,r,Rf_mkChar(sp.c_str())); REAL(RSTOIC)[r] = ri->getReactant(r)->getStoichiometry(); } //cout << "Reactant level :|" << endl; @@ -129,7 +129,7 @@ SEXP getReactionList(Model *model, const vector &attr_terms, vectorgetProduct(p)->getSpecies(); add_elem( species, sp ); - SET_STRING_ELT(PRODUCTS,p,mkChar(sp.c_str())); + SET_STRING_ELT(PRODUCTS,p,Rf_mkChar(sp.c_str())); REAL(PSTOIC)[p] = ri->getProduct(p)->getStoichiometry(); } //cout << "Product level :|" << endl; @@ -145,11 +145,11 @@ SEXP getReactionList(Model *model, const vector &attr_terms, vectorgetParameter(k)->getValue(); - SET_STRING_ELT(KNAMES,k,mkChar(kinetics->getParameter(k)->getId().c_str())); + SET_STRING_ELT(KNAMES,k,Rf_mkChar(kinetics->getParameter(k)->getId().c_str())); SET_VECTOR_ELT(KINETICS,k,value); UNPROTECT(1); } - setAttrib(KINETICS,R_NamesSymbol,KNAMES); + Rf_setAttrib(KINETICS,R_NamesSymbol,KNAMES); //cout << "kinetic level :|" << endl; int numOfModifiers = ri->getNumModifiers(); @@ -163,30 +163,30 @@ SEXP getReactionList(Model *model, const vector &attr_terms, vectorgetAnnotation(), comp_attr_terms, comp_attr, comp_attr_names); add_elem(compartment, comp->getId()); add_elem(comp_name, comp->getName()); - SET_STRING_ELT(GENES,m,mkChar(sp->getName().c_str())); + SET_STRING_ELT(GENES,m,Rf_mkChar(sp->getName().c_str())); } PROTECT(COMPARTMENT = NEW_STRING(compartment.size())); PROTECT(COMP_NAME = NEW_STRING(compartment.size())); for(size_t a=0; a< compartment.size(); a++){ - SET_STRING_ELT(COMPARTMENT,a, mkChar(compartment[a].c_str() )); - SET_STRING_ELT(COMP_NAME,a, mkChar(comp_name[a].c_str() )); + SET_STRING_ELT(COMPARTMENT,a, Rf_mkChar(compartment[a].c_str() )); + SET_STRING_ELT(COMP_NAME,a, Rf_mkChar(comp_name[a].c_str() )); } PROTECT( REACTION = NEW_LIST(attr.size() + comp_attr.size() + 11) ); PROTECT( REACTIONNAMES = NEW_STRING(attr.size() + comp_attr.size() + 11) ); - SET_VECTOR_ELT(REACTION,0,NAME); SET_STRING_ELT(REACTIONNAMES,0,mkChar("name")); - SET_VECTOR_ELT(REACTION,1,REVERSIBLE); SET_STRING_ELT(REACTIONNAMES,1,mkChar("reversible")); - SET_VECTOR_ELT(REACTION,2,REACTANTS); SET_STRING_ELT(REACTIONNAMES,2,mkChar("reactants")); - SET_VECTOR_ELT(REACTION,3,RSTOIC);SET_STRING_ELT(REACTIONNAMES,3,mkChar("reactant.stoichiometry")); - SET_VECTOR_ELT(REACTION,4,PRODUCTS); SET_STRING_ELT(REACTIONNAMES,4,mkChar("products")); - SET_VECTOR_ELT(REACTION,5,PSTOIC);SET_STRING_ELT(REACTIONNAMES,5,mkChar("product.stoichiometry")); - SET_VECTOR_ELT(REACTION,6,KINETICS);SET_STRING_ELT(REACTIONNAMES,6,mkChar("kinetics")); - SET_VECTOR_ELT(REACTION,7,GENES); SET_STRING_ELT(REACTIONNAMES,7,mkChar("genes")); - SET_VECTOR_ELT(REACTION,8,COMPARTMENT); SET_STRING_ELT(REACTIONNAMES,8,mkChar("compartment")); - SET_VECTOR_ELT(REACTION,9,COMP_NAME); SET_STRING_ELT(REACTIONNAMES,9,mkChar("compartment.name")); - SET_VECTOR_ELT(REACTION,10,PATHWAY); SET_STRING_ELT(REACTIONNAMES,10,mkChar("pathway")); + SET_VECTOR_ELT(REACTION,0,NAME); SET_STRING_ELT(REACTIONNAMES,0,Rf_mkChar("name")); + SET_VECTOR_ELT(REACTION,1,REVERSIBLE); SET_STRING_ELT(REACTIONNAMES,1,Rf_mkChar("reversible")); + SET_VECTOR_ELT(REACTION,2,REACTANTS); SET_STRING_ELT(REACTIONNAMES,2,Rf_mkChar("reactants")); + SET_VECTOR_ELT(REACTION,3,RSTOIC);SET_STRING_ELT(REACTIONNAMES,3,Rf_mkChar("reactant.stoichiometry")); + SET_VECTOR_ELT(REACTION,4,PRODUCTS); SET_STRING_ELT(REACTIONNAMES,4,Rf_mkChar("products")); + SET_VECTOR_ELT(REACTION,5,PSTOIC);SET_STRING_ELT(REACTIONNAMES,5,Rf_mkChar("product.stoichiometry")); + SET_VECTOR_ELT(REACTION,6,KINETICS);SET_STRING_ELT(REACTIONNAMES,6,Rf_mkChar("kinetics")); + SET_VECTOR_ELT(REACTION,7,GENES); SET_STRING_ELT(REACTIONNAMES,7,Rf_mkChar("genes")); + SET_VECTOR_ELT(REACTION,8,COMPARTMENT); SET_STRING_ELT(REACTIONNAMES,8,Rf_mkChar("compartment")); + SET_VECTOR_ELT(REACTION,9,COMP_NAME); SET_STRING_ELT(REACTIONNAMES,9,Rf_mkChar("compartment.name")); + SET_VECTOR_ELT(REACTION,10,PATHWAY); SET_STRING_ELT(REACTIONNAMES,10,Rf_mkChar("pathway")); // Put MIRIAM attributes in the list. int idx = 11; @@ -194,11 +194,11 @@ SEXP getReactionList(Model *model, const vector &attr_terms, vector &attr_terms, vector species, const vector PROTECT( ID = NEW_STRING(species.size()) ); for (size_t i = 0;i < species.size(); i++) { - SET_STRING_ELT(ID,i, mkChar(species[i].c_str())); + SET_STRING_ELT(ID,i, Rf_mkChar(species[i].c_str())); SET_VECTOR_ELT(SPECIESFRAME, i, get_species_info(model, species[i], attr_terms)); } - setAttrib(SPECIESFRAME,R_NamesSymbol,ID); + Rf_setAttrib(SPECIESFRAME,R_NamesSymbol,ID); UNPROTECT(2); return(SPECIESFRAME); @@ -255,7 +255,7 @@ SEXP get_species_info(Model *model, const string species, const vector & SEXP SP, SPNAMES; SEXP NAME,COMPARTMENT, COMP_NAME, PATHWAY; PROTECT(PATHWAY = NEW_STRING(1)); - SET_STRING_ELT(PATHWAY,0, mkChar(model->getName().c_str()) ); + SET_STRING_ELT(PATHWAY,0, Rf_mkChar(model->getName().c_str()) ); Species *sp = speciesList->get( species ); @@ -276,18 +276,18 @@ SEXP get_species_info(Model *model, const string species, const vector & PROTECT(NAME = NEW_STRING(1)); PROTECT(COMPARTMENT = NEW_STRING(1)); PROTECT(COMP_NAME = NEW_STRING(1)); - SET_STRING_ELT(NAME,0, mkChar(sp->getName().c_str() )); - SET_STRING_ELT(COMPARTMENT,0, mkChar(comp->getId().c_str() )); - SET_STRING_ELT(COMP_NAME,0, mkChar(comp->getName().c_str() )); + SET_STRING_ELT(NAME,0, Rf_mkChar(sp->getName().c_str() )); + SET_STRING_ELT(COMPARTMENT,0, Rf_mkChar(comp->getId().c_str() )); + SET_STRING_ELT(COMP_NAME,0, Rf_mkChar(comp->getName().c_str() )); PROTECT( SP = NEW_LIST(attr.size() + comp_attr.size() + 4) ); PROTECT( SPNAMES = NEW_STRING(attr.size() + comp_attr.size() + 4) ); - SET_VECTOR_ELT(SP, 0, NAME); SET_STRING_ELT(SPNAMES, 0, mkChar("name")); - SET_VECTOR_ELT(SP, 1, COMPARTMENT); SET_STRING_ELT(SPNAMES, 1, mkChar("compartment")); - SET_VECTOR_ELT(SP, 2, COMP_NAME); SET_STRING_ELT(SPNAMES, 2, mkChar("compartment.name")); - SET_VECTOR_ELT(SP, 3, PATHWAY); SET_STRING_ELT(SPNAMES, 3, mkChar("pathway")); + SET_VECTOR_ELT(SP, 0, NAME); SET_STRING_ELT(SPNAMES, 0, Rf_mkChar("name")); + SET_VECTOR_ELT(SP, 1, COMPARTMENT); SET_STRING_ELT(SPNAMES, 1, Rf_mkChar("compartment")); + SET_VECTOR_ELT(SP, 2, COMP_NAME); SET_STRING_ELT(SPNAMES, 2, Rf_mkChar("compartment.name")); + SET_VECTOR_ELT(SP, 3, PATHWAY); SET_STRING_ELT(SPNAMES, 3, Rf_mkChar("pathway")); // Put MIRIAM attributes in the list. int idx = 4; @@ -295,11 +295,11 @@ SEXP get_species_info(Model *model, const string species, const vector & SEXP ATTR; PROTECT( ATTR = NEW_STRING(attr[a].size()) ); for(size_t a_sub=0; a_sub< attr[a].size(); a_sub++) - SET_STRING_ELT(ATTR, a_sub, mkChar( attr[a][a_sub].c_str() )); + SET_STRING_ELT(ATTR, a_sub, Rf_mkChar( attr[a][a_sub].c_str() )); SET_VECTOR_ELT(SP, idx, ATTR); string at_name = ( ((string)"miriam.") + attr_names[a]); - SET_STRING_ELT(SPNAMES,idx,mkChar(at_name.c_str())); + SET_STRING_ELT(SPNAMES,idx,Rf_mkChar(at_name.c_str())); UNPROTECT(1); idx++; } @@ -308,11 +308,11 @@ SEXP get_species_info(Model *model, const string species, const vector & SEXP ATTR; PROTECT( ATTR = NEW_STRING(comp_attr[a].size()) ); for(size_t a_sub=0; a_sub< comp_attr[a].size(); a_sub++) - SET_STRING_ELT(ATTR, a_sub, mkChar( comp_attr[a][a_sub].c_str() )); + SET_STRING_ELT(ATTR, a_sub, Rf_mkChar( comp_attr[a][a_sub].c_str() )); SET_VECTOR_ELT(SP, idx, ATTR); string at_name = ( ((string)"compartment.miriam.") + comp_attr_names[a]); - SET_STRING_ELT(SPNAMES,idx,mkChar( at_name.c_str())); + SET_STRING_ELT(SPNAMES,idx,Rf_mkChar( at_name.c_str())); UNPROTECT(1); idx++; } @@ -320,7 +320,7 @@ SEXP get_species_info(Model *model, const string species, const vector & free_vec(comp_attr); free_vec(comp_attr_names); free_vec(comp_attr_terms); //cout<<"species"; - setAttrib(SP,R_NamesSymbol,SPNAMES); + Rf_setAttrib(SP,R_NamesSymbol,SPNAMES); UNPROTECT(6); return(SP); } @@ -351,7 +351,7 @@ SEXP readsbml_sign(SEXP FILENAME, SEXP ATTR_TERMS, SEXP VERBOSE){ Model *model = document->getModel(); if(!model){ if(verbose) Rprintf(": Error.\n"); - Rf_warningcall(mkChar(filename), "No model in file"); + Rf_warningcall(Rf_mkChar(filename), "No model in file"); continue; } @@ -366,7 +366,7 @@ SEXP readsbml_sign(SEXP FILENAME, SEXP ATTR_TERMS, SEXP VERBOSE){ fatal=true; break; } }//loop over errors. - Rf_warningcall(mkChar(filename), "%s", message.str().c_str()); + Rf_warningcall(Rf_mkChar(filename), "%s", message.str().c_str()); } if(fatal) continue; @@ -380,7 +380,7 @@ SEXP readsbml_sign(SEXP FILENAME, SEXP ATTR_TERMS, SEXP VERBOSE){ PROTECT( NONG = NEW_INTEGER(non_gene.size()) ); for(size_t i=0; i &species, vector &no SEXP INFO, NAME, NAME_; PROTECT( INFO = NEW_LIST(1) ); PROTECT( NAME = NEW_STRING(1) ); PROTECT( NAME_ = NEW_STRING(1) ); - SET_STRING_ELT(NAME,0, mkChar(ri->getName().c_str()) ); - SET_STRING_ELT(NAME_,0, mkChar("name") ); + SET_STRING_ELT(NAME,0, Rf_mkChar(ri->getName().c_str()) ); + SET_STRING_ELT(NAME_,0, Rf_mkChar("name") ); SET_VECTOR_ELT(INFO, 0, NAME); SET_NAMES(INFO, NAME_); info.push_back(INFO); UNPROTECT(2); @@ -484,7 +484,7 @@ void readsbml_sign_int(Model *model, vector &species, vector &no } const char* URL_decode(const char* URL){ - SEXP x = EVAL(lang2(install("URLdecode"), mkString(URL))); + SEXP x = EVAL(Rf_lang2(Rf_install("URLdecode"), Rf_mkString(URL))); return(CHAR(STRING_ELT(x,0))); }