From 633465e4c8ae5b126d8c9b6a8015e43bab1e2d6c Mon Sep 17 00:00:00 2001 From: einarr Date: Sun, 6 Mar 2011 14:38:24 +0000 Subject: [PATCH] * Added function fro reading laydi selections. * Fixed bug in documentation of write.laydi.selection. --- R/laydi/R/laydi.R | 16 +++++++++ R/laydi/man/read.laydi.selection.Rd | 53 ++++++++++++++++++++++++++++ R/laydi/man/write.laydi.selection.Rd | 2 +- 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 R/laydi/man/read.laydi.selection.Rd diff --git a/R/laydi/R/laydi.R b/R/laydi/R/laydi.R index b6fc85a..1b5ef17 100644 --- a/R/laydi/R/laydi.R +++ b/R/laydi/R/laydi.R @@ -42,4 +42,20 @@ write.laydi.selection <- function(data, con) { close(con) } +read.laydi.selection <- function(con) { + # If con is a file name, open it + opened.here = FALSE + if (is.character(con)){ + con = file(con) + opened.here = TRUE + } + + ids <- readLines(con=con, encoding="UTF-8") + + # If con was a string, close file now + if (opened.here) + close(con) + + ids +} diff --git a/R/laydi/man/read.laydi.selection.Rd b/R/laydi/man/read.laydi.selection.Rd new file mode 100644 index 0000000..f1e5a20 --- /dev/null +++ b/R/laydi/man/read.laydi.selection.Rd @@ -0,0 +1,53 @@ +\name{read.laydi.selection} +\alias{read.laydi.selection} +\title{read.laydi.selection} +\description{ +Reads a list of identifiers from a file. +} +\usage{ +read.laydi.selection(con) +} +\arguments{ + \item{con}{ + Connection (or file name) to read from. If con is a character string, it + will be treated as a file name, and the file will be opened, read and + closed. If con is an open connection (file descriptor), the file will + remain open. + } +} + +\details{ +%% ~~ If necessary, more details than the description above ~~ +} +\value{ +%% ~Describe the value returned +%% If it is a LIST, use +%% \item{comp1 }{Description of 'comp1'} +%% \item{comp2 }{Description of 'comp2'} +%% ... +} +\references{ +Laydi and the laydi R package are not published in the litterature. Source code +can be found at http://dev.pvv.ntnu.no/projects/laydi +} +\author{ +Einar Ryeng +} +\note{ +%% ~~further notes~~ +} + +%% ~Make other sections like Warning with \section{Warning }{....} ~ + +\seealso{ +%% ~~objects to See Also as \code{\link{help}}, ~~~ +} +\examples{ + +read.laydi.selection("/tmp/selected_samples") + +} + +\keyword{ IO } +\keyword{ file } + diff --git a/R/laydi/man/write.laydi.selection.Rd b/R/laydi/man/write.laydi.selection.Rd index 8558bed..47a508d 100644 --- a/R/laydi/man/write.laydi.selection.Rd +++ b/R/laydi/man/write.laydi.selection.Rd @@ -52,7 +52,7 @@ Einar Ryeng } \examples{ -write.laydi.selection(c("sample1", "sample2", "sample3", "/tmp/selected_samples")) +write.laydi.selection(c("sample1", "sample2", "sample3"), "/tmp/selected_samples") }