Record Class HeavyAtomLimitChecker

java.lang.Object
java.lang.Record
chemaxon.calculations.api.HeavyAtomLimitChecker
Record Components:
defaultLimit - the default limit
limitsByTag - The map of limits for each tag. Does not have to include all tags.
All Implemented Interfaces:
TaggedCalculatorInputChecker

@PublicApi public record HeavyAtomLimitChecker(int defaultLimit, Map<CalculatorTag,Integer> limitsByTag) extends Record implements TaggedCalculatorInputChecker
An input checker that only accepts molecules with at most a certain number of heavy atoms.

Apart from the default limit, specific limits can be given for each CalculatorTag that affects performance (other tags are ignored). These tags represent different optional calculations that can be switched on or off on calculators, e.g. the tautomerization plugin can calculate canonical, dominant, major and generic tautomers with very different computation costs.

Based on these performance-related tags:

  • If there is no such tag on the calculator (it has regular performance), or there is a tag, but it has no entry in the map, then the default limit is used.
  • If there are multiple tags, then the minimum of their limits is used.

Negative numbers mean infinity (the lack of a limit).

  • Constructor Details

    • HeavyAtomLimitChecker

      public HeavyAtomLimitChecker(int defaultLimit, Map<CalculatorTag,Integer> limitsByTag)
      Creates an instance of a HeavyAtomLimitChecker record class.
      Parameters:
      defaultLimit - the value for the defaultLimit record component
      limitsByTag - the value for the limitsByTag record component
  • Method Details

    • defaultChecker

      public static HeavyAtomLimitChecker defaultChecker()
      Creates a heavy atom limit checker using the default configuration.

      With these default limits, most calculators complete under about 5 seconds per input structure. The few exceptions are simply too slow to finish in such short time with any reasonable limit, but they should still process each input in a few minutes with these limits.

      Please note that these limits may change in future versions without any preliminary notice if better values are found. If you want to ensure that your limits do not change, export this checker using toProperties(), save it, and reload it later with fromProperties(Properties).

      Returns:
      the new checker
    • fromProperties

      public static HeavyAtomLimitChecker fromProperties(InputStream inputStream) throws IOException
      Parses the given input stream into a Properties object and passes that to fromProperties(Properties).
      Parameters:
      inputStream - the properties file to parse
      Returns:
      the new checker
      Throws:
      IllegalArgumentException - if the given properties file does not conform to the rules specified in the JavaDoc of fromProperties(Properties)
      IOException
    • fromProperties

      public static HeavyAtomLimitChecker fromProperties(Properties properties)
      Creates a heavy atom limit checker from the given configuration.

      The properties file is parsed using these rules:

      • Values are parsed as ints.
      • The special "*" key specifies the default limit. If not set, -1 is used instead.
      • All other keys are mapped to a constant in the CalculatorTag enum with two modifications:
        • "/" is replaced with "_",
        • the key is converted to upper case.
      Parameters:
      properties - the properties to parse
      Returns:
      the new checker
      Throws:
      IllegalArgumentException - if the given properties file does not conform to the rules above
    • toProperties

      public Properties toProperties()
      Exports this checker into the format defined by fromProperties(Properties).
      Returns:
      a new properties object describing this checker
    • apply

      public List<CalculatorError> apply(TaggedCalculator calculator, Molecule molecule)
      Description copied from interface: TaggedCalculatorInputChecker
      Checks the given molecule and returns the found errors, or an empty list if the molecule is valid.

      Apart from the molecule that should be checked, this method also receives the calculator instance.

      Specified by:
      apply in interface TaggedCalculatorInputChecker
      Parameters:
      calculator - the calculator instance
      molecule - the input molecule
      Returns:
      a list of found errors, typically empty or containing a single element
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • defaultLimit

      public int defaultLimit()
      Returns the value of the defaultLimit record component.
      Returns:
      the value of the defaultLimit record component
    • limitsByTag

      public Map<CalculatorTag,Integer> limitsByTag()
      Returns the value of the limitsByTag record component.
      Returns:
      the value of the limitsByTag record component