subset.atoms: Subsetting 'atoms' and 'pdb' Objects

View source: R/subset.atoms.R

subset.atomsR Documentation

Subsetting ‘atoms’ and ‘pdb’ Objects

Description

Return subsets of ‘atoms’ or ‘pdb’ objects which meet conditions.

Usage

## S3 method for class 'atoms'
subset(x, subset, drop = FALSE, reindex.all = TRUE, ...)

## S3 method for class 'pdb'
subset(x, subset, drop = FALSE, reindex.all = TRUE, ...)

Arguments

x

object to be subsetted.

subset

logical expression indicating elements or rows to keep: missing values are taken as false.

drop

passed on to [ indexing operator.

reindex.all

a single element logical vector indicating if residues and elements IDs have to be reindexed after subsetting.

...

further arguments to be passed to or from other methods.

Details

For an ‘atoms’ object the method is similar to the data.frame method (see subset) but allow to directly reindex the elements and residues IDs. For a ‘pdb’ object subsetting is applied on the atoms and conect components of the object in a consistent way. First the atoms component is subsetted and then the conect component is filtered to keep only the conectivity for the subset.

Value

Return a subsetted object of the same class as x.

See Also

subset, pdb, atoms, reindex

Examples

x <- read.pdb(system.file("examples/PCBM_ODCB.pdb", package="Rpdb"))
y <- subset(x, x$atoms$eleid %in% sample(x$atoms$eleid, 10))
is(y)
y <- subset(x$atoms, x$atoms$eleid %in% sample(x$atoms$eleid, 10))
is(y)
x <- coords(x)
y <- subset(x, x < 0)
is(y)


Rpdb documentation built on Sept. 28, 2023, 5:07 p.m.