This example demonstrates how to subset a surface based on an associated molecular property. The largest hydrophobic patch will be extracted. The following simple definition of hydrophobic will be used: vertices associated with atoms in hydrophobic residues are considered hydrophobic.
This property is first mapped into the clique of one. The surface is
then cropped to only be the hydrophobic
parts. OEMakeConnectedSurfaceCliques is used to organize the
surface into connected components. Each clique between 1 and
nclqs inclusive is a different component. The area of each
component is then calculated using the OESurfaceCliqueArea
function. The surface is then cropped to the largest component.
1 /*******************************************************************
2 * Copyright 2006, 2007, OpenEye Scientific Software, Inc.
3 *******************************************************************/
4 #include "openeye.h"
5
6 #include "oeplatform.h"
7 #include "oesystem.h"
8 #include "oechem.h"
9 #include "oespicoli.h"
10
11 using namespace OEChem;
12 using namespace OESystem;
13 using namespace OEPlatform;
14 using namespace OESpicoli;
15
16 bool AtomInHydrophobicResidue(OEAtomBase *atom)
17 {
18 switch(OEGetResidueIndex(atom))
19 {
20 case OEResidueIndex::ALA:
21 case OEResidueIndex::ILE:
22 case OEResidueIndex::LEU:
23 case OEResidueIndex::MET:
24 case OEResidueIndex::PHE:
25 case OEResidueIndex::PRO:
26 case OEResidueIndex::TRP:
27 case OEResidueIndex::VAL:
28 return true;
29 default:
30 return false;
31 }
32 }
33
34 int main(int argc, char *argv[])
35 {
36 if (argc!=3)
37 OEThrow.Usage("%s <protein> <surface>", argv[0]);
38
39 oemolistream ifs(argv[1]);
40 OEGraphMol mol;
41 OEReadMolecule(ifs, mol);
42 OEPerceiveResidues(mol);
43 OEAssignBondiVdWRadii(mol);
44
45 // Generate the molecular surface
46 OESurface surf;
47 OEMakeMolecularSurface(surf, mol, 0.5f);
48
49 // Mark all the vertices associated with hydrophobic atoms
50 for (unsigned int i = 0; i < surf.GetNumVertices(); ++i)
51 {
52 OEAtomBase *atom=mol.GetAtom(OEHasAtomIdx(surf.GetAtomsElement(i)));
53 if (AtomInHydrophobicResidue(atom))
54 surf.SetVertexCliqueElement(i, 1);
55 }
56
57 // Crop to only those triangles
58 OESurfaceCropToClique(surf, 1);
59
60 // nlqs is the number of different connected components
61 unsigned int nclqs = OEMakeConnectedSurfaceCliques(surf);
62
63 // Find the largest component
64 unsigned int maxclq = 0;
65 double maxarea = 0.0;
66 for (unsigned int i = 1; i <= nclqs; ++i)
67 {
68 double area = OESurfaceCliqueArea(surf, i);
69 oeout << "clique: " << i << " area: " << area << oeendl;
70 if (area > maxarea)
71 {
72 maxclq = i;
73 maxarea = area;
74 }
75 }
76
77 // Crop to it
78 OESurfaceCropToClique(surf, maxclq);
79
80 OEWriteSurface(argv[2], surf);
81
82 return 0;
83 }
Note that the same OESurface object is reused for each of the
subsetted surfaces. To maintain the original surface as well as the
surface subset, the OEMakeCliqueSurface function can be used.