MolChemicalFeatureFactory.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (C) 2004-2006 Rational Discovery LLC
00003 //
00004 //   @@ All Rights Reserved @@
00005 //  This file is part of the RDKit.
00006 //  The contents are covered by the terms of the BSD license
00007 //  which is included in the file license.txt, found at the root
00008 //  of the RDKit source tree.
00009 //
00010 #ifndef __CHEMICALFEATUREFACTORY_H_02122004_1545__
00011 #define __CHEMICALFEATUREFACTORY_H_02122004_1545__
00012 
00013 #include "MolChemicalFeatureDef.h"
00014 #include <iostream>
00015 #include <boost/shared_ptr.hpp>
00016 
00017 namespace RDKit {
00018   class MolChemicalFeature;
00019   typedef boost::shared_ptr<MolChemicalFeature> FeatSPtr;
00020   typedef std::list< FeatSPtr > FeatSPtrList;
00021   typedef FeatSPtrList::iterator FeatSPtrList_I;
00022 
00023   //! The class for finding chemical features in molecules
00024   class MolChemicalFeatureFactory {
00025   public:
00026 
00027     //! returns the number of feature definitions
00028     int getNumFeatureDefs() const {return d_featDefs.size();};
00029 
00030     //! returns an iterator referring to the first feature definition
00031     MolChemicalFeatureDef::CollectionType::iterator
00032     beginFeatureDefs() { return d_featDefs.begin(); };
00033     //! returns an iterator referring to the end of the feature definitions
00034     MolChemicalFeatureDef::CollectionType::iterator
00035     endFeatureDefs() { return d_featDefs.end(); };
00036     
00037     //! returns a const_iterator referring to the first feature definition
00038     MolChemicalFeatureDef::CollectionType::const_iterator
00039     beginFeatureDefs() const { return d_featDefs.begin(); };
00040     //! returns a const_iterator referring to the end of the feature definitions
00041     MolChemicalFeatureDef::CollectionType::const_iterator
00042     endFeatureDefs() const { return d_featDefs.end(); };
00043     
00044     //! appends a feature definition to the collection of features defs.
00045     void addFeatureDef(MolChemicalFeatureDef::CollectionType::value_type featDef){
00046       d_featDefs.push_back(featDef);
00047     }
00048 
00049     //! returns a list of features on the molecule
00050     /*!
00051       \param mol          The molecule of interest
00052       \param includeOnly  (optional) if this is non-null, only features in this
00053                           family will be returned
00054     */
00055     FeatSPtrList getFeaturesForMol(const ROMol &mol,const char *includeOnly="") const;
00056 
00057   private:
00058     MolChemicalFeatureDef::CollectionType d_featDefs;
00059   };
00060 
00061   //! constructs a MolChemicalFeatureFactory from the data in a stream
00062   MolChemicalFeatureFactory *buildFeatureFactory(std::istream &inStream);
00063   //! constructs a MolChemicalFeatureFactory from the data in a string
00064   MolChemicalFeatureFactory *buildFeatureFactory(const std::string &featureData);
00065   
00066 }// end of namespace RDKit
00067 
00068 #endif