~ubuntu-branches/ubuntu/wily/r-bioc-genomicranges/wily-proposed

« back to all changes in this revision

Viewing changes to R/RangedData-methods.R

  • Committer: Package Import Robot
  • Author(s): Andreas Tille
  • Date: 2013-10-18 10:40:04 UTC
  • Revision ID: package-import@ubuntu.com-20131018104004-ktm4ub0pcoybnir6
Tags: upstream-1.12.4
ImportĀ upstreamĀ versionĀ 1.12.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
### =========================================================================
 
2
### RangedData/RangesList implementation of the GenomicRanges API
 
3
### -------------------------------------------------------------------------
 
4
###
 
5
 
 
6
### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
7
### seqinfo
 
8
###
 
9
 
 
10
setMethod("seqinfo", "List", function(x) {
 
11
  si <- metadata(x)$seqinfo
 
12
  if (is.null(si)) {
 
13
    sn <- names(x)
 
14
    if (is.null(sn))
 
15
      sn <- as.character(seq(length(x)))
 
16
    si <- Seqinfo(unique(sn))
 
17
  }
 
18
  si  
 
19
})
 
20
 
 
21
setMethod("seqinfo", "RangesList", function(x) {
 
22
  si <- callNextMethod()
 
23
  if (!is.null(universe(x)))
 
24
    genome(si) <- universe(x)
 
25
  si
 
26
})
 
27
 
 
28
### FIXME: needs sanity checks
 
29
setReplaceMethod("seqinfo", "List",
 
30
                 function(x, value) {
 
31
                   metadata(x)$seqinfo <- value
 
32
                   x
 
33
                 })
 
34
 
 
35
setMethod("seqinfo", "RangedData", function(x) seqinfo(ranges(x)))
 
36
setReplaceMethod("seqinfo", "RangedData",
 
37
                 function(x, value) {
 
38
                   seqinfo(ranges(x)) <- value
 
39
                   x
 
40
                 })
 
41
 
 
42
### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
43
### seqnames
 
44
###
 
45
 
 
46
setMethod("seqnames", "RangesList", function(x) {
 
47
  if (is.null(names(x)))
 
48
    NULL
 
49
  else seqsplit(Rle(space(x)), rep(names(x), elementLengths(x)))
 
50
})
 
51
 
 
52
setMethod("seqnames", "RangedData", function(x) space(x))
 
53