[Chimera-users] Clustering docking results using "headless" Chimera
Conrad Huang
conrad at cgl.ucsf.edu
Wed Jun 27 11:03:57 PDT 2012
Yes, a script is still probably the easiest way to do what you want.
However, there is a call in the old script that no longer exists in the
new one. I'm attaching a new script that will do a couple things
differently than before:
- Instead of opening files in the script, it will now use models that
have already been opened.
- It will call matchmaker to align all models to the model with the
lowest model/submodel number (usually the first model opened).
To run it, save the script as "cluster.py" and run the command:
chimera --nogui --silent your_model_files cluster.py
where cluster.py is the name of the script. The first model opened will
be the reference structure to which everything else is aligned.
In the script, Matchmaker is invoked by the line:
chimera.runCommand("mm %s %s" % (ref.oslIdent(), m.oslIdent()))
If you want to use more options (see
http://www.cgl.ucsf.edu/chimera/docs/UsersGuide/midas/mmaker.html for
details), just add it after the second "%s" on the line.
Please let me if this does what you need, or if you'd like it to do more
stuff.
Conrad
On 6/26/2012 7:57 PM, Hurt, Darrell (NIH/NIAID) [E] wrote:
> Hi there,
>
> I want to use Chimera on a server (or in an automated fashion by
> command line; "-nogui") to read in a bunch (1000s) of PDB structures
> (each having an identical number of atoms) and then do clustering
> using the NMRCLUST code that you've so conveniently adapted.
>
> I found this old thread:
> http://www.cgl.ucsf.edu/pipermail/chimera-users/2008-October/003193.html
>
> Is this still the preferred method for doing what I'm hoping?
>
> Also, is it possible to do a MatchMaker alignment before the
> clustering?
>
> Thanks, Darrell
>
>
> -- Darrell Hurt, Ph.D. Section Head, Computational Biology
> Bioinformatics and Computational Biosciences Branch (BCBB)
> OCICB/OSMO/OD/NIAID/NIH
>
> 31 Center Drive, Room 3B62B, MSC 2135 Bethesda, MD 20892-2135 Office
> 301-402-0095 Mobile 301-758-3559
> http://bioinformatics.niaid.nih.gov<http://bioinformatics.niaid.nih.gov/>
> (Within NIH) http://exon.niaid.nih.gov<http://exon.niaid.nih.gov/>
> (Public)
>
> Disclaimer: The information in this e-mail and any of its attachments
> is confidential and may contain sensitive information. It should not
> be used by anyone who is not the original intended recipient. If you
> have received this e-mail in error please inform the sender and
> delete it from your mailbox or any other storage devices. National
> Institute of Allergy and Infectious Diseases shall not accept
> liability for any statements made that are sender's own and not
> expressly made on behalf of the NIAID by one of its representatives.
>
> _______________________________________________ Chimera-users mailing
> list Chimera-users at cgl.ucsf.edu
> http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users
-------------- next part --------------
def clusterModels(modelList):
from EnsembleMatch.distmat import DistanceMatrix
from chimera import match
# First we need to construct a full distance matrix, including
# possibly identical elements
fulldm = DistanceMatrix(len(modelList))
sameAs = {}
atoms = [ match._coordArray(m.atoms) for m in modelList ]
for i in range(len(modelList)):
mi = modelList[i]
if mi in sameAs:
continue
ai = atoms[i]
for j in range(i + 1, len(modelList)):
aj = atoms[j]
m = match.Match(ai, aj)
if m.rms <= 0:
# Detect identical elements and track them
mj = modelList[j]
sameAs[mj] = mi
fulldm.set(i, j, m.rms)
# Now we reduce the distance matrix by removing identical elements
if not sameAs:
# No identical elements, just use the whole thing
dm = fulldm
models = modelList
else:
models = []
indexMap = []
for i, mi in enumerate(modelList):
if mi in sameAs:
# Skip identical element
continue
models.append(mi)
indexMap.append(i)
dm = DistanceMatrix(len(models))
for i in range(len(models)):
im = indexMap[i]
for j in range(i + 1, len(models)):
jm = indexMap[j]
dm.set(i, j, fulldm.get(im, jm))
# Next we run the clustering algorithm
from EnsembleMatch.nmrclust import NMRClust
nmrc = NMRClust(dm)
# Next reformat the results into something useful.
# "clusterInfo" is a list of whose elements are 2-tuples of
# (cluster representative model, list of models in cluster)
clusterInfo = []
for cid, c in enumerate(nmrc.clusters):
members = c.members()
mList = []
for member in members:
m = models[member]
m.clusterId = cid
m.clusterRep = 0
mList.append(m)
rep = nmrc.representative(c)
m = models[rep]
m.clusterRep = len(members)
clusterInfo.append((m, mList))
for mj, mi in sameAs.iteritems():
mj.clusterId = mi.clusterId
mj.clusterRep = 0
rep, members = clusterInfo[mi.clusterId]
rep.clusterRep += 1
members.append(mj)
return clusterInfo
# Here's an example on how you can use the function above.
# Run this script with:
# chimera --nogui --silent your_model_files cluster.py
# where cluster.py is the name of this file. The first model
# opened will be the reference structure to which everything
# else is aligned.
if __name__ == "chimeraOpenSandbox":
import chimera
models = chimera.openModels.list(modelTypes=[chimera.Molecule])
ref = models[0]
for m in models[1:]:
chimera.runCommand("mm %s %s" % (ref.oslIdent(), m.oslIdent()))
ci = clusterModels(models)
print len(models), "models ->", len(ci), "clusters"
for rep, members in ci:
print rep.oslIdent(), "(%d member)" % len(members)
for m in members:
print '\t', m.oslIdent()
More information about the Chimera-users
mailing list