alhambra.tilesets#

Module Contents#

Classes#

XgrowGlueOpts

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

GrowSelfComplementaryGlues

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

GrowPerfectGlues

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

GrowOrthogonalGlues

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

GrowFullGlues

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

TileSet

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

Functions#

_generate_stickydesign_energetic_classes(→ None)

Attributes#

log

_gl

T

SD_ENERGETICS_CLASSES

HAS_SD_ACCEL

alhambra.tilesets.log[source]#
alhambra.tilesets._gl[source]#
alhambra.tilesets.T[source]#
class alhambra.tilesets.XgrowGlueOpts[source]#

Bases: abc.ABC

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

get_xgrow_gse(tileset: TileSet) float | None[source]#
abstract calculate_gses(tileset: TileSet) tuple[list[xgrow.tileset.Bond], list[xgrow.tileset.Glue]][source]#
glue_name_map(tileset: TileSet) Callable[[str], str][source]#
classmethod from_str(glueopts: str) XgrowGlueOpts[source]#
class alhambra.tilesets.GrowSelfComplementaryGlues[source]#

Bases: XgrowGlueOpts

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

get_xgrow_gse(tileset: TileSet) float | None[source]#
glue_name_map(tileset: TileSet) Callable[[str], str][source]#
calculate_gses(tileset: TileSet) tuple[list[xgrow.tileset.Bond], list[xgrow.tileset.Glue]][source]#
alhambra.tilesets.SD_ENERGETICS_CLASSES: dict[str, stickydesign.EnergeticsBasic][source]#
alhambra.tilesets.HAS_SD_ACCEL: bool = False[source]#
alhambra.tilesets._generate_stickydesign_energetic_classes() None[source]#
class alhambra.tilesets.GrowPerfectGlues[source]#

Bases: XgrowGlueOpts

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

get_xgrow_gse(tileset: TileSet) float | None[source]#
calculate_gses(tileset: TileSet) tuple[list[xgrow.tileset.Bond], list[xgrow.tileset.Glue]][source]#
class alhambra.tilesets.GrowOrthogonalGlues[source]#

Bases: XgrowGlueOpts

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

temperature: float | None[source]#
alpha: float | None[source]#
get_xgrow_gse(tileset: TileSet) float | None[source]#
calculate_gses(tileset: TileSet) tuple[list[xgrow.tileset.Bond], list[xgrow.tileset.Glue]][source]#
class alhambra.tilesets.GrowFullGlues[source]#

Bases: XgrowGlueOpts

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

temperature: float | None[source]#
threshold: float = 0.0[source]#
alpha: float | None[source]#
get_xgrow_gse(tileset: TileSet) float | None[source]#
calculate_gses(tileset: TileSet) tuple[list[xgrow.tileset.Bond], list[xgrow.tileset.Glue]][source]#
class alhambra.tilesets.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)[source]#

Bases: alhambra.classes.Serializable

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

property allglues: alhambra.glues.GlueList[source]#
property alldomains: alhambra.glues.GlueList[source]#
tiles: alhambra.tiles.TileList[alhambra.tiles.Tile][source]#
glues: alhambra.glues.GlueList[alhambra.glues.Glue][source]#
seeds: dict[str | int, alhambra.seeds.Seed][source]#
lattices: dict[str | int, alhambra.grid.Lattice][source]#
guards: dict[str | int, list[str]][source]#
params: dict[source]#
classmethod 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[source]#

Given some TileSets, or lists of Tiles from which to take tiles, generate an TileSet from the mix.

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[source]#

Run the tilesystem in Xgrow.

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)[source]#
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)[source]#
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[source]#

Convert Alhambra TileSet to an XGrow TileSet

_to_xgrow_dict() dict[source]#

DEPRECATED: to xgrow dict

summary()[source]#

Returns a short summary line about the TileSet

__repr__() str[source]#

Return repr(self).

__str__() str[source]#

Return str(self).

classmethod from_scadnano(des: scadnano.Design, ret_fails: bool = False) TileSet[source]#

Create TileSet from Scadnano Design.

to_scadnano(lattice: alhambra.grid.LatticeSupportingScadnano | None = None) scadnano.Design[source]#

Export TileSet (with lattice) as Scadnano Design.

to_dict() dict[source]#
classmethod from_dict(d: dict) TileSet[source]#
_serialize() Any[source]#
classmethod _deserialize(input: Any) TileSet[source]#
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][source]#

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

Parameters:
  • lattice (AbstractLattice | int | str) – Lattice or reference to a lattice in the tileset

  • x (int | slice | None, optional) – index in the lattice, by default None

  • y (int | slice | None, optional) – index in the lattice, by default None

  • copy (bool, optional) – 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

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][source]#
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)[source]#

Create an SVG layout diagram from a lattice.

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

Parameters:
  • xgrowarray (ndarray or dict) – 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.

  • filename (string) – File name / path of the output file.

abstract reduce_tiles(preserve=('s22', 'ld'), tries=10, threads=1, returntype='equiv', best=1, key=None, initequiv=None)[source]#

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

Parameters:
  • tileset (TileSet) – The system to reduce.

  • preserve (a tuple or list of strings, optional) – 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’).

  • tries (int, optional) – The number of times to run the algorithm.

  • threads (int, optional) – The number of threads to use (using multiprocessing).

  • returntype ('TileSet' or 'equiv' (default 'equiv')) – 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).

  • best (int or None, optional) – 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)

  • key (function (ts, equiv1, equiv2) -> some number/comparable) – 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.

  • initequiv (equiv) – If provided, the equivalence array to start from. If None, start from the tileset without any merged glues.

Returns:

reduced – The reduced system/systems

Return type:

single TileSet or equiv, or list

abstract reduce_ends(preserve=['s22', 'ld'], tries=10, threads=1, returntype='equiv', best=1, key=None, initequiv=None)[source]#

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

Parameters:
  • tileset (TileSet) – The system to reduce.

  • preserve (a tuple or list of strings, optional) – 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’).

  • tries (int, optional) – The number of times to run the algorithm.

  • threads (int, optional) – The number of threads to use (using multiprocessing).

  • returntype ('TileSet' or 'equiv' (default 'equiv')) – 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).

  • best (int or None, optional) – 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)

  • key (function (ts, equiv1, equiv2) -> some number/comparable) – 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.

  • initequiv (equiv) – If provided, the equivalence array to start from. If None, start from the tileset without any merged glues.

Returns:

reduced – The reduced system/systems

Return type:

single TileSet or equiv, or list

abstract latticedefects(direction='e', depth=2, pp=True, rotate=False)[source]#

Calculate and show possible small lattice defect configurations.

abstract apply_equiv(equiv)[source]#

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

Parameters:

equiv (ndarray) – An equivalence array, for this tileset, generated by reduction functions.

Returns:

A tileset with the equivalence array, and thus the reduction, applied.

Return type:

TileSet

check_consistent()[source]#

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.

copy()[source]#

Return a full (deep) copy of the TileSet

classmethod from_file(path_or_stream: io.TextIOWrapper | str | os.PathLike[str], format: Literal[json, yaml, None] = None) TileSet[source]#
to_file(path_or_stream: str | os.PathLike[str] | io.TextIOWrapper)[source]#