Chemical Descriptors Library: Indexed Molecule
Indexed Molecule

indexed_molecule<Molecule>

When one does a substructure search, is often required to have the mapping of atoms from the query molecule to the "searched" molecule.
The indexed_molecule<> is a class that behaves the same way as a plain molecule<>, but it also provides a map from the indices of vertices of a query molecule, to the indices of the vertices of this molecule. Further, it provides the type of dissociations for the atoms of the mapped fragment. The mapped fragment can be either fused to other fragment, or connected to other fragment.
For example, lets consider that we are searching the fragment shown in figure 1, in the molecule of figure 2 (arbitrary vertex indices are shown in white) :

 

Figure 1: Query molecule

 

 

Figure 2: Searched molecule

 

There are two possible mappings from the fragment of Figure 1 to the molecule of Figure 2:
Figure 1 indices    |    Figure 2 indices
-----------------------------------------
      0      ------------->    10
      1      ------------->    11
      2      ------------->    12
      3      ------------->    13
      4      ------------->    14
      5      ------------->    15
      
and

Figure 1 indices | Figure 2 indices ----------------------------------------- 0 -------------> 10 1 -------------> 15 2 -------------> 14 3 -------------> 13 4 -------------> 12 5 -------------> 11
These two mappings are stored in a member variable in the indexed_molecule class.
Also, vertices 12, 14 and 15 of Figure 2 can be tagged to express that vertex 12 is connected to a benzene fragment, and vertices 14 and 15 are fused to a N1CNCC1 fragment.

As will be explained later, the indexed_molecule<> is the result type of the application of a substructure search operator to a plain molecule.
indexed_molecule<> inherits from a plain molecule<>. Following is a synopsis for the new members:

Synopsis

namespace morpho {
namespace cdl {

  template <class Molecule>
  class indexed_molecule : public Molecule {
    
    //
    //--------   Types
    //
    
    typedef Molecule                                             Base;
    
    typedef std::pair<vertex_descriptor,vertex_descriptor>       vertex_pair_t;
    typedef std::vector<std::vector<vertex_pair_t> >             vertex_mapping_t;
    
    enum dissociation_character_type {
        NOT_YET_KNOWN  = 0
      , WAS_CONNECTED  = 1
      , WAS_FUSED      = 2
    };
    
    typedef std::pair<size_t,dissociation_character_type>  dissociation_pair_t;
    typedef std::vector<dissociation_pair_t>               dissociations_t;

    //
    //--------   Functions
    //
    
    //------------- constructors
    indexed_molecule();
    
    indexed_molecule(const nail_juice<self>&,bool,bool);    
    
    indexed_molecule(const Base&);
    
    indexed_molecule(const graph_type&, bool);
    
    indexed_molecule(const indexed_molecule<Molecule>&);
    
    //------------- utilities
    
    // --- for dissociation_character_type
    dissociation_character_type diss_not_known();
    dissociation_character_type diss_connected();
    dissociation_character_type diss_fused();
    
    // --- for dissociations ---
    const dissociations_t& get_dissociations() const;
    void put_dissociation(dissociation_pair_t);
    
    // --- for the mapping ---
    const vertex_mapping_t& get_mapping() const;
    
    void set_mapping(const vertex_mapping_t&);
    
    bool empty() const;
    
    std::vector<size_t>
    get_vertex(size_t) const;
    
    std::vector<std::pair<size_t,size_t> >
    get_vertex_and_map_index(size_t) const;
    
    size_t size() const;
    
    void delete_mapping(vertex_map_it_t);
    void delete_mapping(size_t);
    
   
    //
    //--------   Variables
    //
   
   protected :
    vertex_mapping_t          m_mapping;
    dissociations_t           m_dissociations;
  
  };
  
} // namespace cdl
} // namespace morpho

Where defined

morpho/cdl/molecule/indexed_molecule.hpp

Template parameters

ParameterDescriptionDefaultModel of / Requirements
Molecule Plain molecule<> class No defaults
morpho::cdl::molecule<>

Associated types

All the types of Molecule are injected in this class.


vertex_mapping_t
The type of the mapping. This type will provide all vertex index -> vertex index mappings from a query molecule to this molecule.
dissociation_pair_t
Type of the dissociation of a vertex. The pair represents: <vertex index, dissociation character>.
dissociations_t;
Container that stores the dissociations of the mapping.

Member functions

All member functions of Molecule are inherited.


indexed_molecule()
Constructs an empty indexed_molecule.
indexed_molecule(const nail_juice<self> j;&,bool add_implicit_h = false, bool initialize = true);
Constructs an indexed_molecule with the information provided in the nail_juice. The two defaulted boolean arguments indicates to add implicit hydrogens and to initialize the molecule respectively.
All maps are empty initialized.
indexed_molecule(const Base& b);
Constructs an indexed_molecule out of a plain molecule. All maps are empty initialized.
indexed_molecule(const graph_type& g, bool add_implicit_h = false);
Constructs an indexed_molecule out of a graph. All the properties of the graph are copied.
indexed_molecule(const indexed_molecule<Molecule>&);
Copy constructor.
dissociation_character_type diss_not_known();
dissociation_character_type diss_connected();
dissociation_character_type diss_fused();
Returns the dissociation types.
const dissociations_t& get_dissociations() const;
Returns a constant reference to the dissociation container.
void put_dissociation(dissociation_pair_t);
Puts a dissociation to the dissociations container.
const vertex_mapping_t& get_mapping() const;
Returns a constant reference to the mapping container.
void set_mapping(const vertex_mapping_t& map);
Sets the mapping container.
bool empty() const;
Returns if the mapping container is empty.
std::vector<size_t>
get_vertex(size_t v) const;
Returns the vertices of this molecule that are mapped to vertex 'v' of the query molecule.
std::vector<std::pair<size_t,size_t> >
get_vertex_and_map_index(size_t v) const;
Returns a container of pairs: the vertices of this molecule that are mapped to vertex 'v' of the query molecule, and also returns the index of the map container where that mapping is present. The pair elements represents these respectively.
size_t size() const;
Returns the size of the map container.
void delete_mapping(vertex_map_it_t pos);
Deletes the mapping pointed to by pos.
void delete_mapping(size_t pos);
Deletes the mapping of position pos.





Copyright © Vladimir Sykora & Cyprotex Ltd 2006