This file is indexed.

/usr/include/rdkit/GraphMol/Atom.h is in librdkit-dev 201503-3.

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
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
//
//  Copyright (C) 2001-2014 Greg Landrum and Rational Discovery LLC
//
//   @@ All Rights Reserved @@
//  This file is part of the RDKit.
//  The contents are covered by the terms of the BSD license
//  which is included in the file license.txt, found at the root
//  of the RDKit source tree.
//
/*! \file Atom.h

  \brief Defines the Atom class and associated typedefs

*/  
#ifndef _RD_ATOM_H
#define _RD_ATOM_H

// Std stuff
#include <iostream>
#include <boost/foreach.hpp>

// ours
#include <Query/QueryObjects.h>
#include <RDGeneral/types.h>
#include <RDGeneral/Dict.h>
#include <GraphMol/details.h>

namespace RDKit{
  class ROMol;
  class RWMol;
  class AtomMonomerInfo;

  //! The class for representing atoms
  /*!

    <b>Notes:</b>
      - many of the methods of Atom require that the Atom be associated
        with a molecule (an ROMol).
      - each Atom maintains a Dict of \c properties:  
          - Each \c property is keyed by name and can store an
	    arbitrary type.
	  - \c Properties can be marked as \c calculated, in which case
	    they will be cleared when the \c clearComputedProps() method
	    is called.
          - Because they have no impact upon chemistry, all \c property
	    operations are \c const, this allows extra flexibility for
	    clients who need to store extra data on Atom objects.
      - Atom objects are lazy about computing their explicit and implicit valence
        values.  These will not be computed until their values are requested.

    <b>Chirality:</b>

    The chirality of an Atom is determined by two things:
      - its \c chiralTag
      - the input order of its bonds (see note below for handling of
        implicit Hs)

    For tetrahedral coordination, the \c chiralTag tells you what
    direction you have to rotate to get from bond 2 to bond 3 while looking
    down bond 1. This is pretty much identical to the SMILES representation of
    chirality.

    NOTE: if an atom has an implicit H, the bond to that H is considered to be
    at the *end* of the list of other bonds.

  */
  class Atom {
    friend class MolPickler; //!< the pickler needs access to our privates
    friend class ROMol;
    friend class RWMol;
  public:

    typedef boost::shared_ptr<Atom>    ATOM_SPTR;
    typedef boost::shared_ptr<const Atom>    C_ATOM_SPTR;
    // FIX: grn...
    typedef Queries::Query<int,Atom const *,true> QUERYATOM_QUERY;

    //! store hybridization
    typedef enum {
      UNSPECIFIED=0, //!< hybridization that hasn't been specified
      S,
      SP,
      SP2,
      SP3,
      SP3D,
      SP3D2,
      OTHER          //!< unrecognized hybridization
    } HybridizationType;

    //! store type of chirality
    typedef enum {
      CHI_UNSPECIFIED=0,  //!< chirality that hasn't been specified
      CHI_TETRAHEDRAL_CW, //!< tetrahedral: clockwise rotation (SMILES \@\@)
      CHI_TETRAHEDRAL_CCW,//!< tetrahedral: counter-clockwise rotation (SMILES \@)
      CHI_OTHER           //!< some unrecognized type of chirality
    } ChiralType;

    Atom();
    //! construct an Atom with a particular atomic number
    explicit Atom(unsigned int num);
    //! construct an Atom with a particular symbol (looked up in the PeriodicTable)
    explicit Atom(std::string what);
    Atom(const Atom & other);
    virtual ~Atom();

    //! makes a copy of this Atom and returns a pointer to it.
    /*!
      <b>Note:</b> the caller is responsible for <tt>delete</tt>ing the result
    */
    virtual Atom *copy() const;

    //! returns our atomic number
    int getAtomicNum() const { return d_atomicNum; };
    //! sets our atomic number
    void setAtomicNum(int newNum) { d_atomicNum = newNum; };

    //! returns our symbol (determined by our atomic number)
    std::string getSymbol() const;

    //! returns a reference to the ROMol that owns this Atom
    ROMol &getOwningMol() const { return *dp_mol; };
  
    //! returns our index within the ROMol
    unsigned int getIdx() const {return d_index;};
    //! sets our index within the ROMol
    /*!
      <b>Notes:</b>
        - this makes no sense if we do not have an owning molecule
	- the index should be <tt>< this->getOwningMol()->getNumAtoms()</tt>
    */
    void setIdx(unsigned int index) {d_index=index;};

    //! returns the explicit degree of the Atom (number of bonded
    //!   neighbors in the graph)
    /*!
      <b>Notes:</b>
        - requires an owning molecule
    */
    unsigned int getDegree() const;

    //! returns the total degree of the Atom (number of bonded
    //!   neighbors + number of Hs)
    /*!
      <b>Notes:</b>
        - requires an owning molecule
    */
    unsigned int getTotalDegree() const;

    //! \brief returns the total number of Hs (implicit and explicit) that
    //! this Atom is bound to
    /*!
      <b>Notes:</b>
        - requires an owning molecule
    */
    unsigned int getTotalNumHs(bool includeNeighbors=false) const;

    //! \brief returns the total valence (implicit and explicit)
    //! for an atom
    /*!
      <b>Notes:</b>
        - requires an owning molecule
    */
    unsigned int getTotalValence() const;

    //! returns the number of implicit Hs this Atom is bound to
    /*!
      <b>Notes:</b>
        - requires an owning molecule
    */
    unsigned int getNumImplicitHs() const;

    //! returns the explicit valence (including Hs) of this atom
    int getExplicitValence() const;

    //! returns the implicit valence for this Atom
    /*!
      <b>Notes:</b>
        - requires an owning molecule
    */
    int getImplicitValence() const;

    //! returns the number of radical electrons for this Atom
    /*!
      <b>Notes:</b>
        - requires an owning molecule
    */
    unsigned int getNumRadicalElectrons() const { return d_numRadicalElectrons; };
    void setNumRadicalElectrons(unsigned int num) { d_numRadicalElectrons=num; };


    //! returns the formal charge of this atom
    int getFormalCharge() const { return d_formalCharge; };
    //! set's the formal charge of this atom
    void setFormalCharge(int what) { d_formalCharge = what;} ;

    //! \brief sets our \c noImplicit flag, indicating whether or not
    //!  we are allowed to have implicit Hs
    void setNoImplicit( bool what ) { df_noImplicit = what; };
    //! returns the \c noImplicit flag
    bool getNoImplicit() const { return df_noImplicit; };
    
    //! sets our number of explict Hs
    void setNumExplicitHs(unsigned int what) { d_numExplicitHs = what; };
    //! returns our number of explict Hs
    unsigned int getNumExplicitHs() const { return d_numExplicitHs; };
  
    //! sets our \c isAromatic flag, indicating whether or not we are aromatic
    void setIsAromatic( bool what ) { df_isAromatic = what; };
    //! returns our \c isAromatic flag
    bool getIsAromatic() const { return df_isAromatic; };

    //! returns our mass
    double getMass() const;

    //! sets our isotope number
    void setIsotope(unsigned int what);
    //! returns our isotope number
    unsigned int getIsotope() const {return d_isotope; };

    //! sets our \c chiralTag
    void setChiralTag(ChiralType what) { d_chiralTag = what; };
    //! inverts our \c chiralTag
    void invertChirality();
    //! returns our \c chiralTag
    ChiralType getChiralTag() const { return static_cast<ChiralType>(d_chiralTag); };

    //! sets our hybridization
    void setHybridization(HybridizationType what) { d_hybrid = what; };
    //! returns our hybridization
    HybridizationType getHybridization() const { return static_cast<HybridizationType>(d_hybrid); };

    // ------------------------------------
    // Some words of explanation before getting down into
    // the query stuff.
    // These query functions are really only here so that they
    //  can have real functionality in subclasses (like QueryAtoms).
    // Since pretty much it's gonna be a mistake to call any of these
    //  (ever), we're saddling them all with a precondition which
    //  is guaranteed to fail.  I'd like to have them be pure virtual,
    //  but that doesn't work since we need to be able to instantiate
    //  Atoms.
    // ------------------------------------

    // This method can be used to distinguish query atoms from standard atoms:
    virtual bool hasQuery() const { return false; };
   
    //! NOT CALLABLE
    virtual void setQuery(QUERYATOM_QUERY *what);

    //! NOT CALLABLE
    virtual QUERYATOM_QUERY *getQuery() const;
    //! NOT CALLABLE
    virtual void expandQuery(QUERYATOM_QUERY *what,
			     Queries::CompositeQueryType how=Queries::COMPOSITE_AND,
			     bool maintainOrder=true);

    //! returns whether or not we match the argument
    /*!
        <b>Notes:</b>
          The general rule is that if a property on this atom has a non-default value,
          the property on the other atom must have the same value.
          The exception to this is H counts, which are ignored. These turns out to be
            impossible to handle generally, so rather than having odd and hard-to-explain
            exceptions, we ignore them entirely.

          Here are the rules for atom-atom matching:
          | This    | Other   | Match | Reason
          | CCO     | CCO     | Yes   |
          | CCO     | CC[O-]  | Yes   |
          | CC[O-]  | CCO     | No    | Charge
          | CC[O-]  | CC[O-]  | Yes   |
          | CC[OH]  | CC[O-]  | Yes   | 
          | CC[OH]  | CCOC    | Yes   |
          | CCO     | CCOC    | Yes   |
          | CCC     | CCC     | Yes   |
          | CCC     | CC[14C] | Yes   |
          | CC[14C] | CCC     | No    | Isotope
          | CC[14C] | CC[14C] | Yes   |
          | C       | OCO     | Yes   |
          | [CH]    | OCO     | Yes   |
          | [CH2]   | OCO     | Yes   |
          | [CH3]   | OCO     | No    | Radical
          | C       | O[CH2]O | Yes   |
          | [CH2]   | O[CH2]O | Yes   |
    */
    virtual bool Match(Atom const *what) const;
    //! \overload
    virtual inline bool Match(const ATOM_SPTR &what) const {
      return Match(what.get());
    };
  

    // ------------------------------------
    //  Local Property Dict functionality
    //  all setProp functions are const because they
    //     are not meant to change the atom chemically 
    // ------------------------------------
    //! returns a list with the names of our \c properties
    STR_VECT getPropList() const {
      return dp_props->keys();
    }

    //! sets a \c property value
    /*!
       \param key the name under which the \c property should be stored.
           If a \c property is already stored under this name, it will be
	   replaced.
       \param val the value to be stored
       \param computed (optional) allows the \c property to be flagged
           \c computed.
     */
    template <typename T>
    void setProp(const char *key, T val, bool computed=false) const{
    
      //if(!dp_props) dp_props = new Dict();
      std::string what(key);
      setProp(what,val, computed);
    }

    //! \overload
    template <typename T>
    void setProp(const std::string &key, T val, bool computed=false) const {
      if (computed) {
	STR_VECT compLst;
	getPropIfPresent(detail::computedPropName, compLst);
	if (std::find(compLst.begin(), compLst.end(), key) == compLst.end()) {
	  compLst.push_back(key);
	  dp_props->setVal(detail::computedPropName, compLst);
	}
      }
      //setProp(key.c_str(),val);
      dp_props->setVal(key, val);
    }

    //! allows retrieval of a particular property value
    /*!

       \param key the name under which the \c property should be stored.
           If a \c property is already stored under this name, it will be
	   replaced.
       \param res a reference to the storage location for the value.

       <b>Notes:</b>
         - if no \c property with name \c key exists, a KeyErrorException will be thrown.
	 - the \c boost::lexical_cast machinery is used to attempt type conversions.
	   If this fails, a \c boost::bad_lexical_cast exception will be thrown.

    */
    template <typename T>
    void getProp(const char *key,T &res) const {
      dp_props->getVal(key,res);
    }
    //! \overload
    template <typename T>
    void getProp(const std::string &key,T &res) const {
      dp_props->getVal(key,res);
    }

    //! \overload
    template <typename T>
    T getProp(const char *key) const {
      return dp_props->getVal<T>(key);
    }
    //! \overload
    template <typename T>
    T getProp(const std::string &key) const {
      return dp_props->getVal<T>(key);
    }

    //! returns whether or not we have a \c property with name \c key
    //!  and assigns the value if we do
    template <typename T>
    bool getPropIfPresent(const char *key,T &res) const {
        return dp_props->getValIfPresent(key,res);
    }
    //! \overload
    template <typename T>
    bool getPropIfPresent(const std::string &key,T &res) const {
        return dp_props->getValIfPresent(key,res);
    }

    //! returns whether or not we have a \c property with name \c key
    bool hasProp(const char *key) const {
      if(!dp_props) return false;
      return dp_props->hasVal(key);
    };
    //! \overload
    bool hasProp(const std::string &key) const {
      if(!dp_props) return false;
      return dp_props->hasVal(key);
    };

    
    //! clears the value of a \c property
    /*!
       <b>Notes:</b>
         - if no \c property with name \c key exists, a KeyErrorException
	   will be thrown.
	 - if the \c property is marked as \c computed, it will also be removed
	   from our list of \c computedProperties
    */
    void clearProp(const char *key) const {
      std::string what(key);
      clearProp(what);
    };
    //! \overload
    void clearProp(const std::string &key) const {
      STR_VECT compLst;
      if(getPropIfPresent(detail::computedPropName, compLst)) {
	STR_VECT_I svi = std::find(compLst.begin(), compLst.end(), key);
	if (svi != compLst.end()) {
	  compLst.erase(svi);
	  dp_props->setVal(detail::computedPropName, compLst);
	}
      }    
      dp_props->clearVal(key);
    };

    //! clears all of our \c computed \c properties
    void clearComputedProps() const {
      STR_VECT compLst;
      if (getPropIfPresent(detail::computedPropName, compLst))
      {
	BOOST_FOREACH(const std::string &sv,compLst){
	  dp_props->clearVal(sv);
	}
	compLst.clear();
	dp_props->setVal(detail::computedPropName, compLst);
      }
    }

    //! returns the perturbation order for a list of integers
    /*!

      This value is associated with chirality.

      \param probe a list of bond indices.  This must be the same
        length as our number of incoming bonds (our degree).
      
      \return the number of swaps required to convert the ordering
	of the probe list to match the order of our incoming bonds:
	e.g. if our incoming bond order is: <tt>[0,1,2,3]</tt>
	\verbatim
	getPerturbationOrder([1,0,2,3]) = 1
	getPerturbationOrder([1,2,3,0]) = 3
	getPerturbationOrder([1,2,0,3]) = 2
	\endverbatim

      See the class documentation for a more detailed description
      of our representation of chirality.

      <b>Notes:</b>
        - requires an owning molecule
      
    */
    int getPerturbationOrder(INT_LIST probe) const;

    //! calculates any of our lazy \c properties
    /*!
      <b>Notes:</b>
        - requires an owning molecule
	- the current lazy \c properties are implicit and explicit valence
    */
    void updatePropertyCache(bool strict=true);

    bool needsUpdatePropertyCache() const;

    //! calculates and returns our explicit valence
    /*!
      <b>Notes:</b>
        - requires an owning molecule
    */
    int calcExplicitValence(bool strict=true);

    //! calculates and returns our implicit valence
    /*!
      <b>Notes:</b>
        - requires an owning molecule
    */
    int calcImplicitValence(bool strict=true);

    AtomMonomerInfo *getMonomerInfo() { return dp_monomerInfo; };
    const AtomMonomerInfo *getMonomerInfo() const { return dp_monomerInfo; };
    //! takes ownership of the pointer
    void setMonomerInfo(AtomMonomerInfo *info) { dp_monomerInfo=info; };
    
  protected:
    //! sets our owning molecule
    void setOwningMol(ROMol *other);
    //! sets our owning molecule
    void setOwningMol(ROMol &other) {setOwningMol(&other);};

    bool df_isAromatic; 
    bool df_noImplicit;
    boost::uint8_t d_numExplicitHs;
    boost::int8_t d_formalCharge;
    boost::uint8_t d_atomicNum;
    // NOTE that these cannot be signed, they are calculated using
    // a lazy scheme and are initialized to -1 to indicate that the
    // calculation has not yet been done.
    boost::int8_t d_implicitValence, d_explicitValence;
    boost::uint8_t d_numRadicalElectrons;
    boost::uint8_t d_chiralTag;
    boost::uint8_t d_hybrid;

    atomindex_t d_index;
    boost::uint16_t d_isotope;

    ROMol *dp_mol;
    Dict *dp_props;
    AtomMonomerInfo *dp_monomerInfo;
    void initAtom();
  };

};
//! allows Atom objects to be dumped to streams
std::ostream & operator<<(std::ostream& target, const RDKit::Atom &at);

#endif