コード例 #1
0
ファイル: rotamer.py プロジェクト: npolizzi/combs_pub
def get_chi(residue_sele, atoms_list):
    '''Take parsedvdm and a list of 4 atoms and calculate dihedral in prody
    Helper function for rotamer()'''

    prody_list = [residue_sele.select('name %s' % name) for name in atoms_list]
    return pr.calcDihedral(prody_list[0], prody_list[1], prody_list[2],
                           prody_list[3])
コード例 #2
0
 def get_sec_struct_phipsi(self, parsed_pdb):
     phipsi = []
     for resn in self.sele.getResnums()[self._ind]:
         try:
             phi = pr.calcDihedral(parsed_pdb.prody_pdb.select(
                 'name C and bonded 1 to (resnum ' + str(resn)
                 + ' segment A chain ' + self.chid + ' name N)'),
                 parsed_pdb.prody_pdb.select(
                     'resnum ' + str(resn)
                     + ' segment A chain ' + self.chid + ' name N'),
                 parsed_pdb.prody_pdb.select(
                     'resnum ' + str(resn)
                     + ' segment A chain ' + self.chid + ' name CA'),
                 parsed_pdb.prody_pdb.select(
                     'resnum ' + str(resn)
                     + ' segment A chain ' + self.chid + ' name C'))[0]
         except:
             phi = None
         try:
             psi = pr.calcDihedral(
                 parsed_pdb.prody_pdb.select(
                     'resnum ' + str(resn)
                     + ' segment A chain ' + self.chid + ' name N'),
                 parsed_pdb.prody_pdb.select(
                     'resnum ' + str(resn)
                     + ' segment A chain ' + self.chid + ' name CA'),
                 parsed_pdb.prody_pdb.select(
                     'resnum ' + str(resn)
                     + ' segment A chain ' + self.chid + ' name C'),
                 parsed_pdb.prody_pdb.select(
                     'name N and bonded 1 to (resnum ' + str(resn)
                     + ' segment A chain ' + self.chid + ' name C)'))[0]
         except:
             psi = None
         if phi is not None and psi is not None:
             phipsi.append('(' + '{0:.2f}'.format(phi) + ' ' + '{0:.2f}'.format(psi) + ')')
         elif phi is None and psi is not None:
             phipsi.append('(' + 'None' + ' ' + '{0:.2f}'.format(psi) + ')')
         elif phi is not None and psi is None:
             phipsi.append('(' + '{0:.2f}'.format(phi) + ' ' + 'None' + ')')
         else:
             phipsi.append('(None None)')
     self.sec_struct_phi_psi = ' '.join(phipsi)
コード例 #3
0
ファイル: Detector.py プロジェクト: klklklzzd/frag_pele
    def read_dihedral(self):

        dihedral_list = self.select_atoms()
        dihedral_results = []
        for dihedral in dihedral_list:
            atoms = []
            for atom in dihedral:
                atoms.append(atom)
            dihedral_angle = prody.calcDihedral(atoms[0], atoms[1], atoms[2],
                                                atoms[3])
            dihedral_results.append(dihedral_angle)
        return dihedral_results
コード例 #4
0
def get_dih3(vdm, ifg, comb):
    return pr.calcDihedral(
        vdm.ires_sele.select('name ' + dih3[vdm.resname][0]),
        ifg.sele.select('name ' + comb.vandarotamer_dict['A1']),
        ifg.sele.select('name ' + comb.vandarotamer_dict['A2']),
        ifg.sele.select('name ' + comb.vandarotamer_dict['A3']))[0]
コード例 #5
0
ファイル: per_atom.py プロジェクト: aozalevsky/peptogrid2
    def process(self, args=None):
        if not args:
            args = self.args
        # Sfn = args['Sfn']

        # Open matrix file in parallel mode
        # Sf = h5py.File(Sfn, 'r')
        args['mpi'] = self.mpi
        extractor = er.PepExtractor(**args)
        lM = len(self.aplist)

        dtype = np.dtype([
            ('name', 'S10'),
            ('pnum', '<i4'),
            ('rnum', '<i4'),
            ('dist', '<f8'),
            ('hdist1', '<f8'),
            ('hdist2', '<f8'),
            ('BD', '<f8'),
            ('FL', '<f8'),
            ('AT', '<f8'),
            ('dir', 'S3'),
            ('aln', 'S20')
        ])

        if self.mpi.rank == 0:
            m = self.aplist[0]
            lm = len(m)
            S = extractor.extract_result(m)
            lS = S.numCoordsets()
            Sf = h5py.File(args['out'], 'w')
            out = Sf.create_dataset(
                'out', (len(self.plist) * lS * lm, ), dtype=dtype)
            Sf.close()

        self.mpi.comm.Barrier()

        Sf = h5py.File(args['out'], 'r+', driver='mpio', comm=self.mpi.comm)
        out = Sf['out']

        # Init storage for matrices
        # Get file name

        # tSfn = 'tmp.' + Sfn
        # tSfn = args['output']

        # stubs = {
        #     'ACE': 'X',
        #     'NME': 'Z',
        # }

        a = prody.parsePDB(args['receptor'])

        OG = a.select('resnum 151 name SG')
        Ob = a.select('resnum 168 and name O')
        ND1 = a.select('resnum 46 and name NE2')

        OXH = a.select("name N resnum 149 150 151")

        t0 = time.time()

        for cm in range(lM):
            m = self.aplist[cm]
            lm = len(m)

            t1 = time.time()
            dt = t1 - t0
            t0 = t1
            print('STEP: %d PERCENT: %.2f%% TIME: %s' % (
                cm, float(cm) / lM * 100, dt))

            try:
                S = extractor.extract_result(m)
            except:
                print('ERROR: BAD PEPTIDE: %s' % m)
                continue

            lS = S.numCoordsets()

            for S_ in range(lS):

                S.setACSIndex(S_)

                tC = S.select('name C')

                dist = np.inf
                rnum = None

                for C in tC.iterAtoms():

                    rnum = C.getResnum()

                    if rnum == 1:
                        continue

                    O = S.select('resnum %i and name O' % rnum)
                    Nl = S.select('resnum %i and name N' % (rnum))
                    N = S.select('resnum %i and name N' % (rnum + 1))

                    C_ = C.getCoords()
                    O_ = O.getCoords()[0]
                    N_ = N.getCoords()[0]

                    dist = prody.calcDistance(C, OG)[0]
                    hdist1 = np.min(prody.calcDistance(OXH, O))
                    hdist2 = np.min(prody.calcDistance(Ob, Nl))

                    nC_ = np.cross((C_ - N_), (O_ - C_))
                    nC_ /= np.linalg.norm(nC_)
                    nC_ = nC_ + C_
                    nC_ = nC_.reshape(1, 3)

                    nC = C.copy()
                    nC.setCoords(nC_)

                    BD = prody.calcAngle(OG, C, O)
                    FL = prody.calcDihedral(OG, nC, C, O)
                    AT = prody.calcAngle(ND1, OG, C)

                    angle_ = prody.calcDihedral(ND1, OG, C, N)

                    # angle_ = prody.calcDistance(Od, N)[0] \
                    #     - prody.calcDistance(Od, C)[0]

                    if angle_ < 0:
                        DIR = 'F'
                    else:
                        DIR = 'R'

                    s = 'X' + m + 'Z'
                    pref = ''

                    if DIR == 'F':
                        seq = s
                        pref = 6 - rnum
                    else:
                        seq = s[::-1]
                        pref = rnum

                    suf = 12 - (pref + len(seq))
                    seq = '-' * pref + seq + '-' * suf

                    # outfmt = "%-10s\t%d\t%6.2f\t%6.2f%6.2f\t%6.2f\t" \
                    #         "%6.2f\t%6.2f\t%3s\t%12s\n"

                    # outstr = outfmt % (
                    #    ('%s_%02d' % (m, S_ + 1),
                    #     rnum, dist, hdist1, hdist2, BD, FL, AT,
                    #     DIR, seq)
                    # )

                    outdata = (m, S_ + 1,
                               rnum, dist, hdist1, hdist2, BD, FL, AT,
                               DIR, seq)

                    ind = (self.tb + cm) * lS * lm + S_ * lm + rnum - 2
                    out[ind] = outdata

        self.database.close()
        Sf.close()