rxn.reaction_preprocessing.mixed_reaction_filter.MixedReactionFilter
- class rxn.reaction_preprocessing.mixed_reaction_filter.MixedReactionFilter(max_reactants=10, max_agents=0, max_products=1, min_reactants=2, min_agents=0, min_products=1, max_reactants_tokens=300, max_agents_tokens=0, max_products_tokens=200, max_absolute_formal_charge=2)[source]
Bases:
object- Parameters
max_reactants (
int, default:10) –max_agents (
int, default:0) –max_products (
int, default:1) –min_reactants (
int, default:2) –min_agents (
int, default:0) –min_products (
int, default:1) –max_reactants_tokens (
int, default:300) –max_agents_tokens (
int, default:0) –max_products_tokens (
int, default:200) –max_absolute_formal_charge (
int, default:2) –
- __init__(max_reactants=10, max_agents=0, max_products=1, min_reactants=2, min_agents=0, min_products=1, max_reactants_tokens=300, max_agents_tokens=0, max_products_tokens=200, max_absolute_formal_charge=2)[source]
Creates a new instance of the type MixedReactionFilter.
- Parameters
max_reactants (
int, default:10) – The maximum number of reactant molecules.max_agents (
int, default:0) – The maximum number of agent molcules.max_products (
int, default:1) – The maximum number of product molecules.min_reactants (
int, default:2) – The minimum number of reactant molecules.min_agents (
int, default:0) – The minium number of agent molecules.min_products (
int, default:1) – The minimum number of product molecules.max_reactants_tokens (
int, default:300) – The maximum number of precursor tokens.max_agents_tokens (
int, default:0) – The maximum number of agent tokens.max_products_tokens (
int, default:200) – The maximum number of product tokens.max_absolute_formal_charge (
int, default:2) – The maximum formal charge (for reactants, agents, or products).
Methods
__init__([max_reactants, max_agents, ...])Creates a new instance of the type MixedReactionFilter.
different_atom_types(reaction)Check whether the products contain atom types not found in the agents or reactants.
formal_charge_exceeded(reaction)Check whether the absolute formal charge of the reactants, agents, or products exceeds a maximum.
invalid_atom_type(reaction)Check whether the reaction contains atoms with invalid atom types such as the asterisk "*".
is_valid(reaction)Whether a reaction is valid based on the rules set on the instance of this MixedReactionFilter class.
max_agent_tokens_exceeded(reaction)Check whether the number of agent tokens exceeds the maximum.
max_agents_exceeded(reaction)Checks whether the number of agents exceeds the maximum.
max_product_tokens_exceeded(reaction)Check whether the number of product tokens exceeds the maximum.
max_products_exceeded(reaction)Checks whether the number of products exceeds the maximum.
max_reactant_tokens_exceeded(reaction)Check whether the number of reactant tokens exceeds the maximum.
max_reactants_exceeded(reaction)Checks whether the number of reactants exceeds the maximum.
min_agents_subceeded(reaction)Checks whether the number of agents exceeds the maximum.
min_products_subceeded(reaction)Checks whether the number of products exceeds the maximum.
min_reactants_subceeded(reaction)Checks whether the number of reactants exceeds the maximum.
products_single_atoms(reaction)Checks whether the products solely consist of single atoms.
products_subset_of_reactants(reaction)Checks whether the set of products is a subset of the set of reactants.
validate(reaction)Make sure that the given reaction is valid; if not, an exception will be raised.
validate_reasons(reaction)- param reaction
- different_atom_types(reaction)[source]
Check whether the products contain atom types not found in the agents or reactants.
It handles the presence of placeholders for polymer head and tail representations.
- Parameters
reaction (
Union[MolEquation,ReactionEquation]) – The reaction to test.- Returns
Whether the products contain atom types not found in the agents or reactants.
- Return type
bool
- formal_charge_exceeded(reaction)[source]
Check whether the absolute formal charge of the reactants, agents, or products exceeds a maximum.
- Parameters
reaction (
Union[MolEquation,ReactionEquation]) – The reaction to test.- Returns
Whether the absolute formal charge of the reactants, agents, or products exceeds a maximum.
- Return type
bool
- invalid_atom_type(reaction)[source]
Check whether the reaction contains atoms with invalid atom types such as the asterisk “*”.
- Parameters
reaction (
Union[MolEquation,ReactionEquation]) – The reaction to test.- Returns
Whether the reaction contains invalid atom types.
- Return type
bool
- is_valid(reaction)[source]
Whether a reaction is valid based on the rules set on the instance of this MixedReactionFilter class.
- Parameters
reaction (
ReactionEquation) – The reaction to validate.- Returns
Whether or not the reaction is valid according to the rules set on the instance of this MixedReactionFilter class.
- Return type
bool
- max_agent_tokens_exceeded(reaction)[source]
Check whether the number of agent tokens exceeds the maximum.
- Parameters
reaction (
ReactionEquation) – The reaction to test.- Returns
Whether the number of agent tokens exceeds the maximum.
- Return type
[type]
- max_agents_exceeded(reaction)[source]
Checks whether the number of agents exceeds the maximum.
- Parameters
reaction (
ReactionEquation) – The reaction to test.- Returns
Whether the number of agents exceeds the maximum.
- Return type
bool
- max_product_tokens_exceeded(reaction)[source]
Check whether the number of product tokens exceeds the maximum.
- Parameters
reaction (
ReactionEquation) – The reaction to test.- Returns
Whether the number of product tokens exceeds the maximum.
- Return type
[type]
- max_products_exceeded(reaction)[source]
Checks whether the number of products exceeds the maximum.
- Parameters
reaction (
ReactionEquation) – The reaction to test.- Returns
Whether the number of products exceeds the maximum.
- Return type
bool
- max_reactant_tokens_exceeded(reaction)[source]
Check whether the number of reactant tokens exceeds the maximum.
- Parameters
reaction (
ReactionEquation) – The reaction to test.- Returns
Whether the number of reactant tokens exceeds the maximum.
- Return type
[type]
- max_reactants_exceeded(reaction)[source]
Checks whether the number of reactants exceeds the maximum.
- Parameters
reaction (
ReactionEquation) – The reaction to test.- Returns
Whether the number of reactants exceeds the maximum.
- Return type
bool
- min_agents_subceeded(reaction)[source]
Checks whether the number of agents exceeds the maximum.
- Parameters
reaction (
ReactionEquation) – The reaction to test.- Returns
Whether the number of agents exceeds the maximum.
- Return type
bool
- min_products_subceeded(reaction)[source]
Checks whether the number of products exceeds the maximum.
- Parameters
reaction (
ReactionEquation) – The reaction to test.- Returns
Whether the number of products exceeds the maximum.
- Return type
bool
- min_reactants_subceeded(reaction)[source]
Checks whether the number of reactants exceeds the maximum.
- Parameters
reaction (
ReactionEquation) – The reaction to test.- Returns
Whether the number of reactants exceeds the maximum.
- Return type
bool
- products_single_atoms(reaction)[source]
Checks whether the products solely consist of single atoms.
- Parameters
reaction (
Union[MolEquation,ReactionEquation]) – The reaction to test.- Returns
Whether the products solely consist of single atoms.
- Return type
bool
- products_subset_of_reactants(reaction)[source]
Checks whether the set of products is a subset of the set of reactants.
- Parameters
reaction (
ReactionEquation) – The reaction to test.- Returns
Whether the set of products is a subset of the set of reactants.
- Return type
bool
- validate(reaction)[source]
Make sure that the given reaction is valid; if not, an exception will be raised.
- Raises
ReactionFilterError – if the reaction does not pass the filters.
- Parameters
reaction (
ReactionEquation) – reaction to validate.- Return type
None