Exemplo n.º 1
0
def main():
    args = parse_args()
    output_holo_file = os.path.join(args.holo_str[:-4]+"_renamed.pdb")

    holo = Structure.fromfile(args.holo_str)
    apo = Structure.fromfile(args.apo_str)
    apo = apo.extract('record', 'ATOM')
    output_holo = holo.extract("resi", 0, '==')
    for chain_h in np.unique(holo.chain):
        holo_copy = holo.copy()
        tmp_h = holo.extract("chain", chain_h, '==')
        tmp_h_atom = tmp_h.extract('record', 'ATOM')
        dist = None
        for chain_a in np.unique(apo.chain):
            tmp_a = apo.extract("chain", chain_a, '==')
            tot_dist = 0
            for coor in tmp_h_atom.coor:
                tot_dist += np.linalg.norm(tmp_a.coor - coor, axis=1)
                tmp_dist = np.median(tot_dist)
            if dist is None:
                dist = tmp_dist
                rename_chain = chain_a
            else:
                if dist > tmp_dist:
                    print('switching')
                    dist = tmp_dist
                    rename_chain = chain_a
        output = holo_copy.extract("chain", chain_h, '==')
        output.chain = rename_chain
        output_holo = output_holo.combine(output)
        del tmp_h
    output_holo.tofile(output_holo_file)
Exemplo n.º 2
0
def main():
    args = parse_args()

    options = Water_Options()
    options.apply_command_args(args)
    structure_pro = Structure.fromfile(args.no_water_structure).reorder()
    structure_pro = structure_pro.extract('e', 'H', '!=')
    structure_wa = Structure.fromfile(args.water_structure).reorder()

    sub_structure = Water_Overlap(structure_pro, structure_wa, args.map,
                                  options)
    sub_structure.run()
Exemplo n.º 3
0
def main():
    args = parse_args()
    holo_structure = Structure.fromfile(args.holo_structure)
    apo_structure = Structure.fromfile(args.apo_structure)

    holo_receptor = holo_structure.extract('record', 'ATOM')
    holo_receptor = holo_receptor.extract('e', 'H', '!=')

    apo_receptor = apo_structure.extract('record', 'ATOM')
    apo_receptor = apo_receptor.extract('e', 'H', '!=')

    rmsd_alpha_carbon(holo_receptor, apo_receptor, args.holo_pdb_name,
                      args.apo_pdb_name)
Exemplo n.º 4
0
def main():
    args = parse_args()
    # Load structure and prepare it
    structure = Structure.fromfile(
        args.structure).reorder()  #put H20 on the bottom
    if not args.pdb is None:
        pdb_name = args.pdb
    else:
        pdb_name = ''
    residue_closest(structure, args.dist, pdb_name)
Exemplo n.º 5
0
def main():
    args = parse_args()
    try:
        os.makedirs(args.directory)
    except OSError:
        pass

    structure = Structure.fromfile(args.structure).reorder()
    structure2 = Structure.fromfile(args.structure2).reorder()
    with open(args.res_list) as f:
        for line in f.readlines():
            print(line)
            res,aa = line.strip().split()
            structure_resi = structure.extract(f'resi {res} and chain {args.chain}')
            structure_resi2 = structure2.extract(f'resi {res} and chain {args.chain}')

            altlocs = len(list(set(structure_resi.altloc)))
            altlocs2 = len(list(set(structure_resi2.altloc)))
            print(args.structure[-8:-4],args.structure2[-8:-4],altlocs,altlocs2,structure_resi.resn[0],structure_resi2.resn[0],structure_resi.chain[0],structure_resi.resi[0],structure_resi2.chain[0],structure_resi2.resi[0])
Exemplo n.º 6
0
def main():
    print(sys.path)
    p = build_argparser()
    args = p.parse_args()

    structure = Structure.fromfile(args.structure).reorder()
    print(structure)
    B_options = Bfactor_options()
    B_options.apply_command_args(args)

    b_factor = Bfactor(structure, B_options)
    b_factor.run()
Exemplo n.º 7
0
    def average_coor_heavy_atom(self):
        structure = Structure.fromfile(self.structure)
        select = structure.extract('record', 'ATOM', '==')

        rmsf_data = []

        for chain in np.unique(select.chain):
            select2 = select.extract('chain', chain, '==')
            residues = set(list(select2.resi))
            residue_ids = []
            for i in residues:
                tmp_i = str(i)
                if ':' in tmp_i:
                    resi = int(tmp_i.split(':')[1][1:])
                else:
                    resi = tmp_i
                residue_ids.append(resi)

            for resid in residue_ids:
                res_tmp = select2.extract('resi', int(resid),
                                          '==')  # this separates each residue
                resn_name = (np.unique(res_tmp.resi)[0],
                             np.unique(res_tmp.resn)[0],
                             np.unique(res_tmp.chain)[0])
                if len(np.unique(res_tmp.altloc)) > 1:
                    RMSF_list = []
                    num_alt = len(np.unique(res_tmp.altloc))
                    #iterating over each atom and getting center for each atom

                    for atom in np.unique(res_tmp.name):
                        RMSF_atom_list = []
                        tmp_atom = res_tmp.extract('name', atom, '==')
                        atom_center = tmp_atom.coor.mean(axis=0)

                        for i in np.unique(tmp_atom.altloc):
                            atom_alt = tmp_atom.extract('altloc', i, '==')
                            RMSF_atom = np.linalg.norm(atom_alt.coor -
                                                       atom_center,
                                                       axis=1)
                            RMSF_atom_list.append(RMSF_atom)
                        RMSF_list.append(
                            (sum(RMSF_atom_list) / len(RMSF_atom_list))[0])
                        rmsf_data.append(
                            tuple((resn_name[0], resn_name[1], resn_name[2],
                                   (sum(RMSF_list) / len(RMSF_list)))))
                else:
                    rmsf_data.append(
                        tuple((resn_name[0], resn_name[1], resn_name[2], 0)))

        rmsf = pd.DataFrame(rmsf_data,
                            columns=['resseq', 'AA', 'Chain', 'RMSF'])
        rmsf['PDB_name'] = self.options.pdb
        rmsf.to_csv(self.pdb + 'qfit_RMSF.csv')
Exemplo n.º 8
0
def main():
    args = parse_args()
    output_file = os.path.join(args.stru[:-4] + "_chain_renamed.pdb")

    stru = Structure.fromfile(args.stru).reorder()
    output = stru.extract("resi", 0, '==')  #to populate
    stru_atom = stru.extract('record', 'ATOM')
    stru_hetatm = stru.extract('record', 'HETATM')
    for chain in np.unique(stru_atom.chain):
        tmp = stru_atom.extract("chain", chain, '==')
        tmp_het = stru_hetatm.extract("chain", chain, '==')
        output = output.combine(tmp)
        output = output.combine(tmp_het)
    output.tofile(output_file)
Exemplo n.º 9
0
def main():
    args = parse_args()
    # Load structure and prepare it
    structure = Structure.fromfile(args.structure).reorder()
    structure = structure.extract('e', 'H', '!=')
    get_occ(structure, args.ligand, args.pdb)
Exemplo n.º 10
0
def main():
    args = parse_args()

    if not args.pdb_name == None:
        pdb_name = args.pdb_name
    else:
        pdb_name = ''
    try:
        structure = Structure.fromfile(args.structure)
    except:
        return

    ligands = structure.extract('record', 'HETATM')
    receptor = structure.extract('record', 'ATOM')
    receptor = receptor.extract('resn', 'HOH', '!=')
    h**o = hetero = 0
    close_res = pd.DataFrame()
    alt_loc = pd.DataFrame()
    for chain in receptor:
        for residue in chain:
            if residue.resn[0] not in ROTAMERS:
                continue
            altlocs = list(set(residue.altloc))
            if (len(altlocs) > 2) or (len(altlocs) == 2 and '' not in altlocs):
                hetero += 1
            else:
                h**o += 1
    total = h**o + hetero
    for ligand_name in list(set(ligands.resn)):
        near_homo = near_hetero = 0
        if ligand_name not in Dict:
            ligand = structure.extract('resn', ligand_name)
            mask = ligand.e != 'H'
            if len(ligand.name[mask]) < 10:
                continue
            neighbors = {}
            for coor in ligand.coor:
                dist = np.linalg.norm(receptor.coor - coor, axis=1)
                for near_residue, near_chain in zip(
                        receptor.resi[dist < 5.0], receptor.chain[dist < 5.0]):
                    key = str(near_residue) + " " + near_chain
                    if key not in neighbors:
                        neighbors[key] = 0
            n = 1
            for key in neighbors.keys():
                residue_id, chain = key.split()
                close_res.loc[n, 'res_id'] = residue_id
                close_res.loc[n, 'chain'] = chain
                n += 1
            close_res.to_csv(dir + pdb_name + '_' + ligand_name +
                             '_closeres.csv',
                             index=False)

            for key in neighbors.keys():
                residue_id, chain = key.split()
                residue = structure.extract(
                    f"chain {chain} and resi {residue_id}")
                if residue.resn[0] not in ROTAMERS:
                    continue
                altlocs = list(set(residue.altloc))
                if (len(altlocs) > 2) or (len(altlocs) == 2
                                          and '' not in altlocs):
                    near_hetero += 1
                else:
                    near_homo += 1
            near_total = near_homo + near_hetero

            near_total = near_homo + near_hetero
            alt_loc.loc[m, 'PDB'] = pdb_name
            alt_loc.loc[m, 'ligand'] = ligand_name
            alt_loc.loc[m, 'Num_Single_Conf'] = h**o
            alt_loc.loc[m, 'Num_Multi_Conf'] = hetero
            alt_loc.loc[m, 'Total_Residues'] = total
            alt_loc.loc[m, 'Num_Single_Conf_Near_Ligand'] = near_homo
            alt_loc.loc[m, 'Num_Multi_Conf_Near_Ligand'] = near_hetero
            alt_loc.loc[m, 'Total_Residues_Near_Ligand'] = near_total
            m += 1

    alt_loc.to_csv(dir + pdb_name + '_Alt_Loc.csv', index=False)
    print(pdb_name, ligand_name, h**o, hetero, total, near_homo, near_hetero,
          near_total)