Chemical Descriptors Library: Juice
Juice

nail_juice<class Molecule>

The nail_juice<> is a class that encapsulates information of the molecular graph. It can be said that it enwraps the minimal information a non-trivial molecular graph should have.
When you construct a graph, you must give information on vertices count and vertex connectivity. Likewise, to construct a meaningful molecular graph, you must provide information on atom types (given as atomic symbol or number), atom connectivity (bonds), chirality, etc. So CDL enwraps this information in the nail_juice. Conveniently the molecule class accepts this structure to its constructor, creating a molecule accordingly to the information provided.
Additionally, the user can attach arbitrary properties to the nail_juice, and parse them with the same interface provided for the nail_juice. These properties are not contained in the structure. The user defined properties are accessed through a generic interface. The use of this inteface is explained later on the text.
As the molecule<> class is highly parametrized, and all the types for its properties are templated, the types for the properties that the nail_juice contain must be the same as the types of the molecular properties. For this reason, the nail_juice is templated with the molecule<> class. In this way, the user can vary the properties types without changing its constructor or parsers.

Template parameters

Table 1:Template parameters
ParameterDescriptionDefault
Molecule The type of CDL molecule class Default molecule<>

Member Variables

Table 2:Member variables of the nails_juice<> class
ParameterDescriptionTypeNested typedef
bonds edge connectivity list of the molecular graph given by the indices of the vertices that are connected std::list<std::pair<unsigned,unsigned> > bonds_t
atoms list for the atomic symbols of each vertex in the molecular graph std::list<std::string> atoms_t
charges list of the charges of the molecule std::list<std::pair<unsigned,int> > charges_t
bond_types list of the bond types (ie. double or triple, default single) std::list<boost::tuple<unsigned,unsigned,typename BondProperty<type_of_bondS,btype>::result_type> > bond_types_t
coordinates depiction coordinates for each vertex std::list<boost::tuple<double,double,double> > coordinates_t
isomerisms list of isomer bonds and their types std::list<boost::tuple<unsigned,unsigned,typename BondProperty<isomerismS,btype>::result_type> > bond_isomerism_t
chiralities chiral bonds and their orientation std::list<boost::tuple<unsigned,unsigned,BondChirality> > bond_chirality_t
chiral_center_type chiral cernters and their type std::list<std::pair<size_t, AtomChirality> > atom_chirality_type

External Properties

As mentioned before, the io interface of nail_juice<> supports adding external properties. External properties are user defined properties that are not contained in the nail_juice<> class. Normaly you will use the >> operator to stream in a juice from the standard stream to your instantiated type. However, if you want to attach properties to the juice, and later get them, you can use the read_juice<> functor. The read_juice<> structure is templated with the properties types that you want to get from the juice. The properties structure uses the same interface as the properties for the molecule class: the boost::property<>. Each type in this structure provides its own operator >>. In this way, you can have as many properties as you want attached to the juice, and the same interface will get them from the standard input.
When you're getting external properties with the read_juice<> interface, you have to construct the functor with:
  1. the list of the names for the XML attributes you have for each property you're getting. The list is provided as std::vector<std::string>
  2. a pointer to the properties (the boost::property<>): Hence, this properties are stored externally.
Also you need to provide a tag for each of your properties (this is boost implementation). The requirenment is that you enumerate your properties as : nail_property1S, nail_property2S, nail_property3S, etc....

Example

Let's assume you want to get a bitstring from the juice.
First you have to create operator >> for the structure that contains your type:
  struct fingernail {
    boost::dynamic_bitset<>   m_fingerprint;
  };

  template <class CharT, class traits>
  std::basic_istream<CharT,traits>&
  operator >> (std::basic_istream<CharT,traits>& in, fingernail& fn) {
    // implementation
  }

  // now to get your property :
  nail_juice<> juice;
  typedef boost::property  prop_t;
  std::vector    name(1,std::string("fingernail"));
  prop_t*    prop(new prop_t);
  read_juice    rj(name,prop);
  rj(std::cin,juice);
Now you have the values retrieved from std::cin attached to your properties. neat :-)

Copyright (c) Vladimir Josef Sykora & Morphochem AG 2003