Exemple #1
0
def _parse_pdb(pdb: Path):
    struct = read_pdb(str(pdb))
    r_work = None
    r_free = None
    bonds = None
    angles = None

    #
    # look for 'REMARK Final:' remark line
    # which specifies r-work, r-free, bonds and angles values
    #
    for rem in struct.raw_remarks:
        match = REM_FINAL_RE.match(rem)
        if match is None:
            continue

        # remark line found, get our values and end the loop
        r_work, r_free, bonds, angles = match.groups()
        break

    # remove all spaces from the space group specification,
    # e.g. 'P 1 21 1' becomes 'P1211'
    spacegroup = "".join(struct.spacegroup_hm.split(" "))

    return (
        spacegroup,
        struct.resolution,
        r_work,
        r_free,
        bonds,
        angles,
        struct.cell,
    )
Exemple #2
0
def _parse_pdb(pdb: Path):
    struct = read_pdb(str(pdb))
    r_work = None
    r_free = None
    bonds = None
    angles = None

    for rem in struct.raw_remarks:
        if rem.startswith(R_WORK_LINE):
            r_work = _cut_prefix_strip(R_WORK_LINE, rem)
        if rem.startswith(R_FREE_LINE):
            r_free = _cut_prefix_strip(R_FREE_LINE, rem)
        if rem.startswith(BONDS_LINE):
            bonds = _cut_prefix_strip(BONDS_LINE, rem)
            bonds = bonds.split(";")[1].strip()
        if rem.startswith(ANGLES_LINE):
            angles = _cut_prefix_strip(ANGLES_LINE, rem)
            angles = angles.split(";")[1].strip()

    # remove all spaces from the space group specification,
    # e.g. 'P 1 21 1' becomes 'P1211'
    spacegroup = "".join(struct.spacegroup_hm.split(" "))

    return (
        spacegroup,
        struct.resolution,
        r_work,
        r_free,
        bonds,
        angles,
        struct.cell,
    )
Exemple #3
0
def find_water_chains(file):
    '''
    Find which chain(s) contain only water molecules
    :param file: A pdb file name.
    :return: A list of chains that contain water
    '''
    structure = gemmi.read_pdb(file)
    old = [x.name for x in structure[0]]
    structure.remove_waters()
    structure.remove_empty_chains()
    new = [x.name for x in structure[0]]
    return list(set(old) - set(new))
Exemple #4
0
def get_chain_center(chain_name, file):
    '''
    Calculate the center of mass for a particular chain within a particular pdb file
    :param chain_name: Name of the chain
    :param file: Filepath of pdb file.
    :return: The center of mass of the specified chain.
    '''
    structure = gemmi.read_pdb(file)[0]
    names = [x.name for x in structure]
    for i in names:
        if i == chain_name:
            continue
        else:
            structure.remove_chain(i)

    return structure.calculate_center_of_mass()
 def __init__(self, pdb):
     self.pdb = gemmi.read_pdb(pdb)