if pieces["<STR_LIT>"]:<EOL><INDENT>rendered = pieces["<STR_LIT>"]<EOL>if pieces["<STR_LIT>"] or pieces["<STR_LIT>"]:<EOL><INDENT>rendered += "<STR_LIT>" % pieces["<STR_LIT>"]<EOL>if pieces["<STR_LIT>"]:<EOL><INDENT>rendered += "<STR_LIT>"<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>rendered = "<STR_LIT>" % pieces["<STR_LIT>"]<EOL>if pieces["<STR_LIT>"]:<EOL><INDENT>rendered += "<STR_LIT>"<EOL><DEDENT><DEDENT>return rendered<EOL>

TAG[.postDISTANCE[.dev0]] .

    The ".dev0" means dirty.

    Eexceptions:
    1: no tags. 0.postDISTANCE[.dev0]


if pieces["<STR_LIT>"]:<EOL><INDENT>rendered = pieces["<STR_LIT>"]<EOL>if pieces["<STR_LIT>"]:<EOL><INDENT>rendered += "<STR_LIT>" % (pieces["<STR_LIT>"], pieces["<STR_LIT>"])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>rendered = pieces["<STR_LIT>"]<EOL><DEDENT>if pieces["<STR_LIT>"]:<EOL><INDENT>rendered += "<STR_LIT>"<EOL><DEDENT>return rendered<EOL>

TAG[-DISTANCE-gHEX][-dirty].

    Like 'git describe --tags --dirty --always'.

    Exceptions:
    1: no tags. HEX[-dirty]  (note: no 'g' prefix)


if pieces["<STR_LIT>"]:<EOL><INDENT>rendered = pieces["<STR_LIT>"]<EOL>rendered += "<STR_LIT>" % (pieces["<STR_LIT>"], pieces["<STR_LIT>"])<EOL><DEDENT>else:<EOL><INDENT>rendered = pieces["<STR_LIT>"]<EOL><DEDENT>if pieces["<STR_LIT>"]:<EOL><INDENT>rendered += "<STR_LIT>"<EOL><DEDENT>return rendered<EOL>

TAG-DISTANCE-gHEX[-dirty].

    Like 'git describe --tags --dirty --always -long'.
    The distance/hash is unconditional.

    Exceptions:
    1: no tags. HEX[-dirty]  (note: no 'g' prefix)


if pieces["<STR_LIT:error>"]:<EOL><INDENT>return {"<STR_LIT:version>": "<STR_LIT>",<EOL>"<STR_LIT>": pieces.get("<STR_LIT>"),<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT:error>": pieces["<STR_LIT:error>"],<EOL>"<STR_LIT:date>": None}<EOL><DEDENT>if not style or style == "<STR_LIT:default>":<EOL><INDENT>style = "<STR_LIT>"  <EOL><DEDENT>if style == "<STR_LIT>":<EOL><INDENT>rendered = render_pep440(pieces)<EOL><DEDENT>elif style == "<STR_LIT>":<EOL><INDENT>rendered = render_pep440_pre(pieces)<EOL><DEDENT>elif style == "<STR_LIT>":<EOL><INDENT>rendered = render_pep440_post(pieces)<EOL><DEDENT>elif style == "<STR_LIT>":<EOL><INDENT>rendered = render_pep440_old(pieces)<EOL><DEDENT>elif style == "<STR_LIT>":<EOL><INDENT>rendered = render_git_describe(pieces)<EOL><DEDENT>elif style == "<STR_LIT>":<EOL><INDENT>rendered = render_git_describe_long(pieces)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>" % style)<EOL><DEDENT>return {"<STR_LIT:version>": rendered, "<STR_LIT>": pieces["<STR_LIT>"],<EOL>"<STR_LIT>": pieces["<STR_LIT>"], "<STR_LIT:error>": None,<EOL>"<STR_LIT:date>": pieces.get("<STR_LIT:date>")}<EOL>

Render the given version pieces into the requested style.


<EOL>cfg = get_config()<EOL>verbose = cfg.verbose<EOL>try:<EOL><INDENT>return git_versions_from_keywords(get_keywords(), cfg.tag_prefix,<EOL>verbose)<EOL><DEDENT>except NotThisMethod:<EOL><INDENT>pass<EOL><DEDENT>try:<EOL><INDENT>root = os.path.realpath(__file__)<EOL>for i in cfg.versionfile_source.split('<STR_LIT:/>'):<EOL><INDENT>root = os.path.dirname(root)<EOL><DEDENT><DEDENT>except NameError:<EOL><INDENT>return {"<STR_LIT:version>": "<STR_LIT>", "<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT:error>": "<STR_LIT>",<EOL>"<STR_LIT:date>": None}<EOL><DEDENT>try:<EOL><INDENT>pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose)<EOL>return render(pieces, cfg.style)<EOL><DEDENT>except NotThisMethod:<EOL><INDENT>pass<EOL><DEDENT>try:<EOL><INDENT>if cfg.parentdir_prefix:<EOL><INDENT>return versions_from_parentdir(cfg.parentdir_prefix, root, verbose)<EOL><DEDENT><DEDENT>except NotThisMethod:<EOL><INDENT>pass<EOL><DEDENT>return {"<STR_LIT:version>": "<STR_LIT>", "<STR_LIT>": None,<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT:error>": "<STR_LIT>", "<STR_LIT:date>": None}<EOL>

Get version information or return default if unable to do so.


super(Flags,self).__init__([(flag.name,flag) for flag in args])<EOL>

For **developers**: Initialize Flags registry with a *list* of :class:`Flag` instances.


return "<STR_LIT>".join([flag.__doc__ for flag in self._itervalues()])<EOL>


super(Flags,self).__setitem__(flag.name,flag)<EOL>

Register a new :class:`Flag` instance with the Flags registry.


super(Flags,self).update([(flag.name,flag) for flag in flags])<EOL>

Update Flags registry with a list of :class:`Flag` instances.


self.name = name<EOL>self.value = default<EOL>self.default = default<EOL>self.mapping = mapping or IdentityMapping()<EOL>self._doctemplate = "<STR_LIT>" + (doc or "<STR_LIT>")<EOL>

Create a new flag which will be registered with FLags.

          newflag = Flag(name,default,mapping,doc)

        :Arguments:
         *name*
            name of the flag, must be a legal python name
         *default*
            default value
         *mapping*
            dict that maps allowed input values to canonical values;
            if ``None`` then no argument checking will be performed and
            all values are directly set.
         *doc*
            doc string; may contain string interpolation mappings for::

                    %%(name)s        name of the flag
                    %%(default)r     default value
                    %%(value)r       current value
                    %%(mapping)r     mapping

            Doc strings are generated dynamically and reflect the current state.


return {'<STR_LIT>':self.get, '<STR_LIT>':self.set, '<STR_LIT>':self.__doc__}<EOL>


from . import log<EOL>log.create("<STR_LIT>", logfile=logfile)<EOL>logging.getLogger("<STR_LIT>").info("<STR_LIT>",<EOL>__version__, logfile)<EOL>

Start logging of messages to file and console.

    The default logfile is named ``gromacs.log`` and messages are
    logged with the tag *gromacs*.


from . import log<EOL>logger = logging.getLogger("<STR_LIT>")<EOL>logger.info("<STR_LIT>", get_version())<EOL>log.clear_handlers(logger)<EOL>


if categories is None:<EOL><INDENT>categories = less_important_warnings<EOL><DEDENT>for c in categories:<EOL><INDENT>try:<EOL><INDENT>w = globals()[c]<EOL><DEDENT>except KeyError:<EOL><INDENT>w = c<EOL><DEDENT>if not issubclass(w, Warning):<EOL><INDENT>raise TypeError("<STR_LIT>".format(c))<EOL><DEDENT>warnings.simplefilter(action, category=w)<EOL><DEDENT>

Set the :meth:`warnings.simplefilter` to *action*.

    *categories* must be a list of warning classes or strings.
    ``None`` selects the defaults,  :data:`gromacs.less_important_warnings`.


filter_gromacs_warnings('<STR_LIT:ignore>', categories=categories)<EOL>

Disable ("ignore") specified warnings from the gromacs package.

    *categories* must be a list of warning classes or strings.
    ``None`` selects the defaults.


filter_gromacs_warnings('<STR_LIT>', categories=categories)<EOL>

Enable ("always") specified warnings from the gromacs package.

    *categories* must be a list of warning classes or strings.
    ``None`` selects the defaults, :data:`gromacs._less_important_warnings`.


def __init__(self, filename=None, **kwargs):

self.autoconvert = kwargs.pop("<STR_LIT>", True)<EOL>self.reverse = kwargs.pop("<STR_LIT>", True)<EOL>self.__array = None<EOL>super(XPM, self).__init__(**kwargs)  <EOL>if filename is not None:<EOL><INDENT>self._init_filename(filename)<EOL>self.read(filename)<EOL><DEDENT>

Initialize xpm structure.

        :Arguments:
          *filename*
              read from xpm file directly
          *autoconvert*
              try to guess the type of the output array from the
              colour legend [``True``]
          *reverse*
              reverse rows (2nd dimension): re-orders the rows so that
              the first row corresponds e.g. to the first residue or
              first H-bonds and not the last) [``True``]


return self.__array<EOL>

XPM matrix as a :class:`numpy.ndarray`.

        The attribute itself cannot be assigned a different array but
        the contents of the array can be modified.


self._init_filename(filename)<EOL>self.parse()<EOL>


with utilities.openany(self.real_filename) as xpm:<EOL><INDENT>meta = [xpm.readline()]<EOL>while not meta[-<NUM_LIT:1>].startswith("<STR_LIT>"):<EOL><INDENT>meta.append(xpm.readline())<EOL><DEDENT>dim = xpm.readline()<EOL>nx, ny, nc, nb = [int(i) for i in self.unquote(dim).split()]<EOL>colors = dict([self.col(xpm.readline()) for i in range(nc)])<EOL>if self.autoconvert:<EOL><INDENT>autoconverter = Autoconverter(mode="<STR_LIT>")<EOL>for symbol, value in colors.items():<EOL><INDENT>colors[symbol] = autoconverter.convert(value)<EOL><DEDENT>self.logger.debug("<STR_LIT>", colors)<EOL><DEDENT>dtype = numpy.array(colors.values()).dtype<EOL>self.logger.debug("<STR_LIT>", dtype.name)<EOL>data = numpy.zeros((int(nx/nb), ny), dtype=dtype)<EOL>self.logger.debug("<STR_LIT>",<EOL>nx, ny, nb, nc, nx/nb, ny)<EOL>iy = <NUM_LIT:0><EOL>xval = []<EOL>yval = []<EOL>autoconverter = Autoconverter(mode="<STR_LIT>")<EOL>for line in xpm:<EOL><INDENT>if line.startswith("<STR_LIT>"):<EOL><INDENT>s = self.uncomment(line).strip()<EOL>if s.startswith('<STR_LIT>'):<EOL><INDENT>xval.extend([autoconverter.convert(x) for x in s[<NUM_LIT:7>:].split()])<EOL><DEDENT>elif s.startswith('<STR_LIT>'):<EOL><INDENT>yval.extend([autoconverter.convert(y) for y in s[<NUM_LIT:7>:].split()])<EOL><DEDENT>continue<EOL><DEDENT>s = self.unquote(line)<EOL>data[:, iy] = [colors[s[k:k+nb]] for k in range(<NUM_LIT:0>,nx,nb)]<EOL>self.logger.debug("<STR_LIT>",<EOL>iy, data.shape[<NUM_LIT:0>], s[:<NUM_LIT:4>], s[-<NUM_LIT:4>:])<EOL>iy += <NUM_LIT:1>  <EOL><DEDENT><DEDENT>self.xvalues = numpy.array(xval)<EOL>if self.reverse:<EOL><INDENT>self.logger.debug("<STR_LIT>", self.reverse)<EOL>self.__array = data[:, ::-<NUM_LIT:1>]<EOL>self.yvalues = numpy.array(yval)<EOL><DEDENT>else:<EOL><INDENT>self.__array = data<EOL>self.yvalues = numpy.array(yval)[::-<NUM_LIT:1>]<EOL><DEDENT>

Parse the xpm file and populate :attr:`XPM.array`.


return s[<NUM_LIT:1>+s.find('<STR_LIT:">'):s.rfind('<STR_LIT:">')]<EOL>

Return string *s* with quotes ``"`` removed.


return s[<NUM_LIT:2>+s.find('<STR_LIT>'):s.rfind('<STR_LIT>')]<EOL>

Return string *s* with C-style comments ``/*`` ... ``*/`` removed.


m = self.COLOUR.search(c)<EOL>if not m:<EOL><INDENT>self.logger.fatal("<STR_LIT>", c)<EOL>raise ParseError("<STR_LIT>".format(c))<EOL><DEDENT>value = m.group('<STR_LIT:value>')<EOL>color = m.group('<STR_LIT>')<EOL>self.logger.debug("<STR_LIT>", c.strip(), color, value)<EOL>return color, value<EOL>


assert isinstance(anumb, int), "<STR_LIT>"<EOL>if not self._anumb_to_atom:   <EOL><INDENT>if self.atoms:<EOL><INDENT>for atom in self.atoms:<EOL><INDENT>self._anumb_to_atom[atom.number] = atom<EOL><DEDENT>return self._anumb_to_atom[anumb]<EOL><DEDENT>else:<EOL><INDENT>self.logger("<STR_LIT>")<EOL>return False<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if anumb in self._anumb_to_atom:<EOL><INDENT>return self._anumb_to_atom[anumb]<EOL><DEDENT>else:<EOL><INDENT>self.logger("<STR_LIT>".format(anumb))<EOL>return False<EOL><DEDENT><DEDENT>

Returns the atom object corresponding to an atom number


if self.atoms:<EOL><INDENT>self._anumb_to_atom = {}<EOL>for i,atom in enumerate(self.atoms):<EOL><INDENT>atom.number = i+<NUM_LIT:1>   <EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.logger("<STR_LIT>")<EOL><DEDENT>

Reset the molecule's atoms :attr:`number` to be 1-indexed


super(TOP, self).__init__()<EOL>self.fname = fname<EOL>self.defaults = {<EOL>'<STR_LIT>': None, '<STR_LIT>':None, '<STR_LIT>':None, '<STR_LIT>':None, '<STR_LIT>':None,<EOL>}<EOL>self.dict_molname_mol = odict()   <EOL>self.found_sections   = []<EOL>self.forcefield       = '<STR_LIT>'<EOL>self.molecules = []<EOL>self._parse(fname)<EOL>self.molecules = tuple(self.molecules)<EOL>

Initialize the TOP structure.

        :Arguments:
          *fname*
              name of the processed.top file


SystemToGroTop(self, filename)<EOL>


moltypenames = list(self.dict_molname_mol.keys())<EOL>moltypenames.sort()<EOL>data = []<EOL>data.append('<STR_LIT:\n>')<EOL>main_items = set(['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'])<EOL>other_items = ['<STR_LIT>'.format(m, len(self.information[m])) for m in list(self.information.keys()) if m not in main_items]<EOL>other_items = '<STR_LIT:U+0020>'.join(other_items)<EOL>nattype = len(self.atomtypes)<EOL>nprtype = len(self.pairtypes)<EOL>nbndtype= len(self.bondtypes)<EOL>nangtype= len(self.angletypes)<EOL>ndihtype= len(self.dihedraltypes)<EOL>nimptype= len(self.impropertypes)<EOL>data.append('<STR_LIT>'.format('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'))<EOL>msg = '<STR_LIT>'.format('<STR_LIT>', nattype, nprtype, nbndtype, nangtype, ndihtype, nimptype, other_items)<EOL>data.append('<STR_LIT:=>' * <NUM_LIT>)<EOL>data.append(msg)<EOL>data.append('<STR_LIT:\n>')<EOL>main_items = set(['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'])<EOL>data.append('<STR_LIT>'.format('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'))<EOL>data.append('<STR_LIT:=>' * <NUM_LIT>)<EOL>for mname in moltypenames:<EOL><INDENT>mol = self.dict_molname_mol[mname]<EOL>other_items = ['<STR_LIT>'.format(m, len(mol.information[m])) for m in list(mol.information.keys()) if m not in main_items]<EOL>other_items = '<STR_LIT:U+0020>'.join(other_items)<EOL>natoms = len(mol.atoms)<EOL>npairs = len(mol.pairs)<EOL>nbonds = len(mol.bonds)<EOL>nangles= len(mol.angles)<EOL>ndih   = len(mol.dihedrals)<EOL>nimp   = len(mol.impropers)<EOL>msg = '<STR_LIT>'.format(mol.name, natoms, npairs, nbonds, nangles, ndih, nimp, other_items)<EOL>data.append(msg)<EOL><DEDENT>return '<STR_LIT:\n>'.join(data)<EOL>


def _find_section(line):<EOL><INDENT>return  line.strip('<STR_LIT:[>').strip('<STR_LIT:]>').strip()<EOL><DEDENT>def _add_info(sys_or_mol, section, container):<EOL><INDENT>if sys_or_mol.information.get(section, False) is False:<EOL><INDENT>sys_or_mol.information[section] = container<EOL><DEDENT><DEDENT>mol        = None   <EOL>curr_sec   = None<EOL>cmap_lines = []<EOL>with open(fname) as f:<EOL><INDENT>for i_line, line in enumerate(f):<EOL><INDENT>if '<STR_LIT:;>' in line:<EOL><INDENT>line = line[<NUM_LIT:0>:line.index('<STR_LIT:;>')]<EOL><DEDENT>line = line.strip()<EOL>if line == '<STR_LIT>':<EOL><INDENT>continue<EOL><DEDENT>if line[<NUM_LIT:0>] == '<STR_LIT:*>':<EOL><INDENT>continue<EOL><DEDENT>if line.startswith('<STR_LIT>'):<EOL><INDENT>msg = '<STR_LIT>'<EOL>msg+= '<STR_LIT>'<EOL>raise ValueError(msg)<EOL><DEDENT>if line[<NUM_LIT:0>] == '<STR_LIT:[>':<EOL><INDENT>curr_sec = _find_section(line)<EOL>self.found_sections.append(curr_sec)<EOL>continue<EOL><DEDENT>fields = line.split()<EOL>if curr_sec == '<STR_LIT>':<EOL><INDENT>'''<STR_LIT>'''<EOL>assert len(fields) in  [<NUM_LIT:2>, <NUM_LIT:5>]<EOL>self.defaults['<STR_LIT>']    = int(fields[<NUM_LIT:0>])<EOL>self.defaults['<STR_LIT>'] = int(fields[<NUM_LIT:1>])<EOL>if len(fields) == <NUM_LIT:5>:<EOL><INDENT>self.defaults['<STR_LIT>'] = fields[<NUM_LIT:2>]<EOL>self.defaults['<STR_LIT>']   = float(fields[<NUM_LIT:3>])<EOL>self.defaults['<STR_LIT>']   = float(fields[<NUM_LIT:4>])<EOL><DEDENT><DEDENT>elif curr_sec == '<STR_LIT>':<EOL><INDENT>'''<STR_LIT>'''<EOL>if len(fields) not in (<NUM_LIT:6>,<NUM_LIT:7>,<NUM_LIT:8>):<EOL><INDENT>self.logger.warning('<STR_LIT>'.format(line))<EOL>continue<EOL><DEDENT>shift = len(fields) - <NUM_LIT:7><EOL>at = blocks.AtomType('<STR_LIT>')<EOL>at.atype = fields[<NUM_LIT:0>]<EOL>if shift == <NUM_LIT:1>: at.bond_type = fields[<NUM_LIT:1>]<EOL>at.mass  = float(fields[<NUM_LIT:2>+shift])<EOL>at.charge= float(fields[<NUM_LIT:3>+shift])<EOL>particletype = fields[<NUM_LIT:4>+shift]<EOL>assert particletype in ('<STR_LIT:A>', '<STR_LIT:S>', '<STR_LIT>', '<STR_LIT:D>')<EOL>if particletype not in ('<STR_LIT:A>',):<EOL><INDENT>self.logger.warning('<STR_LIT>'.format(line))<EOL><DEDENT>sig = float(fields[<NUM_LIT:5>+shift])<EOL>eps = float(fields[<NUM_LIT:6>+shift])<EOL>at.gromacs= {'<STR_LIT>': {'<STR_LIT>':eps, '<STR_LIT>':sig, '<STR_LIT>':None, '<STR_LIT>':None} }<EOL>self.atomtypes.append(at)<EOL>_add_info(self, curr_sec, self.atomtypes)<EOL><DEDENT>elif curr_sec == '<STR_LIT>':<EOL><INDENT>assert len(fields) == <NUM_LIT:2><EOL>mol = blocks.Molecule()<EOL>mol.name = fields[<NUM_LIT:0>]<EOL>mol.exclusion_numb = int(fields[<NUM_LIT:1>])<EOL>self.dict_molname_mol[mol.name] = mol<EOL><DEDENT>elif curr_sec == '<STR_LIT>':<EOL><INDENT>'''<STR_LIT>'''<EOL>aserial = int(fields[<NUM_LIT:0>])<EOL>atype   = fields[<NUM_LIT:1>]<EOL>resnumb = int(fields[<NUM_LIT:2>])<EOL>resname = fields[<NUM_LIT:3>]<EOL>aname   = fields[<NUM_LIT:4>]<EOL>cgnr    = int(fields[<NUM_LIT:5>])<EOL>charge  = float(fields[<NUM_LIT:6>])<EOL>rest = fields[<NUM_LIT:7>:]<EOL>atom         = blocks.Atom()<EOL>atom.name    = aname<EOL>atom.atomtype= atype<EOL>atom.number  = aserial<EOL>atom.resname = resname<EOL>atom.resnumb = resnumb<EOL>atom.charge  = charge<EOL>if rest:<EOL><INDENT>mass = float(rest[<NUM_LIT:0>])<EOL>atom.mass = mass<EOL><DEDENT>mol.atoms.append(atom)<EOL>_add_info(mol, curr_sec, mol.atoms)<EOL><DEDENT>elif curr_sec in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>'''<STR_LIT>'''<EOL>ai, aj = fields[:<NUM_LIT:2>]<EOL>fu     = int(fields[<NUM_LIT:2>])<EOL>assert fu in (<NUM_LIT:1>,<NUM_LIT:2>)<EOL>pair = blocks.InteractionType('<STR_LIT>')<EOL>if fu == <NUM_LIT:1>:<EOL><INDENT>if curr_sec=='<STR_LIT>':<EOL><INDENT>pair.atype1 = ai<EOL>pair.atype2 = aj<EOL>v, w = list(map(float, fields[<NUM_LIT:3>:<NUM_LIT:5>]))<EOL>pair.gromacs = {'<STR_LIT>': {'<STR_LIT>':None, '<STR_LIT>':None, '<STR_LIT>':w, '<STR_LIT>':v}, '<STR_LIT>':fu }<EOL>self.pairtypes.append(pair)<EOL>_add_info(self, curr_sec, self.pairtypes)<EOL><DEDENT>elif curr_sec == '<STR_LIT>':<EOL><INDENT>ai, aj = list( map(int, [ai,aj]) )<EOL>pair.atom1 = mol.atoms[ai-<NUM_LIT:1>]<EOL>pair.atom2 = mol.atoms[aj-<NUM_LIT:1>]<EOL>pair.gromacs['<STR_LIT>'] = fu<EOL>mol.pairs.append(pair)<EOL>_add_info(mol, curr_sec, mol.pairs)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise NotImplementedError('<STR_LIT>'.format(curr_sec,fu))<EOL><DEDENT><DEDENT>elif curr_sec == '<STR_LIT>':<EOL><INDENT>'''<STR_LIT>'''<EOL>assert len(fields) == <NUM_LIT:5><EOL>ai, aj = fields[:<NUM_LIT:2>]<EOL>fu     = int(fields[<NUM_LIT:2>])<EOL>assert fu == <NUM_LIT:1><EOL>sig    = float(fields[<NUM_LIT:3>])<EOL>eps    = float(fields[<NUM_LIT:4>])<EOL>nonbond_param = blocks.NonbondedParamType('<STR_LIT>')<EOL>nonbond_param.atype1 = ai<EOL>nonbond_param.atype2 = aj<EOL>nonbond_param.gromacs['<STR_LIT>'] = fu<EOL>nonbond_param.gromacs['<STR_LIT>'] = {'<STR_LIT>': eps, '<STR_LIT>': sig}<EOL>self.nonbond_params.append(nonbond_param)<EOL>_add_info(self, curr_sec, self.nonbond_params)<EOL><DEDENT>elif curr_sec in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>'''<STR_LIT>'''<EOL>ai, aj = fields[:<NUM_LIT:2>]<EOL>fu     = int(fields[<NUM_LIT:2>])<EOL>assert fu in (<NUM_LIT:1>,<NUM_LIT:2>,<NUM_LIT:3>,<NUM_LIT:4>,<NUM_LIT:5>,<NUM_LIT:6>,<NUM_LIT:7>,<NUM_LIT:8>,<NUM_LIT:9>,<NUM_LIT:10>)<EOL>if fu != <NUM_LIT:1>:<EOL><INDENT>raise NotImplementedError('<STR_LIT>'.format(fu))<EOL><DEDENT>bond = blocks.BondType('<STR_LIT>')<EOL>if fu == <NUM_LIT:1>:<EOL><INDENT>if curr_sec == '<STR_LIT>':<EOL><INDENT>bond.atype1 = ai<EOL>bond.atype2 = aj<EOL>b0, kb = list(map(float, fields[<NUM_LIT:3>:<NUM_LIT:5>]))<EOL>bond.gromacs = {'<STR_LIT>':{'<STR_LIT>':kb, '<STR_LIT>':b0}, '<STR_LIT>':fu}<EOL>self.bondtypes.append(bond)<EOL>_add_info(self, curr_sec, self.bondtypes)<EOL><DEDENT>elif curr_sec == '<STR_LIT>':<EOL><INDENT>ai, aj = list(map(int, [ai, aj]))<EOL>bond.atom1 = mol.atoms[ai-<NUM_LIT:1>]<EOL>bond.atom2 = mol.atoms[aj-<NUM_LIT:1>]<EOL>bond.gromacs['<STR_LIT>'] = fu<EOL>if len(fields) > <NUM_LIT:3>:<EOL><INDENT>b0, kb = list(map(float, fields[<NUM_LIT:3>:<NUM_LIT:5>]))<EOL>bond.gromacs = {'<STR_LIT>':{'<STR_LIT>':kb, '<STR_LIT>':b0}, '<STR_LIT>':fu}<EOL><DEDENT>mol.bonds.append(bond)<EOL>_add_info(mol, curr_sec, mol.bonds)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise NotImplementedError<EOL><DEDENT><DEDENT>elif curr_sec in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>'''<STR_LIT>'''<EOL>ai, aj , ak = fields[:<NUM_LIT:3>]<EOL>fu          = int(fields[<NUM_LIT:3>])<EOL>assert fu in (<NUM_LIT:1>,<NUM_LIT:2>,<NUM_LIT:3>,<NUM_LIT:4>,<NUM_LIT:5>,<NUM_LIT:6>,<NUM_LIT:8>)  <EOL>if fu not in (<NUM_LIT:1>,<NUM_LIT:2>,<NUM_LIT:5>):<EOL><INDENT>raise NotImplementedError('<STR_LIT>'.format(fu))<EOL><DEDENT>ang = blocks.AngleType('<STR_LIT>')<EOL>if fu == <NUM_LIT:1>:<EOL><INDENT>if curr_sec == '<STR_LIT>':<EOL><INDENT>ang.atype1 = ai<EOL>ang.atype2 = aj<EOL>ang.atype3 = ak<EOL>tetha0, ktetha = list(map(float, fields[<NUM_LIT:4>:<NUM_LIT:6>]))<EOL>ang.gromacs = {'<STR_LIT>':{'<STR_LIT>':ktetha, '<STR_LIT>':tetha0, '<STR_LIT>':None, '<STR_LIT>':None}, '<STR_LIT>':fu}<EOL>self.angletypes.append(ang)<EOL>_add_info(self, curr_sec, self.angletypes)<EOL><DEDENT>elif curr_sec == '<STR_LIT>':<EOL><INDENT>ai, aj, ak = list(map(int, [ai, aj, ak]))<EOL>ang.atom1 = mol.atoms[ai-<NUM_LIT:1>]<EOL>ang.atom2 = mol.atoms[aj-<NUM_LIT:1>]<EOL>ang.atom3 = mol.atoms[ak-<NUM_LIT:1>]<EOL>ang.gromacs['<STR_LIT>'] = fu<EOL>mol.angles.append(ang)<EOL>_add_info(mol, curr_sec, mol.angles)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError<EOL><DEDENT><DEDENT>elif fu == <NUM_LIT:2>:<EOL><INDENT>if curr_sec == '<STR_LIT>':<EOL><INDENT>raise NotImplementedError()<EOL><DEDENT>elif curr_sec == '<STR_LIT>':<EOL><INDENT>ai, aj, ak = list(map(int, [ai, aj, ak]))<EOL>ang.atom1 = mol.atoms[ai-<NUM_LIT:1>]<EOL>ang.atom2 = mol.atoms[aj-<NUM_LIT:1>]<EOL>ang.atom3 = mol.atoms[ak-<NUM_LIT:1>]<EOL>ang.gromacs['<STR_LIT>'] = fu<EOL>tetha0, ktetha = list(map(float, fields[<NUM_LIT:4>:<NUM_LIT:6>]))<EOL>ang.gromacs = {'<STR_LIT>':{'<STR_LIT>':ktetha, '<STR_LIT>':tetha0, '<STR_LIT>':None, '<STR_LIT>':None}, '<STR_LIT>':fu}<EOL>mol.angles.append(ang)<EOL>_add_info(mol, curr_sec, mol.angles)<EOL><DEDENT><DEDENT>elif fu == <NUM_LIT:5>:<EOL><INDENT>if curr_sec == '<STR_LIT>':<EOL><INDENT>ang.atype1 = ai<EOL>ang.atype2 = aj<EOL>ang.atype3 = ak<EOL>tetha0, ktetha, s0, kub = list(map(float, fields[<NUM_LIT:4>:<NUM_LIT:8>]))<EOL>ang.gromacs = {'<STR_LIT>':{'<STR_LIT>':ktetha, '<STR_LIT>':tetha0, '<STR_LIT>':kub, '<STR_LIT>':s0}, '<STR_LIT>':fu}<EOL>self.angletypes.append(ang)<EOL>_add_info(self, curr_sec, self.angletypes)<EOL><DEDENT>elif curr_sec == '<STR_LIT>':<EOL><INDENT>ai, aj, ak = list(map(int, [ai, aj, ak]))<EOL>ang.atom1 = mol.atoms[ai-<NUM_LIT:1>]<EOL>ang.atom2 = mol.atoms[aj-<NUM_LIT:1>]<EOL>ang.atom3 = mol.atoms[ak-<NUM_LIT:1>]<EOL>ang.gromacs['<STR_LIT>'] = fu<EOL>mol.angles.append(ang)<EOL>_add_info(mol, curr_sec, mol.angles)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise NotImplementedError<EOL><DEDENT><DEDENT>elif curr_sec in  ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>'''<STR_LIT>'''<EOL>if curr_sec == '<STR_LIT>' and len(fields) == <NUM_LIT:6>:<EOL><INDENT>fields.insert(<NUM_LIT:2>, '<STR_LIT:X>')<EOL>fields.insert(<NUM_LIT:0>, '<STR_LIT:X>')<EOL><DEDENT>ai, aj, ak, am = fields[:<NUM_LIT:4>]<EOL>fu = int(fields[<NUM_LIT:4>])<EOL>assert fu in (<NUM_LIT:1>,<NUM_LIT:2>,<NUM_LIT:3>,<NUM_LIT:4>,<NUM_LIT:5>,<NUM_LIT:8>,<NUM_LIT:9>)<EOL>if fu not in (<NUM_LIT:1>,<NUM_LIT:2>,<NUM_LIT:3>,<NUM_LIT:4>,<NUM_LIT:9>):<EOL><INDENT>raise NotImplementedError('<STR_LIT>'.format(fu))<EOL><DEDENT>dih = blocks.DihedralType('<STR_LIT>')<EOL>imp = blocks.ImproperType('<STR_LIT>')<EOL>if fu in (<NUM_LIT:1>,<NUM_LIT:3>,<NUM_LIT:9>):<EOL><INDENT>if curr_sec == '<STR_LIT>':<EOL><INDENT>dih.atype1 = ai<EOL>dih.atype2 = aj<EOL>dih.atype3 = ak<EOL>dih.atype4 = am<EOL>dih.line = i_line + <NUM_LIT:1><EOL>if fu == <NUM_LIT:1>:<EOL><INDENT>delta, kchi, n = list(map(float, fields[<NUM_LIT:5>:<NUM_LIT:8>]))<EOL>dih.gromacs['<STR_LIT>'].append({'<STR_LIT>':kchi, '<STR_LIT:n>':n, '<STR_LIT>':delta})<EOL><DEDENT>elif fu == <NUM_LIT:3>:<EOL><INDENT>c0, c1, c2, c3, c4, c5 = list(map(float, fields[<NUM_LIT:5>:<NUM_LIT:11>]))<EOL>m = dict(c0=c0, c1=c1, c2=c2, c3=c3, c4=c4, c5=c5)<EOL>dih.gromacs['<STR_LIT>'].append(m)<EOL><DEDENT>elif fu == <NUM_LIT:4>:<EOL><INDENT>delta, kchi, n = list(map(float, fields[<NUM_LIT:5>:<NUM_LIT:8>]))<EOL>dih.gromacs['<STR_LIT>'].append({'<STR_LIT>':kchi, '<STR_LIT:n>':int(n), '<STR_LIT>':delta})<EOL><DEDENT>elif fu == <NUM_LIT:9>:<EOL><INDENT>delta, kchi, n = list(map(float, fields[<NUM_LIT:5>:<NUM_LIT:8>]))<EOL>dih.gromacs['<STR_LIT>'].append({'<STR_LIT>':kchi, '<STR_LIT:n>':int(n), '<STR_LIT>':delta})<EOL><DEDENT>else:<EOL><INDENT>raise ValueError<EOL><DEDENT>dih.gromacs['<STR_LIT>'] = fu<EOL>self.dihedraltypes.append(dih)<EOL>_add_info(self, curr_sec, self.dihedraltypes)<EOL><DEDENT>elif curr_sec == '<STR_LIT>':<EOL><INDENT>ai, aj, ak, am = list(map(int, fields[:<NUM_LIT:4>]))<EOL>dih.atom1 = mol.atoms[ai-<NUM_LIT:1>]<EOL>dih.atom2 = mol.atoms[aj-<NUM_LIT:1>]<EOL>dih.atom3 = mol.atoms[ak-<NUM_LIT:1>]<EOL>dih.atom4 = mol.atoms[am-<NUM_LIT:1>]<EOL>dih.gromacs['<STR_LIT>'] = fu<EOL>dih.line = i_line + <NUM_LIT:1><EOL>if fu == <NUM_LIT:1>:<EOL><INDENT>delta, kchi, n = list(map(float, fields[<NUM_LIT:5>:<NUM_LIT:8>]))<EOL>dih.gromacs['<STR_LIT>'].append({'<STR_LIT>':kchi, '<STR_LIT:n>': int(n), '<STR_LIT>':delta})<EOL><DEDENT>elif fu == <NUM_LIT:3>:<EOL><INDENT>pass<EOL><DEDENT>elif fu == <NUM_LIT:4>:<EOL><INDENT>pass<EOL><DEDENT>elif fu == <NUM_LIT:9>:<EOL><INDENT>if len(fields[<NUM_LIT:5>:<NUM_LIT:8>]) == <NUM_LIT:3>:<EOL><INDENT>delta, kchi, n = list(map(float, fields[<NUM_LIT:5>:<NUM_LIT:8>]))<EOL>dih.gromacs['<STR_LIT>'].append({'<STR_LIT>':kchi, '<STR_LIT:n>':int(n), '<STR_LIT>':delta})<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError<EOL><DEDENT>mol.dihedrals.append(dih)<EOL>_add_info(mol, curr_sec, mol.dihedrals)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError<EOL><DEDENT><DEDENT>elif fu in (<NUM_LIT:2>,<NUM_LIT:4>):<EOL><INDENT>if curr_sec == '<STR_LIT>':<EOL><INDENT>imp.atype1 = ai<EOL>imp.atype2 = aj<EOL>imp.atype3 = ak<EOL>imp.atype4 = am<EOL>imp.line = i_line + <NUM_LIT:1><EOL>if fu == <NUM_LIT:2>:<EOL><INDENT>psi0 , kpsi = list(map(float, fields[<NUM_LIT:5>:<NUM_LIT:7>]))<EOL>imp.gromacs['<STR_LIT>'].append({'<STR_LIT>':kpsi, '<STR_LIT>': psi0})<EOL><DEDENT>elif fu == <NUM_LIT:4>:<EOL><INDENT>psi0 , kpsi, n = list(map(float, fields[<NUM_LIT:5>:<NUM_LIT:8>]))<EOL>imp.gromacs['<STR_LIT>'].append({'<STR_LIT>':kpsi, '<STR_LIT>': psi0, '<STR_LIT:n>': int(n)})<EOL><DEDENT>else:<EOL><INDENT>raise ValueError<EOL><DEDENT>imp.gromacs['<STR_LIT>'] = fu<EOL>self.impropertypes.append(imp)<EOL>_add_info(self, curr_sec, self.impropertypes)<EOL><DEDENT>elif curr_sec == '<STR_LIT>':<EOL><INDENT>ai, aj, ak, am = list(map(int, fields[:<NUM_LIT:4>]))<EOL>imp.atom1 = mol.atoms[ai-<NUM_LIT:1>]<EOL>imp.atom2 = mol.atoms[aj-<NUM_LIT:1>]<EOL>imp.atom3 = mol.atoms[ak-<NUM_LIT:1>]<EOL>imp.atom4 = mol.atoms[am-<NUM_LIT:1>]<EOL>imp.gromacs['<STR_LIT>'] = fu<EOL>imp.line = i_line + <NUM_LIT:1><EOL>if fu == <NUM_LIT:2>:<EOL><INDENT>pass<EOL><DEDENT>elif fu == <NUM_LIT:4>:<EOL><INDENT>if len(fields[<NUM_LIT:5>:<NUM_LIT:8>]) == <NUM_LIT:3>:<EOL><INDENT>psi0 , kpsi, n = list(map(float, fields[<NUM_LIT:5>:<NUM_LIT:8>]))<EOL>imp.gromacs['<STR_LIT>'].append({'<STR_LIT>':kpsi, '<STR_LIT>': psi0, '<STR_LIT:n>': int(n)})<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError<EOL><DEDENT>mol.impropers.append(imp)<EOL>_add_info(mol, curr_sec, mol.impropers)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise NotImplementedError<EOL><DEDENT><DEDENT>elif curr_sec in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>cmap = blocks.CMapType('<STR_LIT>')<EOL>if curr_sec == '<STR_LIT>':<EOL><INDENT>cmap_lines.append(line)<EOL>_add_info(self, curr_sec, self.cmaptypes)<EOL><DEDENT>else:<EOL><INDENT>ai, aj, ak, am, an = list(map(int, fields[:<NUM_LIT:5>]))<EOL>fu = int(fields[<NUM_LIT:5>])<EOL>assert fu == <NUM_LIT:1><EOL>cmap.atom1 = mol.atoms[ai-<NUM_LIT:1>]<EOL>cmap.atom2 = mol.atoms[aj-<NUM_LIT:1>]<EOL>cmap.atom3 = mol.atoms[ak-<NUM_LIT:1>]<EOL>cmap.atom4 = mol.atoms[am-<NUM_LIT:1>]<EOL>cmap.atom8 = mol.atoms[an-<NUM_LIT:1>]<EOL>cmap.gromacs['<STR_LIT>'] = fu<EOL>mol.cmaps.append(cmap)<EOL>_add_info(mol, curr_sec, mol.cmaps)<EOL><DEDENT><DEDENT>elif curr_sec == '<STR_LIT>':<EOL><INDENT>'''<STR_LIT>'''<EOL>assert len(fields) == <NUM_LIT:4><EOL>ai = int(fields[<NUM_LIT:0>])<EOL>fu = int(fields[<NUM_LIT:1>])<EOL>assert fu == <NUM_LIT:1><EOL>settle = blocks.SettleType('<STR_LIT>')<EOL>settle.atom = mol.atoms[ai-<NUM_LIT:1>]<EOL>settle.dOH = float(fields[<NUM_LIT:2>])<EOL>settle.dHH = float(fields[<NUM_LIT:3>])<EOL>mol.settles.append(settle)<EOL>_add_info(mol, curr_sec, mol.settles)<EOL><DEDENT>elif curr_sec == "<STR_LIT>":<EOL><INDENT>'''<STR_LIT>'''<EOL>assert len(fields) == <NUM_LIT:7><EOL>ai = int(fields[<NUM_LIT:0>])<EOL>aj = int(fields[<NUM_LIT:1>])<EOL>ak = int(fields[<NUM_LIT:2>])<EOL>al = int(fields[<NUM_LIT:3>])<EOL>fu = int(fields[<NUM_LIT:4>])<EOL>assert fu == <NUM_LIT:1><EOL>a = float(fields[<NUM_LIT:5>])<EOL>b = float(fields[<NUM_LIT:6>])<EOL>vs3 = blocks.VirtualSites3Type('<STR_LIT>')<EOL>vs3.atom1 = ai<EOL>vs3.atom2 = aj<EOL>vs3.atom3 = ak<EOL>vs3.atom4 = al<EOL>vs3.gromacs['<STR_LIT>'] = fu<EOL>vs3.gromacs['<STR_LIT>'] = { '<STR_LIT:a>': a, '<STR_LIT:b>':b }<EOL>mol.virtual_sites3.append(vs3)<EOL>_add_info(mol, curr_sec, mol.virtual_sites3)<EOL><DEDENT>elif curr_sec in ('<STR_LIT>',):<EOL><INDENT>ai = int(fields[<NUM_LIT:0>])<EOL>other = list(map(int, fields[<NUM_LIT:1>:]))<EOL>exc = blocks.Exclusion()<EOL>exc.main_atom  = mol.atoms[ai-<NUM_LIT:1>]<EOL>exc.other_atoms= [mol.atoms[k-<NUM_LIT:1>] for k in other]<EOL>mol.exclusions.append(exc)<EOL>_add_info(mol, curr_sec, mol.exclusions)<EOL><DEDENT>elif curr_sec in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>'''<STR_LIT>'''<EOL>ai, aj = fields[:<NUM_LIT:2>]<EOL>fu = int(fields[<NUM_LIT:2>])<EOL>assert fu in (<NUM_LIT:1>,<NUM_LIT:2>)<EOL>cons = blocks.ConstraintType('<STR_LIT>')<EOL>if fu in [<NUM_LIT:1>, <NUM_LIT:2>]:<EOL><INDENT>if curr_sec == '<STR_LIT>':<EOL><INDENT>cons.atype1 = ai<EOL>cons.atype2 = aj<EOL>b0 = float(fields[<NUM_LIT:3>])<EOL>cons.gromacs = {'<STR_LIT>':{'<STR_LIT>':b0}, '<STR_LIT>': fu}<EOL>self.constrainttypes.append(cons)<EOL>_add_info(self, curr_sec, self.constrainttypes)<EOL><DEDENT>elif curr_sec == '<STR_LIT>':<EOL><INDENT>ai, aj = list(map(int, fields[:<NUM_LIT:2>]))<EOL>cons.atom1 = mol.atoms[ai-<NUM_LIT:1>]<EOL>cons.atom2 = mol.atoms[aj-<NUM_LIT:1>]<EOL>cons.gromacs['<STR_LIT>'] = fu<EOL>mol.constraints.append(cons)<EOL>_add_info(mol, curr_sec, mol.constraints)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError<EOL><DEDENT><DEDENT>elif curr_sec in ('<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>'):<EOL><INDENT>pass<EOL><DEDENT>elif curr_sec in ('<STR_LIT>',):<EOL><INDENT>'''<STR_LIT>'''<EOL>pass<EOL><DEDENT>elif curr_sec == '<STR_LIT>':<EOL><INDENT>self.name = fields[<NUM_LIT:0>]<EOL><DEDENT>elif curr_sec == '<STR_LIT>':<EOL><INDENT>assert len(fields) == <NUM_LIT:2><EOL>mname, nmol = fields[<NUM_LIT:0>], int(fields[<NUM_LIT:1>])<EOL>for i in range(nmol):<EOL><INDENT>self.molecules.append(self.dict_molname_mol[mname])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise NotImplementedError('<STR_LIT>'.format(curr_sec))<EOL><DEDENT><DEDENT><DEDENT>curr_cons = None<EOL>for line in cmap_lines:<EOL><INDENT>if len(line.split()) == <NUM_LIT:8>:<EOL><INDENT>cons = blocks.CMapType('<STR_LIT>')<EOL>atype1, atype2, atype3, atype4, atype8, func, sizeX, sizeY = line.replace("<STR_LIT:\\>","<STR_LIT>").split()<EOL>func, sizeX, sizeY = int(func), int(sizeX), int(sizeY)<EOL>cons.atype1 = atype1<EOL>cons.atype2 = atype2<EOL>cons.atype3 = atype3<EOL>cons.atype4 = atype4<EOL>cons.atype8 = atype8<EOL>cons.gromacs = {'<STR_LIT>':[], '<STR_LIT>': func}<EOL>curr_cons = cons<EOL><DEDENT>elif len(line.split()) == <NUM_LIT:10>:<EOL><INDENT>cmap_param = map(float, line.replace("<STR_LIT:\\>","<STR_LIT>").split())<EOL>cons.gromacs['<STR_LIT>'] += cmap_param<EOL><DEDENT>elif len(line.split()) == <NUM_LIT:6>:<EOL><INDENT>cmap_param = map(float, line.replace("<STR_LIT:\\>","<STR_LIT>").split())<EOL>cons.gromacs['<STR_LIT>'] += cmap_param<EOL>self.cmaptypes.append(curr_cons)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError<EOL><DEDENT><DEDENT>

Parse a processed.top GROMACS topology file

        The function reads in the file line-by-line, and it's a bunch of 'elif' statements,
        writing parameter/atom line to current section/molecule.

        ParamTypes are added to self.xyztypes (AtomType goes to self.atomtypes).
        Params are added to current molecule (Atom goes to mol.atoms.append(atom))

        MoleculeTypes and Molecules are odd, and are added to
            * MoleculeType to :attr:`self.dict_molname_mol[mol.name] = mol`
            * Molecule to :attr:`self.molecules.append(self.dict_molname_mol[mname])`

        :obj:`curr_sec` variable stores to current section being read-in
        :obj:`mol` variable stores the current molecule being read-in
        :obj:`cmap_lines` are a little odd, since CMAP parameters are stored on multiple lines

        :Arguments:
          *fname*
              name of the processed.top file

        :Returns: None


def __init__(self, system, outfile="<STR_LIT>", multiple_output=False):

self.logger = logging.getLogger('<STR_LIT>')<EOL>self.logger.debug("<STR_LIT>")<EOL>self.system   = system<EOL>self.outfile = outfile<EOL>self.multiple_output = multiple_output<EOL>self.assemble_topology()<EOL>self.logger.debug("<STR_LIT>")<EOL>

Initialize GROMACS topology writer.

        :Arguments:
          *system*
              :class:`blocks.System` object, containing the topology
          *outfile*
              name of the file to write to
          *multiple_output*
              if True, write moleculetypes to separate files, named mol_MOLNAME.itp (default: False)


self.logger.debug("<STR_LIT>")<EOL>top = '<STR_LIT>'<EOL>self.logger.debug("<STR_LIT>")<EOL>top += self.toptemplate<EOL>top = top.replace('<STR_LIT>',       '<STR_LIT>'.join( self._make_defaults(self.system)) )<EOL>top = top.replace('<STR_LIT>',      '<STR_LIT>'.join( self._make_atomtypes(self.system)) )<EOL>top = top.replace('<STR_LIT>',  '<STR_LIT>'.join( self._make_nonbond_param(self.system)) )<EOL>top = top.replace('<STR_LIT>',      '<STR_LIT>'.join( self._make_pairtypes(self.system)) )<EOL>top = top.replace('<STR_LIT>',      '<STR_LIT>'.join( self._make_bondtypes(self.system)) )<EOL>top = top.replace('<STR_LIT>','<STR_LIT>'.join( self._make_constrainttypes(self.system)))<EOL>top = top.replace('<STR_LIT>',     '<STR_LIT>'.join( self._make_angletypes(self.system)))<EOL>top = top.replace('<STR_LIT>',  '<STR_LIT>'.join( self._make_dihedraltypes(self.system)) )<EOL>top = top.replace('<STR_LIT>',  '<STR_LIT>'.join( self._make_impropertypes(self.system)) )<EOL>top = top.replace('<STR_LIT>',      '<STR_LIT>'.join( self._make_cmaptypes(self.system)) )<EOL>for i,(molname,m) in enumerate(self.system.dict_molname_mol.items()):<EOL><INDENT>itp = self.itptemplate<EOL>itp = itp.replace('<STR_LIT>',  '<STR_LIT>'.join( self._make_moleculetype(m, molname, m.exclusion_numb))  )<EOL>itp = itp.replace('<STR_LIT>',         '<STR_LIT>'.join( self._make_atoms(m))  )<EOL>itp = itp.replace('<STR_LIT>',         '<STR_LIT>'.join( self._make_bonds(m))  )<EOL>itp = itp.replace('<STR_LIT>',         '<STR_LIT>'.join( self._make_pairs(m))  )<EOL>itp = itp.replace('<STR_LIT>',       '<STR_LIT>'.join( self._make_settles(m))  )<EOL>itp = itp.replace('<STR_LIT>','<STR_LIT>'.join( self._make_virtual_sites3(m))  )<EOL>itp = itp.replace('<STR_LIT>',    '<STR_LIT>'.join( self._make_exclusions(m))  )<EOL>itp = itp.replace('<STR_LIT>',        '<STR_LIT>'.join( self._make_angles(m)) )<EOL>itp = itp.replace('<STR_LIT>',     '<STR_LIT>'.join( self._make_dihedrals(m)) )<EOL>itp = itp.replace('<STR_LIT>',     '<STR_LIT>'.join( self._make_impropers(m)) )<EOL>itp = itp.replace('<STR_LIT>',         '<STR_LIT>'.join( self._make_cmaps(m)) )<EOL>if not self.multiple_output:<EOL><INDENT>top += itp<EOL><DEDENT>else:<EOL><INDENT>outfile = "<STR_LIT>".format(molname)<EOL>top += '<STR_LIT>'.format( molname )<EOL>with open(outfile, "<STR_LIT:w>") as f:<EOL><INDENT>f.writelines([itp])<EOL><DEDENT><DEDENT><DEDENT>top += '<STR_LIT>'<EOL>top += '<STR_LIT>'<EOL>molecules = [("<STR_LIT>", <NUM_LIT:0>)]<EOL>for m in self.system.molecules:<EOL><INDENT>if (molecules[-<NUM_LIT:1>][<NUM_LIT:0>] != m.name):<EOL><INDENT>molecules.append([m.name, <NUM_LIT:0>])<EOL><DEDENT>if molecules[-<NUM_LIT:1>][<NUM_LIT:0>] == m.name:<EOL><INDENT>molecules[-<NUM_LIT:1>][<NUM_LIT:1>] += <NUM_LIT:1><EOL><DEDENT><DEDENT>for molname, n in molecules[<NUM_LIT:1>:]:<EOL><INDENT>top += '<STR_LIT>'.format(molname, n)<EOL><DEDENT>top += '<STR_LIT:\n>'<EOL>with open(self.outfile, '<STR_LIT:w>') as f:<EOL><INDENT>f.writelines([top])<EOL><DEDENT>

Call the various member self._make_* functions to convert the topology object into a string


if not isinstance(obj, six.string_types):<EOL><INDENT>return obj<EOL><DEDENT>try:<EOL><INDENT>obj = six.text_type(obj)<EOL><DEDENT>except TypeError:<EOL><INDENT>pass<EOL><DEDENT>return obj<EOL>

Convert obj to unicode (if it can be be converted).

    Conversion is only attempted if `obj` is a string type (as
    determined by :data:`six.string_types`).

    .. versionchanged:: 0.7.0
       removed `encoding keyword argument


x = to_unicode(x)  <EOL>try:<EOL><INDENT>x = x.strip()<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT>m = re.match(r"""<STR_LIT>""", x)<EOL>if m is None:<EOL><INDENT>for converter in int, float, to_unicode:   <EOL><INDENT>try:<EOL><INDENT>return converter(x)<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>x = to_unicode(m.group('<STR_LIT:value>'))<EOL><DEDENT>return x<EOL>

Convert string x to the most useful type, i.e. int, float or unicode string.

    If x is a quoted string (single or double quotes) then the quotes
    are stripped and the enclosed string returned.

    .. Note::

       Strings will be returned as Unicode strings (using :func:`to_unicode`).

    .. versionchanged:: 0.7.0
       removed `encoding keyword argument


<EOL>def promote_i4(typestr):<EOL><INDENT>if typestr[<NUM_LIT:1>:] == '<STR_LIT>':<EOL><INDENT>typestr = typestr[<NUM_LIT:0>]+'<STR_LIT>'<EOL><DEDENT>return typestr<EOL><DEDENT>dtype = [(name, promote_i4(typestr)) for name,typestr in a.dtype.descr]<EOL>return a.astype(dtype)<EOL>

Return view of the recarray with all int32 cast to int64.


pytypes = [pyify(typestr) for name,typestr in a.dtype.descr]<EOL>def convert_record(r):<EOL><INDENT>return tuple([converter(value) for converter, value in zip(pytypes,r)])<EOL><DEDENT>return (convert_record(r) for r in a)<EOL>

Slow conversion of a recarray into a list of records with python types.

    Get the field names from :attr:`a.dtype.names`.

    :Returns: iterator so that one can handle big input arrays


def __init__(self, mode="<STR_LIT>",  mapping=None, active=True, sep=False, **kwargs):

self._convertors = {'<STR_LIT>': to_unicode,<EOL>'<STR_LIT>': besttype,<EOL>'<STR_LIT>': self._convert_singlet,<EOL>'<STR_LIT>': self._convert_fancy,<EOL>}<EOL>self.convert = None  <EOL>if mapping is None:<EOL><INDENT>mapping = {'<STR_LIT>': None, '<STR_LIT>':None,<EOL>'<STR_LIT:True>':True, '<STR_LIT:x>': True, '<STR_LIT:X>':True, '<STR_LIT:yes>':True, '<STR_LIT>':True, '<STR_LIT>':True,<EOL>'<STR_LIT:False>':False, '<STR_LIT>': False, '<STR_LIT:->':False, '<STR_LIT:None>':False, '<STR_LIT:none>':False, }<EOL><DEDENT>self.mapping = mapping<EOL>self.mode = mode<EOL>self.__active = None<EOL>self.active = kwargs.pop('<STR_LIT>', active)   <EOL>if sep is True:<EOL><INDENT>sep = None   <EOL><DEDENT>self.sep = sep<EOL>

Initialize the converter.

        :Arguments:
          *mode*
             defines what the converter does

                "simple"
                    convert entries with :func:`besttype`
                "singlet"
                    convert entries with :func:`besttype` and apply
                    mappings
                "fancy"
                    first splits fields into lists, tries mappings,
                    and does the stuff that "singlet" does
                "unicode"
                    convert all entries with :func:`to_unicode`

          *mapping*
              any dict-like mapping that supports lookup. If``None`` then the
              hard-coded defaults are used

          *active* or *autoconvert*
              initial state of the :attr:`Autoconverter.active` toggle.
              ``False`` deactivates any conversion. [``True``]

          *sep*
              character to split on (produces lists); use ``True`` or ``None``
              (!) to split on all white space.

        .. versionchanged:: 0.7.0
           removed `encoding keyword argument


if self.sep is False:<EOL><INDENT>x = self._convert_singlet(field)<EOL><DEDENT>else:<EOL><INDENT>x = tuple([self._convert_singlet(s) for s in field.split(self.sep)])<EOL>if len(x) == <NUM_LIT:0>:<EOL><INDENT>x = '<STR_LIT>'<EOL><DEDENT>elif len(x) == <NUM_LIT:1>:<EOL><INDENT>x = x[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>return x<EOL>

Convert to a list (sep != None) and convert list elements.


def break_array(a, threshold=numpy.pi, other=None):

assert len(a.shape) == <NUM_LIT:1>, "<STR_LIT>"<EOL>if other is not None and a.shape != other.shape:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>breaks = numpy.where(numpy.abs(numpy.diff(a)) >= threshold)[<NUM_LIT:0>]<EOL>breaks += <NUM_LIT:1><EOL>m = len(breaks)<EOL>b = numpy.empty((len(a) + m))<EOL>b_breaks = breaks + numpy.arange(m)<EOL>mask =  numpy.zeros_like(b, dtype=numpy.bool)<EOL>mask[b_breaks] = True<EOL>b[~mask] = a<EOL>b[mask] = numpy.NAN<EOL>if other is not None:<EOL><INDENT>c = numpy.empty_like(b)<EOL>c[~mask] = other<EOL>c[mask] = numpy.NAN<EOL>ma_c = numpy.ma.array(c, mask=mask)<EOL><DEDENT>else:<EOL><INDENT>ma_c = None<EOL><DEDENT>return numpy.ma.array(b, mask=mask), ma_c<EOL>

Create a array which masks jumps >= threshold.

    Extra points are inserted between two subsequent values whose
    absolute difference differs by more than threshold (default is
    pi).

    Other can be a secondary array which is also masked according to
    *a*.

    Returns (*a_masked*, *other_masked*) (where *other_masked* can be
    ``None``)


def __init__(self, filename=None, names=None, array=None, permissive=False, **kwargs):

self.__array = None           <EOL>self.__cache = {}             <EOL>self.savedata = kwargs.pop('<STR_LIT>', False)<EOL>if filename is not None:<EOL><INDENT>self._init_filename(filename)  <EOL><DEDENT>if names is None:<EOL><INDENT>self.names = []<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>self.names = names.split('<STR_LIT:U+002C>')<EOL><DEDENT>except AttributeError:<EOL><INDENT>self.names = names<EOL><DEDENT><DEDENT>self.metadata = kwargs.pop('<STR_LIT>', {})  <EOL>self.permissive = permissive<EOL>self.stride = kwargs.pop('<STR_LIT>', <NUM_LIT:1>)<EOL>self.corrupted_lineno = None      <EOL>self.ncorrel = kwargs.pop('<STR_LIT>', <NUM_LIT>)<EOL>self.__correlkwargs = {}          <EOL>if array is not None:<EOL><INDENT>self.set(array)<EOL><DEDENT>

Initialize the class from a xvg file.

        :Arguments:
              *filename*
                    is the xvg file; it can only be of type XY or
                    NXY. If it is supplied then it is read and parsed
                    when :attr:`XVG.array` is accessed.
              *names*
                    optional labels for the columns (currently only
                    written as comments to file); string with columns
                    separated by commas or a list of strings
              *array*
                    read data from *array* (see :meth:`XVG.set`)
              *permissive*
                    ``False`` raises a :exc:`ValueError` and logs and errior
                    when encountering data lines that it cannot parse.
                    ``True`` ignores those lines and logs a warning---this is
                    a risk because it might read a corrupted input file [``False``]
              *stride*
                    Only read every *stride* line of data [1].
              *savedata*
                    ``True`` includes the data (:attr:`XVG.array`` and
                    associated caches) when the instance is pickled (see
                    :mod:`pickle`); this is oftens not desirable because the
                    data are already on disk (the xvg file *filename*) and the
                    resulting pickle file can become very big. ``False`` omits
                    those data from a pickle. [``False``]
              *metadata*
                    dictionary of metadata, which is not touched by the class


self._init_filename(filename)<EOL>self.parse()<EOL>


self._init_filename(filename)<EOL>with utilities.openany(self.real_filename, '<STR_LIT:w>') as xvg:<EOL><INDENT>xvg.write("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>xvg.write("<STR_LIT>".format(self.names))<EOL>for xyy in self.array.T:<EOL><INDENT>xyy.tofile(xvg, sep="<STR_LIT:U+0020>", format="<STR_LIT>")  <EOL>xvg.write('<STR_LIT:\n>')<EOL><DEDENT><DEDENT>

Write array to xvg file *filename* in NXY format.

        .. Note:: Only plain files working at the moment, not compressed.


if self.__array is None:<EOL><INDENT>self.parse()<EOL><DEDENT>return self.__array<EOL>

Represent xvg data as a (cached) numpy array.

        The array is returned with column-first indexing, i.e. for a data file with
        columns X Y1 Y2 Y3 ... the array a will be a[0] = X, a[1] = Y1, ... .


a = self.array<EOL>return numpy.ma.MaskedArray(a, mask=numpy.logical_not(numpy.isfinite(a)))<EOL>

Represent data as a masked array.

        The array is returned with column-first indexing, i.e. for a data file with
        columns X Y1 Y2 Y3 ... the array a will be a[0] = X, a[1] = Y1, ... .

        inf and nan are filtered via :func:`numpy.isfinite`.


return self.array[<NUM_LIT:1>:].mean(axis=<NUM_LIT:1>)<EOL>


return self.array[<NUM_LIT:1>:].std(axis=<NUM_LIT:1>)<EOL>

Standard deviation from the mean of all data columns.


return self.array[<NUM_LIT:1>:].min(axis=<NUM_LIT:1>)<EOL>


return self.array[<NUM_LIT:1>:].max(axis=<NUM_LIT:1>)<EOL>


def _tcorrel(self, nstep=<NUM_LIT:100>, **kwargs):

t = self.array[<NUM_LIT:0>,::nstep]<EOL>r = gromacs.collections.Collection([numkit.timeseries.tcorrel(t, Y, nstep=<NUM_LIT:1>, **kwargs) for Y in self.array[<NUM_LIT:1>:,::nstep]])<EOL>return r<EOL>

Correlation "time" of data.

        The 0-th column of the data is interpreted as a time and the
        decay of the data is computed from the autocorrelation
        function (using FFT).

        .. SeeAlso:: :func:`numkit.timeseries.tcorrel`


self.ncorrel = kwargs.pop('<STR_LIT>', self.ncorrel) or <NUM_LIT><EOL>nstep = kwargs.pop('<STR_LIT>', None)<EOL>if nstep is None:<EOL><INDENT>nstep = len(self.array[<NUM_LIT:0>])/float(self.ncorrel)<EOL>nstep = int(numpy.ceil(nstep))  <EOL><DEDENT>kwargs['<STR_LIT>'] = nstep<EOL>self.__correlkwargs.update(kwargs)  <EOL>return self.__correlkwargs<EOL>

Set and change the parameters for calculations with  correlation functions.

        The parameters persist until explicitly changed.

        :Keywords:
           *nstep*
               only process every *nstep* data point to speed up the FFT; if
               left empty a default is chosen that produces roughly 25,000 data
               points (or whatever is set in *ncorrel*)
           *ncorrel*
               If no *nstep* is supplied, aim at using *ncorrel* data points for
               the FFT; sets :attr:`XVG.ncorrel` [25000]
           *force*
               force recalculating correlation data even if cached values are
               available
           *kwargs*
               see :func:`numkit.timeseries.tcorrel` for other options

        .. SeeAlso: :attr:`XVG.error` for details and references.


return self._correlprop('<STR_LIT>')<EOL>

Error on the mean of the data, taking the correlation time into account.

        See [FrenkelSmit2002]_ `p526`_:

           error = sqrt(2*tc*acf[0]/T)

        where acf() is the autocorrelation function of the fluctuations around
        the mean, y-<y>, tc is the correlation time, and T the total length of
        the simulation.

        .. [FrenkelSmit2002] D. Frenkel and B. Smit, Understanding
                             Molecular Simulation. Academic Press, San
                             Diego 2002

        .. _p526: http://books.google.co.uk/books?id=XmyO2oRUg0cC&pg=PA526


Correlation time of the data.

        See :meth:`XVG.error` for details.


if stride is None:<EOL><INDENT>stride = self.stride<EOL><DEDENT>self.corrupted_lineno = []<EOL>irow  = <NUM_LIT:0>  <EOL>with utilities.openany(self.real_filename) as xvg:<EOL><INDENT>rows = []<EOL>ncol = None<EOL>for lineno,line in enumerate(xvg):<EOL><INDENT>line = line.strip()<EOL>if len(line) == <NUM_LIT:0>:<EOL><INDENT>continue<EOL><DEDENT>if "<STR_LIT:label>" in line and "<STR_LIT>" in line:<EOL><INDENT>self.xaxis = line.split('<STR_LIT:">')[-<NUM_LIT:2>]<EOL><DEDENT>if "<STR_LIT:label>" in line and "<STR_LIT>" in line:<EOL><INDENT>self.yaxis = line.split('<STR_LIT:">')[-<NUM_LIT:2>]<EOL><DEDENT>if line.startswith("<STR_LIT>"):<EOL><INDENT>if not "<STR_LIT>" in self.metadata: self.metadata["<STR_LIT>"] = []<EOL>self.metadata["<STR_LIT>"].append(line.split("<STR_LIT>")[-<NUM_LIT:1>])<EOL><DEDENT>if line.startswith("<STR_LIT>") and "<STR_LIT>" not in line:<EOL><INDENT>name = line.split("<STR_LIT>")[-<NUM_LIT:1>].replace('<STR_LIT:">','<STR_LIT>').strip()<EOL>self.names.append(name)<EOL><DEDENT>if line.startswith(('<STR_LIT:#>', '<STR_LIT:@>')) :<EOL><INDENT>continue<EOL><DEDENT>if line.startswith('<STR_LIT:&>'):<EOL><INDENT>raise NotImplementedError('<STR_LIT>'.format(self.real_filename))<EOL><DEDENT>try:<EOL><INDENT>row = [float(el) for el in line.split()]<EOL><DEDENT>except:<EOL><INDENT>if self.permissive:<EOL><INDENT>self.logger.warn("<STR_LIT>",<EOL>self.real_filename, lineno+<NUM_LIT:1>, line)<EOL>self.corrupted_lineno.append(lineno+<NUM_LIT:1>)<EOL>continue<EOL><DEDENT>self.logger.error("<STR_LIT>",<EOL>self.real_filename, lineno+<NUM_LIT:1>, line)<EOL>raise<EOL><DEDENT>if ncol is not None and len(row) != ncol:<EOL><INDENT>if self.permissive:<EOL><INDENT>self.logger.warn("<STR_LIT>",<EOL>self.real_filename, lineno+<NUM_LIT:1>, line)<EOL>self.corrupted_lineno.append(lineno+<NUM_LIT:1>)<EOL>continue<EOL><DEDENT>errmsg = "<STR_LIT>".format(self.real_filename, lineno+<NUM_LIT:1>, line)<EOL>self.logger.error(errmsg)<EOL>raise IOError(errno.ENODATA, errmsg, self.real_filename)<EOL><DEDENT>if irow % stride == <NUM_LIT:0>:<EOL><INDENT>ncol = len(row)<EOL>rows.append(row)<EOL><DEDENT>irow += <NUM_LIT:1><EOL><DEDENT><DEDENT>try:<EOL><INDENT>self.__array = numpy.array(rows).transpose()    <EOL><DEDENT>except:<EOL><INDENT>self.logger.error("<STR_LIT>"<EOL>"<STR_LIT>", self.real_filename)<EOL>raise<EOL><DEDENT>finally:<EOL><INDENT>del rows<EOL><DEDENT>

Read and cache the file as a numpy array.

        Store every *stride* line of data; if ``None`` then the class default is used.

        The array is returned with column-first indexing, i.e. for a data file with
        columns X Y1 Y2 Y3 ... the array a will be a[0] = X, a[1] = Y1, ... .


self.__array = numpy.asarray(a)<EOL>

Set the *array* data from *a* (i.e. completely replace).

        No sanity checks at the moment...


columns = kwargs.pop('<STR_LIT>', Ellipsis)         <EOL>maxpoints = kwargs.pop('<STR_LIT>', self.maxpoints_default)<EOL>transform = kwargs.pop('<STR_LIT>', lambda x: x)  <EOL>method = kwargs.pop('<STR_LIT>', "<STR_LIT>")<EOL>ax = kwargs.pop('<STR_LIT>', None)<EOL>if columns is Ellipsis or columns is None:<EOL><INDENT>columns = numpy.arange(self.array.shape[<NUM_LIT:0>])<EOL><DEDENT>if len(columns) == <NUM_LIT:0>:<EOL><INDENT>raise MissingDataError("<STR_LIT>")<EOL><DEDENT>if len(self.array.shape) == <NUM_LIT:1> or self.array.shape[<NUM_LIT:0>] == <NUM_LIT:1>:<EOL><INDENT>a = numpy.ravel(self.array)<EOL>X = numpy.arange(len(a))<EOL>a = numpy.vstack((X, a))<EOL>columns = [<NUM_LIT:0>] + [c+<NUM_LIT:1> for c in columns]<EOL><DEDENT>else:<EOL><INDENT>a = self.array<EOL><DEDENT>color = kwargs.pop('<STR_LIT>', self.default_color_cycle)<EOL>try:<EOL><INDENT>cmap = matplotlib.cm.get_cmap(color)<EOL>colors = cmap(matplotlib.colors.Normalize()(numpy.arange(len(columns[<NUM_LIT:1>:]), dtype=float)))<EOL><DEDENT>except TypeError:<EOL><INDENT>colors = cycle(utilities.asiterable(color))<EOL><DEDENT>if ax is None:<EOL><INDENT>ax = plt.gca()<EOL><DEDENT>a = self.decimate(method, numpy.asarray(transform(a))[columns], maxpoints=maxpoints)<EOL>ma = numpy.ma.MaskedArray(a, mask=numpy.logical_not(numpy.isfinite(a)))<EOL>for column, color in zip(range(<NUM_LIT:1>,len(columns)), colors):<EOL><INDENT>if len(ma[column]) == <NUM_LIT:0>:<EOL><INDENT>warnings.warn("<STR_LIT>".format(**vars()), category=MissingDataWarning)<EOL><DEDENT>kwargs['<STR_LIT>'] = color<EOL>ax.plot(ma[<NUM_LIT:0>], ma[column], **kwargs)   <EOL><DEDENT>return ax<EOL>

Plot xvg file data.

        The first column of the data is always taken as the abscissa
        X. Additional columns are plotted as ordinates Y1, Y2, ...

        In the special case that there is only a single column then this column
        is plotted against the index, i.e. (N, Y).

        :Keywords:
          *columns* : list
               Select the columns of the data to be plotted; the list
               is used as a numpy.array extended slice. The default is
               to use all columns. Columns are selected *after* a transform.
          *transform* : function
               function ``transform(array) -> array`` which transforms
               the original array; must return a 2D numpy array of
               shape [X, Y1, Y2, ...] where X, Y1, ... are column
               vectors.  By default the transformation is the
               identity [``lambda x: x``].
          *maxpoints* : int
               limit the total number of data points; matplotlib has issues processing
               png files with >100,000 points and pdfs take forever to display. Set to
               ``None`` if really all data should be displayed. At the moment we simply
               decimate the data at regular intervals. [10000]
          *method*
               method to decimate the data to *maxpoints*, see :meth:`XVG.decimate`
               for details
          *color*
               single color (used for all plots); sequence of colors
               (will be repeated as necessary); or a matplotlib
               colormap (e.g. "jet", see :mod:`matplotlib.cm`). The
               default is to use the :attr:`XVG.default_color_cycle`.
          *ax*
               plot into given axes or create new one if ``None`` [``None``]
          *kwargs*
               All other keyword arguments are passed on to :func:`matplotlib.pyplot.plot`.

        :Returns:
          *ax*
               axes instance


ax = kwargs.pop('<STR_LIT>', None)<EOL>columns = kwargs.pop('<STR_LIT>', Ellipsis)         <EOL>if columns is Ellipsis or columns is None:<EOL><INDENT>columns = numpy.arange(self.array.shape[<NUM_LIT:0>])<EOL><DEDENT>if len(columns) < <NUM_LIT:2>:<EOL><INDENT>raise MissingDataError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>color = kwargs.pop('<STR_LIT>', self.default_color_cycle)<EOL>try:<EOL><INDENT>cmap = matplotlib.cm.get_cmap(color)<EOL>colors = cmap(matplotlib.colors.Normalize()(numpy.arange(len(columns[<NUM_LIT:1>:]), dtype=float)))<EOL><DEDENT>except TypeError:<EOL><INDENT>colors = cycle(utilities.asiterable(color))<EOL><DEDENT>if ax is None:<EOL><INDENT>ax = plt.gca()<EOL><DEDENT>t = columns[<NUM_LIT:0>]<EOL>kwargs['<STR_LIT>'] = True<EOL>kwargs['<STR_LIT>'] = ax<EOL>for column, color in zip(columns[<NUM_LIT:1>:], colors):<EOL><INDENT>kwargs['<STR_LIT>'] = color<EOL>self.errorbar(columns=[t, column, column], **kwargs)<EOL><DEDENT>return ax<EOL>

Plot data like :meth:`XVG.plot` with the range of **all** data shown.

        Data are reduced to *maxpoints* (good results are obtained
        with low values such as 100) and the actual range of observed
        data is plotted as a translucent error band around the mean.

        Each column in *columns* (except the abscissa, i.e. the first
        column) is decimated (with :meth:`XVG.decimate`) and the range
        of data is plotted alongside the mean using
        :meth:`XVG.errorbar` (see for arguments). Additional
        arguments:

        :Kewords:
           *maxpoints*
                number of points (bins) to coarsen over
           *color*
                single color (used for all plots); sequence of colors
                (will be repeated as necessary); or a matplotlib
                colormap (e.g. "jet", see :mod:`matplotlib.cm`). The
                default is to use the :attr:`XVG.default_color_cycle`.
           *method*
                Method to coarsen the data. See :meth:`XVG.decimate`

        The *demean* keyword has no effect as it is required to be ``True``.

        .. SeeAlso:: :meth:`XVG.plot`, :meth:`XVG.errorbar` and :meth:`XVG.decimate`


ax = kwargs.pop('<STR_LIT>', None)<EOL>color = kwargs.pop('<STR_LIT>', '<STR_LIT>')<EOL>filled = kwargs.pop('<STR_LIT>', True)<EOL>fill_alpha = kwargs.pop('<STR_LIT>', <NUM_LIT>)<EOL>kwargs.setdefault('<STR_LIT>', <NUM_LIT:0>)<EOL>kwargs.setdefault('<STR_LIT>', <NUM_LIT:1>)<EOL>kwargs.setdefault('<STR_LIT>', color)<EOL>kwargs.setdefault('<STR_LIT>', <NUM_LIT>)<EOL>kwargs.setdefault('<STR_LIT>', None)<EOL>columns = kwargs.pop('<STR_LIT>', Ellipsis)         <EOL>maxpoints = kwargs.pop('<STR_LIT>', self.maxpoints_default)<EOL>transform = kwargs.pop('<STR_LIT>', lambda x: x)  <EOL>method = kwargs.pop('<STR_LIT>', "<STR_LIT>")<EOL>if method != "<STR_LIT>":<EOL><INDENT>raise NotImplementedError("<STR_LIT>")<EOL><DEDENT>error_method = kwargs.pop('<STR_LIT>', "<STR_LIT>")  <EOL>percentile = numpy.abs(kwargs.pop('<STR_LIT>', <NUM_LIT>))<EOL>demean = kwargs.pop('<STR_LIT>', False)<EOL>try:<EOL><INDENT>data = numpy.asarray(transform(self.array))[columns]<EOL><DEDENT>except IndexError:<EOL><INDENT>raise MissingDataError("<STR_LIT>".format(columns))<EOL><DEDENT>if data.shape[-<NUM_LIT:1>] == <NUM_LIT:0>:<EOL><INDENT>raise MissingDataError("<STR_LIT>")<EOL><DEDENT>a = numpy.zeros((data.shape[<NUM_LIT:0>], maxpoints), dtype=numpy.float64)<EOL>a[<NUM_LIT:0>:<NUM_LIT:2>] = self.decimate("<STR_LIT>", data[<NUM_LIT:0>:<NUM_LIT:2>], maxpoints=maxpoints)<EOL>error_data = numpy.vstack((data[<NUM_LIT:0>], data[<NUM_LIT:2>:]))<EOL>if error_method == "<STR_LIT>":<EOL><INDENT>if percentile > <NUM_LIT:50>:<EOL><INDENT>upper_per = percentile<EOL>lower_per = <NUM_LIT:100> - percentile<EOL><DEDENT>else:<EOL><INDENT>upper_per = <NUM_LIT:100> - percentile<EOL>lower_per = percentile<EOL><DEDENT>upper = a[<NUM_LIT:2>:] = self.decimate("<STR_LIT>", error_data, maxpoints=maxpoints,<EOL>per=upper_per, demean=False)[<NUM_LIT:1>:]<EOL>lower = self.decimate("<STR_LIT>", error_data, maxpoints=maxpoints,<EOL>per=lower_per, demean=False)[<NUM_LIT:1>:]<EOL><DEDENT>else:<EOL><INDENT>a[<NUM_LIT:2>:] = self.decimate(error_method, error_data, maxpoints=maxpoints, demean=demean)[<NUM_LIT:1>:]<EOL>lower = None<EOL><DEDENT>ma = numpy.ma.MaskedArray(a, mask=numpy.logical_not(numpy.isfinite(a)))<EOL>if lower is not None:<EOL><INDENT>mlower = numpy.ma.MaskedArray(lower, mask=numpy.logical_not(numpy.isfinite(lower)))<EOL><DEDENT>X = ma[<NUM_LIT:0>]          <EOL>Y = ma[<NUM_LIT:1>]<EOL>try:<EOL><INDENT>kwargs['<STR_LIT>'] = ma[<NUM_LIT:3>]<EOL>kwargs['<STR_LIT>'] = ma[<NUM_LIT:2>]<EOL><DEDENT>except IndexError:<EOL><INDENT>try:<EOL><INDENT>kwargs['<STR_LIT>'] = ma[<NUM_LIT:2>]<EOL><DEDENT>except IndexError:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT><DEDENT>if ax is None:<EOL><INDENT>ax = plt.gca()<EOL><DEDENT>if filled:<EOL><INDENT>if error_method == "<STR_LIT>":<EOL><INDENT>if demean:<EOL><INDENT>y1 = mlower[-<NUM_LIT:1>]<EOL>y2 = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>y1 = Y - mlower[-<NUM_LIT:1>]<EOL>y2 = Y + kwargs['<STR_LIT>']<EOL><DEDENT><DEDENT>else:<EOL><INDENT>y1 = Y - kwargs['<STR_LIT>']<EOL>y2 = Y + kwargs['<STR_LIT>']<EOL><DEDENT>ax.fill_between(X, y1, y2, color=color, alpha=fill_alpha)<EOL><DEDENT>else:<EOL><INDENT>if error_method == "<STR_LIT>":<EOL><INDENT>if demean:<EOL><INDENT>kwargs['<STR_LIT>'] = numpy.vstack((mlower[-<NUM_LIT:1>], kwargs['<STR_LIT>']))<EOL><DEDENT>else:<EOL><INDENT>kwargs['<STR_LIT>'] = numpy.vstack((Y - mlower[-<NUM_LIT:1>], Y + kwargs['<STR_LIT>']))<EOL><DEDENT>try:<EOL><INDENT>kwargs['<STR_LIT>'] = numpy.vstack((X - mlower[<NUM_LIT:0>], X + kwargs['<STR_LIT>']))<EOL><DEDENT>except (KeyError, IndexError):<EOL><INDENT>pass<EOL><DEDENT><DEDENT>ax.errorbar(X, Y, **kwargs)<EOL><DEDENT>for kw in "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>":<EOL><INDENT>kwargs.pop(kw, None)<EOL><DEDENT>kwargs['<STR_LIT>'] = <NUM_LIT:1.0><EOL>ax.plot(X, Y, color=color, **kwargs)<EOL>return ax<EOL>

errorbar plot for a single time series with errors.

        Set *columns* keyword to select [x, y, dy] or [x, y, dx, dy],
        e.g. ``columns=[0,1,2]``. See :meth:`XVG.plot` for
        details. Only a single timeseries can be plotted and the user
        needs to select the appropriate columns with the *columns*
        keyword.

        By default, the data are decimated (see :meth:`XVG.plot`) for
        the default of *maxpoints* = 10000 by averaging data in
        *maxpoints* bins.

        x,y,dx,dy data can plotted with error bars in the x- and
        y-dimension (use *filled* = ``False``).

        For x,y,dy use *filled* = ``True`` to fill the region between
        y±dy. *fill_alpha* determines the transparency of the fill
        color. *filled* = ``False`` will draw lines for the error
        bars. Additional keywords are passed to
        :func:`pylab.errorbar`.

        By default, the errors are decimated by plotting the 5% and
        95% percentile of the data in each bin. The percentile can be
        changed with the *percentile* keyword; e.g. *percentile* = 1
        will plot the 1% and 99% perentile (as will *percentile* =
        99).

        The *error_method* keyword can be used to compute errors as
        the root mean square sum (*error_method* = "rms") across each
        bin instead of percentiles ("percentile"). The value of the
        keyword *demean* is applied to the decimation of error data
        alone.

        .. SeeAlso::

           :meth:`XVG.plot` lists keywords common to both methods.


def decimate(self, method, a, maxpoints=<NUM_LIT>, **kwargs):

methods = {'<STR_LIT>': self.decimate_mean,<EOL>'<STR_LIT>': self.decimate_min,<EOL>'<STR_LIT>': self.decimate_max,<EOL>'<STR_LIT>': self.decimate_smooth,<EOL>'<STR_LIT>': self.decimate_rms,<EOL>'<STR_LIT>': self.decimate_percentile,<EOL>'<STR_LIT:error>': self.decimate_error,  <EOL>'<STR_LIT>': self.decimate_circmean,<EOL>}<EOL>if len(a.shape) == <NUM_LIT:1>:<EOL><INDENT>X = numpy.arange(len(a))<EOL>a = numpy.vstack([X, a])<EOL><DEDENT>ny = a.shape[-<NUM_LIT:1>]   <EOL>if maxpoints is None or ny <= maxpoints:<EOL><INDENT>return a<EOL><DEDENT>return methods[method](a, maxpoints, **kwargs)<EOL>

Decimate data *a* to *maxpoints* using *method*.

        If *a* is a 1D array then it is promoted to a (2, N) array
        where the first column simply contains the index.

        If the array contains fewer than *maxpoints* points or if
        *maxpoints* is ``None`` then it is returned as it is. The
        default for *maxpoints* is 10000.

        Valid values for the reduction *method*:

          * "mean", uses :meth:`XVG.decimate_mean` to coarse grain by
            averaging the data in bins along the time axis

          * "circmean", uses :meth:`XVG.decimate_circmean` to coarse
            grain by calculating the circular mean of the data in bins
            along the time axis. Use additional keywords *low* and
            *high* to set the limits. Assumes that the data are in
            degrees.

          * "min" and "max* select the extremum in each bin

          * "rms", uses :meth:`XVG.decimate_rms` to coarse grain by
            computing the root mean square sum of the data in bins
            along the time axis (for averaging standard deviations and
            errors)

          * "percentile" with keyword *per*: :meth:`XVG.decimate_percentile`
            reduces data in each bin to the percentile *per*

          * "smooth", uses :meth:`XVG.decimate_smooth` to subsample
            from a smoothed function (generated with a running average
            of the coarse graining step size derived from the original
            number of data points and *maxpoints*)

        :Returns: numpy array ``(M', N')`` from a ``(M', N)`` array
                  with ``M' == M`` (except when ``M == 1``, see above)
                  and ``N' <= N`` (``N'`` is *maxpoints*).


def decimate_mean(self, a, maxpoints, **kwargs):

return self._decimate(numkit.timeseries.mean_histogrammed_function, a, maxpoints, **kwargs)<EOL>

Return data *a* mean-decimated on *maxpoints*.

        Histograms each column into *maxpoints* bins and calculates
        the weighted average in each bin as the decimated data, using
        :func:`numkit.timeseries.mean_histogrammed_function`. The coarse grained
        time in the first column contains the centers of the histogram
        time.

        If *a* contains <= *maxpoints* then *a* is simply returned;
        otherwise a new array of the same dimensions but with a
        reduced number of  *maxpoints* points is returned.

        .. Note::

           Assumes that the first column is time.


def decimate_circmean(self, a, maxpoints, **kwargs):

a_rad = numpy.vstack((a[<NUM_LIT:0>], numpy.deg2rad(a[<NUM_LIT:1>:])))<EOL>b = self._decimate(numkit.timeseries.circmean_histogrammed_function, a_rad, maxpoints, **kwargs)<EOL>y_ma, x_ma = break_array(b[<NUM_LIT:1>], threshold=numpy.pi, other=b[<NUM_LIT:0>])<EOL>v = [y_ma]<EOL>for y in b[<NUM_LIT:2>:]:<EOL><INDENT>v.append(break_array(y, threshold=numpy.pi)[<NUM_LIT:0>])<EOL>if v[-<NUM_LIT:1>].shape != v[<NUM_LIT:0>].shape:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>return numpy.vstack((x_ma, numpy.rad2deg(v)))<EOL>

Return data *a* circmean-decimated on *maxpoints*.

        Histograms each column into *maxpoints* bins and calculates
        the weighted circular mean in each bin as the decimated data,
        using
        :func:`numkit.timeseries.circmean_histogrammed_function`. The
        coarse grained time in the first column contains the centers
        of the histogram time.

        If *a* contains <= *maxpoints* then *a* is simply returned;
        otherwise a new array of the same dimensions but with a
        reduced number of  *maxpoints* points is returned.

        Keywords *low* and *high* can be used to set the
        boundaries. By default they are [-pi, +pi].

        This method returns a **masked** array where jumps are flagged
        by an insertion of a masked point.

        .. Note::

           Assumes that the first column is time and that the data are
           in **degrees**.

        .. Warning::

           Breaking of arrays only works properly with a two-column
           array because breaks are only inserted in the x-column
           (a[0]) where y1 = a[1] has a break.


def decimate_min(self, a, maxpoints, **kwargs):

return self._decimate(numkit.timeseries.min_histogrammed_function, a, maxpoints, **kwargs)<EOL>

Return data *a* min-decimated on *maxpoints*.

        Histograms each column into *maxpoints* bins and calculates
        the minimum in each bin as the decimated data, using
        :func:`numkit.timeseries.min_histogrammed_function`. The coarse grained
        time in the first column contains the centers of the histogram
        time.

        If *a* contains <= *maxpoints* then *a* is simply returned;
        otherwise a new array of the same dimensions but with a
        reduced number of  *maxpoints* points is returned.

        .. Note::

           Assumes that the first column is time.


def decimate_max(self, a, maxpoints, **kwargs):

return self._decimate(numkit.timeseries.max_histogrammed_function, a, maxpoints, **kwargs)<EOL>

Return data *a* max-decimated on *maxpoints*.

        Histograms each column into *maxpoints* bins and calculates
        the maximum in each bin as the decimated data, using
        :func:`numkit.timeseries.max_histogrammed_function`. The coarse grained
        time in the first column contains the centers of the histogram
        time.

        If *a* contains <= *maxpoints* then *a* is simply returned;
        otherwise a new array of the same dimensions but with a
        reduced number of  *maxpoints* points is returned.

        .. Note::

           Assumes that the first column is time.


def decimate_rms(self, a, maxpoints, **kwargs):

return self._decimate(numkit.timeseries.rms_histogrammed_function, a, maxpoints, **kwargs)<EOL>

Return data *a* rms-decimated on *maxpoints*.

        Histograms each column into *maxpoints* bins and calculates
        the root mean square sum in each bin as the decimated data,
        using :func:`numkit.timeseries.rms_histogrammed_function`. The coarse
        grained time in the first column contains the centers of the
        histogram time.

        If *a* contains <= *maxpoints* then *a* is simply returned;
        otherwise a new array of the same dimensions but with a
        reduced number of  *maxpoints* points is returned.

        .. Note::

           Assumes that the first column is time.


def decimate_percentile(self, a, maxpoints, **kwargs):

return self._decimate(numkit.timeseries.percentile_histogrammed_function, a, maxpoints, **kwargs)<EOL>

Return data *a* percentile-decimated on *maxpoints*.

        Histograms each column into *maxpoints* bins and calculates
        the percentile *per* in each bin as the decimated data, using
        :func:`numkit.timeseries.percentile_histogrammed_function`. The
        coarse grained time in the first column contains the centers
        of the histogram time.

        If *a* contains <= *maxpoints* then *a* is simply returned;
        otherwise a new array of the same dimensions but with a
        reduced number of  *maxpoints* points is returned.

        .. Note::

           Assumes that the first column is time.

        :Keywords:

        *per*
            percentile as a percentage, e.g. 75 is the value that splits
            the data into the lower 75% and upper 25%; 50 is the median [50.0]

        .. SeeAlso:: :func:`numkit.timeseries.regularized_function` with :func:`scipy.stats.scoreatpercentile`


def decimate_error(self, a, maxpoints, **kwargs):

warnings.warn("<STR_LIT>",<EOL>category=gromacs.exceptions.LowAccuracyWarning)<EOL>return self._decimate(numkit.timeseries.error_histogrammed_function, a,<EOL>maxpoints, **kwargs)<EOL>

Return data *a* error-decimated on *maxpoints*.

        Histograms each column into *maxpoints* bins and calculates an
        error estimate in each bin as the decimated data, using
        :func:`numkit.timeseries.error_histogrammed_function`. The
        coarse grained time in the first column contains the centers
        of the histogram time.

        If *a* contains <= *maxpoints* then *a* is simply returned;
        otherwise a new array of the same dimensions but with a
        reduced number of  *maxpoints* points is returned.

        .. SeeAlso:: :func:`numkit.timeseries.tcorrel`

        .. Note::

           Assumes that the first column is time.

           Does not work very well because often there are too few
           datapoints to compute a good autocorrelation function.


def decimate_smooth(self, a, maxpoints, window="<STR_LIT>"):

ny = a.shape[-<NUM_LIT:1>]   <EOL>stepsize = int(ny / maxpoints)<EOL>if stepsize % <NUM_LIT:2> == <NUM_LIT:0>:<EOL><INDENT>stepsize += <NUM_LIT:1>  <EOL><DEDENT>out = numpy.empty_like(a)<EOL>out[<NUM_LIT:0>,:] = a[<NUM_LIT:0>]<EOL>for i in range(<NUM_LIT:1>, a.shape[<NUM_LIT:0>]):<EOL><INDENT>out[i,:] = numkit.timeseries.smooth(a[i], stepsize, window=window)<EOL><DEDENT>if maxpoints == self.maxpoints_default:  <EOL><INDENT>warnings.warn("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>% (ny, maxpoints, ny/stepsize, window, stepsize),<EOL>category=AutoCorrectionWarning)<EOL><DEDENT>return out[..., ::stepsize]<EOL>

Return smoothed data *a* decimated on approximately *maxpoints* points.

        1. Produces a smoothed graph using the smoothing window *window*;
           "flat" is a running average.
        2. select points at a step size approximatelt producing maxpoints

        If *a* contains <= *maxpoints* then *a* is simply returned;
        otherwise a new array of the same dimensions but with a
        reduced number of points (close to *maxpoints*) is returned.

        .. Note::

           Assumes that the first column is time (which will *never*
           be smoothed/averaged), except when the input array *a* is
           1D and therefore to be assumed to be data at equidistance
           timepoints.

        TODO:
        - Allow treating the 1st column as data


if self.savedata:<EOL><INDENT>d = self.__dict__<EOL><DEDENT>else:<EOL><INDENT>mangleprefix = '<STR_LIT:_>'+self.__class__.__name__<EOL>def demangle(k):<EOL><INDENT>"""<STR_LIT>"""<EOL>if k.startswith(mangleprefix):<EOL><INDENT>k = k.replace(mangleprefix,'<STR_LIT>')<EOL><DEDENT>return k<EOL><DEDENT>d = {}<EOL>for k in self.__dict__:<EOL><INDENT>d[k] = self.__pickle_excluded.get(demangle(k), self.__dict__[k])<EOL><DEDENT><DEDENT>return d<EOL>

custom pickling protocol: http://docs.python.org/library/pickle.html

        If :attr:`XVG.savedata` is ``False`` then any attributes in
        :attr:`XVG.__pickle_excluded` are *not* pickled as they are but simply
        pickled with the default value.


def __init__(self, filename=None, autoconvert=True, **kwargs):

super(MDP, self).__init__(**kwargs)  <EOL>self.autoconvert = autoconvert<EOL>if filename is not None:<EOL><INDENT>self._init_filename(filename)<EOL>self.read(filename)<EOL><DEDENT>

Initialize mdp structure.

        :Arguments:
          *filename*
              read from mdp file
          *autoconvert* : boolean
              ``True`` converts numerical values to python numerical types;
              ``False`` keeps everything as strings [``True``]
          *kwargs*
              Populate the MDP with key=value pairs. (NO SANITY CHECKS; and also
              does not work for keys that are not legal python variable names such
              as anything that includes a minus '-' sign or starts with a number).


self._init_filename(filename)<EOL>def BLANK(i):<EOL><INDENT>return "<STR_LIT>".format(i)<EOL><DEDENT>def COMMENT(i):<EOL><INDENT>return "<STR_LIT>".format(i)<EOL><DEDENT>data = odict()<EOL>iblank = icomment = <NUM_LIT:0><EOL>with open(self.real_filename) as mdp:<EOL><INDENT>for line in mdp:<EOL><INDENT>line = line.strip()<EOL>if len(line) == <NUM_LIT:0>:<EOL><INDENT>iblank += <NUM_LIT:1><EOL>data[BLANK(iblank)] = '<STR_LIT>'<EOL>continue<EOL><DEDENT>m = self.COMMENT.match(line)<EOL>if m:<EOL><INDENT>icomment += <NUM_LIT:1><EOL>data[COMMENT(icomment)] = m.group('<STR_LIT:value>')<EOL>continue<EOL><DEDENT>m = self.PARAMETER.match(line)<EOL>if m:<EOL><INDENT>parameter = m.group('<STR_LIT>')<EOL>value =  self._transform(m.group('<STR_LIT:value>'))<EOL>data[parameter] = value<EOL><DEDENT>else:<EOL><INDENT>errmsg = '<STR_LIT>'.format(**vars())<EOL>self.logger.error(errmsg)<EOL>raise ParseError(errmsg)<EOL><DEDENT><DEDENT><DEDENT>super(MDP,self).update(data)<EOL>


def write(self, filename=None, skipempty=False):

with open(self.filename(filename, ext='<STR_LIT>'), '<STR_LIT:w>') as mdp:<EOL><INDENT>for k,v in self.items():<EOL><INDENT>if k[<NUM_LIT:0>] == '<STR_LIT:B>':        <EOL><INDENT>mdp.write("<STR_LIT:\n>")<EOL><DEDENT>elif k[<NUM_LIT:0>] == '<STR_LIT:C>':      <EOL><INDENT>mdp.write("<STR_LIT>".format(**vars()))<EOL><DEDENT>else:                  <EOL><INDENT>if skipempty and (v == '<STR_LIT>' or v is None):<EOL><INDENT>continue<EOL><DEDENT>if isinstance(v, six.string_types) or not hasattr(v, '<STR_LIT>'):<EOL><INDENT>mdp.write("<STR_LIT>".format(**vars()))<EOL><DEDENT>else:<EOL><INDENT>mdp.write("<STR_LIT>".format(k,'<STR_LIT:U+0020>'.join(map(str, v))))<EOL><DEDENT><DEDENT><DEDENT><DEDENT>

Write mdp file to *filename*.

        :Keywords:
           *filename*
               output mdp file; default is the filename the mdp
               was read from
           *skipempty* : boolean
               ``True`` removes any parameter lines from output that
               contain empty values [``False``]

        .. Note:: Overwrites the file that the mdp was read from if no
                  *filename* supplied.


self._init_filename(filename)<EOL>data = odict()<EOL>with open(self.real_filename) as ndx:<EOL><INDENT>current_section = None<EOL>for line in ndx:<EOL><INDENT>line = line.strip()<EOL>if len(line) == <NUM_LIT:0>:<EOL><INDENT>continue<EOL><DEDENT>m = self.SECTION.match(line)<EOL>if m:<EOL><INDENT>current_section = m.group('<STR_LIT:name>')<EOL>data[current_section] = []  <EOL>continue<EOL><DEDENT>if current_section is not None:<EOL><INDENT>data[current_section].extend(map(int, line.split()))<EOL><DEDENT><DEDENT><DEDENT>super(NDX,self).update(odict([(name, self._transform(atomnumbers))<EOL>for name, atomnumbers in data.items()]))<EOL>


def write(self, filename=None, ncol=ncol, format=format):

with open(self.filename(filename, ext='<STR_LIT>'), '<STR_LIT:w>') as ndx:<EOL><INDENT>for name in self:<EOL><INDENT>atomnumbers = self._getarray(name)  <EOL>ndx.write('<STR_LIT>'.format(name))<EOL>for k in range(<NUM_LIT:0>, len(atomnumbers), ncol):<EOL><INDENT>line = atomnumbers[k:k+ncol].astype(int)   <EOL>n = len(line)<EOL>ndx.write(("<STR_LIT:U+0020>".join(n*[format])+'<STR_LIT:\n>') % tuple(line))<EOL><DEDENT>ndx.write('<STR_LIT:\n>')<EOL><DEDENT><DEDENT>

Write index file to *filename* (or overwrite the file that the index was read from)


return self[name]<EOL>

Return index array for index group *name*.


self[name] = value<EOL>

Set or add group *name* as a 1D numpy array.


return len(self[name])<EOL>

Return number of entries for group *name*.


return self.keys()<EOL>


return {name: len(atomnumbers) for name, atomnumbers in self.items()}<EOL>

Return a dict with group names and number of entries,


return [{'<STR_LIT:name>': name, '<STR_LIT>': len(atomnumbers), '<STR_LIT>': nr+<NUM_LIT:1>} for<EOL>nr,(name,atomnumbers) in enumerate(self.items())]<EOL>

Return a list of groups in the same format as  :func:`gromacs.cbook.get_ndx_groups`.

        Format:
           [ {'name': group_name, 'natoms': number_atoms, 'nr':  # group_number}, ....]


return self[name]<EOL>

Helper getter that is used in write().
        Override when using a _transform that stores something that
        cannot be indexed, e.g. when using set()s.


return numpy.ravel(v).astype(int)<EOL>

Transform input to the stored representation.

        Override eg with ``return set(v)`` for index lists as sets.


return self._sum([self[k] for k in groupnames if k in self])<EOL>

Return an index group that contains atoms from all  *groupnames*.

        The method will silently ignore any groups that are not in the
        index.

        **Example**

        Always make a solvent group from water and ions, even if not
        all ions are present in all simulations::

           I['SOLVENT'] = I.join('SOL', 'NA+', 'K+', 'CL-')


<EOL>commands = utilities.asiterable(commands)<EOL>for command in commands:<EOL><INDENT>try:<EOL><INDENT>driver, name = command.split()<EOL><DEDENT>except ValueError:<EOL><INDENT>driver, name = None, command<EOL><DEDENT>executable = driver if driver else name<EOL>if utilities.which(executable):<EOL><INDENT>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise OSError(errno.ENOENT, "<STR_LIT>", "<STR_LIT:U+002CU+0020>".join(commands))<EOL><DEDENT>return driver, name<EOL>

Return *driver* and *name* of the first command that can be found on :envvar:`PATH`


if not os.path.exists(logfile):<EOL><INDENT>return None<EOL><DEDENT>with open(logfile, '<STR_LIT:rb>') as log:<EOL><INDENT>log.seek(-<NUM_LIT>, <NUM_LIT:2>)<EOL>for line in log:<EOL><INDENT>line = line.decode('<STR_LIT>')<EOL>if line.startswith("<STR_LIT>"):<EOL><INDENT>return True<EOL><DEDENT><DEDENT><DEDENT>return False<EOL>

Check if ``mdrun`` finished successfully.

    Analyses the output from ``mdrun`` in *logfile*. Right now we are
    simply looking for the line "Finished mdrun on node" in the last 1kb of
    the file. (The file must be seeakable.)

    :Arguments:
      *logfile* : filename
         Logfile produced by ``mdrun``.

    :Returns: ``True`` if all ok, ``False`` if not finished, and
              ``None`` if the *logfile* cannot be opened


try:<EOL><INDENT>gromacs.mdrun_d(h=True, stdout=False, stderr=False)<EOL>logger.debug("<STR_LIT>")<EOL>return gromacs.mdrun_d<EOL><DEDENT>except (AttributeError, GromacsError, OSError):<EOL><INDENT>wmsg = "<STR_LIT>""<STR_LIT>"<EOL>logger.warn(wmsg)<EOL>warnings.warn(wmsg, category=AutoCorrectionWarning)<EOL>return gromacs.mdrun<EOL><DEDENT>

Return double precision ``mdrun`` or fall back to single precision.

    This convenience function tries :func:`gromacs.mdrun_d` first and
    if it cannot run it, falls back to :func:`gromacs.mdrun` (without
    further checking).

    .. versionadded:: 0.5.1


def __init__(self, dirname=os.path.curdir, **kwargs):

<EOL>self.dirname = dirname<EOL>self.driver, self.name = find_gromacs_command(self.mdrun)<EOL>cls = type('<STR_LIT>', (core.GromacsCommand,),<EOL>{'<STR_LIT>': self.name,<EOL>'<STR_LIT>': self.driver,<EOL>'<STR_LIT>': "<STR_LIT>".format(self.driver, self.name)<EOL>})<EOL>kwargs['<STR_LIT>'] = '<STR_LIT>'    <EOL>self.MDRUN = cls(**kwargs)  <EOL>logname = kwargs.get('<STR_LIT:g>')          <EOL>if logname in (True, None):        <EOL><INDENT>logname = '<STR_LIT>'             <EOL>deffnm = kwargs.get('<STR_LIT>')<EOL>if deffnm is not None:<EOL><INDENT>logname = deffnm<EOL><DEDENT><DEDENT>self.logname = os.path.realpath(<EOL>os.path.join(self.dirname, self.filename(logname, ext='<STR_LIT>')))<EOL>

Set up a simple run with ``mdrun``.

        :Keywords:
           *dirname*
               Change to this directory before launching the job. Input
               files must be supplied relative to this directory.
           *keywords*
               All other keword arguments are used to construct the
               :class:`~gromacs.tools.mdrun` commandline. Note that only
               keyword arguments are allowed.


cmd = self.MDRUN.commandline()<EOL>if self.mpiexec:<EOL><INDENT>cmd = self.mpicommand(**mpiargs) + cmd<EOL><DEDENT>return cmd<EOL>

Returns simple command line to invoke mdrun.

        If :attr:`mpiexec` is set then :meth:`mpicommand` provides the mpi
        launcher command that prefixes the actual ``mdrun`` invocation:

           :attr:`mpiexec` [*mpiargs*]  :attr:`mdrun` [*mdrun-args*]

        The *mdrun-args* are set on initializing the class. Override
        :meth:`mpicommand` to fit your system if the simple default
        OpenMP launcher is not appropriate.


if self.mpiexec is None:<EOL><INDENT>raise NotImplementedError("<STR_LIT>")<EOL><DEDENT>ncores = kwargs.pop('<STR_LIT>', <NUM_LIT:8>)<EOL>return [self.mpiexec, '<STR_LIT>', str(ncores)]<EOL>

Return a list of the mpi command portion of the commandline.

        Only allows primitive mpi at the moment:
           *mpiexec* -n *ncores* *mdrun* *mdrun-args*

        (This is a primitive example for OpenMP. Override it for more
        complicated cases.)


return<EOL>

Called directly before launching the process.


return<EOL>

Called directly after the process terminated (also if it failed).


def run(self, pre=None, post=None, mdrunargs=None, **mpiargs):

if pre is None:<EOL><INDENT>pre = {}<EOL><DEDENT>if post is None:<EOL><INDENT>post = {}<EOL><DEDENT>if mdrunargs is not None:<EOL><INDENT>try:<EOL><INDENT>self.MDRUN.gmxargs.update(mdrunargs)<EOL><DEDENT>except (ValueError, TypeError):<EOL><INDENT>msg = "<STR_LIT>".format(mdrunargs)<EOL>logger.error(msg)<EOL>raise<EOL><DEDENT><DEDENT>cmd = self.commandline(**mpiargs)<EOL>with utilities.in_dir(self.dirname, create=False):<EOL><INDENT>try:<EOL><INDENT>self.prehook(**pre)<EOL>logger.info("<STR_LIT:U+0020>".join(cmd))<EOL>rc = subprocess.call(cmd)<EOL><DEDENT>except:<EOL><INDENT>logger.exception("<STR_LIT>")<EOL>raise<EOL><DEDENT>finally:<EOL><INDENT>self.posthook(**post)<EOL><DEDENT><DEDENT>if rc == <NUM_LIT:0>:<EOL><INDENT>logger.info("<STR_LIT>".format(rc))<EOL><DEDENT>else:<EOL><INDENT>logger.critical("<STR_LIT>".format(rc))<EOL><DEDENT>return rc<EOL>

Execute the mdrun command (possibly as a MPI command) and run the simulation.

        :Keywords:
          *pre*
             a dictionary containing keyword arguments for the :meth:`prehook`
          *post*
             a dictionary containing keyword arguments for the :meth:`posthook`
          *mdrunargs*
             a dictionary with keyword arguments for :program:`mdrun` which supersede
             **and update** the defaults given to the class constructor
          *mpiargs*
             all other keyword arguments that are processed by :meth:`mpicommand`


rc = None   <EOL>try:<EOL><INDENT>rc = self.run(**kwargs)<EOL><DEDENT>except:<EOL><INDENT>logger.exception("<STR_LIT>")<EOL><DEDENT>status = self.check_success()<EOL>if status:<EOL><INDENT>logger.info("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>logger.error("<STR_LIT>")<EOL><DEDENT>return status<EOL>

Run :program:`mdrun` and check if run completed when it finishes.

        This works by looking at the mdrun log file for 'Finished
        mdrun on node'. It is useful to implement robust simulation
        techniques.

        :Arguments:
           *kwargs* are keyword arguments that are passed on to
           :meth:`run` (typically used for mpi things)

        :Returns:
           - ``True`` if run completed successfully
           - ``False`` otherwise


return check_mdrun_success(self.logname)<EOL>

Check if :program:`mdrun` finished successfully.

        (See :func:`check_mdrun_success` for details)


cmd = ['<STR_LIT>', '<STR_LIT>']<EOL>logger.info("<STR_LIT>"+"<STR_LIT:U+0020>".join(cmd))<EOL>rc = subprocess.call(cmd)<EOL>return rc<EOL>


global trj_compact, rmsd_backbone, trj_fitted, trj_xyfitted<EOL>trj_compact = tools.Trjconv(ur='<STR_LIT>', center=True, boxcenter='<STR_LIT>', pbc='<STR_LIT>',<EOL>input=('<STR_LIT>','<STR_LIT>'),<EOL>doc="""<STR_LIT>""")<EOL>rmsd_backbone = tools.G_rms(what='<STR_LIT>', fit='<STR_LIT>',<EOL>input=('<STR_LIT>','<STR_LIT>'),<EOL>doc="""<STR_LIT>""")<EOL>trj_fitted = tools.Trjconv(fit='<STR_LIT>',<EOL>input=('<STR_LIT>', '<STR_LIT>'),<EOL>doc="""<STR_LIT>"""<EOL>es a trajectory fitted to the protein in the XY-plane only.<EOL>is useful for membrane proteins. The system *must* be oriented so<EOL>the membrane is in the XY plane. The protein backbone is used<EOL>the least square fit, centering is done for the whole protein.<EOL>that centering together with fitting does not always work well<EOL>that one sometimes need two runs of trjconv: one to center and<EOL>to fit.<EOL>ote:: Gromacs <NUM_LIT>x only

Define functions for the top level name space.

    Definitions are collected here so that they can all be wrapped in
    a try-except block that avoids code failing when the Gromacs tools
    are not available --- in some cases they are not necessary to use
    parts of GromacsWrapper.

    .. Note:: Any function defined here **must be listed in ``global``**!


if xy:<EOL><INDENT>fitmode = '<STR_LIT>'<EOL>kwargs.pop('<STR_LIT>', None)<EOL><DEDENT>else:<EOL><INDENT>fitmode = kwargs.pop('<STR_LIT>', '<STR_LIT>')  <EOL><DEDENT>intrj = kwargs.pop('<STR_LIT:f>', None)<EOL>suffix = os.path.splitext(intrj)[<NUM_LIT:1>]<EOL>if not suffix in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>suffix = '<STR_LIT>'<EOL><DEDENT>outtrj = kwargs.pop('<STR_LIT:o>', None)<EOL>ndx = kwargs.pop('<STR_LIT:n>', None)<EOL>ndxcompact = kwargs.pop('<STR_LIT>', ndx)<EOL>structures = kwargs.pop('<STR_LIT:s>', None)<EOL>if type(structures) in (tuple, list):<EOL><INDENT>try:<EOL><INDENT>compact_structure, fit_structure = structures<EOL><DEDENT>except:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>compact_structure = fit_structure = structures<EOL><DEDENT>inpfit = kwargs.pop('<STR_LIT:input>', ('<STR_LIT>', '<STR_LIT>','<STR_LIT>'))<EOL>try:<EOL><INDENT>_inpcompact = inpfit[<NUM_LIT:1>:]     <EOL><DEDENT>except TypeError:<EOL><INDENT>_inpcompact = None<EOL><DEDENT>inpcompact = kwargs.pop('<STR_LIT>', _inpcompact)  <EOL>fd, tmptrj = tempfile.mkstemp(suffix=suffix, prefix='<STR_LIT>')<EOL>logger.info("<STR_LIT>".format(**vars()))<EOL>logger.info("<STR_LIT>".format(**vars()))<EOL>logger.info("<STR_LIT>".format(**vars()))<EOL>logger.info("<STR_LIT>".format(**vars()))<EOL>logger.debug("<STR_LIT>".format(**vars()))<EOL>sys.stdout.flush()<EOL>try:<EOL><INDENT>gromacs.trjconv(s=compact_structure, f=intrj, o=tmptrj, n=ndxcompact,<EOL>ur='<STR_LIT>', center=True, boxcenter='<STR_LIT>', pbc='<STR_LIT>',<EOL>input=inpcompact, **kwargs)<EOL>kwargs['<STR_LIT>'] = "<STR_LIT:none>"<EOL>if compact_structure == fit_structure:<EOL><INDENT>gromacs.trjconv(s=fit_structure, f=tmptrj, o=outtrj, n=ndx, fit=fitmode, center=True, input=inpfit, **kwargs)<EOL><DEDENT>else:<EOL><INDENT>inpfit = [inpfit[<NUM_LIT:0>], inpfit[-<NUM_LIT:1>]]<EOL>gromacs.trjconv(s=fit_structure, f=tmptrj, o=outtrj, n=ndx, fit=fitmode, input=inpfit, **kwargs)<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>utilities.unlink_gmx(tmptrj)<EOL><DEDENT>

Center everything and make a compact representation (pass 1) and fit the system to a reference (pass 2).

    :Keywords:
       *s*
           input structure file (tpr file required to make molecule whole);
           if a list or tuple is provided then s[0] is used for pass 1 (should be a tpr)
           and s[1] is used for the fitting step (can be a pdb of the whole system)

           If a second structure is supplied then it is assumed that the fitted
           trajectory should *not* be centered.
       *f*
           input trajectory
       *o*
           output trajectory
       *input*
           A list with three groups. The default is
               ['backbone', 'protein','system']
           The fit command uses all three (1st for least square fit,
           2nd for centering, 3rd for output), the centered/make-whole stage use
           2nd for centering and 3rd for output.
       *input1*
           If *input1* is supplied then *input* is used exclusively
           for the fitting stage (pass 2) and *input1* for the centering (pass 1).
       *n*
           Index file used for pass 1 and pass 2.
       *n1*
           If *n1* is supplied then index *n1* is only used for pass 1
           (centering) and *n* for pass 2 (fitting).
       *xy* : boolean
           If ``True`` then only do a rot+trans fit in the xy plane
           (good for membrane simulations); default is ``False``.
       *kwargs*
           All other arguments are passed to :class:`~gromacs.tools.Trjconv`.

    Note that here we first center the protein and create a compact box, using
    ``-pbc mol -ur compact -center -boxcenter tric`` and write an intermediate
    xtc. Then in a second pass we perform a rotation+translation fit (or
    restricted to the xy plane if *xy* = ``True`` is set) on the intermediate
    xtc to produce the final trajectory. Doing it in this order has the
    disadvantage that the solvent box is rotating around the protein but the
    opposite order (with center/compact second) produces strange artifacts
    where columns of solvent appear cut out from the box---it probably means
    that after rotation the information for the periodic boundaries is not
    correct any more.

    Most kwargs are passed to both invocations of
    :class:`gromacs.tools.Trjconv` so it does not really make sense to use eg
    *skip*; in this case do things manually.

    By default the *input* to the fit command is ('backbone',
    'protein','system'); the compact command always uses the second and third
    group for its purposes or if this fails, prompts the user.

    Both steps cannot performed in one pass; this is a known limitation of
    ``trjconv``. An intermediate temporary XTC files is generated which should
    be automatically cleaned up unless bad things happened.

    The function tries to honour the input/output formats. For instance, if you
    want trr output you need to supply a trr file as input and explicitly give
    the output file also a trr suffix.

    .. Note:: For big trajectories it can **take a very long time**
              and consume a **large amount of temporary diskspace**.

    We follow the `g_spatial documentation`_ in preparing the trajectories::

       trjconv -s a.tpr -f a.xtc -o b.xtc -center -boxcenter tric -ur compact -pbc mol
       trjconv -s a.tpr -f b.xtc -o c.xtc -fit rot+trans

    .. _`g_spatial documentation`: http://www.gromacs.org/Documentation/Gromacs_Utilities/g_spatial


def cat(prefix="<STR_LIT>", dirname=os.path.curdir, partsdir="<STR_LIT>", fulldir="<STR_LIT>",<EOL>resolve_multi="<STR_LIT>"):

gmxcat = {'<STR_LIT>': gromacs.trjcat,<EOL>'<STR_LIT>': gromacs.trjcat,<EOL>'<STR_LIT>': gromacs.eneconv,<EOL>'<STR_LIT>': utilities.cat,<EOL>}<EOL>def _cat(prefix, ext, partsdir=partsdir, fulldir=fulldir):<EOL><INDENT>filenames = glob_parts(prefix, ext)<EOL>if ext.startswith('<STR_LIT:.>'):<EOL><INDENT>ext = ext[<NUM_LIT:1>:]<EOL><DEDENT>outfile = os.path.join(fulldir, prefix + '<STR_LIT:.>' + ext)<EOL>if not filenames:<EOL><INDENT>return None<EOL><DEDENT>nonempty_files = []<EOL>for f in filenames:<EOL><INDENT>if os.stat(f).st_size == <NUM_LIT:0>:<EOL><INDENT>logger.warn("<STR_LIT>".format(**vars()))<EOL>continue<EOL><DEDENT>if os.path.islink(f):<EOL><INDENT>errmsg = "<STR_LIT>""<STR_LIT>" % vars()<EOL>logger.exception(errmsg)<EOL>raise NotImplementedError(errmsg)<EOL><DEDENT>shutil.move(f, partsdir)<EOL>nonempty_files.append(f)<EOL><DEDENT>filepaths = [os.path.join(partsdir, f) for f in nonempty_files]<EOL>gmxcat[ext](f=filepaths, o=outfile)<EOL>return outfile<EOL><DEDENT>_resolve_options = ("<STR_LIT>", "<STR_LIT>")<EOL>if not resolve_multi in _resolve_options:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>" % vars())<EOL><DEDENT>if fulldir == os.path.curdir:<EOL><INDENT>wmsg = "<STR_LIT>"<EOL>logger.warning(wmsg)<EOL>warnings.warn(wmsg, category=BadParameterWarning)<EOL><DEDENT>with utilities.in_dir(dirname, create=False):<EOL><INDENT>utilities.mkdir_p(partsdir)<EOL>utilities.mkdir_p(fulldir)<EOL>for ext in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>logger.info("<STR_LIT>", vars())<EOL>outfile = _cat(prefix, ext, partsdir)<EOL>logger.info("<STR_LIT>", vars())<EOL><DEDENT>for ext in ('<STR_LIT>', '<STR_LIT>'):              <EOL><INDENT>filenames = glob_parts(prefix, ext)<EOL>if len(filenames) == <NUM_LIT:0>:<EOL><INDENT>continue                        <EOL><DEDENT>elif len(filenames) == <NUM_LIT:1>:<EOL><INDENT>pick = filenames[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>if resolve_multi == "<STR_LIT>":<EOL><INDENT>logger.warning("<STR_LIT>"<EOL>"<STR_LIT>", vars())<EOL>for f in filenames:<EOL><INDENT>shutil.move(f, partsdir)<EOL><DEDENT>continue                    <EOL><DEDENT>elif resolve_multi == "<STR_LIT>":<EOL><INDENT>pick = prefix + '<STR_LIT:.>' + ext<EOL>if not pick in filenames:<EOL><INDENT>pick = filenames[-<NUM_LIT:1>]  <EOL><DEDENT><DEDENT><DEDENT>final = os.path.join(fulldir, prefix + '<STR_LIT:.>' + ext)<EOL>shutil.copy(pick, final)  <EOL>for f in filenames:<EOL><INDENT>shutil.move(f, partsdir)<EOL><DEDENT>logger.info("<STR_LIT>"<EOL>"<STR_LIT>", vars())<EOL><DEDENT><DEDENT>partsdirpath = utilities.realpath(dirname, partsdir)<EOL>logger.warn("<STR_LIT>"<EOL>"<STR_LIT>", vars())<EOL>

Concatenate all parts of a simulation.

    The xtc, trr, and edr files in *dirname* such as prefix.xtc,
    prefix.part0002.xtc, prefix.part0003.xtc, ... are

       1) moved to the *partsdir* (under *dirname*)
       2) concatenated with the Gromacs tools to yield prefix.xtc, prefix.trr,
          prefix.edr, prefix.gro (or prefix.md) in *dirname*
       3) Store these trajectories in *fulldir*

    .. Note:: Trajectory files are *never* deleted by this function to avoid
              data loss in case of bugs. You will have to clean up yourself
              by deleting *dirname*/*partsdir*.

              Symlinks for the trajectories are *not* handled well and
              break the function. Use hard links instead.

    .. Warning:: If an exception occurs when running this function then make
                 doubly and triply sure where your files are before running
                 this function again; otherwise you might **overwrite data**.
                 Possibly you will need to manually move the files from *partsdir*
                 back into the working directory *dirname*; this should onlu overwrite
                 generated files so far but *check carefully*!

    :Keywords:
        *prefix*
            deffnm of the trajectories [md]
        *resolve_multi"
            how to deal with multiple "final" gro or pdb files: normally there should
            only be one but in case of restarting from the checkpoint of a finished
            simulation one can end up with multiple identical ones.
              - "pass" : do nothing and log a warning
              - "guess" : take prefix.pdb or prefix.gro if it exists, otherwise the one of
                          prefix.partNNNN.gro|pdb with the highes NNNN
        *dirname*
            change to *dirname* and assume all tarjectories are located there [.]
        *partsdir*
             directory where to store the input files (they are moved out of the way);
             *partsdir* must be manually deleted [parts]
        *fulldir*
             directory where to store the final results [full]


if ext.startswith('<STR_LIT:.>'):<EOL><INDENT>ext = ext[<NUM_LIT:1>:]<EOL><DEDENT>files = glob.glob(prefix+'<STR_LIT:.>'+ext) + glob.glob(prefix+'<STR_LIT>'+ext)<EOL>files.sort()   <EOL>return files<EOL>