Esempio n. 1
0
def calculate_single(pdb_id, cid, seq_marker):
    seq_marker = int(seq_marker)
    pdb_data = pdb_interface.get_info_for(pdb_id)
    if pdb_data is None:
        raise Exception(f"PDB file download fail for {pdb_id}.")
    ATOM, HETATM, hb = pdb_data
    try:
        dsr_snos = _get_sno_range(ATOM, cid, seq_marker)
        if dsr_snos is None or len(dsr_snos) != 30 or dsr_snos[0] != seq_marker:
            msg = f"ATOM lines not found in range({seq_marker}, "
            f"{seq_marker + 30}) for {pdb_id}:{cid}.<br>"
            raise Exception(msg)
        res, C, CA, N = _from_considered_elements_single(ATOM, dsr_snos, cid)
        pept_bonds = _get_pept_bonds(CA, dsr_snos)
        # For filling descr df
        res_CA = _get_res_CA(res, CA, dsr_snos)
        angles, CA = dihedrals.get_descr_dihedrals(C, CA, N, dsr_snos)

        hbond_descr = hbonds.get_descr_hb(hb, ATOM, HETATM, dsr_snos)

        heavy_atom_contacts, hetatom_contacts, hetatom_covalent = \
            contacts.get_contacts(ATOM, HETATM, cid, dsr_snos)

        descr = _assemble_descr(hetatom_contacts, hetatom_covalent,
                                heavy_atom_contacts, angles, hbond_descr,
                                res_CA, pept_bonds)

        full_descr = _add_columns(descr, pdb_id, seq_marker, cid)
    except Exception as e:
        msg = f"Exception caught in descriptor calculation. Traceback: " \
              f"<{traceback.format_exc()}>. Error: <{e}>"
        raise Exception(msg)
    return full_descr
Esempio n. 2
0
def calculate(motif_pos_map):
    descrs = pd.DataFrame()
    print(f"Total length: {len(motif_pos_map)}.")
    print(len(motif_pos_map))
    for i, (pdb_id, motif_cid_map) in enumerate(motif_pos_map.items()):
        if not (i % 10):
            print(i)
        print(f"{len(motif_pos_map) - i}: {pdb_id}")
        motif_pos_s = motif_cid_map['sno_markers']
        cids = motif_cid_map['cid']

        pdb_data = pdb_interface.get_info_for(pdb_id)
        if pdb_data is None:
            continue
        ATOM, HETATM, hb = pdb_data
        if not isinstance(motif_pos_s, list):
            motif_pos_s = [motif_pos_s]
            cids = [cids]

        for motif_pos, cid in zip(motif_pos_s, cids):
            try:
                dsr_snos = _get_sno_range(ATOM, cid, motif_pos)
                if dsr_snos is None:
                    continue
                res, C, CA, N = _from_considered_elements(ATOM, dsr_snos, cid)
                pept_bonds = _get_pept_bonds(CA, dsr_snos)
                # For filling descr df
                res_CA = _get_res_CA(res, CA, dsr_snos)
                angles, CA = dihedrals.get_descr_dihedrals(C, CA, N, dsr_snos)

                hbond_descr = hbonds.get_descr_hb(hb, ATOM, HETATM, dsr_snos)

                heavy_atom_contacts, hetatom_contacts, hetatom_covalent = \
                    contacts.get_contacts(ATOM, HETATM, cid, dsr_snos)

                descr = _assemble_descr(hetatom_contacts, hetatom_covalent,
                                        heavy_atom_contacts, angles, hbond_descr,
                                        res_CA, pept_bonds)

                full_descr = _add_columns(descr, pdb_id, motif_pos, cid)
                descrs = descrs.append(full_descr, ignore_index=True)
            except Exception as e:
                print(e)
                print(f"Calc_descr failed for {pdb_id}:{cid}")
                pdb_suffix = pdb_id.lower().strip()
                if pdb_suffix+".pkl" in paths.PDB_PARSED_SET:
                    os.remove(os.path.join(paths.PDB_PARSED,
                                           pdb_suffix + ".pkl"))
                # raise
                continue
    return descrs
Esempio n. 3
0
def calculate(motif_pos_map):
    descrs = pd.DataFrame()
    i = 0
    for pdb_id, motif_cid_map in motif_pos_map.items():
        i += 1
        # if pdb_id != "2xsx":
        #     continue
        motif_pos = motif_cid_map['sno_markers']
        cid = motif_cid_map['cid']

        pdb_data = pdb_interface.get_info_for(pdb_id)
        if pdb_data is None:
            continue
        ATOM, HETATM, hb = pdb_data
        try:
            motif_pos = motif_pos[0]
            dsr_snos = _get_sno_range(ATOM, cid, motif_pos)
            if dsr_snos is None:
                continue
            res, C, CA, N = _from_considered_elements(ATOM, dsr_snos, cid)
            pept_bonds = _get_pept_bonds(CA, dsr_snos)
            # For filling descr df
            res_CA = _get_res_CA(res, CA, dsr_snos)
            angles, CA = dihedrals.get_descr_dihedrals(C, CA, N, dsr_snos)

            hbond_descr = hbonds.get_descr_hb(hb, ATOM, HETATM, dsr_snos)

            heavy_atom_contacts, hetatom_contacts, hetatom_covalent = \
                contacts.get_contacts(ATOM, HETATM, cid, dsr_snos)

            descr = _assemble_descr(hetatom_contacts, hetatom_covalent,
                                    heavy_atom_contacts, angles, hbond_descr,
                                    res_CA, pept_bonds)

            full_descr = _add_columns(descr, pdb_id, motif_pos, cid)
            descrs = descrs.append(full_descr, ignore_index=True)
        except:
            print(f"Calc_descr failed for {pdb_id}:{cid}")
            raise
            continue
    return descrs