File: ClassSeq.R

package info (click to toggle)
r-cran-seqinr 3.3-3-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,844 kB
  • ctags: 69
  • sloc: ansic: 1,955; makefile: 13
file content (84 lines) | stat: -rw-r--r-- 1,969 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

##########################################################################
#
# SeqFastadna:
# 

as.SeqFastadna <- function(object, name = NULL, Annot = NULL){
  attributes(object) <- list(name = name, Annot = Annot)
  class(object) <- "SeqFastadna"	
  return(object)
}

is.SeqFastadna <- function(object) inherits(object, "SeqFastadna")

summary.SeqFastadna <- function(object, alphabet = s2c("acgt"), ...){
  length <- getLength(object)
  compo <- count(object, 1, alphabet = alphabet)
  return(list(length = length , composition = compo, GC = GC(object)))
}

#
# SeqFastaAA:
#

as.SeqFastaAA <- function(object, name = NULL, Annot = NULL){
  attributes(object) <- list(name = name, Annot= Annot)
  class(object) <- "SeqFastaAA"	
  return(object)
}

is.SeqFastaAA <- function(object) inherits(object, "SeqFastaAA")

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]]))
}


#
# SeqAcnucWeb:
#

as.SeqAcnucWeb <- function(object, length, frame, ncbigc){
  attributes(object) <- list(length = as.numeric(length),
    frame = as.numeric(frame), ncbigc = as.numeric(ncbigc))
  class(object) <- "SeqAcnucWeb"
  return(object)
}

is.SeqAcnucWeb <- function(object) inherits(object, "SeqAcnucWeb")


print.SeqAcnucWeb <- function(x, ...)
{
  res <- c(x, attr(x, "length"), attr(x, "frame"), attr(x, "ncbigc"))
  names(res) <- c("name", "length", "frame", "ncbicg")
  print(res, ...)
}

#
# SeqFrag:
#


as.SeqFrag <- function(object, begin, end, name){
  attr(object, "seqMother") <- name
  attr(object, "begin") <- begin
  attr(object,"end") <- end
  class(object) <- "SeqFrag"
  return(object)
}

is.SeqFrag <- function(object) inherits(object, "SeqFrag")

#
# Query Acnuw Web (qaw class)
#

print.qaw <- function(x, ...)
{
  cat(x$nelem, x$type, "for", list1$call$query)
}