Closed philipyang1 closed 1 year ago
The code you are seeing are grouping the reactions based on template hash, and there could be many reactions being represented by the same template. So the grouping is used to figure out how many reactions there are per unique template.
The template hash is calculated by the rxnutils
package: https://molecularai.github.io/reaction_utils/templates.html It is the hash_from_bits
method that is used in the latest publicly available models for AiZynthFinder.
@SGenheden ,thanks for your answers.
Philip Yang
I notice the comment for template_hash is "a unique hash for each unique template. Will be used to filter uncommon templates.".
I have two questions here. Very Thanks! 1) If this template_hash is unique, why here we need to apply "group by" based on template_hash? in which case that the templete_group.size() value >1 instead of 1?
2) If I have a retro-template for a reaction, how can I get the template_hash for this template? can I use hash method like below?
_retro_canonical = products_string + '>>' + reactants_string hexhash = (retrocanonical).apply(lambda x: hashlib.sha256(x.encode('utf-8')).hexdigest())
Very Thanks! Philip Yang