Permalink
Browse files

most documentation done. passes check on R and R-devel

  • Loading branch information...
1 parent 9730239 commit ab37559535487b852bbe19fbd86ec658b7ab5230 @gmbecker committed Mar 12, 2012
Showing with 358 additions and 129 deletions.
  1. +3 −2 DESCRIPTION
  2. +4 −2 NAMESPACE
  3. +26 −88 R/ViewInIGB.R
  4. +6 −37 R/igbTrack.R
  5. +39 −0 man/ViewInIGB-methods.Rd
  6. +87 −0 man/ViewInIGB.Rd
  7. +46 −0 man/igbSession-class.Rd
  8. +70 −0 man/igbTrack-class.Rd
  9. +77 −0 man/showInIGB.Rd
View
@@ -6,6 +6,7 @@ Date: 2012-02-24
Author: Gabriel Becker
Maintainer: Gabriel Becker <gmbecker@ucdavis.edu>
Description: This package allows R uses to send instructions to a running (external) IGB session. These include navigating to a genome, loading data (adding a track), chaning the viewing region, etc.
-Depends:rtracklayer, methods
+Depends:methods
+Imports:rtracklayer, GenomicRanges
Collate:igbTrack.R ViewInIGB.R rigbLite-internal.R
-License: LGPL
+License: Artistic-2.0
View
@@ -1,5 +1,7 @@
importClassesFrom(rtracklayer, "Quickload", "QuickloadGenome")
-importMethodsFrom(rtracklayer, "genome", "genome<-", "track<-")
-exportPattern("^[[:alpha:]]+")
+importMethodsFrom(rtracklayer, "genome", "uri")
+importClassesFrom(GenomicRanges, "GRanges")
+importFrom(rtracklayer, "genome", "genome<-", "track<-", "uri")
exportMethods("ViewInIGB", "genome", "genome<-", "track<-")
exportClasses("igbTrack", "igbSession")
+export("showInIGB")
View
@@ -1,4 +1,4 @@
-setClassUnion("sockOrNULL", list("sockconn", "NULL"))
+setOldClass("sockconn")
igbSession = setRefClass("igbSession",
fields = list(
.port = "numeric",
@@ -21,29 +21,25 @@ igbSession = setRefClass("igbSession",
{
ViewInIGB(x, ..., con = .self$connection)
},
- 'setRegion' = function(x, chromosome="1")
+ 'setRegion' = function(x)
{
- ViewInIGB(region = x, chromosome = chromosome, con = .self$connection)
+ ViewInIGB(region = x, con = .self$connection)
},
initialize = function(...)
{
args = list(...)
- port = args$port
- if(is.null(port))
- {
- port = 7085
- args$port = port
- }
- .port <<- port
+ tmpport = args$port
+ if(is.null(tmpport))
+ tmpport = 7085
+
+ .port <<- tmpport
if(is.null(args$connection))
{
-
- con <- tryCatch(socketConnection(host = "localhost", port = port, open = "wa"), error = function(e) stop("Unable to connect to IGB. Is it running on the the selected port?"))
-
+ tmpcon <- tryCatch(socketConnection(host = "localhost", port = port, open = "wa"), error = function(e) stop("Unable to connect to IGB. Is it running on the the selected port?"))
} else {
- con <- args$connection
+ tmpcon <- args$connection
}
- .connection <<- con
+ .connection <<- tmpcon
})
)
@@ -66,59 +62,9 @@ setMethod("region<-", representation(object = "igbSession"),
}
)
-if(FALSE)
- {
-setClass("igbTrack", representation(genome = "character", region = "numeric", chromosome = "character", loadMode = "character", dataFile = "character"))
-
-setMethod("genome<-", "igbTrack", function(object, ..., value)
- {
- object@genome = track
- object
- })
-
-setMethod("genome", "igbTrack", function(object, ...)
- object@genome
- )
-
-setGeneric("loadmode", function(object) standardGeneric("loadmode"))
-setMethod("loadmode", "igbTrack", function(object) object@loadMode)
-
-setGeneric("loadmode<-", function(object, ..., value) standardGeneric("loadmode<-"))
-setMethod("loadmode<-", "igbTrack", function(object, ..., value) {
- object@loadMode = value
- object
-})
-
-setGeneric("chromosome", function(object) standardGeneric("chromosome"))
-setMethod("chromosome", "igbTrack", function(object) object@chromosome)
-
-setGeneric("chromosome<-", function(object, ..., value) standardGeneric("chromosome<-"))
-setMethod("chromosome<-", "igbTrack", function(object, ..., value)
- {
- object@chromosome = value
- object
- })
-
-setGeneric("region", function(object, ...) standardGeneric("region"))
-setMethod("region", "igbTrack", function(object, ...) object@region)
-
-setGeneric("region<-", function(object, ..., value) standardGeneric("region<-"))
-setMethod("region<-", "igbTrack", function(object, ..., value)
- {
- object@region = value
- object
- })
-
-
-
-}
-ConnectToIGB = function(port = 7085)
- igbCon <<-socketConnection(host = "localhost", port = port, open ="wa")
-
-
showInIGB = function( con,
genome = NULL,
- goto,
+ goto = NULL,
dataFile = NULL,
loadMode,
refresh = TRUE,
@@ -133,9 +79,12 @@ showInIGB = function( con,
script = NULL
if(!is.null(genome))
script = c(script, paste("genome", genome))
- if(!missing(goto))
- script = c(script, paste("goto", goto))
- if(!is.null(dataFile))
+ if(!is.null(goto))
+ {
+ goto = paste(as.character(seqnames(goto)), ":", paste(start(goto), end(goto), sep="-"), sep="")
+ script = c(script, paste("goto", goto))
+ }
+ if(!is.null(dataFile))
{
script = c(script, paste("load", dataFile))
if(!missing(loadMode))
@@ -150,20 +99,14 @@ showInIGB = function( con,
}
setGeneric("ViewInIGB",
- function(x, genome = NULL, dataFile = NULL, chromosome = 1, region = NULL, loadMode = "REGION_IN_VIEW", refresh = TRUE, con = socketConnection("localhost", port = 7085, open ="wa"))
+ function(x, genome = NULL, dataFile = NULL, region = NULL, loadMode = "REGION_IN_VIEW", refresh = TRUE, con = socketConnection("localhost", port = 7085, open ="wa"))
{
- if(!is.null(region))
- {
- if (is.numeric(region))
- region = paste(region, collapse = "-")
- region = paste(chromosome, region, sep=":")
- }
standardGeneric("ViewInIGB")
})
setMethod("ViewInIGB", representation(x = "QuickloadGenome", dataFile = "character"),
- function(x, genome = NULL, dataFile = NULL,chromosome = 1, region = NULL, loadMode = "REGION_IN_VIEW", refresh = TRUE, con = socketConnection("localhost", port = 7085, open ="wa"))
+ function(x, genome = NULL, dataFile = NULL, region = NULL, loadMode = "REGION_IN_VIEW", refresh = TRUE, con = socketConnection("localhost", port = 7085, open ="wa"))
{
showInIGB(genome = genome(x),
goto = region,
@@ -176,7 +119,7 @@ setMethod("ViewInIGB", representation(x = "QuickloadGenome", dataFile = "charact
setMethod("ViewInIGB", representation(x = "Quickload", genome = "character", dataFile = "character"),
- function(x, genome = NULL, dataFile = NULL, chromosome = 1, region = NULL, loadMode = "REGION_IN_VIEW", refresh = TRUE,con = socketConnection("localhost", port = 7085, open ="wa"))
+ function(x, genome = NULL, dataFile = NULL, region = NULL, loadMode = "REGION_IN_VIEW", refresh = TRUE,con = socketConnection("localhost", port = 7085, open ="wa"))
{
if(is.null(genome))
@@ -192,7 +135,7 @@ setMethod("ViewInIGB", representation(x = "Quickload", genome = "character", dat
setMethod("ViewInIGB", representation(x = "ANY", dataFile = "character"),
- function(x, genome = NULL, dataFile = NULL, chromosome = 1, region = NULL, loadMode = "REGION_IN_VIEW", refresh = TRUE, con = socketConnection("localhost", port = 7085, open ="wa"))
+ function(x, genome = NULL, dataFile = NULL, region = NULL, loadMode = "REGION_IN_VIEW", refresh = TRUE, con = socketConnection("localhost", port = 7085, open ="wa"))
{
@@ -206,11 +149,11 @@ setMethod("ViewInIGB", representation(x = "ANY", dataFile = "character"),
setMethod("ViewInIGB", representation(x="igbTrack"),
- function(x, genome = NULL, dataFile = NULL, chromosome = 1, region = NULL, loadMode = "REGION_IN_VIEW", refresh = TRUE, con = socketConnection("localhost", port = 7085, open ="wa"))
+ function(x, genome = NULL, dataFile = NULL, region = NULL, loadMode = "REGION_IN_VIEW", refresh = TRUE, con = socketConnection("localhost", port = 7085, open ="wa"))
{
- goto = paste(chromosome(x), ":", paste(region(x), collapse="-"))
+
showInIGB(genome = genome(x),
- goto= goto,
+ goto= region(x),
loadMode = loadmode(x),
dataFile = uri(x),
refresh = refresh(x),
@@ -220,13 +163,8 @@ setMethod("ViewInIGB", representation(x="igbTrack"),
})
setMethod("ViewInIGB", representation(x="ANY"),
- function(x, genome = NULL, dataFile = NULL, chromosome = 1, region = NULL, loadMode = "REGION_IN_VIEW", refresh = TRUE, con = socketConnection("localhost", port = 7085, open ="wa"))
+ function(x, genome = NULL, dataFile = NULL, region = NULL, loadMode = "REGION_IN_VIEW", refresh = TRUE, con = socketConnection("localhost", port = 7085, open ="wa"))
{
- #if (!is.null(region))
- # goto = paste(chromosome, ":", paste(region, collapse="-"), collapse = "")
- # else
- # goto = NULL
- print(region)
showInIGB(genome = genome,
goto= region,
loadMode = loadMode,
View
@@ -4,7 +4,7 @@
#
#
- setClass( Class = "igbTrack" , representation = representation( genome = "character" , chromosome = "character" , region = "numeric" , loadmode = "character" , refresh = "logical" , uri = "character"))
+ setClass( Class = "igbTrack" , representation = representation( genome = "character" , region = "GRanges" , loadmode = "character" , refresh = "logical" , uri = "character"))
if (!isGeneric( "genome" )) {
if (is.function( "genome" ))
fun <- get( "genome" , mode = "function")
@@ -14,7 +14,7 @@ if (is.function( "genome" ))
}
-setMethod( f = genome , definition = function(x)
+setMethod( f = "genome" , definition = function(x)
{
x@genome
} , signature = c( x = "igbTrack"))
@@ -36,37 +36,6 @@ x
} , signature = c( x = "igbTrack"))
-if (!isGeneric( "chromosome" )) {
-if (is.function( "chromosome" ))
- fun <- get( "chromosome" , mode = "function")
- else
- fun <- function( object , ... ) standardGeneric( "chromosome" )
- setGeneric( "chromosome" , fun)
-}
-
-
-setMethod( f = chromosome , definition = function(object , ...)
-{
-object@chromosome
-} , signature = c( object = "igbTrack"))
-
-
-if (!isGeneric( "chromosome<-" )) {
-if (is.function( "chromosome<-" ))
- fun <- get( "chromosome<-" , mode = "function")
- else
- fun <- function( object , ... , value ) standardGeneric( "chromosome<-" )
- setGeneric( "chromosome<-" , fun)
-}
-
-
-setMethod( f = "chromosome<-" , definition = function(object , ... , value)
-{
-object@chromosome = value
-object
-} , signature = c( object = "igbTrack"))
-
-
if (!isGeneric( "region" )) {
if (is.function( "region" ))
fun <- get( "region" , mode = "function")
@@ -76,7 +45,7 @@ if (is.function( "region" ))
}
-setMethod( f = region , definition = function(object , ...)
+setMethod( f = "region" , definition = function(object , ...)
{
object@region
} , signature = c( object = "igbTrack"))
@@ -107,7 +76,7 @@ if (is.function( "loadmode" ))
}
-setMethod( f = loadmode , definition = function(object , ...)
+setMethod( f = "loadmode" , definition = function(object , ...)
{
object@loadmode
} , signature = c( object = "igbTrack"))
@@ -138,7 +107,7 @@ if (is.function( "refresh" ))
}
-setMethod( f = refresh , definition = function(object , ...)
+setMethod( f = "refresh" , definition = function(object , ...)
{
object@refresh
} , signature = c( object = "igbTrack"))
@@ -169,7 +138,7 @@ if (is.function( "uri" ))
}
-setMethod( f = uri , definition = function(x , ...)
+setMethod( f = "uri" , definition = function(x , ...)
{
x@uri
} , signature = c( x = "igbTrack"))
View
@@ -0,0 +1,39 @@
+\name{ViewInIGB-methods}
+\docType{methods}
+\alias{ViewInIGB-methods}
+\alias{ViewInIGB,ANY,ANY,ANY-method}
+\alias{ViewInIGB,ANY,ANY,character-method}
+\alias{ViewInIGB,Quickload,character,character-method}
+\alias{ViewInIGB,QuickloadGenome,ANY,character-method}
+\title{Manipulate Current View in IGB Session }
+\description{
+ Manipulate view and load data in a running IGB session.
+}
+\section{Methods}{
+\describe{
+
+\item{\code{signature(x = "ANY", genome = "ANY", dataFile = "ANY")}}{
+Default method.
+}
+
+\item{\code{signature(x = "ANY", genome = "ANY", dataFile = "character")}}{
+dataFile is assumed to be an absolute path.
+}
+
+\item{\code{signature(x = "igbTrack", genome = "ANY", dataFile = "ANY")}}{
+Sets view to that specified by the igbTrack object. Other arguments are ignored.
+}
+
+\item{\code{signature(x = "Quickload", genome = "character", dataFile = "character")}}{
+\code{dataFile} is assumed to be a path relative to the specified genome
+within the specified Quickload bed, ie <\code{uri(x)}>/\code{genome}/\code{dataFile}.
+}
+
+\item{\code{signature(x = "QuickloadGenome", genome = "ANY", dataFile = "character")}}{
+\code{dataFile} is assumed to be a path relative to the URI of the passed in
+QuickloadGenome object, ie <\code{uri(x)}>/\code{dataFile}.
+}
+}}
+\keyword{methods}
+\keyword{ ViewInIGB }
+\keyword{ IGB }
Oops, something went wrong.

0 comments on commit ab37559

Please sign in to comment.