D
- Underlying descriptor typeT
- Unguarded descriptor typepublic final class OverlapAnalysisContext<D extends Descriptor,T extends Serializable> extends Object implements Serializable, Guarded
This context collects typical domain specific parameters required for an overlap analysis setup and execution
(involving input molecule standardization, descriptor/fingerprint generation and comparison using a specific
metric).
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 default to:
StandardizerWrappers.identityStandardizer()
DescriptorGenerator.getDefaultComparator()
DEFAULT_PAGESIZE
DEFAULT_QUERY_PAGESIZE
DescriptorComparator#comparisonContext()
Since overlap analysis represents only internal identifiers and unguarded descriptor 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:
OverlapAnalysisContext
, DescriptorGenerator
or
StandardizerWrapper
reference in a static
contextUnguardedPagedSimilarity
instances.Guarded.EnsureThat, Guarded.New
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_PAGESIZE
Default pagesize.
|
static int |
DEFAULT_QUERY_PAGESIZE
Default number for query grouping.
|
Modifier and Type | Method and Description |
---|---|
<N extends Serializable> |
comparisonContext(ComparisonContext<?,D,N> comparisonContext)
Update represented comparison context.
|
PagedDescriptorStorage<D> |
createEmptyStorage()
Create an empty storage.
|
OverlapAnalysisContext<D,T> |
descriptorComparator(DescriptorComparator comparator)
Update descriptor comparator.
|
UnguardedPagedOverlap<T> |
deserializeUnguardedPagedOverlap(ObjectInputStream ois,
Sink<Descriptor> onDescriptorRead,
SubProgressObserver po)
Deserialize an
UnguardedPagedSimilarity from binary serialized from. |
UnguardedPagedOverlap<T> |
deserializeUnguardedPagedOverlap(ObjectInputStream ois,
SubProgressObserver po)
Deserialize an
UnguardedPagedSimilarity from binary serialized from. |
DescriptorComparator<D> |
getDescriptorComparator()
Gets represented descriptor comparator.
|
DescriptorGenerator<D> |
getDescriptorGenerator()
Gets represented descriptor generator.
|
Object |
getGuardObject()
Gets the guard object associated to the generated descriptors/utilities.
|
int |
getPagesize()
Gets represented page size.
|
int |
getQueryPagesize() |
StandardizerWrapper |
getStandardizer()
Gets represented standardizer wrapper.
|
UnguardedDissimilarityCalculator<T> |
getUnguardedDissimilarityCalculator()
Gets represented unguarded dissimilarty calculator.
|
UnguardedExtractor<D,T> |
getUnguardedExtractor()
Gets represented unguarded form extractor.
|
static <D extends Descriptor> |
initial(DescriptorGenerator<D> generator)
Empty representation with specified DescriptorGenerator.
|
static <D extends Descriptor> |
initial(DescriptorGenerator<D> generator,
DescriptorComparator<D> comparator)
Empty representation with specified DescriptorGenerator and comparator.
|
OverlapAnalysisContext<D,T> |
pagesize(int pagesize)
Update pagesize.
|
ImmutableList<T> |
parseDescriptorsToUnguardeds(List<String> descs,
SubProgressObserver po)
Parse multiple descriptors and transform them into unguarded representations.
|
T |
parseDescriptorToUnguarded(String desc)
Parse descriptor and transform it into the unguarded representation.
|
OverlapAnalysisContext<D,T> |
queryPagesize(int queryPagesize)
Update query pagesize.
|
OverlapAnalysisContext<D,T> |
standardizer(StandardizerWrapper standardizer)
Update standardizer.
|
String |
toString() |
String |
toString(boolean multiline)
Create String representation.
|
T |
transformMolecule(Molecule molecule)
Transform molecule according to the represented context.
|
ImmutableList<T> |
transformMolecules(List<Molecule> molecules,
SubProgressObserver po)
Transform molecules according to the represented context.
|
<N extends Serializable> |
unguarded(UnguardedContext<D,N> unguardedContext)
Update represented unguarded layer.
|
<N extends Serializable> |
unguarded(UnguardedExtractor<D,N> extractor,
UnguardedDissimilarityCalculator<N> unguardedCalc)
Update represented unguarded layer.
|
public static final int DEFAULT_PAGESIZE
public static final int DEFAULT_QUERY_PAGESIZE
public static <D extends Descriptor> OverlapAnalysisContext<D,byte[]> initial(DescriptorGenerator<D> generator)
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()
.
D
- Underlying descriptor typegenerator
- DescriptorGenerator representedDEFAULT_PAGESIZE
; others initialized to defaultspublic static <D extends Descriptor> OverlapAnalysisContext<D,byte[]> initial(DescriptorGenerator<D> generator, DescriptorComparator<D> comparator)
Note that DescriptorGenerator
determines underlying Descriptor
type thus it is not
modifiable.
The specified comparator must match to the generator: the comparator needed to be created by the passed descriptor generator.
D
- Underlying descriptor typegenerator
- DescriptorGenerator representedcomparator
- DescriptorComparator representedDEFAULT_PAGESIZE
; others initialized to their
defaultspublic OverlapAnalysisContext<D,T> descriptorComparator(DescriptorComparator comparator)
DescriptorComparator.unguardedContext()
.
Note that guard objects are checked; the passed comparator must match to the underlying
DescriptorGenerator
specified for initial(com.chemaxon.descriptors.common.DescriptorGenerator)
or initial(com.chemaxon.descriptors.common.DescriptorGenerator, com.chemaxon.descriptors.common.DescriptorComparator)
.
comparator
- Comparator to be usedpublic <N extends Serializable> OverlapAnalysisContext<D,N> comparisonContext(ComparisonContext<?,D,N> comparisonContext)
Note that guard objects are checked; the guard associated to the passed context
Guarded.getGuardObject()
must match to the represented guard
getGuardObject()
.
N
- New unguarded representation typecomparisonContext
- New comparison context to representpublic OverlapAnalysisContext<D,T> pagesize(int pagesize)
pagesize
- New pagesizepublic OverlapAnalysisContext<D,T> queryPagesize(int queryPagesize)
queryPagesize
- New query pagesizepublic OverlapAnalysisContext<D,T> standardizer(StandardizerWrapper standardizer)
standardizer
- New standardizerpublic <N extends Serializable> OverlapAnalysisContext<D,N> unguarded(UnguardedContext<D,N> unguardedContext)
UnguardedDissimilarityCalculator
represented by the given
ComparisonContext
be consistent with the DescriptorComparator
represented by this context.N
- New unguarded representation typeunguardedContext
- Unguarded context containing extractor/comparatorpublic <N extends Serializable> OverlapAnalysisContext<D,N> unguarded(UnguardedExtractor<D,N> extractor, UnguardedDissimilarityCalculator<N> unguardedCalc)
UnguardedDissimilarityCalculator
passed be consistent with the
DescriptorComparator
represented by this context.N
- New unguarded representation typeextractor
- Extractor of unguarded representationunguardedCalc
- Unguarded comparatorpublic DescriptorGenerator<D> getDescriptorGenerator()
public DescriptorComparator<D> getDescriptorComparator()
public StandardizerWrapper getStandardizer()
public UnguardedExtractor<D,T> getUnguardedExtractor()
public int getPagesize()
public int getQueryPagesize()
public UnguardedDissimilarityCalculator<T> getUnguardedDissimilarityCalculator()
public PagedDescriptorStorage<D> createEmptyStorage()
Note that the returned storage has no reference to the serializer of this context.
public UnguardedPagedOverlap<T> deserializeUnguardedPagedOverlap(ObjectInputStream ois, SubProgressObserver po) throws IOException, ClassNotFoundException
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.
ois
- Source stream to deserialize frompo
- Progress observer to track progress. Method ProgressObserver.done()
will be invoked upon
completionIOException
- Propagated from deserializationClassNotFoundException
- Propagated from deserializationpublic UnguardedPagedOverlap<T> deserializeUnguardedPagedOverlap(ObjectInputStream ois, Sink<Descriptor> onDescriptorRead, SubProgressObserver po) throws IOException, ClassNotFoundException
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.
ois
- Source stream to deserialize fromonDescriptorRead
- Callback to invoke on each deserialized descriptor or null
po
- Progress observer to track progress. Method ProgressObserver.done()
will be invoked upon
completionIOException
- Propagated from deserializationClassNotFoundException
- Propagated from deserializationpublic T parseDescriptorToUnguarded(String desc)
desc
- Descriptor String representationpublic ImmutableList<T> parseDescriptorsToUnguardeds(List<String> descs, SubProgressObserver po)
descs
- Descriptors String representationspo
- Progress observer to track progresspublic T transformMolecule(Molecule molecule)
The following steps are executed:
Molecule.cloneMolecule()
StandardizerWrapper
using
StandardizerWrapper.standardize(chemaxon.struc.Molecule)
DescriptorGenerator
using
DescriptorGenerator.generateDescriptor(chemaxon.struc.Molecule)
Function
molecule
- Molecule to transform. The molecule is cloned using Molecule.cloneMolecule()
before
transformations.public ImmutableList<T> transformMolecules(List<Molecule> molecules, SubProgressObserver po)
For each molecule the following steps are executed:
Molecule.cloneMolecule()
StandardizerWrapper
using
StandardizerWrapper.standardize(chemaxon.struc.Molecule)
DescriptorGenerator
using
DescriptorGenerator.generateDescriptor(chemaxon.struc.Molecule)
Function
molecules
- Molecules to transform. The molecules are cloned using Molecule.cloneMolecule()
before
transformations.po
- Progress observer to track progresspublic String toString(boolean multiline)
multiline
- Create multiline (more readable) output.public Object getGuardObject()
Guarded
This method is intended to use only for ensuring the compatibility of manipulated objects.
Implementations might use the associated DescriptorGenerator
or DescriptorParameters
reference as
the guard object, however it is a non recommended practice to use this method to access the associated generator
to perform further operations on it.
getGuardObject
in interface Guarded
null
.