Class AutoMapper
- All Implemented Interfaces:
ReactionMapper
AutoMapper is a tool that performs automated chemical reaction mapping. The term mapping refers to the
association of reactant side atoms to product side atoms. It can also identify and mark the reaction center during
mapping. Please note, that when potential tetrahedral stereo centers need to be taken into account for correct
mapping, it is necessary to provide coordinates for all the atoms in the reaction.
AutoMapper supports three mapping styles:
ReactionMapper.MappingStyle.COMPLETE(default)ReactionMapper.MappingStyle.CHANGINGReactionMapper.MappingStyle.MATCHING
Helper functions are added to support concurrent mapping of reactions coming from various sources, such as
- files
- collections (
Collection) - iterators (
Iterator).
API usage examples
Basic example, shows how to map a single reaction:
RxnMolecule reaction = RxnMolecule.getReaction(MolImporter
.importMol("COC1OC(CO)C(OC)C(O)C1O.OS(O)(=O)=O>>COC1OC(COS(O)(=O)=O)C(OC)C(O)C1O.[H]O[H]"));
AutoMapper mapper = new AutoMapper();
mapper.map(reaction);
System.out.println(MolExporter.exportToFormat(reaction, "smiles"));
Map all reactions in a file, and mark the reaction centers:
MolImporter importer = new MolImporter("unmapped.smiles");
MolExporter exporter = new MolExporter("mapped.mrv", "mrv");
AutoMapper.mapReaction(importer, exporter, new AutoMapper.Options().setMarkBonds(true));
importer.close();
exporter.close();
Map reactions during iteration:
MolImporter importer = new MolImporter("unmapped.smiles");
Iterator<Molecule> mappedMoleculeIterator = AutoMapper.iterator(importer.iterator());
while (mappedMoleculeIterator.hasNext()) {
Molecule mappedReaction = mappedMoleculeIterator.next();
// do something with the mapped reaction ...
}
importer.close();
In concurrent mode reactions are cached. The default cache size is 1000, which can be overridden with "chemaxon.automapper.AutoMapper.cacheSize" Java system property. In case of invalid cache size (not positive, or not a valid number) the default value is used.
- Since:
- 6.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classConfiguration options for automated reaction mapping when using static mapping methods.static interfaceAuto-closeable result iterator forAutoMapper.Nested classes/interfaces inherited from interface chemaxon.reaction.mapper.ReactionMapper
ReactionMapper.MappingStyle -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intdefault cache sizestatic final Stringcache size property key -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the mapping style of the mapper.booleanReturns if the mapper will keep the initial mapping or not.booleanReturns if the mapper marks the reaction center bonds or not.static AutoMapper.ResultIteratorReturns an auto-closeable result iterator that maps the reactions provided by the given input iterator.static AutoMapper.ResultIteratoriterator(Iterator<Molecule> reactions, AutoMapper.Options options) Returns an auto-closeable result iterator that maps the reactions provided by the given input iterator using the given options.booleanmap(RxnMolecule reaction) Maps the reaction.static voidmapReaction(MolImporter importer, MolExporter exporter) Deprecated, for removal: This API element is subject to removal in a future version.static voidmapReaction(MolImporter importer, MolExporter exporter, AutoMapper.Options options) Deprecated, for removal: This API element is subject to removal in a future version.UsemapReactions(MolImporter, MolExporter, Options)instead.static voidmapReaction(MolImporter importer, MolExporter exporter, ReactionMapper... mappers) Deprecated, for removal: This API element is subject to removal in a future version.No replacement.static voidmapReaction(AutoMapper.Options options, Molecule... reactions) Deprecated, for removal: This API element is subject to removal in a future version.UsemapReactions(Collection, Options)instead.static voidmapReaction(ReactionMapper[] mappers, Molecule... reactions) Deprecated, for removal: This API element is subject to removal in a future version.No replacement.static voidmapReaction(Molecule reaction) Maps the given reaction.static voidmapReaction(Molecule... reactions) Deprecated, for removal: This API element is subject to removal in a future version.UsemapReactions(Molecule...)instead.static voidmapReaction(Molecule reaction, AutoMapper.Options options) Maps the given reaction.static voidmapReaction(Collection<Molecule> reactions) Deprecated, for removal: This API element is subject to removal in a future version.UsemapReactions(Collection)instead.static voidmapReaction(Collection<Molecule> reactions, AutoMapper.Options options) Deprecated, for removal: This API element is subject to removal in a future version.UsemapReactions(Collection, Options)instead.static voidmapReaction(Collection<Molecule> reactions, ReactionMapper... mappers) Deprecated, for removal: This API element is subject to removal in a future version.No replacement.static voidmapReactions(MolImporter importer, MolExporter exporter) Maps the reactions read from the given importer and writes them to the given exporter.static voidmapReactions(MolImporter importer, MolExporter exporter, AutoMapper.Options options) Maps the reactions read from the given importer using the given options and writes them to the given exporter.static voidmapReactions(Molecule... reactions) Maps the given reactions.static voidmapReactions(Collection<Molecule> reactions) Maps the given reactions.static voidmapReactions(Collection<Molecule> reactions, AutoMapper.Options options) Maps the given reactions using the given options.voidsetKeepMapping(boolean keepMapping) Sets if the initial mapping of the atoms should be kept or not.voidSets the mapping stylevoidsetMarkBonds(boolean markResult) Sets if the changing bonds should be marked or not.voidsetTimeLimit(long timeLimitMilliseconds) Sets time limit for the calculation.static voidRemove atom maps from the given structure
-
Field Details
-
DEFAULT_CACHE_SIZE_PROPERTY
cache size property key- See Also:
-
DEFAULT_CACHE_SIZE
public static final int DEFAULT_CACHE_SIZEdefault cache size- See Also:
-
-
Constructor Details
-
AutoMapper
public AutoMapper()Initializes anAutoMapperobject
-
-
Method Details
-
mapReaction
Maps the given reaction.- Parameters:
reaction- the reaction to map
-
mapReaction
Maps the given reaction.- Parameters:
reaction- the reaction to mapoptions- the mapping options to use- See Also:
-
mapReactions
Maps the given reactions. Utilizes multiple threads if possible.- Parameters:
reactions- the reactions to map
-
mapReactions
Maps the given reactions. Utilizes multiple threads if possible.- Parameters:
reactions- the collection of reactions to map
-
mapReactions
Maps the given reactions using the given options. Utilizes multiple threads if possible.- Parameters:
reactions- the collection of reactions to mapoptions- the mapping options to use- See Also:
-
mapReactions
Maps the reactions read from the given importer and writes them to the given exporter. Utilizes multiple threads if possible.- Parameters:
importer- the importer to read reactions fromexporter- the exporter to write mapped reactions to- Throws:
IOException- on export failure
-
mapReactions
public static void mapReactions(MolImporter importer, MolExporter exporter, AutoMapper.Options options) throws IOException Maps the reactions read from the given importer using the given options and writes them to the given exporter. Utilizes multiple threads if possible.- Parameters:
importer- the importer to read reactions fromexporter- the exporter to write mapped reactions tooptions- the mapping options to use for mapping- Throws:
MolExportException- on export failureIOException- on export failure- See Also:
-
iterator
Returns an auto-closeable result iterator that maps the reactions provided by the given input iterator. Utilizes multiple threads if possible.NOTE: the returned iterator provides the same molecule instances with mapping numbers added. Use this iterator with try-with-resources statement.
- Parameters:
reactions- the input iterator for the reactions to map- Returns:
AutoMapper.ResultIteratorthat provides the mapped molecules
-
iterator
public static AutoMapper.ResultIterator iterator(Iterator<Molecule> reactions, AutoMapper.Options options) Returns an auto-closeable result iterator that maps the reactions provided by the given input iterator using the given options. Utilizes multiple threads if possible.NOTE: the returned iterator provides the same molecule instances with mapping numbers added. Use this iterator with try-with-resources statement.
- Parameters:
reactions- the input iterator for the reactions to mapoptions- the mapping options to use- Returns:
AutoMapper.ResultIteratorthat provides the mapped molecules- See Also:
-
mapReaction
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2026) public static void mapReaction(Molecule... reactions) Deprecated, for removal: This API element is subject to removal in a future version.UsemapReactions(Molecule...)instead. This method will be removed in a future release.Maps the reactions in the specified collection using multiple threads if possible.- Parameters:
reactions- the array of reactions to map
-
mapReaction
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2026) public static void mapReaction(AutoMapper.Options options, Molecule... reactions) Deprecated, for removal: This API element is subject to removal in a future version.UsemapReactions(Collection, Options)instead. This method will be removed in a future release.Maps the reactions in the specified collection using the specified options.- Parameters:
options- the mapping options to usereactions- the array of reactions to map
-
mapReaction
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2026) public static void mapReaction(ReactionMapper[] mappers, Molecule... reactions) Deprecated, for removal: This API element is subject to removal in a future version.No replacement. This method will be removed in a future release.Maps the reactions in the specified collection using the specified mappers in multiple threads. The number of mappers specifies the number of threads to use.- Parameters:
mappers- the mappers to usereactions- the collections of reactions to map
-
mapReaction
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2026) public static void mapReaction(Collection<Molecule> reactions) Deprecated, for removal: This API element is subject to removal in a future version.UsemapReactions(Collection)instead. This method will be removed in a future release.Maps the reactions in the specified collection using multiple threads if possible.- Parameters:
reactions- the collection of reactions to map
-
mapReaction
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2026) public static void mapReaction(Collection<Molecule> reactions, AutoMapper.Options options) Deprecated, for removal: This API element is subject to removal in a future version.UsemapReactions(Collection, Options)instead. This method will be removed in a future release.Maps the reactions in the specified collection using the specified options.- Parameters:
reactions- the collections of reactions to mapoptions- the mapping options to use- See Also:
-
mapReaction
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2026) public static void mapReaction(Collection<Molecule> reactions, ReactionMapper... mappers) Deprecated, for removal: This API element is subject to removal in a future version.No replacement. This method will be removed in a future release.Maps the reactions in the specified collection using the specified mappers in multiple threads. The number of mappers specifies the number of threads to use.- Parameters:
reactions- the collections of reactions to mapmappers- the mappers to use
-
mapReaction
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2026) public static void mapReaction(MolImporter importer, MolExporter exporter) throws MolExportException, IOException Deprecated, for removal: This API element is subject to removal in a future version.UsemapReactions(MolImporter, MolExporter)instead. This method will be removed in a future release.Reads the reactions from the importer, maps them, and writes to the exporter. Uses multiple threads for mapping if possible.- Parameters:
importer- the importer to read reactions fromexporter- the exporter to write mapped reactions to- Throws:
MolExportException- on export failureIOException- on export failure
-
mapReaction
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2026) public static void mapReaction(MolImporter importer, MolExporter exporter, AutoMapper.Options options) throws MolExportException, IOException Deprecated, for removal: This API element is subject to removal in a future version.UsemapReactions(MolImporter, MolExporter, Options)instead. This method will be removed in a future release.Reads the reactions from the importer, maps them, and writes to the exporter. Uses the specified number of threads for mapping.- Parameters:
importer- the importer to read reactions fromexporter- the exporter to write mapped reactions tooptions- the mapping options to use for mapping- Throws:
MolExportException- on export failureIOException- on export failure- See Also:
-
mapReaction
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2026) public static void mapReaction(MolImporter importer, MolExporter exporter, ReactionMapper... mappers) throws MolExportException, IOException Deprecated, for removal: This API element is subject to removal in a future version.No replacement. This method will be removed in a future release.Reads the reactions from the importer, maps them, and writes to the exporter. Uses the specified mappers for mapping. The number of mappers specified the number of threads to use.- Parameters:
importer- the importer to read reactions fromexporter- the exporter to write mapped reactions tomappers- the mappers to use- Throws:
MolExportException- on export failureIOException- on export failure
-
map
Maps the reaction.- Specified by:
mapin interfaceReactionMapper- Parameters:
reaction- is the reaction to be mapped- Returns:
trueif mapping was successful
-
setMappingStyle
Sets the mapping style- Specified by:
setMappingStylein interfaceReactionMapper- Parameters:
style- the mapping style to set- See Also:
-
getMappingStyle
Returns the mapping style of the mapper.- Returns:
- the mapping style of the mapper
-
setMarkBonds
public void setMarkBonds(boolean markResult) Description copied from interface:ReactionMapperSets if the changing bonds should be marked or not.- Specified by:
setMarkBondsin interfaceReactionMapper- Parameters:
markResult- specifies if the reaction center should be marked or not
-
isMarkBonds
public boolean isMarkBonds()Returns if the mapper marks the reaction center bonds or not.- Returns:
- if the mapper marks the reaction center bonds or not
-
setKeepMapping
public void setKeepMapping(boolean keepMapping) Description copied from interface:ReactionMapperSets if the initial mapping of the atoms should be kept or not.- Specified by:
setKeepMappingin interfaceReactionMapper- Parameters:
keepMapping- specifies if the initial mapping of the atoms should be kept or not
-
setTimeLimit
public void setTimeLimit(long timeLimitMilliseconds) Description copied from interface:ReactionMapperSets time limit for the calculation. When the time limit is reached, the atoms are mapped according to the mapping found so far.- Specified by:
setTimeLimitin interfaceReactionMapper- Parameters:
timeLimitMilliseconds- time limit in milliseconds, -1 means disabled.
-
isKeepMapping
public boolean isKeepMapping()Returns if the mapper will keep the initial mapping or not.- Returns:
- if the mapper will keep the initial mapping or not
-
unmap
Remove atom maps from the given structure- Parameters:
mol- the structure to unmap
-
mapReactions(MolImporter, MolExporter)instead.