Skip to content

Commit

Permalink
Protein-Protein MMGBSA bug (#59)
Browse files Browse the repository at this point in the history
* feat: support protein-protein complex calculation

* version 0.1.7

* fix: index error bug
  • Loading branch information
Aunity authored Nov 6, 2024
1 parent 6543335 commit e2b61b3
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions unigbsa/simulation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,19 +499,42 @@ def ligand_validate(sdfile, outfile=None):


def gen_index_for_gbsa(rec, lig, outfile='index.ndx'):
lig_atoms, rec_atoms = 0, 0
for key, (mol, _) in rec.molecules.items():
if key.startswith(('MOL', 'protein', 'system', 'Protein')):
rec_atoms += len(mol.atoms)
for key, (mol, _) in lig.molecules.items():
if key.startswith(('MOL', 'protein', 'system', 'Protein')):
lig_atoms += len(mol.atoms)
syscount = 1
lig_atoms, rec_atoms, sys_atoms = 0, 0, 0
lig_keys, rec_keys = [], []
except_resnames = ('SOL')
for mol, reslist in rec.split():
if len(mol.residues) == 1:
title = mol.residues[0].name if mol.residues[0].name.strip() else "UNK"
else:
title = f'Sgement-{syscount}'
syscount += 1
n_atoms = len(mol.atoms) * len(reslist)
if title not in except_resnames:
rec_atoms += n_atoms
rec_keys.append(title)
sys_atoms += n_atoms
for mol, reslist in lig.split():
if len(mol.residues) == 1:
title = mol.residues[0].name if mol.residues[0].name.strip() else "UNK"
else:
title = f'Sgement-{syscount}'
syscount += 1
n_atoms = len(mol.atoms) * len(reslist)
if title not in except_resnames:
lig_atoms += n_atoms
lig_keys.append(title)
sys_atoms += n_atoms

atom_dict = {
'System': (1, lig_atoms+rec_atoms+1),
'ligand': (1, lig_atoms+1),
'receptor': (lig_atoms+1, rec_atoms+lig_atoms+1)
}

logging.info(f"molecules in REC: {','.join(rec_keys)}")
logging.info(f"molecules in LIG: {','.join(lig_keys)}")

with open(outfile, 'w') as fw:
for k, (s, e) in atom_dict.items():
fw.write(f'\n[ {k} ]\n')
Expand Down

0 comments on commit e2b61b3

Please sign in to comment.