public final class AutoMapper extends Object implements Mapper<RxnMolecule>
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.
AutoMapper
supports three mapping styles:
Helper functions are added to support concurrent mapping of reactions coming from various sources, such as
Collection
)
Iterator
).
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.
Modifier and Type | Class and Description |
---|---|
static class |
AutoMapper.Options
Option object for set common options when mapping called by static way.
|
Mapper.MappingStyle
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_CACHE_SIZE
default cache size
|
static String |
DEFAULT_CACHE_SIZE_PROPERTY
cache size property key
|
Constructor and Description |
---|
AutoMapper()
Initializes an
AutoMapper object |
Modifier and Type | Method and Description |
---|---|
Mapper.MappingStyle |
getMappingStyle()
Returns the mapping style of the mapper.
|
boolean |
isKeepMapping()
Returns if the mapper will keep the initial mapping or not.
|
boolean |
isMarkBonds()
Returns if the mapper marks the reaction center bonds or not.
|
static Iterator<Molecule> |
iterator(Iterator<Molecule> iterator)
Returns an iterator that will return the mapped molecules from the specified iterator.
NOTE: the returned iterator provides the same molecule instances with maps added |
static Iterator<Molecule> |
iterator(Iterator<Molecule> iterator,
AutoMapper.Options options)
Returns an iterator that will return the mapped molecules from the specified iterator using the specified number
of threads for mapping.
NOTE: the returned iterator provides the same molecule instances with maps added |
static Iterator<Molecule> |
iterator(Iterator<Molecule> iterator,
Mapper<RxnMolecule>... mappers)
Returns an iterator that will return the mapped molecules from the specified iterator using the specified mappers
for mapping.
|
boolean |
map(RxnMolecule reaction)
Maps the reaction.
|
static void |
mapReaction(AutoMapper.Options options,
Molecule... reactions)
Maps the reactions in the specified collection using the specified options.
|
static void |
mapReaction(Collection<Molecule> reactions)
Maps the reactions in the specified collection using multiple threads if possible.
|
static void |
mapReaction(Collection<Molecule> reactions,
AutoMapper.Options options)
Maps the reactions in the specified collection using the specified options.
|
static void |
mapReaction(Collection<Molecule> reactions,
Mapper<RxnMolecule>... mappers)
Maps the reactions in the specified collection using the specified mappers in multiple threads.
|
static void |
mapReaction(Mapper<RxnMolecule>[] mappers,
Molecule... reactions)
Maps the reactions in the specified collection using the specified mappers in multiple threads.
|
static void |
mapReaction(Molecule... reactions)
Maps the reactions in the specified collection using multiple threads if possible.
|
static void |
mapReaction(MolImporter importer,
MolExporter exporter)
Reads the reactions from the importer, maps them, and writes to the exporter.
|
static void |
mapReaction(MolImporter importer,
MolExporter exporter,
AutoMapper.Options options)
Reads the reactions from the importer, maps them, and writes to the exporter.
|
static void |
mapReaction(MolImporter importer,
MolExporter exporter,
Mapper<RxnMolecule>... mappers)
Reads the reactions from the importer, maps them, and writes to the exporter.
|
void |
setKeepMapping(boolean keepMapping)
Sets if the initial mapping of the given object should be kept or not.
|
void |
setMappingStyle(Mapper.MappingStyle style)
Sets the mapping style
|
void |
setMarkBonds(boolean markResult)
Sets if the changing bonds should be marked or not.
|
static void |
unmap(Molecule item)
Remove atom maps from the given structure
|
public static final String DEFAULT_CACHE_SIZE_PROPERTY
public static final int DEFAULT_CACHE_SIZE
public AutoMapper()
AutoMapper
objectpublic static void mapReaction(Molecule... reactions)
reactions
- the array of reactions to mappublic static void mapReaction(AutoMapper.Options options, Molecule... reactions)
options
- the mapping options to usereactions
- the array of reactions to mapAutoMapper.Options
public static void mapReaction(Mapper<RxnMolecule>[] mappers, Molecule... reactions)
mappers
- the mappers to usereactions
- the collections of reactions to mappublic static void mapReaction(Collection<Molecule> reactions)
reactions
- the collection of reactions to mappublic static void mapReaction(Collection<Molecule> reactions, AutoMapper.Options options)
reactions
- the collections of reactions to mapoptions
- the mapping options to useAutoMapper.Options
public static void mapReaction(Collection<Molecule> reactions, Mapper<RxnMolecule>... mappers)
reactions
- the collections of reactions to mapmappers
- the mappers to usepublic static void mapReaction(MolImporter importer, MolExporter exporter) throws MolExportException, IOException
importer
- the importer to read reactions fromexporter
- the exporter to write mapped reactions toMolExportException
- on export failureIOException
- on export failurepublic static void mapReaction(MolImporter importer, MolExporter exporter, AutoMapper.Options options) throws MolExportException, IOException
importer
- the importer to read reactions fromexporter
- the exporter to write mapped reactions tooptions
- the mapping options to use for mappingMolExportException
- on export failureIOException
- on export failureAutoMapper.Options
public static void mapReaction(MolImporter importer, MolExporter exporter, Mapper<RxnMolecule>... mappers) throws MolExportException, IOException
importer
- the importer to read reactions fromexporter
- the exporter to write mapped reactions tomappers
- the mappers to useMolExportException
- on export failureIOException
- on export failurepublic static Iterator<Molecule> iterator(Iterator<Molecule> iterator)
iterator
- the input data iteratorIterator.remove()
.public static Iterator<Molecule> iterator(Iterator<Molecule> iterator, AutoMapper.Options options)
iterator
- the input data iteratoroptions
- the mapping options to useIterator.remove()
.AutoMapper.Options
public static Iterator<Molecule> iterator(Iterator<Molecule> iterator, Mapper<RxnMolecule>... mappers)
iterator
- the input data iteratormappers
- the mappers to useIterator.remove()
.public boolean map(RxnMolecule reaction)
map
in interface Mapper<RxnMolecule>
reaction
- is the reaction to be mappedtrue
if mapping was successfulpublic void setMappingStyle(Mapper.MappingStyle style)
setMappingStyle
in interface Mapper<RxnMolecule>
style
- the mapping style to setMapper.MappingStyle.COMPLETE
,
Mapper.MappingStyle.CHANGING
,
Mapper.MappingStyle.MATCHING
public Mapper.MappingStyle getMappingStyle()
public void setMarkBonds(boolean markResult)
Mapper
setMarkBonds
in interface Mapper<RxnMolecule>
markResult
- if the reaction center should be marked or notpublic boolean isMarkBonds()
public void setKeepMapping(boolean keepMapping)
Mapper
setKeepMapping
in interface Mapper<RxnMolecule>
keepMapping
- if the initial mapping of the given object should be kept or notpublic boolean isKeepMapping()
public static void unmap(Molecule item)
item
- the structure to unmap