From 3da8acc5a6513bf8c7a83c6f8a140b4bde7e5312 Mon Sep 17 00:00:00 2001 From: Peng Xu Date: Thu, 22 May 2025 12:30:05 -0700 Subject: [PATCH] adding DFTB-C HMO file; handle Cl; handle edge case when glycine-merge enable; bug fix --- fragit/fragmentation.py | 15 ++++++++++----- fragit/gamessfmo.py | 1 + share/hmo/DFTB-C | 5 +++++ 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 share/hmo/DFTB-C diff --git a/fragit/fragmentation.py b/fragit/fragmentation.py index b654f72..d36253f 100644 --- a/fragit/fragmentation.py +++ b/fragit/fragmentation.py @@ -12,7 +12,7 @@ except ImportError: raise OBNotFoundException("OpenBabel not found. Please install OpenBabel to use FragIt.") -from fragit.util import remove_duplicates, flatten, difference, uniqifyListOfLists, is_tuple_values_in_either_list, LABEL2Z +from fragit.util import remove_duplicates, flatten, difference, uniqifyListOfLists, is_tuple_values_in_either_list, LABEL2Z, Z2LABEL from fragit.config import FragItConfig, FragItDataBase @@ -97,7 +97,8 @@ def _remove_metal_atoms(self): break for i in range(1, self.mol.NumAtoms()+1): atom = self.mol.GetAtom(i) - if atom.GetAtomicNum() in [1, 6, 7, 8, 9, 12, 15, 16]: +# PX: not make Cl to Cl- + if atom.GetAtomicNum() in [1, 6, 7, 8, 9, 12, 15, 16, 17]: if atom not in self._atoms: self._atoms.append(atom) added += 1 @@ -108,8 +109,8 @@ def _remove_metal_atoms(self): atomic_charge = 0 # default if atom.GetAtomicNum() in [11, 19]: # Na+ and K+: atomic_charge = 1 - elif atom.GetAtomicNum() in [9, 17]: # F- and Cl- - atomic_charge = -1 + #elif atom.GetAtomicNum() in [9, 17]: # F- and Cl- + # atomic_charge = -1 new_atom = openbabel.OBAtom() new_atom.Duplicate(atom) @@ -191,6 +192,10 @@ def do_fragment_merging(self): fragments = self.get_fragments() fragments_to_merge.reverse() for fragment_id in fragments_to_merge: + #PX : for edge case, + # when the first fragment is glycine,do not merge. + if fragment_id == 0: + continue previous_fragment = fragment_id-1 ifrag = fragments.pop(fragment_id) jfrag = fragments[previous_fragment].extend(ifrag) @@ -580,7 +585,7 @@ def name_fragment(self, atoms: List[int]) -> str: if len(atoms) == 1: atom = self.mol.GetAtom(atoms[0]) charge_lbl = charge_lbls[atom.GetFormalCharge()] - element = LABEL2Z[atom.GetAtomicNum()] + element = Z2LABEL[atom.GetAtomicNum()] return "{0:s}{1:s}".format(element, charge_lbl) else: for residue in openbabel.OBResidueIter(self.mol): diff --git a/fragit/gamessfmo.py b/fragit/gamessfmo.py index 6b9eec7..6d070de 100644 --- a/fragit/gamessfmo.py +++ b/fragit/gamessfmo.py @@ -29,6 +29,7 @@ GAMESS_BASIS_GROUP['cc-pVTZ'] = "GBASIS=CCT" GAMESS_BASIS_GROUP['aug-cc-pVDZ'] = "GBASIS=ACCD" GAMESS_BASIS_GROUP['aug-cc-pVTZ'] = "GBASIS=ACCT" +GAMESS_BASIS_GROUP['DFTB-C'] = "GBASIS=DFTB" # basis set data for atoms in $DATA group GAMESS_DATA_BASIS: Dict[str, Dict[str, str]] = dict() diff --git a/share/hmo/DFTB-C b/share/hmo/DFTB-C new file mode 100644 index 0000000..417413d --- /dev/null +++ b/share/hmo/DFTB-C @@ -0,0 +1,5 @@ + DFTB-C 4 4 + 1 0 0.558756 0.000000 0.000000 0.829332 + 0 1 0.558757 0.781901 0.000000 -0.276445 + 0 1 0.558756 -0.390951 0.677146 -0.276445 + 0 1 0.558756 -0.390951 -0.677146 -0.276445