Esempio n. 1
0
def _autoDetectTopology(folder):
    topo = {}
    for tt in __topotypes:
        files = glob(path.join(folder, '*.{}'.format(tt)))
        if len(files) > 0:
            if len(files) > 1:
                logger.warning('Multiple "{}" files were found in folder {}. '
                               'Picking {} as the topology'.format(tt, folder, files[0]))
            topo[tt] = files[0]
    if len(topo) == 0:
        raise RuntimeError('No topology file found in folder {}. '
                           'Supported extensions are {}'.format(folder, list(_TOPOLOGY_READERS.keys())))
    return list(topo.values())
Esempio n. 2
0
def _autoDetectTrajectories(folder):
    from moleculekit.readers import _TRAJECTORY_READERS
    import natsort

    for tt in _TRAJECTORY_READERS:
        if tt in (
                "xsc",
        ):  # Some trajectory readers don't really load trajectories like xsc
            continue
        trajectories = glob(path.join(folder, "*.{}".format(tt)))
        if len(trajectories) > 0:
            return natsort.natsorted(trajectories)


__readers = list(_TOPOLOGY_READERS.keys())
__defaultReaders = ["pdb", "prmtop", "psf"]
__otherReaders = list(np.setdiff1d(__readers, __defaultReaders))
__topotypes = (__defaultReaders + __otherReaders
               )  # Prepending PDB, PSF, PRMTOP so that they are the default


def _autoDetectTopology(folder):
    topo = {}
    for tt in __topotypes:
        files = glob(path.join(folder, "*.{}".format(tt)))
        if len(files) > 0:
            if len(files) > 1:
                logger.warning('Multiple "{}" files were found in folder {}. '
                               "Picking {} as the topology".format(
                                   tt, folder, files[0]))