jklustor-overlap-0.0.2-20140619012940 (ChemAxon)


com.chemaxon.overlap
Class OverlapAnalysisContext<D extends com.chemaxon.descriptors.common.Descriptor,T extends Serializable>

Object
  extended by com.chemaxon.overlap.OverlapAnalysisContext<D,T>
Type Parameters:
D - Underlying descriptor type
T - Unguarded descriptor type TODO: make context Serializable; prerequisite is to make generators serializable
All Implemented Interfaces:
Serializable

public final class OverlapAnalysisContext<D extends com.chemaxon.descriptors.common.Descriptor,T extends Serializable>
extends Object
implements Serializable

Context for an overlap analysis.

This context collects typical domain specific parameters required for an overlap analysis setup and execution. Some parameters required for setup are considered to be execution environment specific, like the used ExecutorService, SubProgressObserver instances, file references, etc which are not covered by this context.

Instances of this cumulative factory class are immutable.

At least a DescriptorGenerator have to be specified; this is enforced through initial factory method initial(com.chemaxon.descriptors.common.DescriptorGenerator). Further members defaults:

Since overlap analysis represents only internal identifiers and unguarded descritptor forms, associations to original structures, IDs, etc are outside the scope of this context.

IMPORTANT EFFICIENCY CONSIDERATIONS: This context holds reference to DescriptorGenerator and StandardizerWrapper instances which might ensure thread safety using ThreadLocal members. Overlap analysis and associated functionality utilize ExecutorService passed from outside. The possible pooling of worker threads by the executing environment might interfere with the thread local storage causing memory leak-like situations. To mitigate this risk following these practices are recommended:

Author:
Gabor Imre
See Also:
http://wiki.apidesign.org/wiki/APIDesignPatterns:CumulativeFactory, Serialized Form

Field Summary
static int DEFAULT_PAGESIZE
          Default pagesize.
 
Method Summary
 PagedDescriptorStorage<D> createEmptyStorage()
          Create an empty storage.
 UnguardedPagedOverlap<T> deserializeUnguardedPagedOverlap(ObjectInputStream ois, com.chemaxon.calculations.common.SubProgressObserver po)
          Deserialize an UnguardedPagedSimilarity from binary serialized from.
 com.chemaxon.descriptors.common.DescriptorComparator<D> getDescriptorComparator()
          Gets represented descriptor comparator.
 com.chemaxon.descriptors.common.DescriptorGenerator<D> getDescriptorGenerator()
          Gets represented descriptor generator.
 int getPagesize()
          Gets represented page size.
 StandardizerWrapper getStandardizer()
          Gets represented standardizer wrapper.
 UnguardedDissimilarityCalculator<T> getUnguardedDissimilarityCalculator()
          Gets represented unguarded dissimilarty calculator.
 Function<D,T> getUnguardedExtractor()
          Gets represented unguarded form extractor.
static
<D extends com.chemaxon.descriptors.common.Descriptor>
OverlapAnalysisContext<D,byte[]>
initial(com.chemaxon.descriptors.common.DescriptorGenerator<D> generator)
          Empty representation with specified DescriptorGenerator.
static
<D extends com.chemaxon.descriptors.common.Descriptor>
OverlapAnalysisContext<D,byte[]>
initial(com.chemaxon.descriptors.common.DescriptorGenerator<D> generator, com.chemaxon.descriptors.common.DescriptorComparator<D> comparator)
          Empty representation with specified DescriptorGenerator and comparator.
 OverlapAnalysisContext<D,T> pagesize(int pagesize)
          Update pagesize.
 OverlapAnalysisContext<D,T> standardizer(StandardizerWrapper standardizer)
          Update standardizer.
 String toString()
           
 String toString(boolean multiline)
          Create String representation.
 ImmutableList<T> transformMolecules(List<chemaxon.struc.Molecule> molecules, com.chemaxon.calculations.common.SubProgressObserver po)
          Transform molecules according to the represented context.
<N extends Serializable>
OverlapAnalysisContext<D,N>
unguarded(Function<D,N> extractor, UnguardedDissimilarityCalculator<N> unguardedCalc)
          Update represented unguarded layer.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_PAGESIZE

public static final int DEFAULT_PAGESIZE
Default pagesize.

See Also:
Constant Field Values
Method Detail

initial

public static <D extends com.chemaxon.descriptors.common.Descriptor> OverlapAnalysisContext<D,byte[]> initial(com.chemaxon.descriptors.common.DescriptorGenerator<D> generator)
Empty representation with specified DescriptorGenerator.

Note that DescriptorGenerator determines underlying Descriptor type thus it is not modifiable. Also, when calling this method the represented DescriptorComparator defaults to the comparator returned by DescriptorGenerator.getDefaultComparator().

Type Parameters:
D - Underlying descriptor type
Parameters:
generator - DescriptorGenerator represented
Returns:
Generator set; pagesize set to the DEFAULT_PAGESIZE; others initialized to defaults

initial

public static <D extends com.chemaxon.descriptors.common.Descriptor> OverlapAnalysisContext<D,byte[]> initial(com.chemaxon.descriptors.common.DescriptorGenerator<D> generator,
                                                                                                              com.chemaxon.descriptors.common.DescriptorComparator<D> comparator)
Empty representation with specified DescriptorGenerator and comparator.

Note that DescriptorGenerator determines underlying Descriptor type thus it is not modifiable.

Type Parameters:
D - Underlying descriptor type
Parameters:
generator - DescriptorGenerator represented
comparator - DescriptorComparator represented
Returns:
Generator and comparatorset; pagesize set to the DEFAULT_PAGESIZE; others initialized to their defaults

pagesize

public OverlapAnalysisContext<D,T> pagesize(int pagesize)
Update pagesize.

Parameters:
pagesize - New pagesize
Returns:
New instance holding updated parameter

standardizer

public OverlapAnalysisContext<D,T> standardizer(StandardizerWrapper standardizer)
Update standardizer.

Parameters:
standardizer - New standardizer
Returns:
New instance holding updated parameter

unguarded

public <N extends Serializable> OverlapAnalysisContext<D,N> unguarded(Function<D,N> extractor,
                                                                      UnguardedDissimilarityCalculator<N> unguardedCalc)
Update represented unguarded layer.

Type Parameters:
N - New unguarded representation type
Parameters:
extractor - Extractor of unguarded representation
unguardedCalc - Unguarded comparator
Returns:
New instance holding updated parameter

getDescriptorGenerator

public com.chemaxon.descriptors.common.DescriptorGenerator<D> getDescriptorGenerator()
Gets represented descriptor generator.

Returns:
Represented generator

getDescriptorComparator

public com.chemaxon.descriptors.common.DescriptorComparator<D> getDescriptorComparator()
Gets represented descriptor comparator.

Returns:
Represented comparator

getStandardizer

public StandardizerWrapper getStandardizer()
Gets represented standardizer wrapper.

Returns:
Represented standardizer

getUnguardedExtractor

public Function<D,T> getUnguardedExtractor()
Gets represented unguarded form extractor.

Returns:
Represented extractot function

getPagesize

public int getPagesize()
Gets represented page size.

Returns:
Represented page size

getUnguardedDissimilarityCalculator

public UnguardedDissimilarityCalculator<T> getUnguardedDissimilarityCalculator()
Gets represented unguarded dissimilarty calculator.

Returns:
Represented ungarded dissimilarity calculator

createEmptyStorage

public PagedDescriptorStorage<D> createEmptyStorage()
Create an empty storage.

Note that the returned storage has no reference to the serializer of this context.

Returns:
Empty storage

deserializeUnguardedPagedOverlap

public UnguardedPagedOverlap<T> deserializeUnguardedPagedOverlap(ObjectInputStream ois,
                                                                 com.chemaxon.calculations.common.SubProgressObserver po)
                                                                               throws IOException,
                                                                                      ClassNotFoundException
Deserialize an UnguardedPagedSimilarity from binary serialized from.

This method delegates call to PagedDescriptorStorage.deserializeUnguarded(int, com.chemaxon.descriptors.common.DescriptorGenerator, com.google.common.base.Function, com.chemaxon.overlap.unguarded.UnguardedDissimilarityCalculator, java.io.ObjectInputStream, com.chemaxon.calculations.common.SubProgressObserver) passing represented context information.

Parameters:
ois - Source stream
po - Progress observer to track progress
Returns:
Deserialized searcher
Throws:
IOException - Propagated from deserialization
ClassNotFoundException - Propagated from deserialization

transformMolecules

public ImmutableList<T> transformMolecules(List<chemaxon.struc.Molecule> molecules,
                                           com.chemaxon.calculations.common.SubProgressObserver po)
Transform molecules according to the represented context.

For each molecule the following steps are executed:

Parameters:
molecules - Molecules to transform. The molecules are cloned using Molecule.cloneMolecule() before transformations.
po - Progress observer to track progress
Returns:
List of unguarded descriptors suitable to pass to searchers.

toString

public String toString(boolean multiline)
Create String representation.

Parameters:
multiline - Create multiline (more readable) output.
Returns:
String representation

toString

public String toString()
Overrides:
toString in class Object

jklustor-overlap-0.0.2-20140619012940 (ChemAxon)