<jupyter_start><jupyter_text>Multiple Chains: Chromatin Dynamics Simulations on Chromosome 10 and Chromosome 11 of GM12878 Cell Line This tutorial should take between 5 to 15 minutes of reading and performing simulations. The first step is to import the **OpenMiChroM** module<jupyter_code>from OpenMiChroM.ChromDynamics import MiChroM
from OpenMiChroM.CndbTools import cndbTools<jupyter_output><empty_output><jupyter_text>`OpenMiChroM` allows the simulation of multiples chromosomes.  In this tutorial, the multiple chain simulation will be performed using the chromosomes 10 and 11 of the human GM12878 cell line.The system is generated based on the collapsed structure of each chromosome.  This collapse step is similar to the one presented in the single chromosome simulation.  For each chromosome, the collapse simulation should be performed.  Chromosome 10 Collapse Simulation<jupyter_code>sim_chr10 = MiChroM(name="chr10", temperature=1.0, time_step=0.01)
sim_chr10.setup(platform="opencl")
sim_chr10.saveFolder('output_chr10_chr11')
Chrom10 = sim_chr10.create_springSpiral(ChromSeq='inputs/chr10_beads.txt')
sim_chr10.loadStructure(Chrom10, center=True)

sim_chr10.addFENEBonds(kfb=30.0)
sim_chr10.addAngles(ka=2.0)
sim_chr10.addRepulsiveSoftCore(Ecut=4.0)
sim_chr10.addFlatBottomHarmonic()

sim_chr10.addTypetoType(mu=3.22, rc = 1.78)
sim_chr10.addIdealChromosome(mu=3.22, rc = 1.78, dinit=3, dend=500)

print("Performing chr10 simulation...")
for _ in range(1000):
    sim_chr10.runSimBlock(500)

sim_chr10.saveStructure(filename="chr10" ,mode="ndb")
del sim_chr10<jupyter_output><empty_output><jupyter_text>Chromosome 11 Collapse Simulation<jupyter_code>sim_chr11 = MiChroM(name="chr11", temperature=1.0, time_step=0.01)
sim_chr11.setup(platform="opencl")
sim_chr11.saveFolder('output_chr10_chr11')
Chrom11 = sim_chr11.create_springSpiral(ChromSeq='inputs/chr11_beads.txt')
sim_chr11.loadStructure(Chrom11, center=True)

sim_chr11.addFENEBonds(kfb=30.0)
sim_chr11.addAngles(ka=2.0)
sim_chr11.addRepulsiveSoftCore(Ecut=4.0)
sim_chr11.addFlatBottomHarmonic()

sim_chr11.addTypetoType(mu=3.22, rc = 1.78)
sim_chr11.addIdealChromosome(mu=3.22, rc = 1.78, dinit=3, dend=500)

print("Perform chr11 simulation...")
for _ in range(1000):
    sim_chr11.runSimBlock(500)

sim_chr11.saveStructure(filename="chr11", mode="ndb")
del sim_chr11<jupyter_output><empty_output><jupyter_text>Once the collapse simulations are done, the collapsed structures of each chromosome should be included in the same simulation system.<jupyter_code>sim_chr10_chr11 = MiChroM(name="chr10_chr11", temperature=1.0, time_step=0.01)
sim_chr10_chr11.setup(platform="opencl")
sim_chr10_chr11.saveFolder('output_chr10_chr11')<jupyter_output><empty_output><jupyter_text>The function `loadNDB`  receives a list of files and saves the chromosome collapse structures in the variable Struc_chr10_chr11.<jupyter_code>Struc_chr10_chr11 = sim_chr10_chr11.loadNDB(NDBfiles=['output_chr10_chr11/chr10_0_block1000.ndb',
                                   'output_chr10_chr11/chr11_0_block1000.ndb'])<jupyter_output><empty_output><jupyter_text>`Struc_chr10_chr11` contains the position of all beads for each chromosome.The variable `chains` shows information of each chromosome. `(start,end,is_ring)`, `is_ring=0` represents a open chromosome chain and `is_ring=1` represents a circular polymer (used for simulating bacteria genome). Before loading the structures in the simulation context, it is necessary to distribute the chromosome chains.- This step is essential for randomizing the initial condition when simulating different replicas.<jupyter_code>Struc_chr10_chr11 = sim_chr10_chr11.setFibPosition(Struc_chr10_chr11, dist=(1.5,3.0))<jupyter_output><empty_output><jupyter_text>Load the chromosomes in the simulation context.<jupyter_code>sim_chr10_chr11.loadStructure(Struc_chr10_chr11, center=True)<jupyter_output><empty_output><jupyter_text>The initial distribution of the chromosome structures can be saved in [.ndb file format](https://ndb.rice.edu/ndb-format). The file is stored in the path given in `saveFolder`.- In the case of having multiple chains in the simulation context, the `saveStructure` function will save each structure separately, and each saved structure will have an index starting from 0 . In this tutorial, 0 is for chr10, and 1 is for chr11<jupyter_code>sim_chr10_chr11.saveStructure(mode='ndb')<jupyter_output><empty_output><jupyter_text>The next step is to add the force field in the simulation object `sim_chr10_chr11`.In this tutorial, the forces are added in two sets:**MiChroM Homopolymer (Bonded) Potentials**<jupyter_code>sim_chr10_chr11.addFENEBonds(kfb=30.0)
sim_chr10_chr11.addAngles(ka=2.0)
sim_chr10_chr11.addRepulsiveSoftCore(Ecut=4.0)
sim_chr10_chr11.addFlatBottomHarmonic(n_rad=20)<jupyter_output><empty_output><jupyter_text>**MiChroM non-Bonded Potentials**Differently from the single chromosome tutorial, here, each force is added separately The `addTypetoType` interaction is independent of the chromosome chain and only depends on the loci types. This potential is added for both chains simultaneously.<jupyter_code>sim_chr10_chr11.addTypetoType(mu=3.22, rc = 1.78)<jupyter_output><empty_output><jupyter_text>On the other hand, in the Ideal Chromossome potential, the forces need to be added for each chromosome separately.The function `addMultiChainIC` receives the chromosome chain and adds the IC potential.- The chromosome chain information can be obtained from the function `chains`. In this case, the data is retrieved from the object `sim_chr10_chr11.chains`.- The Ideal Chromosome potential was applied from the genomic distance d = 3 to d=500. The range values can be adjusted based on the chromosome length.<jupyter_code>sim_chr10_chr11.addMultiChainIC(chains=sim_chr10_chr11.chains[0], mu=3.22, rc = 1.78, dinit=3, dend=500)
sim_chr10_chr11.addMultiChainIC(chains=sim_chr10_chr11.chains[1], mu=3.22, rc = 1.78, dinit=3, dend=500)<jupyter_output><empty_output><jupyter_text>**The simulation setup is complete!**To run the production simulation, it is necessary to initialize the .cndb file to save the chromatin dynamics trajectory.The files will be saved in the output folder defined using the `saveFolder` function.Each chromosome will be stored separately.   The same procedure is adopted when using the `saveStructure` function.<jupyter_code>sim_chr10_chr11.initStorage('traj_chr10_chr11', mode='w')<jupyter_output><empty_output><jupyter_text>Sets the parameters of the production simulations:$block = 5\times10^2$  $n\_blocks = 2\times10^3$<jupyter_code>block = 5*10**2
n_blocks = 5*10**2
for _ in range(n_blocks):
    sim_chr10_chr11.runSimBlock(block) 
    sim_chr10_chr11.saveStructure()<jupyter_output><empty_output><jupyter_text>Once the simulation is performed, it is necessary to close the .cndb file to avoid losing the trajectory data.<jupyter_code>sim_chr10_chr11.storage[0].close() #close the cndb file for chr10
sim_chr10_chr11.storage[1].close() #close the cndb file for chr11<jupyter_output><empty_output><jupyter_text>To visualize the chromosome's 3D structures in the standard visualization software for macromolecules, there are available scripts for converting the ndb/cndb file format to .pdb and .gro. For details, please check the [Nucleome Data Bank](https://ndb.rice.edu/ndb-format).The ndb plugin for visualizing the chromatin dynamics trajectories in VMD/Chimera/Pymol is under development.<jupyter_code>sim_chr10_chr11.saveStructure(mode="ndb")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08671978751660027, 'fraction_numerical': 0.055644090305444885, 'mean_word_length': 7.312362030905077, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 61, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '15', 'dir': 'jupyter-structured-clean-dedup', 'id': '335214', 'license': 'MIT', 'n_tokens_mistral': 2761, 'n_tokens_neox': 2454, 'n_words': 658, 'path': 'docs/source/Tutorials/Tutorial_Multiple_Chromosomes.ipynb', 'repo_name': 'ed29rice/OpenMiChroM', 'size': '7530'}