[Seqinr-commits] r2111 - in pkg: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Feb 4 17:57:36 CET 2021


Author: simonpenel
Date: 2021-02-04 17:57:36 +0100 (Thu, 04 Feb 2021)
New Revision: 2111

Modified:
   pkg/DESCRIPTION
   pkg/R/ClassSeq.R
Log:
Fixing bug spotted by Jean-Baka Domelevo Entfellner in the function  summary

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2021-01-15 13:25:37 UTC (rev 2110)
+++ pkg/DESCRIPTION	2021-02-04 16:57:36 UTC (rev 2111)
@@ -1,7 +1,7 @@
 Encoding: UTF-8
 Package: seqinr
-Version: 4.2-6
-Date: 2021-01-15
+Version: 4.2-7
+Date: 2021-02-4
 Title: Biological Sequences Retrieval and Analysis
 Authors at R: c(person("Delphine", "Charif", role = "aut"),
              person("Olivier", "Clerc", role = "ctb"),

Modified: pkg/R/ClassSeq.R
===================================================================
--- pkg/R/ClassSeq.R	2021-01-15 13:25:37 UTC (rev 2110)
+++ pkg/R/ClassSeq.R	2021-02-04 16:57:36 UTC (rev 2111)
@@ -2,11 +2,11 @@
 ##########################################################################
 #
 # SeqFastadna:
-# 
+#
 
 as.SeqFastadna <- function(object, name = NULL, Annot = NULL){
   attributes(object) <- list(name = name, Annot = Annot)
-  class(object) <- "SeqFastadna"	
+  class(object) <- "SeqFastadna"
   return(object)
 }
 
@@ -14,8 +14,14 @@
 
 summary.SeqFastadna <- function(object, alphabet = s2c("acgt"), ...){
   length <- getLength(object)
+  if(nchar(object[1]) > 1) {
+  compo <- count(s2c(object), 1, alphabet = alphabet)
+  return(list(length = length , composition = compo, GC = GC(s2c(object))))
+  }
+  else {
   compo <- count(object, 1, alphabet = alphabet)
   return(list(length = length , composition = compo, GC = GC(object)))
+  }
 }
 
 #
@@ -24,7 +30,7 @@
 
 as.SeqFastaAA <- function(object, name = NULL, Annot = NULL){
   attributes(object) <- list(name = name, Annot= Annot)
-  class(object) <- "SeqFastaAA"	
+  class(object) <- "SeqFastaAA"
   return(object)
 }
 
@@ -32,8 +38,15 @@
 
 summary.SeqFastaAA <- function(object,...){
   length <- getLength(object)
-  compo <- table(factor(object, levels = levels(SEQINR.UTIL$CODON.AA$L)))
-  return(list(length = length, composition=compo/length, AA.Property=AAstat(object,plot=FALSE)[[2]]))
+  if(nchar(object[1]) > 1) {
+  compo <- table(factor(s2c(object), levels = levels(SEQINR.UTIL$CODON.AA$L)))
+  return(list(length = length, composition=compo/length, AA.Property=AAstat(s2c(object),plot=FALSE)[[2]]))
+  }
+  else {
+    compo <- table(factor(object, levels = levels(SEQINR.UTIL$CODON.AA$L)))
+    return(list(length = length, composition=compo/length, AA.Property=AAstat(object,plot=FALSE)[[2]]))
+  }
+
 }
 
 
@@ -81,4 +94,3 @@
 {
   cat(x$nelem, x$type, "for", list1$call$query)
 }
-	



More information about the Seqinr-commits mailing list