:py:mod:`alhambra.tilesets`
===========================

.. py:module:: alhambra.tilesets


Module Contents
---------------

Classes
~~~~~~~

.. autoapisummary::

   alhambra.tilesets.XgrowGlueOpts
   alhambra.tilesets.GrowSelfComplementaryGlues
   alhambra.tilesets.GrowPerfectGlues
   alhambra.tilesets.GrowOrthogonalGlues
   alhambra.tilesets.GrowFullGlues
   alhambra.tilesets.TileSet



Functions
~~~~~~~~~

.. autoapisummary::

   alhambra.tilesets._generate_stickydesign_energetic_classes



Attributes
~~~~~~~~~~

.. autoapisummary::

   alhambra.tilesets.log
   alhambra.tilesets._gl
   alhambra.tilesets.T
   alhambra.tilesets.SD_ENERGETICS_CLASSES
   alhambra.tilesets.HAS_SD_ACCEL


.. py:data:: log

   

.. py:data:: _gl

   

.. py:data:: T

   

.. py:class:: XgrowGlueOpts


   Bases: :py:obj:`abc.ABC`

   Helper class that provides a standard way to create an ABC using
   inheritance.

   .. py:method:: get_xgrow_gse(tileset: TileSet) -> float | None


   .. py:method:: calculate_gses(tileset: TileSet) -> tuple[list[xgrow.tileset.Bond], list[xgrow.tileset.Glue]]
      :abstractmethod:


   .. py:method:: glue_name_map(tileset: TileSet) -> Callable[[str], str]


   .. py:method:: from_str(glueopts: str) -> XgrowGlueOpts
      :classmethod:



.. py:class:: GrowSelfComplementaryGlues


   Bases: :py:obj:`XgrowGlueOpts`

   Helper class that provides a standard way to create an ABC using
   inheritance.

   .. py:method:: get_xgrow_gse(tileset: TileSet) -> float | None


   .. py:method:: glue_name_map(tileset: TileSet) -> Callable[[str], str]


   .. py:method:: calculate_gses(tileset: TileSet) -> tuple[list[xgrow.tileset.Bond], list[xgrow.tileset.Glue]]



.. py:data:: SD_ENERGETICS_CLASSES
   :type: dict[str, stickydesign.EnergeticsBasic]

   

.. py:data:: HAS_SD_ACCEL
   :type: bool
   :value: False

   

.. py:function:: _generate_stickydesign_energetic_classes() -> None


.. py:class:: GrowPerfectGlues


   Bases: :py:obj:`XgrowGlueOpts`

   Helper class that provides a standard way to create an ABC using
   inheritance.

   .. py:method:: get_xgrow_gse(tileset: TileSet) -> float | None


   .. py:method:: calculate_gses(tileset: TileSet) -> tuple[list[xgrow.tileset.Bond], list[xgrow.tileset.Glue]]



.. py:class:: GrowOrthogonalGlues


   Bases: :py:obj:`XgrowGlueOpts`

   Helper class that provides a standard way to create an ABC using
   inheritance.

   .. py:attribute:: temperature
      :type: float | None

      

   .. py:attribute:: alpha
      :type: float | None

      

   .. py:method:: get_xgrow_gse(tileset: TileSet) -> float | None


   .. py:method:: calculate_gses(tileset: TileSet) -> tuple[list[xgrow.tileset.Bond], list[xgrow.tileset.Glue]]



.. py:class:: GrowFullGlues


   Bases: :py:obj:`XgrowGlueOpts`

   Helper class that provides a standard way to create an ABC using
   inheritance.

   .. py:attribute:: temperature
      :type: float | None

      

   .. py:attribute:: threshold
      :type: float
      :value: 0.0

      

   .. py:attribute:: alpha
      :type: float | None

      

   .. py:method:: get_xgrow_gse(tileset: TileSet) -> float | None


   .. py:method:: calculate_gses(tileset: TileSet) -> tuple[list[xgrow.tileset.Bond], list[xgrow.tileset.Glue]]



.. py:class:: TileSet(tiles: Iterable[alhambra.tiles.Tile] = tuple(), glues: Iterable[alhambra.glues.Glue] = tuple(), seeds: Mapping[str | int, alhambra.seeds.Seed] | None = None, *, seed: alhambra.seeds.Seed | None = None, lattices: Mapping[str | int, alhambra.grid.Lattice] | None = None, guards: Mapping[str | int, list[str]] = dict(), params: dict | None = None)


   Bases: :py:obj:`alhambra.classes.Serializable`

   Class representing a tileset, whether abstract or sequence-level.

   .. py:property:: allglues
      :type: alhambra.glues.GlueList


   .. py:property:: alldomains
      :type: alhambra.glues.GlueList


   .. py:attribute:: tiles
      :type: alhambra.tiles.TileList[alhambra.tiles.Tile]

      

   .. py:attribute:: glues
      :type: alhambra.glues.GlueList[alhambra.glues.Glue]

      

   .. py:attribute:: seeds
      :type: dict[str | int, alhambra.seeds.Seed]

      

   .. py:attribute:: lattices
      :type: dict[str | int, alhambra.grid.Lattice]

      

   .. py:attribute:: guards
      :type: dict[str | int, list[str]]

      

   .. py:attribute:: params
      :type: dict

      

   .. py:method:: from_mix(mix: alhambra_mixes.Mix, tilesets_or_lists: TileSet | alhambra.tiles.TileList | Iterable[TileSet | alhambra.tiles.TileList], *, seed: bool | alhambra.seeds.Seed = False, base_conc: alhambra_mixes.ureg.Quantity | str = Q_(100.0, nM)) -> TileSet
      :classmethod:

      Given some :any:`TileSet`\ s, or lists of :any:`Tile`\ s from which to
      take tiles, generate an TileSet from the mix.


   .. py:method:: run_xgrow(to_lattice: bool = True, _include_out: bool = False, glues: XgrowGlueOpts | str | None = None, seed: str | int | alhambra.seeds.Seed | None | Literal[False] = None, seed_offset: tuple[int, int] | None = None, xgrow_seed: tuple[int, int, int | str] | None = None, **kwargs: Any) -> Any

      Run the tilesystem in Xgrow.


   .. py:method:: to_rgrow(glue_handling: XgrowGlueOpts | str | None = None, seed: str | int | alhambra.seeds.Seed | None | Literal[False] = None, seed_offset: tuple[int, int] | None = None, **kwargs)


   .. py:method:: to_rgrow_dict(glue_handling: XgrowGlueOpts | str | None = None, seed: str | int | alhambra.seeds.Seed | None | Literal[False] = None, seed_offset: tuple[int, int] | None = None, **kwargs)


   .. py:method:: to_xgrow(glue_handling: XgrowGlueOpts | str | None = None, seed: str | int | alhambra.seeds.Seed | None | Literal[False] = None, seed_offset: tuple[int, int] | None = None) -> xgrow.tileset.TileSet

      Convert Alhambra TileSet to an XGrow TileSet


   .. py:method:: _to_xgrow_dict() -> dict

      DEPRECATED: to xgrow dict


   .. py:method:: summary()

      Returns a short summary line about the TileSet


   .. py:method:: __repr__() -> str

      Return repr(self).


   .. py:method:: __str__() -> str

      Return str(self).


   .. py:method:: from_scadnano(des: scadnano.Design, ret_fails: bool = False) -> TileSet
      :classmethod:

      Create TileSet from Scadnano Design.


   .. py:method:: to_scadnano(lattice: alhambra.grid.LatticeSupportingScadnano | None = None) -> scadnano.Design

      Export TileSet (with lattice) as Scadnano Design.


   .. py:method:: to_dict() -> dict


   .. py:method:: from_dict(d: dict) -> TileSet
      :classmethod:


   .. py:method:: _serialize() -> Any


   .. py:method:: _deserialize(input: Any) -> TileSet
      :classmethod:


   .. py:method:: lattice_tiles(lattice: alhambra.grid.AbstractLattice | int | str | numpy.ndarray, *, x: int | slice | None = None, y: int | slice | None = None, copy: bool = False) -> list[alhambra.tiles.Tile]

      Return a list of (unique) tiles in a lattice, potentially taking a slice of the lattice.

      :param lattice: Lattice or reference to a lattice in the tileset
      :type lattice: AbstractLattice | int | str
      :param x: index in the lattice, by default None
      :type x: int | slice | None, optional
      :param y: index in the lattice, by default None
      :type y: int | slice | None, optional
      :param copy: return copies if True (useful for creating a new set) or tiles in the set if False (useful for modifying the set), by default False
      :type copy: bool, optional


   .. py:method:: create_guards_square(lattice: alhambra.grid.AbstractLattice, square_size: int, init_x: int = 0, init_y: int = 0, skip: Callable[[alhambra.glues.Glue], bool] = _skip_polyT_and_inertname) -> list[str]


   .. py:method:: create_abstract_diagram(lattice: alhambra.grid.AbstractLattice | str | int | numpy.ndarray | None, filename=None, scale=1, guards: Collection[str] | str | int = tuple(), seed: str | bool | alhambra.seeds.Seed = True, seed_offset: tuple[int, int] = (0, 0), **options)

      Create an SVG layout diagram from a lattice.

      This currently uses the abstract diagram bases to create the
      layout diagrams.

      :param xgrowarray: Xgrow output.  This may be a numpy array of
                         an xgrow state, obtained in some way, or may be the 'array'
                         output of xgrow.run.
      :type xgrowarray: ndarray or dict
      :param filename: File name / path of the output file.
      :type filename: string


   .. py:method:: reduce_tiles(preserve=('s22', 'ld'), tries=10, threads=1, returntype='equiv', best=1, key=None, initequiv=None)
      :abstractmethod:

      Apply tile reduction algorithm, preserving some set of properties, and using a multiprocessing pool.

      :param tileset: The system to reduce.
      :type tileset: TileSet
      :param preserve: The properties to preserve.  Currently supported are 's1' for first order
                       sensitivity, 's2' for second order sensitivity, 's22' for two-by-two sensitivity,
                       'ld' for small lattice defects, and 'gs' for glue sense (to avoid spurious
                       hierarchical attachment).  Default is currently ('s22', 'ld').
      :type preserve: a tuple or list of strings, optional
      :param tries: The number of times to run the algorithm.
      :type tries: int, optional
      :param threads: The number of threads to use (using multiprocessing).
      :type threads: int, optional
      :param returntype: The type of object to return.  If 'equiv', returns an array of glue equivalences
                         (or list, if best != 1) that can be applied to the tileset with apply_equiv, or used
                         for further reduction.  If 'TileSet', return a TileSet with the equiv already applied
                         (or a list, if best != 1).
      :type returntype: 'TileSet' or 'equiv' (default 'equiv')
      :param best: The number of systems to return.  If 1, the result will be returned
                   directly; if k > 1, a list will be returned of the best k results (per cmp);
                   if k = None, a list of *all* results will be returned, sorted by cmp. (default 1)
      :type best: int or None, optional
      :param key: A comparison function for equivs, to sort the results. FIXME: documentation needed.
                  Default (if None) here is to sort by number of glues in the system, regardless of number
                  of tiles.
      :type key: function (ts, equiv1, equiv2) -> some number/comparable
      :param initequiv: If provided, the equivalence array to start from.  If None, start from the tileset without
                        any merged glues.
      :type initequiv: equiv

      :returns: **reduced** -- The reduced system/systems
      :rtype: single TileSet or equiv, or list


   .. py:method:: reduce_ends(preserve=['s22', 'ld'], tries=10, threads=1, returntype='equiv', best=1, key=None, initequiv=None)
      :abstractmethod:

      Apply end reduction algorithm, preserving some set of properties, and using a multiprocessing pool.

      :param tileset: The system to reduce.
      :type tileset: TileSet
      :param preserve: The properties to preserve.  Currently supported are 's1' for first order
                       sensitivity, 's2' for second order sensitivity, 's22' for two-by-two sensitivity,
                       'ld' for small lattice defects, and 'gs' for glue sense (to avoid spurious
                       hierarchical attachment).  Default is currently ('s22', 'ld').
      :type preserve: a tuple or list of strings, optional
      :param tries: The number of times to run the algorithm.
      :type tries: int, optional
      :param threads: The number of threads to use (using multiprocessing).
      :type threads: int, optional
      :param returntype: The type of object to return.  If 'equiv', returns an array of glue equivalences
                         (or list, if best != 1) that can be applied to the tileset with apply_equiv, or used
                         for further reduction.  If 'TileSet', return a TileSet with the equiv already applied
                         (or a list, if best != 1).
      :type returntype: 'TileSet' or 'equiv' (default 'equiv')
      :param best: The number of systems to return.  If 1, the result will be returned
                   directly; if k > 1, a list will be returned of the best k results (per cmp);
                   if k = None, a list of *all* results will be returned, sorted by cmp. (default 1)
      :type best: int or None, optional
      :param key: A comparison function for equivs, to sort the results. FIXME: documentation needed.
                  Default (if None) here is to sort by number of glues in the system, regardless of number
                  of tiles.
      :type key: function (ts, equiv1, equiv2) -> some number/comparable
      :param initequiv: If provided, the equivalence array to start from.  If None, start from the tileset without
                        any merged glues.
      :type initequiv: equiv

      :returns: **reduced** -- The reduced system/systems
      :rtype: single TileSet or equiv, or list


   .. py:method:: latticedefects(direction='e', depth=2, pp=True, rotate=False)
      :abstractmethod:

      Calculate and show possible small lattice defect configurations.


   .. py:method:: apply_equiv(equiv)
      :abstractmethod:

      Apply an equivalence array (from, eg, `TileSet.reduce_ends` or `TileSet.reduce_tiles`).

      :param equiv: An equivalence array, *for this tileset*, generated by reduction functions.
      :type equiv: ndarray

      :returns: A tileset with the equivalence array, and thus the reduction, applied.
      :rtype: TileSet


   .. py:method:: check_consistent()

      Check the TileSet consistency.

      Check a number of properties of the TileSet for consistency.
      In particular:

         * Each tile must pass Tile.check_consistent()
         * TileSet.ends and TileSet.tiles.endlist() must not contain conflicting
           ends or end sequences.
         * If there is a seed:
             * It must be of an understood type (it must be in seeds.seedtypes)
             * All adapter locations must be valid.
             * The seed must pass its check_consistent and check_sequence.


   .. py:method:: copy()

      Return a full (deep) copy of the TileSet


   .. py:method:: from_file(path_or_stream: io.TextIOWrapper | str | os.PathLike[str], format: Literal[json, yaml, None] = None) -> TileSet
      :classmethod:


   .. py:method:: to_file(path_or_stream: str | os.PathLike[str] | io.TextIOWrapper)



