{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Single Chromosome Simulation for Classic MiChroM"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This tutorial should take between 10 to 20 minutes of reading and performing simulations."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Chromatin Dynamics Simulations on Chromosome 10 of stomach GRCh38 (from ENCODE Project)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Note**: This tutorial will be running in OpenMiChroM version 1.1.0 or greater. Please ensure you have the correct version installed before proceeding."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The first step is to import the **OpenMiChroM** module"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from OpenMiChroM.ChromDynamics import MiChroM"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Download the bed file that contains the sequence annotation for stomach via ENCODE website (https://www.encodeproject.org/)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%bash\n",
"wget -O Tutorials/Chromosomes_simulations/inputs/ENCFF963ZUJ.bed.gz https://www.encodeproject.org/files/ENCFF963ZUJ/@@download/ENCFF963ZUJ.bed.gz \n",
"gunzip -f Tutorials/Chromosomes_simulations/inputs/ENCFF963ZUJ.bed.gz \n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"`MiChroM` class sets the initial parameters of the simulation:\n",
"\n",
"- `timeStep=0.01`: set the simulation time step to perfom the integration
\n",
"- `temperature=1.0`: set the temperature of your simulation
"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sim = MiChroM(name='stomach_GRCh38', temperature=1.0, timeStep=0.01)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There are four hardware platform options to run the simulations: \n",
"```python\n",
"platform=\"cuda\"\n",
"platform=\"opencl\"\n",
"platform=\"hip\"\n",
"platform=\"cpu\"\n",
"```\n",
"\n",
"Choose accordingly."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sim.setup(platform=\"Cuda\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Set the directory name in which the output of the simulation is saved:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"sim.saveFolder('/home/antonio/test_OM1.1')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The next step is to load the chromatin compartment sequence for chromosome 10 and generate an initial 3D structure to start the simulation. We can use the [createSpringSpiral](https://open-michrom.readthedocs.io/en/latest/OpenMiChroM.html#OpenMiChroM.ChromDynamics.MiChroM.createSpringSpiral) function to set the initial configuration of the polymer based in the sequence file.\n",
"\n",
"We will use the bed file download above, and set the chromosome 10 to slice the file and get the sequence annotation."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sim.buildClassicMichrom(ChromSeq='Tutorials/Chromosomes_simulations/inputs/ENCFF963ZUJ.bed', chromosome='chr10')\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As you can see on the output above, we build the system with MiChroM Potential add the homopolymer potentials and the Michrom Potentials.\n",
"\n",
"The system reports some statitics as, number of beads, number of chains and the initial energy potential for each force applied."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we create the reporters to save the simulation infos. There are 3 types of reporters:\n",
"\n",
"**statistics**: Attaches a reporter to collect simulation statistics such as step number, radius of gyration (RG), total energy, potential energy, kinetic energy, and temperature.\n",
"\n",
"**trajectory**: Attaches a reporter to save trajectory data (xyz per bead per chain) during the simulation. The file format to save the trajectory data. Options are 'cndb', 'swb','ndb', 'pdb', 'gro', 'xyz'. (Default: 'cndb')\n",
"\n",
"**energy components**: Saves energy components per force group to a separate file named 'energyComponents.txt' in the simulation folder. Requires that statistics is True\n",
"\n",
"set the number of steps interval we will save this information, here I choose 1000 steps"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"sim.createReporters(statistics=True, traj=True, trajFormat=\"cndb\", energyComponents=True, interval=10**3)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The `sim.run()` function is used to start the simulation. The parameters for this function are:\n",
"\n",
"- `nsteps`: The number of steps to run the simulation. In this case, it is set to \\(10^5\\).\n",
"- `report`: A boolean value indicating whether to report the simulation progress. Here, it is set to `True`.\n",
"- `interval`: The interval at which the simulation reports progress. In this case, it is set to \\(10^4\\) steps.\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sim.run(nsteps=10**6, report=True, interval=10**4)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"After the simulation end, in the output folder you will find the files, in this tutorial the files was saved in \"/home/antonio/test_OM1.1\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%bash\n",
"cat /home/antonio/test_OM1.1/initialStats.txt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%bash\n",
"head -n 10 /home/antonio/test_OM1.1/statistics.txt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%bash\n",
"head -n 10 /home/antonio/test_OM1.1/energyComponents.txt"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}