openfn.gds: Open a GDS file

View source: R/gdsfmt-main.r

openfn.gdsR Documentation

Open a GDS file

Description

Open an existing file of CoreArray Genomic Data Structure (GDS) for reading or writing.

Usage

openfn.gds(filename, readonly=TRUE, allow.duplicate=FALSE, allow.fork=FALSE,
    allow.error=FALSE, use.abspath=TRUE)

Arguments

filename

the file name of a GDS file to be opened

readonly

if TRUE, the file is opened read-only; otherwise, it is allowed to write data to the file

allow.duplicate

if TRUE, it is allowed to open a GDS file with read-only mode when it has been opened in the same R session

allow.fork

TRUE for parallel environment using forking, see details

allow.error

TRUE for data recovery from a crashed GDS file

use.abspath

if TRUE, 'filename' of the gds.class object is set to be the absolute path

Details

This function opens an existing GDS file for reading (or, if readonly=FALSE, for writing). To create a new GDS file, use createfn.gds instead.

If the file is opened read-only, all data in the file are not allowed to be changed, including hierachical structure, variable names, data fields, etc.

mclapply and mcmapply in the R package parallel rely on unix forking. However, the forked child process inherits copies of the parent's set of open file descriptors. Each file descriptor in the child refers to the same open file description as the corresponding file descriptor in the parent. This means that the two descriptors share open file status flags, current file offset, and signal-driven I/O attributes. The sharing of file description can cause a serious problem (wrong reading, even program crashes), when child processes read or write the same GDS file simultaneously. allow.fork=TRUE adds additional file operations to avoid any conflict using forking. The current implementation does not support writing in forked processes.

Value

Return an object of class gds.class.

filename

the file name to be created

id

internal file id, an integer

root

an object of class gdsn.class, the root of hierachical structure

readonly

whether it is read-only or not

Author(s)

Xiuwen Zheng

See Also

createfn.gds, closefn.gds

Examples

# cteate a GDS file
f <- createfn.gds("test.gds")

# add a list to "test.gds"
node <- add.gdsn(f, name="list", val=list(x=c(1,2), y=c("T","B","C"), z=TRUE))
# close
closefn.gds(f)

# open the same file
f <- openfn.gds("test.gds")

# read
(node <- index.gdsn(f, "list"))
read.gdsn(node)

# close the GDS file
closefn.gds(f)


# delete the temporary file
unlink("test.gds", force=TRUE)

zhengxwen/gdsfmt documentation built on Sept. 27, 2024, 10:08 a.m.