Class HashGeneratorMaker

java.lang.Object
org.openscience.cdk.hash.HashGeneratorMaker

public final class HashGeneratorMaker extends Object
Fluent API for creating hash generators. The maker is first configured with one or more attributes. Once fully configured the generator is made by invoking atomic(), molecular() or ensemble(). The order of the built-in configuration methods does not matter however when specifying custom encoders with encode(AtomEncoder) the order they are added is the order they will be used. Therefore one can expect different hash codes if there is a change in the order they are specified.
Examples
 // simple
 MoleculeHashGenerator generator = new HashGeneratorMaker().depth(16)
                                                           .elemental()
                                                           .molecular();

 // fast
 MoleculeHashGenerator generator = new HashGeneratorMaker().depth(8)
                                                           .elemental()
                                                           .isotopic()
                                                           .charged()
                                                           .orbital()
                                                           .molecular();
 // comprehensive
 MoleculeHashGenerator generator = new HashGeneratorMaker().depth(32)
                                                           .elemental()
                                                           .isotopic()
                                                           .charged()
                                                           .chiral()
                                                           .perturbed()
                                                           .molecular();
 
Author:
John May
Source code:
main
Belongs to CDK module:
hash
  • Constructor Details

    • HashGeneratorMaker

      public HashGeneratorMaker()
  • Method Details

    • depth

      public HashGeneratorMaker depth(int depth)
      Specify the depth of the hash generator. Larger values discriminate more molecules.
      Parameters:
      depth - how deep should the generator hash
      Returns:
      reference for fluent API
      Throws:
      IllegalArgumentException - if the depth was less then zero
    • elemental

      public HashGeneratorMaker elemental()
      Discriminate elements.
      Returns:
      fluent API reference (self)
      See Also:
    • isotopic

      public HashGeneratorMaker isotopic()
      Discriminate isotopes.
      Returns:
      fluent API reference (self)
      See Also:
    • charged

      public HashGeneratorMaker charged()
      Discriminate protonation states.
      Returns:
      fluent API reference (self)
      See Also:
    • orbital

      public HashGeneratorMaker orbital()
      Discriminate atomic orbitals.
      Returns:
      fluent API reference (self)
      See Also:
    • radical

      public HashGeneratorMaker radical()
      Discriminate free radicals.
      Returns:
      fluent API reference (self)
      See Also:
    • chiral

      public HashGeneratorMaker chiral()
      Generate different hash codes for stereoisomers. The currently supported geometries are:
      • Tetrahedral
      • Double Bond
      • Cumulative Double Bonds
      Returns:
      fluent API reference (self)
    • suppressHydrogens

      public HashGeneratorMaker suppressHydrogens()
      Suppress any explicit hydrogens in the encoding of hash values. The generation of hashes acts as though the hydrogens are not present and as such preserves stereo-encoding.
      Returns:
      fluent API reference (self)
    • perturbed

      public HashGeneratorMaker perturbed()
      Discriminate atoms experiencing uniform environments. This method uses MinimumEquivalentCyclicSet to break symmetry but depending on application one may need a more comprehensive method. Please refer to perturbWith(EquivalentSetFinder) for further configuration details.
      Returns:
      fluent API reference (self)
      See Also:
      • MinimumEquivalentCyclicSet
      • perturbWith(EquivalentSetFinder)
    • encode

      public HashGeneratorMaker encode(AtomEncoder encoder)
      Add a custom encoder to the hash generator which will be built. Although not enforced, the encoder should be stateless and should not modify any passed inputs.
      Parameters:
      encoder - an atom encoder
      Returns:
      fluent API reference (self)
      Throws:
      NullPointerException - no encoder provided
    • ensemble

      public EnsembleHashGenerator ensemble()
      Given the current configuration create an EnsembleHashGenerator.
      Returns:
      instance of the generator
      Throws:
      IllegalArgumentException - no depth or encoders were configured
    • molecular

      public MoleculeHashGenerator molecular()
      Given the current configuration create an MoleculeHashGenerator.
      Returns:
      instance of the generator
      Throws:
      IllegalArgumentException - no depth or encoders were configured
    • atomic

      public AtomHashGenerator atomic()
      Given the current configuration create an AtomHashGenerator.
      Returns:
      instance of the generator
      Throws:
      IllegalArgumentException - no depth or encoders were configured