This file is indexed.

/usr/include/mmdb/mmdb_graph.h is in libmmdb-dev 1.23.2.1-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
//  =================================================================
//
//   CCP4 Coordinate Library: support of coordinate-related
//   functionality in protein crystallography applications.
//
//   Copyright (C) Eugene Krissinel 2000-2008.
//
//    This library is free software: you can redistribute it and/or
//    modify it under the terms of the GNU Lesser General Public
//    License version 3, modified in accordance with the provisions
//    of the license to address the requirements of UK law.
//
//    You should have received a copy of the modified GNU Lesser
//    General Public License along with this library. If not, copies
//    may be downloaded from http://www.ccp4.ac.uk/ccp4license.php
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU Lesser General Public License for more details.
//
//  =================================================================
//
//    08.07.08   <--  Date of Last Modification.
//                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//  -----------------------------------------------------------------
//
//  **** Module  :  mmdb_graph  <interface>
//       ~~~~~~~~~
//  **** Classes :  CVertex     ( graph vertex                        )
//       ~~~~~~~~~  CEdge       ( graph edge                          )
//                  CGraph      ( structural graph                    )
//                  CMatch      ( match of structural graphs          )
//                  CGraphMatch ( CSIA algorithms for graphs matching )
//
//   (C) E. Krissinel 2000-2008
//
//  When used, please cite:
//
//   Krissinel, E. and Henrick, K. (2004)
//   Common subgraph isomorphism detection by backtracking search.
//   Software - Practice and Experience, 34, 591-607.
//
//  =================================================================
//

#ifndef  __MMDB_Graph__
#define  __MMDB_Graph__


#ifndef  __TIME_H
#include <time.h>
#endif

#ifndef  __MMDB_Atom__
#include "mmdb_atom.h"
#endif

//  ==========================  CVertex  ============================

DefineClass(CVertex)

#define  CHIRAL_RIGHT      0x10000000
#define  CHIRAL_LEFT       0x20000000
#define  ATOM_LEAVING      0x40000000
#define  HYDROGEN_BOND     0x0F000000
#define  SYMREL_MASK       0x00FF0000
#define  CHIRAL_MASK       0xCFFFFFFF
#define  TYPE_MASK         0x00FFFFFF

class CVertex : public CStream  {

  friend class CGraph;
  friend class CGraphMatch;
  friend class CSBase0;

  public:

    CVertex ();
    CVertex ( RPCStream Object );
    CVertex ( int  vtype, cpstr vname );
    CVertex ( int  vtype );
    CVertex ( cpstr chem_elem );
    CVertex ( cpstr chem_elem, cpstr name );
    ~CVertex();

    void  SetVertex  ( cpstr chem_elem );
    void  SetVertex  ( int vtype, cpstr vname );
    void  SetVertex  ( int vtype   );
    void  SetType    ( int vtype   );
    void  SetTypeExt ( int typeExt );

    void  RemoveChirality();
    void  LeaveChirality ( int eltype );

    void  SetName     ( cpstr vname );
    void  SetProperty ( int vprop  );
    void  SetID       ( int vid    );
    void  AddBond     ();
    void  CopyNBonds  ( PCVertex V );
    int   GetProperty () { return property; }
    int   GetID       () { return id;       }
    int   GetUserID   () { return user_id;  }
    pstr  GetName     () { return name;     }
    int   GetType     () { return type;     }
    int   GetNBonds   ();

    void  SaveType    ();  // in userid
    void  RestoreType ();  // from userid
    void  CopyType    ( PCVertex V );

    virtual void Print ( int PKey );

    virtual void Copy ( PCVertex V );

    void  read  ( RCFile f );
    void  write ( RCFile f );

    void  mem_read  ( cpstr S, int & l );
    void  mem_write ( pstr S, int & l );

  protected:
    pstr name;     // name may be general, "C", "Hg", "Cl" etc.
    int  type;     // type of vertex, see comments in mmdb_graph.cpp
    int  type_ext; // vertex type extention
    int  property; // flagwise properties -- user-defined
    int  id;       // a graph-defined vertex id
    int  user_id;  // a user-defined vertex id

    void InitVertex();

};

DefineStreamFunctions(CVertex)



//  ===========================  CEdge  =============================

#define BOND_SINGLE    1
#define BOND_DOUBLE    2
#define BOND_AROMATIC  3
#define BOND_TRIPLE    4

DefineClass(CEdge)

class CEdge : public CStream  {

  friend class CGraph;
  friend class CGMatch;
  friend class CSBase0;

  public:

    CEdge ();
    CEdge ( RPCStream Object );
    CEdge ( int vx1, int vx2, int btype );  // vx1,vx2 are numbered
                                            // as 1,2,3 on and refer
                                            // to vertices in the order
                                            // as they were added to
                                            // the graph; btype>0
    ~CEdge();

    void  SetEdge ( int vx1, int vx2, cpstr btype );
    void  SetEdge ( int vx1, int vx2, int  btype ); // btype>0

    void  SetType     ( int btype );
    void  SetProperty ( int eprop );
    void  SaveType    ();  // in property
    void  RestoreType ();  // from property

    int   GetVertex1  () { return v1-1;     }
    int   GetVertex2  () { return v2-1;     }
    int   GetType     () { return type;     }
    int   GetProperty () { return property; }

    virtual void Print ( int PKey );

    virtual void Copy  ( PCEdge G );

    void  read  ( RCFile f );
    void  write ( RCFile f );

    void  mem_read  ( cpstr S, int & l );
    void  mem_write ( pstr S, int & l );

  protected:
    int  v1,v2;  //  >=1
    int  type;
    int  property;

    void  InitEdge();

};

DefineStreamFunctions(CEdge)



//  ==========================  CGraph  ============================

#define MKGRAPH_Ok             0
#define MKGRAPH_NoAtoms        -1
#define MKGRAPH_ChangedAltLoc  1
#define MKGRAPH_MaxOccupancy   2

DefineClass(CGraph)

class CGraph : public CStream  {

  friend class CGraphMatch;
  friend class CSBase0;

  public :

    CGraph ();
    CGraph ( PCResidue R, cpstr altLoc=NULL );
    CGraph ( RPCStream Object );
    ~CGraph();

    void  Reset   ();
    void  SetName ( cpstr gname );
    pstr  GetName () { return name; }

    //   AddVertex(..) and AddEdge(..) do not copy the objects, but
    // take them over. This means that application should forget
    // about pointers to V and G once they were given to CGraph.
    // Vertices and edges  must be allocated newly prior each call
    // to AddVertex(..) and AddEdge(..).
    void  AddVertex   ( PCVertex  V );
    void  AddEdge     ( PCEdge    G );
    void  SetVertices ( PPCVertex V, int vlen );
    void  SetEdges    ( PPCEdge   G, int glen );

    void  RemoveChirality();
    void  LeaveChirality ( int eltype );

    //   MakeGraph(..) makes a graph corresponding to residue R.
    // The graphs vertices then correspond to the residue's atoms
    // (CVertex::userid points to atom R->atom[CVertex::userid]),
    // edges are calculated as chemical bonds between atoms basing
    // on the table of cut-off distances.
    //   altCode specifies a particular conformation that should be
    // used for making the graph. If it is set to "" or NULL ("empty"
    // altcode) but the residue does not have conformation which
    // contains *only* ""-altcode atoms, a conformation corresponding
    // to maximal occupancy will be used. The same will happen if
    // altcode information in residue is not correct, whatever altCode
    // is specified.
    //   After making the graph, Build(..) should be called as usual
    // before graph matching.
    //   Non-negative return means that graph has been made.
    // MakeGraph(..) may return:
    //   MKGRAPH_Ok             everything is Ok
    //   MKGRAPH_NoAtoms        residue does not have atoms, graph
    //                          is not made
    //   MKGRAPH_ChangedAltLoc  a different altcode was used because
    //                          the residue has only one altcode and
    //                          that is different of
    //   MKGRAPH_MaxOccupancy   a maximal-occupancy conformation has
    //                          been chosen because of default
    //                          ""-altcode supplied or incorrect
    //                          altcode information in the residue
    int   MakeGraph   ( PCResidue R, cpstr altLoc=NULL );

    int   MakeGraph   ( PPCAtom atom, int nAtoms );

    void  HideType    ( int bond_vx_type );
    void  ExcludeType ( int type );

    void  MakeSymmetryRelief ( Boolean noCO2 );
    void  IdentifyRings      ();

    int   Build       ( Boolean bondOrder );  // returns 0 if Ok

    void  MakeVertexIDs      ();  // simply numbers vertices as 1.. on
    int   GetVertexID        ( int vertexNo );
    int   GetVertexNo        ( cpstr vname  );
    // GetBondedVertexID(..) works after MoveType(..)
    int   GetNBondedVertices ( int vertexNo );
    int   GetBondedVertexID  ( int vertexNo, int bond_vx_type,
                               int bondNo );

    PCVertex   GetVertex ( int vertexNo );  // 1<=vertexNo<=nVertices
    int   GetNofVertices () { return nVertices; }

    PCEdge    GetEdge    ( int edgeNo );    // 1<=edgeNo<=nEdges
    int   GetNofEdges    () { return nEdges;    }

    void  GetVertices ( PPCVertex & V, int & nV );
    void  GetEdges    ( PPCEdge   & E, int & nE );

    virtual void Print();
    void  Print1();

    virtual void Copy ( PCGraph G );

    void  read  ( RCFile f );
    void  write ( RCFile f );

    void  mem_read  ( cpstr S, int & l );
    void  mem_write ( pstr S, int & l );

  protected :
    pstr      name;
    int       nVertices,nEdges, nAllVertices,nAllEdges;
    PPCVertex Vertex;
    PPCEdge   Edge;
    imatrix   graph;

    void  InitGraph ();
    void  FreeMemory();

  private :
    int  nVAlloc,nEAlloc,nGAlloc;

};

DefineStreamFunctions(CGraph)


//  ==========================  CMatch  ============================

DefineClass(CMatch)
DefineStreamFunctions(CMatch)

class CMatch : public CStream  {

  friend class CGraphMatch;

  public :

    CMatch ();
    CMatch ( RPCStream Object );
    CMatch ( ivector FV1, ivector FV2, int nv, int n, int m );
    ~CMatch();

    // FV1[] and FV2[] are copied into internal buffers
    void SetMatch ( ivector FV1, ivector FV2, int nv, int n, int m );

    Boolean isMatch       ( ivector FV1, ivector FV2, int nv );
    Boolean isCombination ( ivector FV1, ivector FV2, int nv );

    // do not allocate or dispose FV1 and FV2 in application!
    void GetMatch ( ivector & FV1, ivector & FV2, int & nv,
                    realtype & p1, realtype & p2 );

    void read  ( RCFile f );
    void write ( RCFile f );

    void mem_read  ( cpstr S, int & l );
    void mem_write ( pstr S, int & l );

  protected :
    int     n1,n2,mlength;
    ivector F1,F2;

    void InitMatch();

  private :
    int nAlloc;

};


//  =======================  CGraphMatch  =========================

#define  _UseRecursion

#define  GMF_UniqueMatch     0x00000001
#define  GMF_NoCombinations  0x00000002

#define  EXTTYPE_Ignore      0
#define  EXTTYPE_Equal       1
#define  EXTTYPE_AND         2
#define  EXTTYPE_OR          3
#define  EXTTYPE_XOR         4
#define  EXTTYPE_NotEqual    5
#define  EXTTYPE_NotAND      6
#define  EXTTYPE_NotOR       7


DefineClass(CGraphMatch)

class CGraphMatch : public CStream  {

  public :

    CGraphMatch ();
    CGraphMatch ( RPCStream Object );
    ~CGraphMatch();

    void SetFlag          ( word flag );
    void RemoveFlag       ( word flag );
    void SetMaxNofMatches ( int maxNofMatches, Boolean stopOnMaxN );
    void SetTimeLimit     ( int maxTimeToRun=0 );
    Boolean GetStopSignal () { return Stop; }

    void Reset();

    //  MatchGraphs looks for maximal common subgraphs of size
    //  not less than minMatch. The number of found subgraphs
    //  is returned by GetNofMatches(), the subgraph vertices
    //  are returned by GetMatch(..). Control parameters:
    //      vertexType   True if vertex type should be taken
    //                   into account and False otherwise
    //      vertexExt    key to use extended vertex types (defined
    //                   as type_ext in CVertex).
    void MatchGraphs    ( PCGraph Gh1, PCGraph Gh2, int minMatch,
                          Boolean vertexType=True,
                          int     vertexExt=EXTTYPE_Ignore );
    void PrintMatches   ();
    int  GetNofMatches  () { return nMatches; }
    int  GetMaxMatchSize() { return maxMatch; }

    // do not allocate or dispose FV1 and FV2 in application!
    // FV1/p1 will always correspond to Gh1, and FV2/p2 -
    // to Gh2 as specified in MatchGraphs(..)
    void GetMatch ( int MatchNo, ivector & FV1, ivector & FV2,
                    int & nv, realtype & p1, realtype & p2 );

    void read  ( RCFile f );
    void write ( RCFile f );

    void mem_read  ( cpstr S, int & l );
    void mem_write ( pstr  S, int & l );

  protected :
    PCGraph   G1,G2;
    PPCVertex V1;
    PPCVertex V2;
    imatrix   c1,c2;
    Boolean   swap;
#ifndef _UseRecursion
    ivector   jj;
#endif
    int       n,m;

    imatrix3  P;
    imatrix   iF1;
    ivector   F1,F2,ix;

    int       nMatches,maxNMatches;
    PPCMatch  Match;
    Boolean   wasFullMatch,Stop,stopOnMaxNMathches;
    word      flags;
    int       maxMatch,timeLimit;

    void    InitGraphMatch();
    void    FreeMemory    ();
    void    FreeRecHeap   ();
    void    GetMemory     ();
    void    GetRecHeap    ();
    int     Initialize    ( Boolean vertexType, int vertexExt );
#ifdef _UseRecursion
    void    Backtrack     ( int i );          // exact matching
#else
    void    Ullman        ();
#endif
    void    Backtrack1    ( int i, int k0 );  // exact/partial matching
    void    CollectMatch  ( int nm );

  private :
    int     nAlloc,mAlloc,nMAlloc;
    time_t  startTime;

};

DefineStreamFunctions(CGraphMatch)

extern void  SetGraphAllocPortion ( int alloc_portion );

/*
extern void  TestGraphMatch();
*/


#endif