[MMTK] Collection.findTransformation()

Kyle Krull krullk@purdue.edu
Tue, 27 May 2003 13:45:15 -0500 (EST)


	The way I'm doing it doesn't generate any error messages.  The
code is pasted below if you're curious.  This is very similar code to what
I sent you a few months ago on sidechain substitution for rotamers if that
sounds familiar.
	The atoms that I'm matching to one another come from different
residues - one is the original residue as found in the PDB file, and the
other residue comes from a rotamer library that is stored in a separate
file.  Since these aren't the same Residues, or even the same
PeptideChain, would your suggested method still work?  If so, how do I do
a superposition fit?  Is there a function for that in
Numeric/Scientific/MMTK?

Kyle

-------------------------------------------------------------

#Original code
#Transform sidechainResidue's sidechain to fit onto originalResidue
transformation, rms = backboneTransformation(sidechainResidue, originalResidue)
transRes = deepcopy(sidechainResidue)
transRes.applyTransformation(transformation)

"""Returns the transformation that maps query onto target
Note: Transformation based *only* on atoms C, C_alpha, and C_beta"""
def backboneTransformation(query, target):
    #Handle special case Gly - no C_beta: Use N instead
    if query.type.name.lower().startswith('glycine') or \
       target.type.name.lower().startswith('glycine'):
        matchNames = ['C', 'C_alpha', 'N']
    else:
        matchNames = ['C', 'C_alpha', 'C_beta']

    #Isolate matching atoms in residues
    queryMatch = map(copy, getAtoms(query, matchNames))
    targetMatch = map(copy, getAtoms(target, matchNames))

    #Make Collections for each residue, and add them to their own
universes
    queryCol = Collection.Collection(queryMatch)
    targetCol = Collection.Collection(targetMatch)
    queryUniverse = InfiniteUniverse()
    queryUniverse.addObject(queryCol)
    targetUniverse = InfiniteUniverse()
    targetUniverse.addObject(targetCol)

    #Return transformation mapping query to target
    return queryCol.findTransformation(targetUniverse.configuration())

"""Returns the atoms from given residue with the given names"""
def getAtoms(residue, names):
    #Input can also be a single string, not in a list
    if(isinstance(names, str)):
        names = [names]

    matchAtoms = []

    #Try to determine type of residue
    if(hasattr(residue, 'atoms')): #Something with an atoms field
        for residueAtom in residue.atoms:
            for n in range(len(names)):
                if (residueAtom.name == names[n]):
                    matchAtoms.append(residueAtom)
    elif(hasattr(residue, '__getitem__')): #Some sort of list
        for a in range(len(residue)):
            for n in range(len(names)):
                if (residue[a].name == names[n]):
                    matchAtoms.append(residue[a])

    return matchAtoms


On Tue, 27 May 2003, Konrad Hinsen wrote:

> On Tuesday 27 May 2003 20:14, Kyle Krull wrote:
>
> > 	Does anybody know what could cause this sort of error?  I've tried
> > looking at the code for findTransformationAsQuaternion(), but it's a bit
> > confusing to me.  What I need is for the atoms to be matched by name, but
> > I'm not sure if this is being done or not.
>
> No. The transformation code is made for comparing two configurations of the
> same system. You should in fact get an error message when you compare
> configurations of different systems. How are you doing it?
>
> There is currently no provision for matching atoms in different molecules in
> MMTK. Matching by name within a residue is rather easy to code in Python
> though. What you should do is create a new Configuration object and then
> store the positions of the matching atoms in it. Then do a superposition fit.
>
> Konrad.
> --
> -------------------------------------------------------------------------------
> Konrad Hinsen                            | E-Mail: hinsen@cnrs-orleans.fr
> Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24
> Rue Charles Sadron                       | Fax:  +33-2.38.63.15.17
> 45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
> France                                   | Nederlands/Francais
> -------------------------------------------------------------------------------
>
>
>