예제 #1
0
    def setUp(self):
        testpath = abspath(join(abspath(__file__), pardir)) + '/../../util/tests/data/'
        import pyemma.util.discrete_trajectories as dt

        self.dtraj = dt.read_discrete_trajectory(testpath + '2well_traj_100K.dat')
        self.tau = 10
        self.msm = markov_state_model(self.dtraj, self.tau)
예제 #2
0
파일: files.py 프로젝트: ismaelresp/PyEMMA
def read_dtrajs_from_pattern(patterns, logger=getLogger()):
    """
    Parameters
    ----------
    patterns : single pattern or list of patterns
        eg. '*.txt' or ['/foo/*/bar/*.txt', '*.txt']

    Returns
    -------
    list of discrete trajectories : list of numpy arrays, dtype=int

    """
    dtrajs = []
    filenames = paths_from_patterns(patterns)
    if filenames == []:
        raise ValueError('no match to given pattern')
    for dt in filenames:
        # skip directories
        if os.path.isdir(dt):
            continue
        logger.info('reading discrete trajectory: %s' % dt)
        try:
            dtrajs.append(read_discrete_trajectory(dt))
        except Exception as e:
            logger.error('Exception occurred during reading of %s:\n%s' %
                         (dt, e))
            raise
    return dtrajs
예제 #3
0
파일: files.py 프로젝트: ismaelresp/PyEMMA
def read_dtrajs_from_pattern(patterns, logger=getLogger()):
    """
    Parameters
    ----------
    patterns : single pattern or list of patterns
        eg. '*.txt' or ['/foo/*/bar/*.txt', '*.txt']

    Returns
    -------
    list of discrete trajectories : list of numpy arrays, dtype=int

    """
    dtrajs = []
    filenames = paths_from_patterns(patterns)
    if filenames == []:
        raise ValueError('no match to given pattern')
    for dt in filenames:
        # skip directories
        if os.path.isdir(dt):
            continue
        logger.info('reading discrete trajectory: %s' % dt)
        try:
            dtrajs.append(read_discrete_trajectory(dt))
        except Exception as e:
            logger.error(
                'Exception occurred during reading of %s:\n%s' % (dt, e))
            raise
    return dtrajs
예제 #4
0
    def setUp(self):
        testpath = abspath(join(abspath(__file__),
                                pardir)) + '/../../util/tests/data/'
        import pyemma.util.discrete_trajectories as dt

        self.dtraj = dt.read_discrete_trajectory(testpath +
                                                 '2well_traj_100K.dat')
        self.tau = 10
        self.msm = markov_state_model(self.dtraj, self.tau)
예제 #5
0
파일: api.py 프로젝트: ismaelresp/PyEMMA
def read_discrete_trajectory(filename):
    r"""Read discrete trajectory from ascii file.   
    
    Parameters
    ---------- 
    filename : str
        The filename of the discretized trajectory file. 
        The filename can either contain the full or the 
        relative path to the file.
    
    Returns
    -------
    dtraj : (M, ) ndarray of int
        Discrete state trajectory.

    See also
    --------
    write_discrete_trajectory

    Notes
    -----
    The discrete trajectory file contains a single column with
    integer entries.

    Examples
    --------

    >>> from tempfile import NamedTemporaryFile    
    >>> from pyemma.msm.io import write_discrete_trajectory, load_discrete_trajectory

    Use temporary file
    
    >>> tmpfile = NamedTemporaryFile()

    Discrete trajectory
    
    >>> dtraj = np.array([0, 1, 0, 0, 1, 1, 0])

    Write to disk (as ascii file)
    
    >>> write_discrete_trajectory(tmpfile.name, dtraj)

    Read from disk

    >>> X = read_discrete_trajectory(tmpfile.name)
    >>> X
    array([0, 1, 0, 0, 1, 1, 0])
    
    """
    return trajectory.read_discrete_trajectory(filename)
예제 #6
0
파일: api.py 프로젝트: ismaelresp/PyEMMA
def read_discrete_trajectory(filename):
    r"""Read discrete trajectory from ascii file.   
    
    Parameters
    ---------- 
    filename : str
        The filename of the discretized trajectory file. 
        The filename can either contain the full or the 
        relative path to the file.
    
    Returns
    -------
    dtraj : (M, ) ndarray of int
        Discrete state trajectory.

    See also
    --------
    write_discrete_trajectory

    Notes
    -----
    The discrete trajectory file contains a single column with
    integer entries.

    Examples
    --------

    >>> from tempfile import NamedTemporaryFile    
    >>> from pyemma.msm.io import write_discrete_trajectory, load_discrete_trajectory

    Use temporary file
    
    >>> tmpfile = NamedTemporaryFile()

    Discrete trajectory
    
    >>> dtraj = np.array([0, 1, 0, 0, 1, 1, 0])

    Write to disk (as ascii file)
    
    >>> write_discrete_trajectory(tmpfile.name, dtraj)

    Read from disk

    >>> X = read_discrete_trajectory(tmpfile.name)
    >>> X
    array([0, 1, 0, 0, 1, 1, 0])
    
    """
    return trajectory.read_discrete_trajectory(filename)
예제 #7
0
 def test_read_discrete_trajectory(self):
     dtraj_np = np.loadtxt(self.filename, dtype=int)
     dtraj = dt.read_discrete_trajectory(self.filename)
     self.assertTrue(np.all(dtraj_np == dtraj))
 def test_read_discrete_trajectory(self):
     dtraj_np=np.loadtxt(self.filename, dtype=int)
     dtraj=dt.read_discrete_trajectory(self.filename)
     self.assertTrue(np.all(dtraj_np==dtraj))
 def test_big(self):
     dtraj = dt.read_discrete_trajectory(testpath+'2well_traj_100K.dat')
     # just run these to see if there's any exception
     dt.index_states(dtraj)