def __init__(self, struct=None, selections=None, names=None, name_all=None,<EOL>ndx=None, out_ndx="<STR_LIT>", offset=<NUM_LIT:0>):
self.structure = struct<EOL>self.ndx = ndx<EOL>self.output = out_ndx<EOL>self.name_all = name_all<EOL>self.offset = offset<EOL>self._command_counter = <NUM_LIT:0><EOL>if selections is None:<EOL><INDENT>selections = []<EOL><DEDENT>if not utilities.iterable(selections):<EOL><INDENT>selections = [selections]<EOL><DEDENT>self.selections = selections<EOL>if names is None:<EOL><INDENT>names = [None] * len(selections)<EOL><DEDENT>self.make_ndx = tools.Make_ndx(f=self.structure, n=self.ndx,<EOL>stdout=False, stderr=False)<EOL>self.indexfiles = dict([self.parse_selection(selection, name)<EOL>for selection, name in zip(selections, names)])<EOL>
Build a index group from the selection arguments.

        If selections and a structure file are supplied then the individual
        selections are constructed with separate calls to
        :func:`gromacs.make_ndx`. Use :meth:`IndexBuilder.combine` to combine
        them into a joint selection or :meth:`IndexBuilder.write` to simply write
        out the individual named selections (useful with *names*).

        :Arguments:

           *struct* : filename
              Structure file (tpr, pdb, ...)

           *selections* : list
              The list must contain strings or tuples, which must be be one of
              the following constructs:

                 "<1-letter aa code><resid>[:<atom name]"

                     Selects the CA of the residue or the specified atom
                     name.

                     example: ``"S312:OA"`` or ``"A22"`` (equivalent to ``"A22:CA"``)

                 ("<1-letter aa code><resid>", "<1-letter aa code><resid>, ["<atom name>"])

                    Selects a *range* of residues. If only two residue
                    identifiers are provided then all atoms are
                    selected. With an optional third atom identifier,
                    only this atom anme is selected for each residue
                    in the range. [EXPERIMENTAL]

                 "@<make_ndx selection>"

                     The ``@`` letter introduces a verbatim ``make_ndx``
                     command. It will apply the given selection without any
                     further processing or checks.

                     example: ``"@a 6234 - 6238"`` or ``'@"SOL"'`` (note the quoting)
                     or ``"@r SER & r 312 & t OA"``.

           *names* : list
              Strings to name the selections; if not supplied or if individuals
              are ``None`` then a default name is created. When simply using
              :meth:`IndexBuilder.write` then these should be supplied.

           *name_all* : string
              Name of the group that is generated by :meth:`IndexBuilder.combine`.

           *offset* : int, dict
              This number is added to the resids in the first selection scheme; this
              allows names to be the same as in a crystal structure. If offset is a
              dict then it is used to directly look up the resids.

           *ndx* : filename or list of filenames
              Optional input index file(s).

           *out_ndx* : filename
              Output index file.