MOLECULE.H

Description : Declaration of classes for atoms and molecules.

Header files called upon : VECTOR.H , MATRIX.H

Files required in project : MOLECULE.CPP , MOLGEOM.CPP

Class details are as follows:

Constant definitions
const int MAXATS=500; maximum number of atoms
const int MAXRES=100; maximum number of residues
const float RADDEG=57.2958; conversion from radians to degrees
const float COS=0.99619; cosine of 5ø
const float SIN=0.08716; sine of 5ø
Non-class functions
void *operator new(size_t s, int no_of_atoms)
Overloads 'new' operator to include an integer parameter to clarify specifically, for example, which array element of an object memory is being allocated for (useful when memory is exhausted as function will write out specifically which array element it failed at)
eg atm[i] = new(i) Atom;
NB function defined in MOLECULE.CPP

inline ostream& operator<< (ostream& os, Atom& a)
Overloads '<<' operator to write out residue name and number of an atom
eg cout << atm1;

Class declaration : Atom

Member variables (protected)
char atnum[5]; string denoting atom number
char atname[5]; string denoting atom name
char resname[4]; string denoting residue name
char resnum[7]; string denoting residue number
Vector xyz; vector containing atom coordinates
float xpt, ypt; float variables
Atom *bond[50]; pointer to other atoms for bond assignment
int no_of_bonds; number of bonds for current atom
Constructors (public)
Atom(){}
Default constructor for Atom class
eg Atom atm1;

Atom(float x, float y, float z) : xyz(x,y,z) {}
Constructor to store objects of class 'Atom' whose coordinates have been initialized
eg Atom atm1(0.1, 0.2, 0.3);

Atom(char *pdb_line)
Constructor that stores the following information as extracted from a line from a PDB file: atom name, atom number, residue name, residue number, coordinates
eg Atom atm1(line);
NB function defined in MOLECULE.CPP

virtual ~Atom(){}
Destructor
Member functions (public)
float &GetX()
Returns x-coordinate of atom
eg float f = atm1.GetX();

float &GetY()
Returns y-coordinate of atom
eg float f = atm1.GetY();

float &GetZ()
Returns z-coordinate of atom
eg float f = atm1.GetZ();

Vector &GetXyz()
Returns vector of coordinates of atom
eg vec1 = atm1.GetXyz();

int &GetNoOfBonds()
Returns number of bonds assigned to atom
eg int i = atm1.GetNoOfBonds();

char *GetAtnum()
Returns atom number of atom as a string
eg char atomnumber[5] = atm1.GetAtnum();

char *GetAtname()
Returns atom name
eg atomname = atm1.GetAtname();

char *GetResname()
Returns residue name of atom
eg residuename = atm1.GetResname();

char *GetResnum()
Returns residue number of atom as a string
eg char residuenumber[7] = atm1.GetResnum();

Atom *GetBond(const int &i)
Returns pointer to an atom corresponding to 'i'th bond of current atom
eg Atom *atm_ptr; atm_ptr = atm1.GetBond(3);

void PutBond(Atom *pt, const &i)
Defines 'i'th bond of current atom by linking it to an atom specified by an atom pointer
eg atm1.PutBond(atm_ptr,3)

static float distance(Atom *atomPt[2])
Returns the bond distance between two atoms specified by an atom pointer
eg Atom *atm_ptr[2];
assign atm_ptr to atoms
cout << Atom::distance(atm_ptr);
NB function defined in MOLGEOM.CPP

static float angle(Atom *atomPt[3])
Returns the bond angle (in degrees) between three atoms specified by an atom pointer
eg Atom *atm_ptr[3];
assign atm_ptr to atoms
cout << Atom::angle(atm_ptr);
NB function defined in MOLGEOM.CPP

static float torsion(Atom *atomPt[4])
Returns the torsion angle (in degrees) between four atoms specified by an atom pointer
eg Atom *atm_ptr[4];
assign atm_ptr to atoms
cout << Atom::torsion(atm_ptr);
NB function defined in MOLGEOM.CPP

void rotate_x(float rot_dir)
Rotates atom by 5ø (as defined by SIN and COS constants) about x-axis; if rot_dir = 1, then anticlockwise rotation looking down axis towards origin, if rot_dir = -1, then clockwise rotation looking down axis towards origin
eg atm1.rotate_x(1)

void rotate_y(float rot_dir)
Rotates atom by 5ø (as defined by SIN and COS constants) about y-axis; if rot_dir = 1, then anticlockwise rotation looking down axis towards origin, if rot_dir = -1, then clockwise rotation looking down axis towards origin
eg atm1.rotate_y(1)

void rotate_z(float rot_dir)
Rotates atom by 5ø (as defined by SIN and COS constants) about z-axis; if rot_dir = 1, then anticlockwise rotation looking down axis towards origin, if rot_dir = -1, then clockwise rotation looking down axis towards origin
eg atm1.rotate_z(1)

void Atom::rotatePdbAtoms(const char *inFile, const char *outFile, const Matrix &rot, const Vector &axis)
Opens a PDB file, reads in coordinate lines, extracts coordinates, rotates coordinates according to matrix using vector as centre of rotation (not origin), and outputs into user-specified file in PDB format
eg rotatePdbAtoms(infile, outfile, mat1, vec1);
NB1 number of atoms restricted by MAXATS as defined in MOLECULE.H
NB2 function defined in MOLECULE.CPP

void Atom::rotatePdbAtoms(const char *inFile, const char *outFile, const Matrix &rot, const Matrix &scale, const Vector &trans)
Opens a PDB file, reads in coordinate line, extracts coordinates, scales coordinates, adds translation vector to coordinates, rotates coordinates about origin (not vector as centre of rotation) and outputs into user-specified file in PDB format
eg rotatePdbAtoms(infile, outfile, mrot, mscale, vtrans);
NB1 number of atom restricted by constant MAXATS
NB2 function defined in MOLECULE.CPP

Derived class declaration : Natom (derived from class Atom)

Constructors (public)
Natom(char *buffer) : Atom(buffer) {}
Constructor with initialization derived from the argument which is a line read in from a PDB file
eg Natom natm1(line);

~Natom(){}
Destructor

Derived class declaration : CAatom (derived from class Atom)

Constructors (public)
CAatom(char *buffer) : Atom(buffer) {}
Constructor with initialization derived from the argument which is a line read in from a PDB file
eg CAatom caatm1(line);

~CAatom(){}
Destructor

Derived class declaration : Catom (derived from class Atom)

Constructors (public)
Catom(char *buffer) : Atom(buffer) {}
Constructor with initialization derived from the argument which is a line read in from a PDB file
eg Catom catm1(line);

~Catom(){}
Destructor

Derived class declaration : Oatom (derived from class Atom)

Constructors (public)
Oatom(char *buffer) : Atom(buffer) {}
Constructor with initialization derived from the argument which is a line read in from a PDB file
eg Oatom oatm1(line);

~Oatom(){}
Destructor

Derived class declaration : LigandAtom (derived from class Atom)

Constructors (public)
LigandAtom(char *buffer) : Atom(buffer) {}
Constructor that stores the following information as extracted from a line from a PDB file: coordinates, residue name, residue identifier (ie number as string)
eg LigandAtom latm1(line);
NB function defined in MOLECULE.CPP

~LigandAtom(){}
Destructor

Class declaration : Molecule

Member variables (protected)
const char *mol_name; (file)name of molecule eg p2ovo.pdb
int no_of_atoms; number of atoms in molecule
Atom *atom[MAXATS]; pointer to another other atoms
Vector centroid; vector for centroid of molecule
static int count; used for array reference of *geomAtom[4]
static Atom *geomAtom[4]; pointer to a maximum of four different atoms, used to explore bond connectivity network for calculation of bond distances, bond angles and torsion angles
Constructors (public)
Molecule(){}
Default constructor for molecule

Molecule(const char *name) : mol_name(name) {}
Constructor for molecule with initialized name
eg Molecule mol1("pdb2ovo.pdb");

Molecule(const Molecule &mol1, const Matrix &rot, const Vector &trans)
Constructor that creates a molecule by rotation about the origin, followed by a translation, of an already initialized molecule
eg Molecule mol2(mol1,matrot,vectrans);
NB1 mol2 is allocated the name 'rotated molecule', and number of atoms equal to that of mol1
NB2 function defined in MOLECULE.CPP

Molecule(const Molecule &m1, const Molecule &m2)
Constructor that creates a molecule by linearly concatenating two individual molecules by linking the atoms linearly
eg Molecule mol3(mol1,mol2);
NB1 mol3 is allocated the name "molecular sum", and contains number of atoms equal to the sum of those in mol1 and mol2
NB2 function defined in MOLECULE.CPP

virtual ~Molecule()
Destructor
Member functions
void PutNoAtoms(int &i)
Assigns number of atoms to a molecule
eg mol1.PutNoAtoms(100);

int &atom_total()
Returns number of atoms in molecule
eg int i = mol1.atom_total();

Atom *&GetAtom(int &i)
Points to 'i'th atom in array (array counts 0 to n-1)
eg Atom *atm_ptr; atm_ptr = mol1.GetAtom(5);

void findBonds(const float& maxBondlength, int oneDirection = 1)
Checks distance between all atoms and assigns a bond between atoms with distance less than that defined by parameter 'maxBondLength'. If 'oneDirection' is given value 0 then reciprocative arrangement occurs ie if atom1 assigned bond to atom2, then atom2 assigned bond to atom1; if 'oneDirection' assigned non-zero then non-reciprocative arrangement occurs, which is adequate for function 'calcGeometry' (see below). Default for 'oneDirection' is 1
eg mol1.findbonds(2.2);
NB function defined in MOLGEOM.CPP

void calcGeometry()
Steps through bond connection network for every atom in a molecule using 'traverse' function (see below) in order to calculate and write out bond distances, bond angles and torsion angles
eg mol1.calcGeometry();
NB1 bond connectivities must alreay have been allocated before using this function ie use function 'findbonds' (see above)
NB2 function defined in MOLGEOM.CPP

void traverse(Atom *pt)
Recursive function that steps through the bond connection network of a molecule on order to calculate and write out bond distances, bond angles and torsion angles. This function is called using function 'calcGeometry()' (see above)
NB function defined in MOLGEOM.CPP

void compare(Molecule &mol)
Checks for equivalent quantity of atoms, then executes an RMS deviation calculation by fitting parameterized molecule onto non-parameterized molecule (also detailing eigenvectors and eigenvalues) and specifies any atoms of the non-parameterized molecule whose RMS deviation with its counterpart is less than 2*sigma
eg mol1.compare(mol2);
NB function defined in MOLECULE.CPP

Class declaration : Residue

As yet undefined

Derived class declaration : Protein (derived from class Molecule)

Member variables (private)
int no_of_res; number of residues in molecule
Residue *residue[MAXRES]; pointers to other residues for connectivity
Constructors (public)
Protein(const char *mol_name)
Constructor to create protein class, details of which are extracted from PDB file (specified by molecule name) containing residue name, residue number and residue count
eg Protein prot1("p2ovo.pdb")
NB function defined in MOLECULE.CPP
Member functions (public)
void printTorsions(){}
As yet undefined

Derived class declaration : ProteinMainChain (derived from class Molecule)

Constructors (public)
ProteinMainChain(const char *mol_name)
Constructor to create protein main-chain, details of which are extracted from PDB file (specified by molecule name), and contain Atom class details of main-chain atoms
eg ProteinMainChain protmc1("p2ovo.pdb");
NB function defined in MOLECULE.CPP
Member functions (public)
void TorsionList()
Calculates and writes out torsion angles for protein main-chain
eg protmc1.torsionList();
NB function defined in MOLGEOM.CPP

Derived class declaration : AlphaCarbonChain (derived from class Molecule)

Constructors (public)
AlphaCarbonChain(const char *mol_name)
Constructor to create alpha-carbon chain, details of which are extracted from a PDB file (specified by molecule name), and contain Atom class details of alpha-carbon atoms
eg AlphaCarbonChain alcc1("p2ovo.pdb")
NB function defined in MOLECULE.CPP