Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 20, 2024
1 parent 1b0812d commit 53a80d5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 24 deletions.
44 changes: 23 additions & 21 deletions grits/finegrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,26 @@


def backmap_snapshot_to_compound(
snapshot,
bead_mapping=None,
bond_head_index=None,
bond_tail_index=None,
library_key=None,
ref_distance=None,
energy_minimize=False
snapshot,
bead_mapping=None,
bond_head_index=None,
bond_tail_index=None,
library_key=None,
ref_distance=None,
energy_minimize=False,
):
# TODO
# assert all 3 dicts have the same keys
if (bead_mapping is None and bond_head_index is None and bond_tail_index is None) == (library_key is None):
raise ValueError(
"Please provide dictionaries or library key."
)
if (
bead_mapping is None
and bond_head_index is None
and bond_tail_index is None
) == (library_key is None):
raise ValueError("Please provide dictionaries or library key.")
if library_key is not None:
bead_mapping=reactant_dict[library_key]['smiles']
bond_tail_index=reactant_dict[library_key]['tail_indices']
bond_head_index=reactant_dict[library_key]['head_indices']
bead_mapping = reactant_dict[library_key]["smiles"]
bond_tail_index = reactant_dict[library_key]["tail_indices"]
bond_head_index = reactant_dict[library_key]["head_indices"]
if not ref_distance:
ref_distance = 1
cg_snap = snapshot
Expand All @@ -47,11 +49,11 @@ def backmap_snapshot_to_compound(
for mapping in bead_mapping:
comp = mb.load(bead_mapping[mapping], smiles=True)
if bond_head_index and bond_tail_index:
remove_atoms = [] # These will be removed
anchor_particles = [] # Store this for making bonds later
'''adding section to remove other particles in reacting group
assuming input for head/tail indices is a list, with the anchor particle listed first'''
if len(bond_tail_index[mapping]) > 1:
remove_atoms = [] # These will be removed
anchor_particles = [] # Store this for making bonds later
"""adding section to remove other particles in reacting group
assuming input for head/tail indices is a list, with the anchor particle listed first"""
if len(bond_tail_index[mapping]) > 1:
extra_tail_particles = []
extra_tail_particles = bond_tail_index[mapping][1:]
for k in extra_tail_particles:
Expand Down Expand Up @@ -136,8 +138,8 @@ def backmap_snapshot_to_compound(
temp_head = temp_comp.children[1]
tail_comp.xyz = temp_tail.xyz
head_comp.xyz = temp_head.xyz
'''maybe replace this section with just:
fg_compound.energy_minimize(steps=500)'''
"""maybe replace this section with just:
fg_compound.energy_minimize(steps=500)"""
return fg_compound


Expand Down
18 changes: 15 additions & 3 deletions grits/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,19 @@ def num2str(num):
}

reactant_dict = {
'pps':{'smiles':{"A":"c1ccc(S)cc1"},'head_indices':{"A":[7]}, 'tail_indices':{"A":[10]}},
'polystyrene':{'smiles':{"A":"C=CC1=CC=CC=C1"}, 'head_indices':{"A":[9]}, 'tail_indices':{"A":[10]}},
'polyalanine':{'smiles':{"A":"C[C@@H](C(=O)O)N"}, 'head_indices':{"A":[12]}, 'tail_indices':{"A":[4,10]}}
"pps": {
"smiles": {"A": "c1ccc(S)cc1"},
"head_indices": {"A": [7]},
"tail_indices": {"A": [10]},
},
"polystyrene": {
"smiles": {"A": "C=CC1=CC=CC=C1"},
"head_indices": {"A": [9]},
"tail_indices": {"A": [10]},
},
"polyalanine": {
"smiles": {"A": "C[C@@H](C(=O)O)N"},
"head_indices": {"A": [12]},
"tail_indices": {"A": [4, 10]},
},
}

0 comments on commit 53a80d5

Please sign in to comment.