{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Placing volumes that contain multiple DNA solenoids\n", "\n", "Multiple solenoid volumes allow for the densest DNA geometries we generate here.\n", "\n", "Up to 9 solenoids can be placed in a voxel by the methods shown in this example.\n", "\n", "*It is recommended that you run this example inside a Jupyter environment*\n", "*rather than a VSCode or similar environment*\n", "\n", "This requires the mayavi jupyter extension\n", "`jupyter nbextension install --py mayavi --user`" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import sys\n", "from pathlib import Path\n", "\n", "try:\n", " from fractaldna.dna_models import dnachain as dna\n", "except (ImportError, ModuleNotFoundError):\n", " sys.path.append(str(Path.cwd().parent.parent.parent))\n", " from fractaldna.dna_models import dnachain as dna\n", "\n", "from mayavi import mlab\n", "\n", "# Disable this option for interactive rendering\n", "mlab.options.offscreen = True\n", "\n", "# Enable this option for an interactive notebook\n", "# mlab.init_notebook()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Making Multiple Solenoids" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Multi-Solenoidal Volumes contain 8 chromatin strands.\n", "chain = dna.MultiSolenoidVolume(voxelheight=750)\n", "# MayaVI plots are best for visualisation here\n", "plot = chain.to_strand_plot()\n", "plot.scene.save_jpg(\"multi_solenoid_strand_plot.jpg\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![multi_solenoid_strand_plot](multi_solenoid_strand_plot.jpg)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# They can be turned, and only select chains can be generated\n", "chain = dna.MultiSolenoidVolume(\n", " voxelheight=1500, separation=400, turn=True, chains=[0, 3, 7]\n", ")\n", "plot = chain.to_line_plot()\n", "plot.scene.save_jpg(\"multi_solenoid_turned_plot.jpg\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![multi_solenoid_turned_plot](multi_solenoid_turned_plot.jpg)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exporting multiple solenoids as text" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# This too can be exported to a dataframe of basepairs\n", "chain.to_frame()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# And a second base pair of histones\n", "chain.histones_to_frame()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "language_info": { "name": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 4 }