Learn R Programming

bio3d (version 2.3-4)

read.mol2: Read MOL2 File

Description

Read a Tripos MOL2 file

Usage

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

# S3 method for mol2 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.mol2.

...

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.

substructure

a data frame containing all substructure 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 ‘@<TRIPOS>MOLECULE’, ‘@<TRIPOS>ATOM’, ‘@<TRIPOS>BOND’ and ‘@<TRIPOS>SUBSTRUCTURE’ records.

In the case of a multi-molecule MOL2 file, each molecule will be stored as an individual ‘mol2’ object in a list. Conversely, if the multi-molecule MOL2 file contains identical molecules in different conformations (typically from a docking 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.

See Also

write.mol2, atom.select.mol2, trim.mol2, as.pdb.mol2 read.pdb

Examples

Run this code
# NOT RUN {
cat("\n")
# }
# NOT RUN {
## Read a single entry MOL2 file
## (returns a single object)
mol <- read.mol2( system.file("examples/aspirin.mol2", package="bio3d") )

## 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"])

## Convert to PDB
pdb <- as.pdb(mol)


## 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)
# }

Run the code above in your browser using DataLab