# Read a PDB file
pdb <- read.pdb( "http://www.rcsb.org/pdb/files/1BG2.pdb" )
# Select all C-alpha atoms
ca.inds <- atom.select(pdb, elety="CA")
# Select all atoms with residues numbers between 65 and 143
res.inds <- atom.select(pdb, resno=65:143)
# Select all C-beta atoms with residues numbers between 65 and 143
cb.inds <- atom.select(pdb, resno=65:143, elety="CB")
# Intersection
inds <- combine.sel(ca.inds, res.inds, op="AND")
print( pdb$atom[ inds$atom, "resid" ] )
print( pdb$xyz[ inds$xyz ] )
# Union
inds2 <- combine.sel(inds, cb.inds, op="+")
# Not
inds3 <- combine.sel(res.inds, ca.inds, op="-")
Run the code above in your browser using DataLab