[CHNOSZ-commits] r113 - in pkg/CHNOSZ: . R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Aug 26 14:52:36 CEST 2016


Author: jedick
Date: 2016-08-26 14:52:36 +0200 (Fri, 26 Aug 2016)
New Revision: 113

Modified:
   pkg/CHNOSZ/DESCRIPTION
   pkg/CHNOSZ/R/basis.R
   pkg/CHNOSZ/R/util.fasta.R
   pkg/CHNOSZ/inst/NEWS
   pkg/CHNOSZ/man/basis.Rd
Log:
improved error handling in uniprot.aa(); add "AA" preset to basis()


Modified: pkg/CHNOSZ/DESCRIPTION
===================================================================
--- pkg/CHNOSZ/DESCRIPTION	2016-05-28 16:49:49 UTC (rev 112)
+++ pkg/CHNOSZ/DESCRIPTION	2016-08-26 12:52:36 UTC (rev 113)
@@ -1,6 +1,6 @@
-Date: 2016-05-28
+Date: 2016-08-26
 Package: CHNOSZ
-Version: 1.0.8
+Version: 1.0.8-1
 Title: Chemical Thermodynamics and Activity Diagrams
 Author: Jeffrey Dick
 Maintainer: Jeffrey Dick <j3ffdick at gmail.com>

Modified: pkg/CHNOSZ/R/basis.R
===================================================================
--- pkg/CHNOSZ/R/basis.R	2016-05-28 16:49:49 UTC (rev 112)
+++ pkg/CHNOSZ/R/basis.R	2016-08-26 12:52:36 UTC (rev 113)
@@ -94,7 +94,7 @@
 # to load a preset basis definition by keyword
 preset.basis <- function(key=NULL) {
   # the available keywords
-  basis.key <- c("CHNOS", "CHNOS+", "CHNOSe", "CHNOPS+", "MgCHNOPS+", "FeCHNOS", "FeCHNOS+")
+  basis.key <- c("CHNOS", "CHNOS+", "CHNOSe", "CHNOPS+", "MgCHNOPS+", "FeCHNOS", "FeCHNOS+", "AA")
   # just list the keywords if none is specified
   if(is.null(key)) return(basis.key)
   # delete any previous basis definition
@@ -109,6 +109,7 @@
   else if(ibase==5) species <- c("Mg+2", "CO2", "H2O", "NH3", "H3PO4", "H2S", "e-", "H+")
   else if(ibase==6) species <- c("Fe2O3", "CO2", "H2O", "NH3", "H2S", "oxygen")
   else if(ibase==7) species <- c("Fe2O3", "CO2", "H2O", "NH3", "H2S", "oxygen", "H+")
+  else if(ibase==8) species <- c("cysteine", "glutamic acid", "glutamine", "H2O", "oxygen")
   # get the preset logact
   logact <- preset.logact(species)
   # load the species and return the result
@@ -117,8 +118,10 @@
 
 # logarithms of activities for preset basis definitions
 preset.logact <- function(species) {
-  bases <- c('H2O','CO2','NH3','H2S','oxygen','H+','e-','Fe2O3')
-  logact <- c(0,-3,-4,-7,-80,-7,-7,0)
+  bases <- c("H2O", "CO2", "NH3", "H2S", "oxygen", "H+", "e-", "Fe2O3",
+             "cysteine", "glutamic acid", "glutamine")
+  logact <- c(0, -3, -4, -7, -80, -7, -7, 0,
+              -4, -4, -4)
   ibase <- match(species, bases)
   logact <- logact[ibase]
   # any unmatched species gets a logarithm of activity of -3

Modified: pkg/CHNOSZ/R/util.fasta.R
===================================================================
--- pkg/CHNOSZ/R/util.fasta.R	2016-05-28 16:49:49 UTC (rev 112)
+++ pkg/CHNOSZ/R/util.fasta.R	2016-08-26 12:52:36 UTC (rev 113)
@@ -147,11 +147,16 @@
   URLstuff <- try(readLines(proteinURL),TRUE)
   options(oldopt)
   if(class(URLstuff)=="try-error") {
-    msgout(" failed\n")
+    msgout(" ::: FAILED :::\n")
     return(NA)
   }
   # 20091102: look for a link to a fasta file
-  linkline <- URLstuff[[grep("/uniprot/.*fasta", URLstuff)[1]]]
+  link <- grep("/uniprot/.*fasta", URLstuff)
+  if(length(link) > 0) linkline <- URLstuff[[link[1]]]
+  else {
+    msgout(" ::: FAILED :::\n")
+    return(NA)
+  }
   # extract accession number from the link
   linkhead <- strsplit(linkline, ".fasta", fixed=TRUE)[[1]][1]
   accession.number <- tail(strsplit(linkhead, "/uniprot/", fixed=TRUE)[[1]], 1)
@@ -159,21 +164,19 @@
   # now download the fasta file
   fastaURL <- paste("http://www.uniprot.org/uniprot/", accession.number, ".fasta", sep="")
   URLstuff <- readLines(fastaURL)
-  # show the name of the protein to the user
+  # get the header information / show  the user
   header <- URLstuff[[1]]
-  header2 <- strsplit(header, paste(protein, ""))[[1]][2]
-  header3 <- strsplit(header2, " OS=")[[1]]
-  protein.name <- header3[1]
-  header4 <- strsplit(header3[2], " GN=")[[1]][1]
-  header5 <- strsplit(header4[1], " PE=")[[1]]
-  organism.name <- header5[1]
-  msgout("uniprot.aa: ", protein.name, " from ", organism.name)
+  header3 <- strsplit(header, "|", fixed=TRUE)[[1]][3]
+  headerP_O <- strsplit(header3, " ")[[1]][1]
+  header.id <- strsplit(header, headerP_O)[[1]][1]
+  header.id <- substr(header.id, 2, nchar(header.id)-1)
+  header.organism <- strsplit(headerP_O, "_")[[1]][2]
+  msgout(paste0(header))
   # 20130206 use read.fasta with lines, start, stop arguments
   aa <- read.fasta(file="", lines=URLstuff, start=start, stop=stop)
   msgout(" (length ", sum(aa[1, 6:25]), ")\n", sep="")
-  po <- strsplit(protein, "_")[[1]]
-  aa$protein <- po[1]
-  aa$organism <- po[2]
+  aa$protein <- header.id
+  aa$organism <- header.organism
   return(aa)
 }
 

Modified: pkg/CHNOSZ/inst/NEWS
===================================================================
--- pkg/CHNOSZ/inst/NEWS	2016-05-28 16:49:49 UTC (rev 112)
+++ pkg/CHNOSZ/inst/NEWS	2016-08-26 12:52:36 UTC (rev 113)
@@ -1,3 +1,10 @@
+CHANGES IN CHNOSZ 1.0.8-1 (2016-08-26)
+--------------------------------------
+
+- Add "AA" as a keyword for preset species in basis() (cysteine,
+  glutamic acid, glutamine, H2O, oxygen).
+
+
 CHANGES IN CHNOSZ 1.0.8 (2016-05-28)
 ------------------------------------
 

Modified: pkg/CHNOSZ/man/basis.Rd
===================================================================
--- pkg/CHNOSZ/man/basis.Rd	2016-05-28 16:49:49 UTC (rev 112)
+++ pkg/CHNOSZ/man/basis.Rd	2016-08-26 12:52:36 UTC (rev 113)
@@ -59,6 +59,7 @@
                         \eqn{\mathrm{NH_3}}{NH3}, \eqn{\mathrm{H_2S}}{H2S}, \eqn{\mathrm{O_2}}{O2} \cr
     \code{FeCHNOS+} \tab \eqn{\mathrm{Fe_2O_3}}{Fe2O3}, \eqn{\mathrm{CO_2}}{CO2}, \eqn{\mathrm{H_2O}}{H2O}, 
                          \eqn{\mathrm{NH_3}}{NH3}, \eqn{\mathrm{H_2S}}{H2S}, \eqn{\mathrm{O_2}}{O2}, \eqn{\mathrm{H^+}}{H+} \cr
+    \code{AA} \tab cysteine, glutamic acid, glutamine, \eqn{\mathrm{H_2O}}{H2O}, \eqn{\mathrm{O_2}}{O2} \cr
   }
 
 }



More information about the CHNOSZ-commits mailing list