DrrDom / crem

CReM: chemically reasonable mutations framework
BSD 3-Clause "New" or "Revised" License
208 stars 38 forks source link

how to employ the grow_mol2/mut_mol2 function #25

Closed MachineGUN001 closed 1 year ago

MachineGUN001 commented 1 year ago

hi, DrrDom,

could you please provide some example for using grow_mol2 and mut_mol2 functions? In particular, how to set the parameters, such as replace_ids? Many many thanks

DrrDom commented 1 year ago

I do not fully understand the question. These functions can be used if one wants to process several molecules simultaneously. This could be efficient with a relatively small number of parallel processes, otherwise access to a fragment DB will become a bottleneck. All arguments can be supplied as usual. Example

from crem.crem import mutate_mol, mutate_mol2
from multiprocessing import Pool
from functools import partial
from rdkit import Chem

m = Chem.MolFromSmiles('CCCC')

pool = Pool(3)

for res in pool.imap_unordered(partial(mutate_mol2, db_name='replacements_sa2.db', replace_ids=[0]), [m]):
    print(len(res), res)
MachineGUN001 commented 1 year ago

got it. thank you for providing the demonstration and explanation. This is a very interesting use.