diff --git a/pdbfixer/pdbfixer.py b/pdbfixer/pdbfixer.py index 4231a5b..4bcf34c 100644 --- a/pdbfixer/pdbfixer.py +++ b/pdbfixer/pdbfixer.py @@ -138,7 +138,6 @@ class CCDResidueDefinition: Description of a residue from the Chemical Component Dictionary (CCD). """ residueName: str - smiles: Optional[str] atoms: list[CCDAtomDefinition] bonds: list[CCDBondDefinition] @@ -155,12 +154,6 @@ def fromReader(cls, reader: PdbxReader) -> 'CCDResidueDefinition': descriptorsData = block.getObj("pdbx_chem_comp_descriptor") typeCol = descriptorsData.getAttributeIndex("type") - smilesCol = descriptorsData.getAttributeIndex("descriptor") - smiles = None - for row in descriptorsData.getRowList(): - if row[typeCol] in ["SMILES", "SMILES_CANONICAL"]: - smiles = row[smilesCol] - break atomData = block.getObj('chem_comp_atom') atomNameCol = atomData.getAttributeIndex('atom_id') @@ -200,7 +193,7 @@ def fromReader(cls, reader: PdbxReader) -> 'CCDResidueDefinition': else: bonds = [] - return cls(residueName=residueName, smiles=smiles, atoms=atoms, bonds=bonds) + return cls(residueName=residueName, atoms=atoms, bonds=bonds) def _guessFileFormat(file, filename): """Guess whether a file is PDB or PDBx/mmCIF based on its filename and contents.""" @@ -452,7 +445,7 @@ def _initializeFromPDBx(self, file): self.modifiedResidues.append(ModifiedResidue(row[asymIdCol], int(row[resNumCol]), row[resNameCol], row[standardResCol])) - def _downloadCCDDefinition(self, residueName: str, checkCache: bool = True) -> Optional[CCDResidueDefinition]: + def _downloadCCDDefinition(self, residueName: str) -> Optional[CCDResidueDefinition]: """ Download a residue definition from the Chemical Component Dictionary. @@ -463,9 +456,6 @@ def _downloadCCDDefinition(self, residueName: str, checkCache: bool = True) -> O residueName : str The name of the residue, as specified in the PDB Chemical Component Dictionary. - checkCache : bool - If ``False``, attempt to re-download the CCD entry regardless of - what is in the cache. Defaults to ``True``. Returns ------- @@ -1572,7 +1562,7 @@ def _createForceField(self, newTopology, water): forcefield._templates[resName] = template indexInResidue = {} # If we can't find formal charges in the CCD, make everything uncharged - formalCharges = defaultdict(lambda: 0) + formalCharges = defaultdict(int) # See if we can get formal charges from the CCD if water: # The formal charges in the CCD can only be relied on if the diff --git a/pdbfixer/tests/test_charge_and_solvate.py b/pdbfixer/tests/test_charge_and_solvate.py index d3fa953..56b698c 100644 --- a/pdbfixer/tests/test_charge_and_solvate.py +++ b/pdbfixer/tests/test_charge_and_solvate.py @@ -29,16 +29,12 @@ def test_charge_and_solvate(pdbCode, soluteCharge): fixer = PDBFixer(pdbid=pdbCode) fixer.findMissingResidues() - chains_to_cap = {chain for chain, resi in fixer.missingResidues} - for chainidx in chains_to_cap: - chain = [*fixer.topology.chains()][chainidx] - last_resi = len([*chain.residues()]) - # Capping with GLY because ACE/NME currently breaks addMissingHydrogens - # Adding a cap keeps the protein compact and the addSolvent call quick - fixer.missingResidues[chainidx, 0] = ["GLY"] - fixer.missingResidues[chainidx, last_resi] = ["GLY"] - # fixer.missingResidues[chainidx, 0] = ['ACE'] - # fixer.missingResidues[chainidx, last_resi] = ['NME'] + chainLengths = [len([*chain.residues()]) for chain in fixer.topology.chains()] + for chainidx, residx in list(fixer.missingResidues): + if residx == 0: + fixer.missingResidues[chainidx, residx] = ["ACE"] + elif residx == chainLengths[chainidx]: + fixer.missingResidues[chainidx, residx] = ["NME"] fixer.findNonstandardResidues() fixer.replaceNonstandardResidues()