Exemplo n.º 1
0
def main(modeldir, genfile, type, write=False):
    proj=Project.load_from('%s/ProjectInfo.yaml' % modeldir.split('Data')[0])
    pops=numpy.loadtxt('%s/Populations.dat' % modeldir)
    map=numpy.loadtxt('%s/Mapping.dat' % modeldir)
    frames=numpy.where(map!=-1)[0]
    data=dict()
    data['rmsd']=numpy.loadtxt('%s.rmsd.dat' % genfile.split('.lh5')[0])
    data['rmsd']=data['rmsd'][frames]
    com=numpy.loadtxt('%s.vmd_com.dat' % genfile.split('.lh5')[0], usecols=(1,))
    refcom=com[0]
    data['com']=com[1:]
    data['com']=numpy.array(data['com'][frames])

    residues=['F36', 'H87', 'I56', 'I90', 'W59', 'Y82', 'hydrophob_dist', 'oxos_dist']
    loops=['loop1', 'loop2', 'loop3']
    for loop in loops:
        data[loop]=numpy.loadtxt('%s.%srmsd.dat' % (genfile.split('.lh5')[0], loop))
        data[loop]=data[loop][frames]
    for res in residues:
        file='%s_%spair.dat' % (genfile.split('.lh5')[0], res)
        if os.path.exists(file):
            data[res]=numpy.loadtxt(file)
            data[res]=data[res][frames]
    angles=['phi', 'omega']
    for ang in angles:
        file='%s_%s.dat' % (genfile.split('.lh5')[0], ang)
        if os.path.exists(file):
            data[ang]=numpy.loadtxt(file)
            data[ang]=data[ang][frames]
    ass=io.loadh('%s/Assignments.Fixed.h5' % modeldir)
    T=mmread('%s/tProb.mtx' % modeldir)
    unbound=numpy.loadtxt('%s/tpt-%s/unbound_%s_states.txt' % (modeldir, type, type), dtype=int)
    bound=numpy.loadtxt('%s/tpt-%s/bound_%s_states.txt' % (modeldir, type, type), dtype=int)

    Tdense=T.todense()
    Tdata=dict()
    for i in unbound:
        for j in unbound:
            if Tdense[i,j]!=0:
                if i not in Tdata.keys():
                    Tdata[i]=[]
                Tdata[i].append(j)
    #print Tdata
    cm=pylab.cm.get_cmap('RdYlBu_r') #blue will be negative components, red positive
    Q=tpt.calculate_committors(unbound, bound, T)
    ohandle=open('%s/commitor_states.txt' % modeldir, 'w')
    for i in range(0,len(Q)):
        if Q[i]>0.40 and Q[i]<0.6:
            ohandle.write('%s\n' % i)
            #t=project.get_random_confs_from_states(ass['arr_0'], [int(i),], 20)
            #t[0].save_to_xtc('%s/commottor_state%s.xtc' % (modeldir, i))
    if write==True:
        for op in sorted(data.keys()):
            pylab.figure()
            pylab.scatter(data['com'], data[op],  c=Q, cmap=cm, alpha=0.7, s=[map_size(i) for i in Q])
            pylab.xlabel('L RMSD')
            pylab.ylabel(op)
            pylab.colorbar()
        pylab.show()
Exemplo n.º 2
0
def run(TC, Uv, Fv):

    # Get committors and flux
    logger.info("Getting committors and flux...")

    Fc = calculate_committors(Uv, Fv, TC)
    logger.info("Calculated forward committors.")
    
    NFlux = calculate_net_fluxes(Uv, Fv, TC)
    logger.info("Calculated net flux.")
    
    return Fc, NFlux
Exemplo n.º 3
0
def run(TC, Uv, Fv):

    # Get committors and flux
    logger.info("Getting committors and flux...")

    Fc = calculate_committors(Uv, Fv, TC)
    logger.info("Calculated forward committors.")

    NFlux = calculate_net_fluxes(Uv, Fv, TC)
    logger.info("Calculated net flux.")

    return Fc, NFlux
Exemplo n.º 4
0
    def set_coordinate_as_committors(self, lag_time=1, symmetrize='transpose'):
        """
        Set the reaction coordinate to be the committors (pfolds).

        Employs the reactant, product states provided as the sources, sinks
        respectively for the committor calculation.

        Parameters
        ----------
        lag_time : int
            The MSM lag time to use (in units of frames) in the estimation
            of the MSM transition probability matrix from the `counts` matrix.

        symmetrize : str {'mle', 'transpose', 'none'}
            Which symmetrization method to employ in the estimation of the
            MSM transition probability matrix from the `counts` matrix.
        """

        t_matrix = MSMLib.build_msm(self.counts, symmetrize)
        self.reaction_coordinate_values = tpt.calculate_committors(
            [self.reactant], [self.product], t_matrix)
        return
Exemplo n.º 5
0
    def set_coordinate_as_committors(self, lag_time=1, symmetrize='transpose'):
        """
        Set the reaction coordinate to be the committors (pfolds).

        Employs the reactant, product states provided as the sources, sinks
        respectively for the committor calculation.

        Parameters
        ----------
        lag_time : int
            The MSM lag time to use (in units of frames) in the estimation
            of the MSM transition probability matrix from the `counts` matrix.

        symmetrize : str {'mle', 'transpose', 'none'}
            Which symmetrization method to employ in the estimation of the
            MSM transition probability matrix from the `counts` matrix.
        """

        t_matrix = MSMLib.build_msm(self.counts, symmetrize)
        self.reaction_coordinate_values = tpt.calculate_committors([self.reactant],
                                                                   [self.product],
                                                                   t_matrix)
        return
Exemplo n.º 6
0
 def test_committors(self):
     Q = tpt.calculate_committors(self.sources, self.sinks, self.tprob)
     Q_ref = io.loadh(tpt_get("committors.h5"), 'Data')
     npt.assert_array_almost_equal(Q, Q_ref)
Exemplo n.º 7
0
 def test_committors(self):
     Q = tpt.calculate_committors(self.sources, self.sinks, self.tprob)
     Q_ref = io.loadh(os.path.join(self.tpt_ref_dir, "committors.h5"), 'Data')
     npt.assert_array_almost_equal(Q, Q_ref)