public IReaction LabelReaction(IReaction reaction, ICanonicalMoleculeLabeller labeller) { Console.Out.WriteLine("labelling"); var canonReaction = new Reaction(); var permutationMap = new Dictionary <IAtomContainer, int[]>(); var canonicalProducts = ChemObjectBuilder.Instance.NewChemObjectSet <IAtomContainer>(); foreach (var product in reaction.Products) { var canonicalForm = labeller.GetCanonicalMolecule(product); if (fixAtomMappingCastType) { FixAtomMapping(canonicalForm); } var canonicalMolecule = canonicalForm.Builder.NewAtomContainer(canonicalForm); permutationMap[canonicalMolecule] = labeller.GetCanonicalPermutation(product); canonicalProducts.Add(canonicalMolecule); } var canonicalReactants = ChemObjectBuilder.Instance.NewChemObjectSet <IAtomContainer>(); foreach (var reactant in reaction.Reactants) { var canonicalForm = labeller.GetCanonicalMolecule(reactant); if (fixAtomMappingCastType) { FixAtomMapping(canonicalForm); } var canonicalMolecule = canonicalForm.Builder.NewAtomContainer(canonicalForm); permutationMap[canonicalMolecule] = labeller.GetCanonicalPermutation(reactant); canonicalReactants.Add(canonicalMolecule); } canonReaction.Products.AddRange(canonicalProducts); canonReaction.Reactants.AddRange(canonicalReactants); CloneAndSortMappings(reaction, canonReaction, permutationMap); return(canonReaction); }