forlilab / Meeko

Interfacing RDKit and AutoDock
GNU Lesser General Public License v2.1
192 stars 48 forks source link

Json Encoders and Decoders in Molsetups and Chorizo Residues #83

Closed psharma-sr closed 4 months ago

psharma-sr commented 8 months ago

Adding JSON encoders and decoders for the MoleculeSetup class and the classes in linked_rdkit_chorizo, tests for those JSON encoders and decoders, and some starting documentation to the molecule setup class.

Now, to get a JSON of an object you should specify an encoder in the json.dumps command:

json.dumps(a_molecule_setup, cls = MoleculeSetup)

And to extract an object from JSON text, you can specify an object hook to decode the json string input to an object:

json.loads(json_string, object_hook=molsetup_json_decoder)

The following JSON Encoders have been added MoleculeSetupEncoder ChorizoResidueEncoder ResidueTemplateEncoder ResiduePadderEncoder ResidueChemTemplatesEncoder LinkedRDKitChorizoEncoder

The following JSON Decoders have been added molsetup_json_decoder chorizo_residue_json_decoder residue_template_json_decoder residue_padder_json_decoder residue_chem_templates_json_decoder linked_rdkit_chorizo_json_decoder

Additional work that needs to be done following this PR:

diogomart commented 8 months ago

added wrappers to make scripting less verbose, e.g

json_string = molsetup.to_json()
new_molsetup = MoleculeSetup.from_json(json_string) # works with RDKitMoleculeSetup also

three fields in the molecule setup can't be encoded yet

feel free to change anything as you see fit!