Learn R Programming

bio3d (version 2.2-4)

read.mol2: Read MOL2 File

Description

Read a Sybyl MOL2 file

Usage

read.mol2(file, maxlines = -1L)
"print"(x, ...)

Arguments

file
a single element character vector containing the name of the MOL2 file to be read.
maxlines
the maximum number of lines to read before giving up with large files. Default is all lines.
x
an object as obtained from read.sdf.
...
additional arguments to ‘print’.

Value

Returns a list of molecules containing the following components:
atom
a data frame containing all atomic coordinate ATOM data, with a row per ATOM and a column per record type. See below for details of the record type naming convention (useful for accessing columns).
bond
a data frame containing all atomic bond information.
xyz
a numeric matrix of ATOM coordinate data.
info
a numeric vector of MOL2 info data.
name
a single element character vector containing the molecule name.

Details

Basic functionality to parse a MOL2 file. The current version reads and stores @MOLECULE, @ATOM and @BOND records.

In the case of a multi-molecule MOL2 file, each molecule will be stored as an individual object in a list. Conversely, if the multi-molecule MOL2 file contains identical molecules in different conformations (typically a dockin run), then the output will be one object with an atom and xyz component (xyz in matrix representation; row-wise coordinates).

See examples for further details.

References

Grant, B.J. et al. (2006) Bioinformatics 22, 2695--2696. For a description of the MOL2 format see: http://www.tripos.com/data/support/mol2.pdf.

See Also

atom.select, read.pdb

Examples

Run this code
cat("\n")
## Not run: 
# ## Read a single entry MOL2 file
# ## (returns a single object)
# mol <- read.mol2("single.mol2")
# 
# ## Short summary of the molecule
# print(mol)
# 
# ## ATOM records
# mol$atom
# 
# ## BOND records
# mol$bond
# 
# ## Print some coordinate data
# head(mol$atom[, c("x","y","z")])
# 
# ## Or coordinates as a numeric vector
# head(mol$xyz)
# 
# ## Print atom charges
# head(mol$atom[, "charge"])
# 
# 
# 
# ## Read a multi-molecule MOL2 file
# ## (returns a list of objects)
# multi.mol <- read.mol2("zinc.mol2")
# 
# ## Number of molecules described in file
# length(multi.mol)
# 
# ## Access ATOM records for the first molecule
# multi.mol[[1]]$atom
# 
# ## Or coordinates for the second molecule
# multi.mol[[2]]$xyz
# 
# 
# 
# ## Process output from docking (e.g. DOCK)
# ## (typically one molecule with many conformations)
# ## (returns one object, but xyz in matrix format)
# dock <- read.mol2("dock.mol2")
# 
# ## Reference PDB file (e.g. X-ray structure)
# pdb <- read.pdb("dock_ref.pdb")
# 
# ## Calculate RMSD of docking modes
# sele <- atom.select(dock, "noh")
# rmsd(pdb$xyz, dock$xyz, b.inds=sele$xyz)
# ## End(Not run)

Run the code above in your browser using DataLab