Structure Models¶
Structure Models for DNA Simulations are included under fractaldna.structure_models.
Long fractals can be generated using L-Strings, which can then be turned into a voxelised representation using the methods in fractaldna.structure_models.voxelisation.
Generating Hilbert Curves using L-Strings¶
- fractaldna.structure_models.hilbert.generate_path(lstring, n=2, distance=10.0, rounding=0, pbar=False)
Generate a path from an l-string
When moving a distance smaller than 1, ensure that rounding is set correctly.
This algorithm works best when moving in integer steps and applying any scaling after generating the path.
- Parameters:
lstring (
str
) – lstring describing pathn (
int
) – steps on path between forward movementsdistance (
float
) – distance between points forward movementsrounding (
int
) – rounding to apply to each positionpbar (
bool
) – display a progress bar
- Return type:
List
[array
]- Returns:
list of XYZ points
Voxelising Fractals¶
- class fractaldna.structure_models.voxelisation.VoxelisedFractal
Class containing a voxelised representation of a fractal
Typically created using the VoxelisedFractal.fromSeed class method
fractal = VoxelisedFractal.fromSeed(‘X’, 1) fractal.fractal contains a list of ‘Voxels’ representing the DNA Path
- center_fractal()
Center the fractal around (x, y, z) = (0, 0, 0)
- Return type:
None
- classmethod fromLString(lstring, pbar=False)
Convert an L-String into a VoxelisedFractal
- Parameters:
lstring (
str
) – L-String to convertpbar (
bool
) – Show a progress bar for generating path and voxels
- Returns:
Voxelised Fractal representation
- classmethod fromSeed(seed, iterations, distance=1)
Make a voxelised fractal from an L-String seed.
The available L-Strings are described in fractaldna.structure_models.hilbert
- Parameters:
seed (
str
) – Seed L-Stringiterations (
int
) – number of times to iterate seeddistance (
float
) – distance between voxels
- Returns:
Voxelised Fractal representation
- classmethod from_path(path, pbar=False)
Convert a path (a list of xyz positions) to a voxelised representation
- Parameters:
path (
Union
[List
[array
],List
[List
],array
]) – path to convertpbar (
bool
) – show a progress bar if true
- Returns:
Voxelised Fractal representation
- to_frame(suppress_hash=False)
Convert voxelised representation to data frame
- Parameters:
suppress_hash (
bool
) – Hide the hash in front of the ‘IDX’ column which is kept for compatibiilty with the Geant4 DNA simulation format- Returns:
Voxelised fractal as a data frame
- to_plot(refine=0, batch=False)
Create a matplotlib figure instance of this fractal
fig = toPlot(refine=0, batch=False) :type refine:
int
:param refine: points to plot in between voxels (more points = clearer path) :type batch:bool
:param batch: True to suppress automatic display of the figure- Return type:
figure
- to_pretty_plot(refine=10, mayavi=False, mask=None)
Create a matplotlib figure instance of this fractal, with curved lines rather than hard corners
fig = to_pretty_plot(refine=10, batch=False)
- Parameters:
refine (
int
) – points to plot in between voxels (more points = clearer path)mayavi (
bool
) – make plot with MayaVImask (
Optional
[Callable
]) – Callable function that returns true for voxels that should be plotted. mask is a function that should take a position three vector and return boolean True/False for any position.
- to_text(sep=' ', comment='#')
- Return a textual representation of the fractal as
KIND POS_X POS_Y POS_Z EUL_PSI EUL_THETA EUL_PHI
- Parameters:
sep (
str
) – string to use to separate fields (default space)comment (
str
) – string to use to denote comment in first line (default hash: #)