File: homoData.R

package info (click to toggle)
r-bioc-annotate 1.84.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,624 kB
  • sloc: makefile: 2
file content (145 lines) | stat: -rw-r--r-- 5,132 bytes parent folder | download | duplicates (5)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
### homoData objects are used by homoPkgBuilder to represent homology data

setClass("homoData", representation(homoOrg = "character",
                                    homoLL = "numeric",
                                    homoType = "character",
                                    homoPS = "numeric",
                                    homoURL = "character",
                                    homoACC = "character",
                                    homoHGID = "numeric"))

# Set the get methods
setGeneric("homoOrg",
               function(object) standardGeneric("homoOrg"))

setMethod("homoOrg", "homoData",
          function(object) object@homoOrg)

setGeneric("homoLL",
               function(object) standardGeneric("homoLL"))

setMethod("homoLL", "homoData",
          function(object) object@homoLL)

setGeneric("homoType",
               function(object) standardGeneric("homoType"))

setMethod("homoType", "homoData",
          function(object) object@homoType)

setGeneric("homoPS",
               function(object) standardGeneric("homoPS"))

setMethod("homoPS", "homoData",
          function(object) object@homoPS)

setGeneric("homoURL",
               function(object) standardGeneric("homoURL"))

setMethod("homoURL", "homoData",
          function(object) object@homoURL)

setGeneric("homoACC",
               function(object) standardGeneric("homoACC"))

setMethod("homoACC", "homoData",
          function(object) object@homoACC)

setGeneric("homoHGID",
               function(object) standardGeneric("homoHGID"))

setMethod("homoHGID", "homoData",
          function(object) object@homoHGID)

setMethod("show", "homoData",
          function(object) {
              if(length(homoOrg(object)) > 0 && !is.na(homoOrg(object))){
                  cat(paste("homoOrg:", homoOrg(object)), fill = TRUE)
              }
              if(length(homoLL(object)) > 0 && !is.na(homoLL(object))){
                  cat(paste("\nhomoLL:", homoLL(object)), fill = TRUE)
              }
              if(length(homoHGID(object)) > 0 && !is.na(homoHGID(object))){
                  cat(paste("\nhomoHGID:", homoHGID(object)), fill = TRUE)
              }
              if(length(homoACC(object)) > 0 && !is.na(homoACC(object))){
                  cat(paste("\nhomoACC:", homoACC(object)), fill = TRUE)
              }
              if(length(homoType(object)) > 0 && !is.na(homoType(object))){
                  cat(paste("\nhomoType:", homoType(object)), fill = TRUE)
              }
              if(length(homoPS(object)) > 0 && !is.na(homoPS(object))){
                  cat(paste("\nhomoPS:", homoPS(object)), fill = TRUE)
              }
              if(length(homoURL(object)) > 0 && !is.na(homoURL(object))){
                  cat(paste("\nhomoURL:", homoURL(object)), fill = TRUE)
              }
              cat("\n")
})

mapOrgs <- function(toMap, what = c("code", "name")){
    fun <- function(x){
        if(what == "code"){
            return(orgs[[x]])
        }else{
            return(names(orgs[orgs == x]))
        }
    }
    what <- match.arg(what)
    orgs <- getOrgNameNCode()
    if(is.null(toMap) || is.na(toMap)){
         return(NA)
    }
    if(length(toMap) == 1){
        return(fun(toMap))
    }else{
        return(sapply(toMap, fun))
    }
}

getOrgNameNCode <- function(){
    return(list("3055" = "Chlamydomonas reinhardtii",
             "3702" = "Arabidopsis thaliana",
             "3847" = "Glycine max",
             "3880" = "Medicago truncatula",
             "4081" = "Lycopersicon esculentum",
             "4513" = "Hordeum vulgare",
             "4530" = "Oryza sativa",
             "4565" = "Triticum aestivum",
             "4577" = "Zea mays",
             "4896" = "Schizosaccharomyces pombe",
             "4932" = "Saccharomyces cerevisiae",
             "5141" = "Neurospora crassa",
             "5833" = "Plasmodium falciparum",
             "6239" = "Caenorhabditis elegans",
             "7165" = "Anopheles gambiae",
             "7227" = "Drosophila melanogaster",
             "7719" = "Ciona intestinalis",
             "7955" = "Danio rerio",
             "8022" = "Oncorhynchus mykiss",
             "8090" = "Oryzias latipes",
             "8355" = "Xenopus laevis",
             "8364" = "Xenopus tropicalis",
             "9031" = "Gallus gallus",
             "9606" = "Homo sapiens",
             "9615" = "Canis familiaris",
             "9598" = "Pan troglodytes",
             "9823" = "Sus scrofa",
             "9913" = "Bos taurus",
             "10090" = "Mus musculus",
             "10116" = "Rattus norvegicus",
             "28985" = "Kluyveromyces, lactis",
             "29760" = "Vitis vinifera",
             "33169" = "Eremothecium gossypii",
             "44689" = "Dictyostelium discoideum",
             "148305" = "Magnaporthe grisea"
            ))
}


homoData <- function(organism, LL, type, PS, ACC, HGID, URL){
    return(new("homoData", homoOrg = mapOrgs(organism),
                   homoLL = LL, homoType = type,
                   homoPS = PS, homoURL = URL,
                   homoACC = ACC, homoHGID = HGID))
}