def _process_plot_kwargs(self, kwargs): import matplotlib.colors from itertools import cycle kw = {} frames = kwargs.pop('frames', None) if frames is None: frames = numpy.sort(self.profiles.keys()[::kwargs.pop('step', 1)]) else: frames = asiterable(frames) kw['frames'] = frames kw['yshift'] = kwargs.pop('yshift', 0.0) kw['rmax'] = kwargs.pop('rmax', None) kw['label'] = kwargs.pop('label', True) if kw['label'] == "_nolegend_": kw['label'] = False elif kw['label'] is None: kw['label'] = True color = kwargs.pop('color', None) if color is None: cmap = kwargs.pop('cmap', matplotlib.cm.jet) normalize = matplotlib.colors.normalize(vmin=numpy.min(frames), vmax=numpy.max(frames)) colors = cmap(normalize(frames)) else: colors = cycle(asiterable(color)) kw['colors'] = colors kw['linestyles'] = cycle(asiterable(kwargs.pop('linestyle', '-'))) return kw, kwargs
def _process_plot_kwargs(self, kwargs): import matplotlib.colors from itertools import cycle kw = {} frames = kwargs.pop("frames", None) if frames is None: frames = np.sort(self.profiles.keys()[:: kwargs.pop("step", 1)]) else: frames = asiterable(frames) kw["frames"] = frames kw["yshift"] = kwargs.pop("yshift", 0.0) kw["rmax"] = kwargs.pop("rmax", None) kw["label"] = kwargs.pop("label", True) if kw["label"] == "_nolegend_": kw["label"] = False elif kw["label"] is None: kw["label"] = True color = kwargs.pop("color", None) if color is None: cmap = kwargs.pop("cmap", matplotlib.cm.jet) normalize = matplotlib.colors.normalize(vmin=np.min(frames), vmax=np.max(frames)) colors = cmap(normalize(frames)) else: colors = cycle(asiterable(color)) kw["colors"] = colors kw["linestyles"] = cycle(asiterable(kwargs.pop("linestyle", "-"))) return kw, kwargs
def process_selection(select): """Return a canonical selection dictionary. Parameters ---------- select : str / tuple / dict - `str` -> Any valid string selection - `dict` -> ``{'mobile':sel1, 'reference':sel2}`` - `tuple` -> ``(sel1, sel2)`` Returns ------- dict selections for 'reference' and 'mobile'. Values are guarenteed to be iterable (so that one can provide selections to retain order) Notes ----- The dictionary input for `select` can be generated by :func:`fasta2select` based on a ClustalW_ or STAMP_ sequence alignment. """ if type(select) is str: select = {'reference': select, 'mobile': select} elif type(select) is tuple: try: select = {'mobile': select[0], 'reference': select[1]} except IndexError: raise IndexError("select must contain two selection strings " "(reference, mobile)") elif type(select) is dict: # compatability hack to use new nomenclature try: select['mobile'] = select['target'] warnings.warn("use key 'mobile' instead of deprecated 'target'; " "'target' will be removed in 0.8", DeprecationWarning) except KeyError: pass try: select['mobile'] select['reference'] except KeyError: raise KeyError("select dictionary must contain entries for keys " "'mobile' and 'reference'.") else: raise TypeError("'select' must be either a string, 2-tuple, or dict") select['mobile'] = asiterable(select['mobile']) select['reference'] = asiterable(select['reference']) return select
def process_selection(select): """Return a canonical selection dictionary. Parameters ---------- select : str / tuple / dict - `str` -> Any valid string selection - `dict` -> ``{'mobile':sel1, 'reference':sel2}`` - `tuple` -> ``(sel1, sel2)`` Returns ------- dict selections for 'reference' and 'mobile'. Values are guarenteed to be iterable (so that one can provide selections to retain order) Notes ----- The dictionary input for `select` can be generated by :func:`fasta2select` based on a ClustalW_ or STAMP_ sequence alignment. """ if type(select) is str: select = {'reference': select, 'mobile': select} elif type(select) is tuple: try: select = {'mobile': select[0], 'reference': select[1]} except IndexError: raise IndexError("select must contain two selection strings " "(reference, mobile)") elif type(select) is dict: # compatability hack to use new nomenclature try: select['mobile'] = select['target'] warnings.warn( "use key 'mobile' instead of deprecated 'target'; " "'target' will be removed in 0.8", DeprecationWarning) except KeyError: pass try: select['mobile'] select['reference'] except KeyError: raise KeyError("select dictionary must contain entries for keys " "'mobile' and 'reference'.") else: raise TypeError("'select' must be either a string, 2-tuple, or dict") select['mobile'] = asiterable(select['mobile']) select['reference'] = asiterable(select['reference']) return select
def process_selection(select): """Return a canonical selection dictionary. Parameters ---------- select : str or tuple or dict - `str` -> Any valid string selection - `dict` -> ``{'mobile':sel1, 'reference':sel2}`` - `tuple` -> ``(sel1, sel2)`` Returns ------- dict selections for 'reference' and 'mobile'. Values are guarenteed to be iterable (so that one can provide selections to retain order) Notes ----- The dictionary input for `select` can be generated by :func:`fasta2select` based on a ClustalW_ or STAMP_ sequence alignment. """ if isinstance(select, string_types): select = {'reference': str(select), 'mobile': str(select)} elif type(select) is tuple: try: select = {'mobile': select[0], 'reference': select[1]} except IndexError: raise_from( IndexError("select must contain two selection strings " "(reference, mobile)"), None, ) elif type(select) is dict: # compatability hack to use new nomenclature try: select['mobile'] select['reference'] except KeyError: raise_from( KeyError("select dictionary must contain entries for keys " "'mobile' and 'reference'."), None, ) else: raise TypeError("'select' must be either a string, 2-tuple, or dict") select['mobile'] = asiterable(select['mobile']) select['reference'] = asiterable(select['reference']) return select
def __init__(self, filename, **kwargs): self.filename = util.filename(filename, ext=native_str("stream")) self._version = kwargs.get("charmm_version", 41) width = 4 if self._version < 36 else 8 if self._version >= 36: self.fmt = (""" IC EDIT DIST %-{width}s %{width}d %-{width}s %-{width}s %{width}d %-{width}s%{width}.1f END """.format(width=width)) else: self.fmt = (""" IC EDIT DIST BYNUM %{width}d BYNUM %{width}d %{width}.1f END """.format(width=width)) date = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime()) user = environ["USER"] self._title = kwargs.get( "title", ( "* Created by fluctmatch on {date}".format(date=date), "* User: {user}".format(user=user), )) if not util.iterable(self._title): self._title = util.asiterable(self._title)
def __init__(cls, name, bases, classdict): type.__init__(type, name, bases, classdict) try: fmt = asiterable(classdict['model']) except KeyError: pass else: for f in fmt: f = f.upper() _MODELS[f] = cls try: description = asiterable(classdict['describe']) except KeyError: pass else: for f, d in zip(fmt, description): f = f.upper() _DESCRIBE[f] = d
def _process_selection(select): """Return a canonical selection dictionary. :Arguments: *select* - any valid selection string for :meth:`~MDAnalysis.core.AtomGroup.AtomGroup.select_atoms` that produces identical selections in *mobile* and *reference*; or - dictionary ``{'mobile':sel1, 'reference':sel2}``. The :func:`fasta2select` function returns such a dictionary based on a ClustalW_ or STAMP_ sequence alignment. - tuple ``(sel1, sel2)`` :Returns: dict with keys `reference` and `mobile`; the values are guaranteed to be iterable (so that one can provide selections that retain order) """ if type(select) is str: select = {'reference': select, 'mobile': select} elif type(select) is tuple: try: select = {'mobile': select[0], 'reference': select[1]} except IndexError: raise IndexError("select must contain two selection strings " "(reference, mobile)") elif type(select) is dict: # compatability hack to use new nomenclature try: select['mobile'] = select['target'] warnings.warn("use key 'mobile' instead of deprecated 'target'; " "'target' will be removed in 0.8", DeprecationWarning) except KeyError: pass try: select['mobile'] select['reference'] except KeyError: raise KeyError("select dictionary must contain entries for keys " "'mobile' and 'reference'.") else: raise TypeError("'select' must be either a string, 2-tuple, or dict") select['mobile'] = asiterable(select['mobile']) select['reference'] = asiterable(select['reference']) return select
def __init__(self, filename, **kwargs): self.filename = util.filename(filename, ext="prm") self._version = kwargs.get("charmm_version", 41) self._nonbonded = kwargs.get("nonbonded", False) date = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime()) user = environ["USER"] self._title = kwargs.get("title", ( "* Created by fluctmatch on {date}".format(date=date), "* User: {user}".format(user=user), )) if not util.iterable(self._title): self._title = util.asiterable(self._title)
def __init__(self, filename, **kwargs): self.filename = util.filename(filename, ext="ic") self._intcor = None self._extended = kwargs.get("extended", True) self._resid = kwargs.get("resid", True) self.key = "EXTENDED" if self._extended else "STANDARD" self.key += "_RESID" if self._resid else "" date = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime()) user = environ["USER"] self._title = kwargs.get( "title", ( "* Created by fluctmatch on {date}".format(date=date), "* User: {user}".format(user=user), )) if not util.iterable(self._title): self._title = util.asiterable(self._title)