How to make a Other DNA Structure

Structures can also be built from paths, or as random placements.

Paths can be used to seed a measured geometry, while random placements serve well when generating isotropic DNA damage measurements

[ ]:
import sys
from pathlib import Path

try:
    # The voxelisation library produces the cubic voxelisation that
    # can be used to build DNA
    from fractaldna.structure_models import voxelisation as v
    from fractaldna.structure_models import random_placements as rp

except (ImportError, ModuleNotFoundError):
    sys.path.append(str(Path.cwd().parent.parent.parent))
    from fractaldna.structure_models import voxelisation as v
    from fractaldna.structure_models import random_placements as rp

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

Producing Voxels from Random Placements

This method generates a random collection of prisms inside a ball. It places candidate prisms in the volume of interest, ensuring there are no overlaps.

[ ]:
placements = rp.generate_non_overlapping_prisms(
    10, np.array([100, 100, 200]), 500, early_exit=-1, verbose=True
)
[ ]:
# A single prism can be plotted as a diagnostic,
# using random points inside the prism
# Arrows show the cardinal axes of the prism

placements.prisms[0].to_plot(n=500, arrows=True)
[ ]:
# Multiple prisms can be plotted together

fig = plt.figure()
ax = fig.add_subplot(111, projection="3d")
for prism in placements.prisms:
    prism.to_plot(ax=ax)
[ ]:
# And the output can be extracted as a Data Frame
placements.to_frame()
[ ]: