Ejemplo n.º 1
0
Archivo: pka.py Proyecto: prokia/htmd
def _pka_backend_internal(mol, pH):
    tmpmol = mol.copy()
    tmpmol.filter("noh")
    pka_pdb = tempfile.NamedTemporaryFile(mode="w+", suffix=".pdb")
    tmpmol.write(pka_pdb.name)

    pka_options, _ = propka.lib.loadOptions('--pH', pH, '--quiet')
    pka_molecule = propka.molecular_container.Molecular_container(pka_pdb.name, pka_options)
    pka_pdb.close()

    # calculating pKa values for ionizable residues -
    pka_molecule.calculate_pka()

    rd = PreparationData()
    rd._importPKAs(pka_molecule)
    return rd.data
Ejemplo n.º 2
0
def _buildResAndMol(pdb2pqr_protein):
    # Here I parse the returned protein object and recreate a Molecule,
    # because I need to access the properties.
    logger.debug("Building Molecule object.")

    name = []
    resid = []
    chain = []
    insertion = []
    coords = []
    resname = []
    segid = []
    element = []
    occupancy = []
    beta = []
    record = []
    charge = []

    prepData = PreparationData()

    for i, residue in enumerate(pdb2pqr_protein.residues):
        # if 'ffname' in residue.__dict__:
        if getattr(residue, 'ffname', None):
            curr_resname = residue.ffname
            if len(curr_resname) >= 4:
                curr_resname = curr_resname[-3:]
                logger.debug("Residue %s has internal name %s, replacing with %s" %
                             (residue, residue.ffname, curr_resname))
        else:
            curr_resname = residue.name

        prepData._setProtonationState(residue, curr_resname)

        # Removed because not really useful
        # if getattr(residue, 'patches', None):
        #     for patch in residue.patches:
        #         prepData._appendPatches(residue, patch)
        #         if patch != "PEPTIDE":
        #             logger.debug("Residue %s has patch %s set" % (residue, patch))

        if getattr(residue, 'wasFlipped', 'UNDEF') != 'UNDEF':
            prepData._setFlipped(residue, residue.wasFlipped)

        prepData._set(residue, 'pdb2pqr_idx', i)

        for atom in residue.atoms:
            name.append(atom.name)
            resid.append(residue.resSeq)
            chain.append(residue.chainID)
            insertion.append(residue.iCode)
            coords.append([atom.x, atom.y, atom.z])
            resname.append(curr_resname)
            segid.append(atom.segID)
            # Fixup element fields for added H (routines.addHydrogens)
            elt = "H" if atom.added and atom.name.startswith("H") else atom.element
            element.append(elt)
            occupancy.append(0.0 if atom.added else atom.occupancy)
            beta.append(99.0 if atom.added else atom.tempFactor)
            charge.append(atom.charge)
            record.append(atom.type)
            if atom.added:
                logger.debug("Coordinates of atom {:s} in residue {:s} were guessed".format(residue.__str__(),atom.name))
                prepData._set(residue, 'guessedAtoms', atom.name, append=True)


    mol_out = _fillMolecule(name, resname, chain, resid, insertion, coords, segid, element,
                            occupancy, beta, charge, record)
    # mol_out.set("element", " ")
    # Re-calculating elements
    mol_out.element[:] = ''
    mol_out.element = mol_out._guessMissingElements()

    prepData._importPKAs(pdb2pqr_protein.pka_protein)

    return mol_out, prepData
Ejemplo n.º 3
0
def _buildResAndMol(pdb2pqr_protein):
    # Here I parse the returned protein object and recreate a Molecule,
    # because I need to access the properties.
    logger.debug("Building Molecule object.")

    name = []
    resid = []
    chain = []
    insertion = []
    coords = []
    resname = []
    segid = []
    element = []
    occupancy = []
    beta = []
    record = []
    charge = []

    prepData = PreparationData()

    for i, residue in enumerate(pdb2pqr_protein.residues):
        # if 'ffname' in residue.__dict__:
        if getattr(residue, 'ffname', None):
            curr_resname = residue.ffname
            if len(curr_resname) >= 4:
                curr_resname = curr_resname[-3:]
                logger.debug(
                    "Residue %s has internal name %s, replacing with %s" %
                    (residue, residue.ffname, curr_resname))
        else:
            curr_resname = residue.name

        prepData._setProtonationState(residue, curr_resname)

        # Removed because not really useful
        # if getattr(residue, 'patches', None):
        #     for patch in residue.patches:
        #         prepData._appendPatches(residue, patch)
        #         if patch != "PEPTIDE":
        #             logger.debug("Residue %s has patch %s set" % (residue, patch))

        if getattr(residue, 'wasFlipped', 'UNDEF') != 'UNDEF':
            prepData._setFlipped(residue, residue.wasFlipped)

        prepData._set(residue, 'pdb2pqr_idx', i)

        for atom in residue.atoms:
            name.append(atom.name)
            resid.append(residue.resSeq)
            chain.append(residue.chainID)
            insertion.append(residue.iCode)
            coords.append([atom.x, atom.y, atom.z])
            resname.append(curr_resname)
            segid.append(atom.segID)
            # Fixup element fields for added H (routines.addHydrogens)
            elt = "H" if atom.added and atom.name.startswith(
                "H") else atom.element
            element.append(elt)
            occupancy.append(0.0 if atom.added else atom.occupancy)
            beta.append(99.0 if atom.added else atom.tempFactor)
            charge.append(atom.charge)
            record.append(atom.type)
            if atom.added:
                logger.debug(
                    "Coordinates of atom {:s} in residue {:s} were guessed".
                    format(residue.__str__(), atom.name))
                prepData._set(residue, 'guessedAtoms', atom.name, append=True)

    mol_out = _fillMolecule(name, resname, chain, resid, insertion, coords,
                            segid, element, occupancy, beta, charge, record)
    # mol_out.set("element", " ")
    # Re-calculating elements
    mol_out.element[:] = ''
    mol_out.element = mol_out._guessMissingElements()

    prepData._importPKAs(pdb2pqr_protein.pka_protein)

    return mol_out, prepData