Match

Defines a match object used to build and refine matches between Molecule type objects. Matches are build by matching pairs of Particles from each Molecule.

[ GAMB | Source | Keywords | Summary | Ancestors | All Members | Descendants ]

Quick Index

AUTHORS
CHANGES LOG
GOALS
USAGE

Class Summary

class Match

{
public:
class ParticleMatch ;
// Contructors
Match();
Match(const RigidTrans3& rt);
Match(const Match& m);
// Match construction and refinement methods.
bool add(const unsigned int modelParticle, const unsigned int sceneParticle, const float score, const float priority);
void add(const unsigned int modelParticle, const unsigned int sceneParticle, const float score );
void add(const ParticleMatch& pm);
float calculateTotalScore();
// Inspection methods.
short size() const;
float rmsd() const;
float totalScore() const;
const RigidTrans3& rigidTrans() const;
int sceneParticle(const unsigned int model) const;
int modelParticle(const unsigned int scene) const;
const ParticleMatch& operator[](const unsigned int index) const ;
ParticleMatch& operator[](const unsigned int index) ;
template< class TMolecule> void calculateBestFit(const TMolecule& model, const TMolecule& scene);
static template< class TMolecule> float calculateLeastSquaresError(const TMolecule& model, const TMolecule& scene);
static template< class TMolecule> float calculateRMSD(const TMolecule& model, const TMolecule& scene);
template< class TComperator> void sortMatchList(const TComperator& comperator);
void clear() ;
protected:
}; // Match

Back to the top of Match


AUTHORS

Meir Fuchs. (meirfux@math.tau.ac.il)

Copyright: SAMBA group, Tel-Aviv Univ. Israel, 1997.

Back to the top of Match


CHANGES LOG

Back to the top of Match


GOALS

The Match class was designed for match building, handling and reefinement. A match assumes two Molecule objects. Using specified pairs of Particles taken from the two Molecules the match is built. A Match has a score, an RMS score and a rigid transformation used by the match. This rigid transformation may be refined and changed by finding the best rigid transformation to match the given pairs of particles stored in the Match.

Special attention should be given to the add method. This method lets the user add a pair to the match. Besides specifying the indices of the Particles within the Molcules the add method recieves a score parameter and a priority parameter. The score parameter specifies how much the Particle pair contributes to the score. The priority tells the add method how "important" the pair is. If a different pair is added, one that clashes with the first pair (i.e. the particles overlap) add has to decide which pair to bump off). The descision is made using the highest priority. An example of a priority function would the inverse distance. In this case add will prefer the closer pair even if the pair with the longer distance scores better.

Becasue of the difficulty in determinig how a match should be constucted and built the non-public members of this class were left protected. This allows a user to write Match descendants that best fit his needs.

Back to the top of Match


USAGE

The following program is a demo utilizing most of the methods supported by the Match object. Given two Molecule<Particle> objects, model and scene this program will randomly match pairs of particles from the molecules using the inverse distance for both score and priority. Every 200 attempts to add random pairs to the match the program recalculates the best linear transformation. This process is repeated 1000 times for a total of 200,000 attempted pair additions.

    Match M;
    for (int i=0; i<1000; i++) {
      for (int j=0; j<200; j++) {
        // randomly pick pair
        unsigned int modelParticle = model.size()*drand48();
	unsigned int sceneParticle = scene.size()*drand48();
	// score is pair distance inverse. 
	float score = (1 / (1+(model[modelParticle] | scene[sceneParticle])));
	// add pair according to score
	M.add(modelParticle, sceneParticle, score ,score);
      } // j
      M.calculateBestFit(model, scene);  // every 200 random pairs recalc
      cout << M.rigidTrans() << '\n';    // rig. trans. and print it.
    } // i

    int matchingParticle;
    for(int i=0; i<model.size(); i++)
      if ((matchingParticle = M.sceneParticle(i)) >= 0)
        cout << i << '\t' << matchingParticle << '\n';

Comment: Generally, it is expected (By me at least) that if a very large linear match infact exists between model and scene (e.g. try model=scene) the calculated rigid transformation will probablistically tend to such a match.

Back to the top of Match


class ParticleMatch ;

ParticleMatch is used by the class implementation to store matching pairs within an STL vector.

  class ParticleMatch
  {
  public:
    ParticleMatch();
    ParticleMatch(unsigned int model, unsigned int scene, 
		  float sc, float pri);

Back to the top of Match


Match();

Construct a new match.

  Match();

Back to the top of Match


Match(const RigidTrans3& rt);

Contruct a new Match object using the candidate rigid transformation used to match the two sets of points. This rigid transformation may be further enhanced after a set of matching pairs is added using the calculateBestFit method.

  Match(const RigidTrans3& rt);

Back to the top of Match


Match(const Match& m);

Match copy contructor. Implicitely declared to make sure that all data referred to by the Match object is actually copied.

  Match(const Match& m);

Back to the top of Match


bool add(const unsigned int modelParticle, const unsigned int sceneParticle, const float score, const float priority);

Add a match pair. The pair is defined using two integers (possibly indices into some array of objects), a match score and a priority. The match score defines how much matching the model particle to the scene particle contributes to the total match score. This score should reflect "how well the pair of particles fit together". A second parameter sent with the pair is their priority. Two particles may have a high score but matching one of the particles with a different particle might be "more correct". For example one might use inverse distance as a priority - prefering particles that are closer and use some bio-chemical properties for score (e.g. hydrophobicity, residue match using PAM scores etc.). The function returns true if the pair of particles was actually added.

  bool add(const unsigned int modelParticle, const unsigned int sceneParticle, 
           const float score, 
           const float priority);

Back to the top of Match


void add(const unsigned int modelParticle, const unsigned int sceneParticle, const float score );

This version of add does not use priority and does not check for double references to the same particles in the match list. The user may prefer to overlook doubly referenced particles in many cases. This method is also faster because no search is performed on the existing pairs.

  void add(const unsigned int modelParticle, const unsigned int sceneParticle, 
           const float score = 1.0);

Back to the top of Match


void add(const ParticleMatch& pm);

Adds ParticleMatch object

  void add(const ParticleMatch& pm);

Back to the top of Match


float calculateTotalScore();

Calculate the total score of the match using the pair scores given for each pair in the match (See the add method).

  float calculateTotalScore();

Back to the top of Match


short size() const;

Returns the match size.

  short size() const;

Back to the top of Match


float rmsd() const;

After calculating the best linear transformation using calculateBestFit this method will return the RMSD of the match.

  float rmsd() const;

Back to the top of Match


float totalScore() const;

After calculating the total score of the match using calculateTotalScore this method will return the total score.

  float totalScore() const;

Back to the top of Match


const RigidTrans3& rigidTrans() const;

At any point, the rigid transformation currently used by the match will be returned.

  const RigidTrans3& rigidTrans() const;

Back to the top of Match


int sceneParticle(const unsigned int model) const;

Given a model particle returns the matching scene particle. If no such particle is found the method will return a negative value.

  int sceneParticle(const unsigned int model) const;

Back to the top of Match


int modelParticle(const unsigned int scene) const;

Given a scene particle returns the matching model particle. If no such particle is found the method will return a negative value.

  int modelParticle(const unsigned int scene) const;

Back to the top of Match


const ParticleMatch& operator[](const unsigned int index) const ;

Return information about the pair indexed by index in the match in the form of a ParticleMatch object reference.

  const ParticleMatch& operator[](const unsigned int index) const                      
;

Function is currently defined inline.


Back to the top of Match


ParticleMatch& operator[](const unsigned int index) ;

Return information about the pair indexed by index in the match in the form of a ParticleMatch object reference.

  ParticleMatch& operator[](const unsigned int index)                      
;

Function is currently defined inline.


Back to the top of Match


template< class TMolecule> void calculateBestFit(const TMolecule& model, const TMolecule& scene);

Calculate the best rigid transformation to minimize the inter-point RMSD using the pair scores as weights. The method accepts the two TMolecules from which the particles are taken from and from which it will get the particles positions. TMolecule should support operator[], like vector<>.

  template< class TMolecule>
  void calculateBestFit(const TMolecule& model, const TMolecule& scene);  

Back to the top of Match


template< class TMolecule> float calculateLeastSquaresError(const TMolecule& model, const TMolecule& scene);

Calculates the least-squares error between the two given TMolecules. A negative value is returned in case of an error.
TMolecule is assumed to be a collection of elements with 3D coordinates. Thus, TMolecule should support operator[] that returns an element with a cast Vector3() opertator. Examples for TMolecule are: vector<Vector3> and Molecule<Atom>.
Author: Oranit Dror (oranit@tau.ac.il)

  template< class TMolecule>
  static float calculateLeastSquaresError(const TMolecule& model, const TMolecule& scene);

Back to the top of Match


template< class TMolecule> float calculateRMSD(const TMolecule& model, const TMolecule& scene);

Calculates the RMSD between the two given TMolecules. A negative is be returned in case of an error.
TMolecule is assumed to be a collection of elements with 3D coordinates. Thus, TMolecule should support operator[] that returns an element with a cast Vector3() opertator. Examples for TMolecule are: vector<Vector3> and Molecule<Atom>.
Author: Oranit Dror (oranit@tau.ac.il)

  template< class TMolecule>
  static float calculateRMSD(const TMolecule& model, const TMolecule& scene);

Back to the top of Match


template< class TComperator> void sortMatchList(const TComperator& comperator);

Sort the match list according to the given Comperator object. The Comperator object is a Binary Predicate that compares two objects, returning true if the first precedes the second. This predicate must satisfy the standard mathematical definition of a strict weak ordering. The precise requirements are stated in the STL StrictWeakOrdering documentation, but what they roughly mean is that the predicate has to behave the way that "less than" behaves: if a is less than b then b is not less than a, if a is less than b and b is less than c then a is less than c, and so on. Author: Oranit Dror (oranit@tau.ac.il)

  template< class TComperator>
  void sortMatchList(const TComperator& comperator);

Back to the top of Match


void clear() ;

Erase the particle pairs of the match list

  void clear()                         
;

Function is currently defined inline.


Back to the top of Match


All Members

public:
class ParticleMatch ;
// Match construction and refinement methods.
bool add(const unsigned int modelParticle, const unsigned int sceneParticle, const float score, const float priority);
void add(const unsigned int modelParticle, const unsigned int sceneParticle, const float score );
void add(const ParticleMatch& pm);
float calculateTotalScore();
// Inspection methods.
short size() const;
float rmsd() const;
float totalScore() const;
const RigidTrans3& rigidTrans() const;
int sceneParticle(const unsigned int model) const;
int modelParticle(const unsigned int scene) const;
const ParticleMatch& operator[](const unsigned int index) const ;
ParticleMatch& operator[](const unsigned int index) ;
template< class TMolecule> void calculateBestFit(const TMolecule& model, const TMolecule& scene);
static template< class TMolecule> float calculateLeastSquaresError(const TMolecule& model, const TMolecule& scene);
static template< class TMolecule> float calculateRMSD(const TMolecule& model, const TMolecule& scene);
template< class TComperator> void sortMatchList(const TComperator& comperator);
void clear() ;
protected:

Back to the top of Match


Ancestors

Class does not inherit from any other class.

Back to the top of Match


Descendants

Class is not inherited by any others.

Back to the top of Match


Generated from source by the Cocoon utilities on Sun Nov 15 13:35:25 2009 .

Report problems to jkotula@unimax.com