Skip to content

Commit

Permalink
Merge branch 'JSON_parsable_base' into scratch_bond
Browse files Browse the repository at this point in the history
  • Loading branch information
diogomart committed Jan 12, 2025
2 parents 0a81777 + 761e829 commit d166afc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions meeko/molsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,21 +533,21 @@ def _decode_object(cls, obj: dict[str, Any]):
molsetup = cls(name, is_sidechain)

molsetup.pseudoatom_count = obj["pseudoatom_count"]
molsetup.atoms = [Atom.json_decoder(x) for x in obj["atoms"]]
molsetup.atoms = [Atom.from_dict(x) for x in obj["atoms"]]
molsetup.bond_info = {
string_to_tuple(k, int): Bond.json_decoder(v)
string_to_tuple(k, int): Bond.from_dict(v)
for k, v in obj["bond_info"].items()
}
molsetup.rings = {
string_to_tuple(k, int): Ring.json_decoder(v) for k, v in obj["rings"].items()
string_to_tuple(k, int): Ring.from_dict(v) for k, v in obj["rings"].items()
}
molsetup.ring_closure_info = RingClosureInfo(
obj["ring_closure_info"]["bonds_removed"],
obj["ring_closure_info"]["pseudos_by_atom"],
)
molsetup.rotamers = [convert_to_tuple_keyed_dict(rotamer, int) for rotamer in obj["rotamers"]]
molsetup.atom_params = obj["atom_params"]
molsetup.restraints = [Restraint.json_decoder(x) for x in obj["restraints"]]
molsetup.restraints = [Restraint.from_dict(x) for x in obj["restraints"]]
molsetup.flexibility_model = obj["flexibility_model"]
if "rigid_body_connectivity" in molsetup.flexibility_model:
tuples_rigid_body_connectivity = {
Expand Down Expand Up @@ -1554,7 +1554,7 @@ def json_encoder(cls, obj: "RDKitMoleculeSetup") -> Optional[dict[str, Any]]:
@classmethod
def _decode_object(cls, obj: dict[str, Any]):

base_molsetup = MoleculeSetup.json_decoder(obj)
base_molsetup = MoleculeSetup.from_dict(obj)
rdkit_molsetup = cls(source = base_molsetup)

# Restores RDKitMoleculeSetup-specific attributes from the json dict
Expand Down
12 changes: 6 additions & 6 deletions meeko/polymer.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,9 @@ def _decode_object(cls, obj: dict[str, Any]):

# Extracting the constructor args from the json representation and creating a ResidueChemTemplates instance
templates = {
k: ResidueTemplate.json_decoder(v, check_keys=False) for k, v in obj["residue_templates"].items()
k: ResidueTemplate.from_dict(v) for k, v in obj["residue_templates"].items()
}
padders = {k: ResiduePadder.json_decoder(v, check_keys=False) for k, v in obj["padders"].items()}
padders = {k: ResiduePadder.from_dict(v) for k, v in obj["padders"].items()}

residue_chem_templates = cls(templates, padders, obj["ambiguous"])

Expand Down Expand Up @@ -963,14 +963,14 @@ def _decode_object(cls, obj: dict[str, Any]):

# Deserializes ResidueChemTemplates from the dict to use as an input, then constructs a Polymer object
# and sets its values using deserialized JSON values.
residue_chem_templates = ResidueChemTemplates.json_decoder(
residue_chem_templates = ResidueChemTemplates.from_dict(
obj["residue_chem_templates"]
)

polymer = cls({}, {}, residue_chem_templates)

polymer.monomers = {
k: Monomer.json_decoder(v, check_keys=False) for k, v in obj["monomers"].items()
k: Monomer.from_dict(v) for k, v in obj["monomers"].items()
}
polymer.log = obj["log"]

Expand Down Expand Up @@ -2130,9 +2130,9 @@ def _decode_object(cls, obj: dict[str, Any]):
rdkit_mol = rdkit_mol_from_json(obj["rdkit_mol"])
padded_mol = rdkit_mol_from_json(obj["padded_mol"])

molsetup = RDKitMoleculeSetup.json_decoder(obj["molsetup"])
molsetup = RDKitMoleculeSetup.from_dict(obj["molsetup"])
if not isinstance(molsetup, RDKitMoleculeSetup):
molsetup = MoleculeSetup.json_decoder(obj["molsetup"])
molsetup = MoleculeSetup.from_dict(obj["molsetup"])

mapidx_to_raw = convert_to_int_keyed_dict(obj["mapidx_to_raw"])
molsetup_mapidx = convert_to_int_keyed_dict(obj["molsetup_mapidx"])
Expand Down

0 comments on commit d166afc

Please sign in to comment.