Package matt

import ""

Overview ▾

Package matt provides a relatively bare bones blackbox for running Matt and easily gathering results like RMSD, core length and a p-value.

This package also provides RunAll which can be used to run many matt instances in parallel.

Please see the 'rmsd' example in the examples directory for a full and complete working example using three samples from the PDB.

Matt is available on the web:

M. Menke, B. Berger, L. Cowen, "Matt: Local Flexibility Aids Protein Multiple Structure Alignment", PLOS Computational Biology, Vol. 4, No 1., 2008.


var DefaultConfig = Config{
    Binary:       "matt",
    OutputPrefix: "",
    Bent:         false,
    RawNumbers:   false,
    Verbose:      true,
    Vomit:        false,

DefaultConfig provides some sane defaults to run Matt with. For example:

results, err := matt.DefaultConfig.Run(pdbArg1, pdbArg2, ...)

type Config

type Config struct {
    // Binary points to the 'matt' executable. If 'matt' is in your PATH,
    // it is sufficient to leave this as 'matt'.
    Binary string

    // OutputPrefix is the parameter given to '-o' in matt. If left blank,
    // the OutputPrefix will be set to a temporary directory in your system's
    // TempDir.
    OutputPrefix string

    // Bent sets the "-b" flag so that Matt outputs "bent" versions of each
    // regular file.
    Bent bool

    // RawNumbers sets the "-r0" flag so that Matt does not renumber all of
    // the residue numbers in the output PDB file.
    // This is useful when you need to determine contiguous alignment
    // regions.
    RawNumbers bool

    // Verbose controls whether all commands executed are printed to stderr.
    Verbose bool

    // When Vomit is true, all vomit from commands executed will also be
    // printed to stderr.
    Vomit bool

Config is used to specify the location of the Matt binary in addition to any relevant parameters that can be passed to Matt. It also controls the level of vomit echoed to stderr.

func (Config) Run

func (conf Config) Run(pargs ...PDBArg) (Results, error)

Run will execute Matt using a particular configuration with a set of PDB file arguments. It handles creation of a temporary directory where Matt writes its output.

After running matt, if you don't intend to use any of the output files, you should call 'Clean' (or 'CleanDir' if you want to remove the parent directory containing the Matt output files).

After Matt is executed, the core length, RMSD and p-value are read from Matt's output 'txt' file automatically. Thus, it is safe to call 'Clean' immediately after running, and still have access to those output values via the 'Results' struct.

func (Config) RunAll

func (conf Config) RunAll(argsets [][]PDBArg) ([]Results, []error)

RunAll will execute Matt is parallel over all sets of PDB arguments given. The order of execution is unspecified, but the order and length of BOTH of the return values []*Results and []error is precisely equivalent to the order and length of the input [][]PDBArg.

Namely, for all i in [0, (length of [][]PDBArg) - 2], then either ([]Results)[i] is not nil EXCLUSIVE OR ([]error)[i] is not nil.

Since this is meant to batch a lot of calls to Matt, several things are forcefully automated for you: 1) The OutputPrefix is forced to be empty, which results in temporary directories being created for each Matt invocation. 2) After each invocation of Matt, 'CleanDir' is used to clean up anything leftover by Matt.

If any particular invocation of Matt fails, it is added to the returned error slice, but does not stop the overall execution. To determine whether invocation 'i' of Matt failed, simply check if the element at index 'i' in the returned error slice is 'nil' or not.

Make sure you have GOMAXPROCS set to an appropriate value, or use something like:


GOMAXPROCS is the maximum number of CPUs that can be executing simultaneously. As of July 10, 2012, this value is set by default to 1.

type PDBArg

type PDBArg struct {
    // Path is the only required field.
    Path   string
    IdCode string
    Chain  byte

    // Matt allows one to specify a range of residues to be aligned.
    // If one of ResidueStart or ResidueEnd is specified, BOTH must be specified
    // in addition to a chain. A violation of this invariant will cause 'Run'
    // to panic.
    ResidueStart, ResidueEnd int

PDBArg corresponds to an argument to Matt. It can be just a file path (represented by the "Path" field), or it can also contain a specific chain and a range of residues to align.

func NewChainArg

func NewChainArg(chain *pdb.Chain) PDBArg

NewChainArg creates a PDBArg value from a *pdb.Chain. It will fill in the Path, IdCode and Chain fields. ResidueStart and ResidueEnd will be set to zero.

func NewPDBArg

func NewPDBArg(entry *pdb.Entry) PDBArg

NewPDBArg creates a PDBArg value from a *pdb.Entry. It will fill in the Path and IdCode fields. ResidueStart and ResidueEnd will be set to zero.

type Results

type Results struct {
    CoreLength int
    RMSD       float64
    Pval       float64
    // contains filtered or unexported fields

Results corresponds to information about Matt's output. Use its methods "Fasta", "Pdb", "Spt" and "Txt" to retrieve the file names of each of Matt's corresponding output files.

func (Results) Clean

func (res Results) Clean()

Clean will delete all files produced by matt. Namely, 'prefix.{fasta,pdb,spt,txt}'. Errors, if they occur, are suppressed. The corresponding bent files are also removed.

func (Results) CleanDir

func (res Results) CleanDir()

CleanDir will run Clean and also remove the directory containing the Matt files. This is usefull when 'Run' is called with an empty OutputPrefix (where a temporary directory is created).

func (Results) Fasta

func (res Results) Fasta() string

Fasta returns the fasta output file path.

func (Results) FastaBent

func (res Results) FastaBent() string

FastaBent returns the bent fasta output file path. This file will only exist if "Bent" is set to true in the Matt configuration.

func (Results) Pdb

func (res Results) Pdb() string

Pdb returns the PDB output file path.

func (Results) PdbBent

func (res Results) PdbBent() string

PdbBent returns the bent PDB output file path. This file will only exist if "Bent" is set to true in the Matt configuration.

func (Results) Spt

func (res Results) Spt() string

Spt returns the Spt output file path.

func (Results) SptBent

func (res Results) SptBent() string

SptBent returns the bent Spt output file path. This file will only exist if "Bent" is set to true in the Matt configuration.

func (Results) Txt

func (res Results) Txt() string

Txt returns the txt output file path.

func (Results) TxtBent

func (res Results) TxtBent() string

TxtBent returns the bent txt output file path. This file will only exist if "Bent" is set to true in the Matt configuration.


Name      Synopsis
     rmsd      Example rmsd shows how to use the matt package to invoke Matt on multiple argument sets in parallel.