Skip to content

Commit

Permalink
deformation
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhuohan1999 committed Sep 30, 2023
1 parent 087c477 commit d9b3659
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 13 deletions.
Binary file added openNucleome/.whole_nucleus_model.py.swp
Binary file not shown.
8 changes: 5 additions & 3 deletions openNucleome/whole_nucleus_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def add_lamina_potential(self, flag, chr_lam_param):
if flag['lam-lam']:
self.chr_system.addForce(self.lamina_model.add_lam_lam(22))
if flag['squeeze_nucleus']:
self.chr_system.addForce(self.lamina_model.add_squeeze_nucleus(23))
self.chr_system.addForce(self.lamina_model.add_squeeze_nucleus(23, k = flag['strength']))

def load_default_settings(self):
'''
Expand All @@ -305,19 +305,21 @@ def load_default_settings(self):
self.add_nucleolus_potential(dict_nuc_ff, chr_nuc_param)
self.add_lamina_potential(dict_lam_ff, chr_lam_param)

def load_customized_settings(self, force_field):
def load_customized_settings(self, force_field, k = 1.0):
'''
Load customized force field settings
Parameters
----------
force_field (Pandas Dataframe, required) :
Store the flag of all the potentials and the parameter file names
k (float, required) :
The strength of force squeezing the nucleus (Default: 1.0)
'''
dict_chrom_ff = {'bond':force_field.loc['chromosome']['bond'], 'angle':force_field.loc['chromosome']['angle'], 'softcore':force_field.loc['chromosome']['softcore'], 'ideal':force_field.loc['chromosome']['ideal'], 'compt':force_field.loc['chromosome']['compt'], 'inter':force_field.loc['chromosome']['inter']}
dict_spec_ff = {'spec-spec':force_field.loc['speckle']['spec-spec'], 'spec-chrom':force_field.loc['speckle']['spec-chrom']}
dict_nuc_ff = {'nuc-nuc':force_field.loc['nucleolus']['nuc-nuc'], 'nuc-spec':force_field.loc['nucleolus']['nuc-spec'], 'nuc-chrom':force_field.loc['nucleolus']['nuc-chrom']}
dict_lam_ff = {'lam-chrom':force_field.loc['lamina']['lam-chrom'], 'hard-wall':force_field.loc['lamina']['hard-wall'], 'lam-lam':self.flag_membrane, 'squeeze_nucleus':self.flag_membrane}
dict_lam_ff = {'lam-chrom':force_field.loc['lamina']['lam-chrom'], 'hard-wall':force_field.loc['lamina']['hard-wall'], 'lam-lam':self.flag_membrane, 'squeeze_nucleus':self.flag_membrane, 'strength': k}
ideal_param_file = force_field.loc['chromosome']['ideal_param_file']
compt_param_file = force_field.loc['chromosome']['compt_param_file']
interchr_param_file = force_field.loc['chromosome']['interchr_param_file']
Expand Down
2 changes: 1 addition & 1 deletion tutorials/HFF_100KB/NuclearDeformation/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## NuclearDeformation

This folder provides tutorials for setting up and performing simulations of the HFF nucleus at the 100KB resolution with the presence of various nuclear landmarks, including nuclear lamina, speckles, and nucleoli. Different from the sphere situation, we applied a force to squeeze the nucleus.
This folder provides tutorials for setting up and performing simulations of the HFF nucleus at the 100KB resolution with the presence of various nuclear landmarks, including nuclear lamina, speckles, and nucleoli. Different from the sphere nucleus situation, we applied a force to squeeze the nucleus.

- simulation.ipynb: The jupyter notebook showing how to create a system and run a simulation

Expand Down
31 changes: 23 additions & 8 deletions tutorials/HFF_100KB/NuclearDeformation/simulation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"id": "0987436b-c228-4ba7-baa9-28e21b3a63ed",
"metadata": {},
"source": [
"## Important parameters"
"## Important parameters\n",
"We defined the important parameters in the next block. First, we set the transition probability between dP particles and P particles as 0.2, and the transition frequency as 4000. When creating the system, we set type 6, 7 as the dP and P particles, respectively, so we kept using 6, 7 here. In this example, we ran a simulation with total length of 3,000,000 steps, and output one configuration and the energy every 2000 steps."
]
},
{
Expand All @@ -55,7 +56,12 @@
"id": "8e0e9ef8-97a2-488e-ba82-5fdfe446b9b3",
"metadata": {},
"source": [
"## Initialize the system"
"## Initialize the system\n",
"We first set up an example \"model\" of class \"OpenNucleome\" with the conserved temperature, damping coefficient, timestep, and the mass scale. In this folder, we also included the initial configuration \"human.pdb\" used for the simulation and created a system according to the initial configuration.\n",
"\n",
"Because during the simulations, we would transit the dP speckle and P speckle particles, here, we logged the start index and end index of speckle particle, and computed the number of speckle particles.\n",
"\n",
"In this example, we moved all the lamina beads, and would consider the dynamics of the membrane, and that is why we set \"True\" (on) for membrane dynamics. Consequently, we need to designate the bonds between specific lamina beads, so we included a text file, which logs all the pairs linked by the bonds, for the variable \"membrane_bond\"."
]
},
{
Expand All @@ -70,7 +76,6 @@
"# Generate new elements and construct topology as well; membrane_dynamics: True for including lamina dynamics, False for excluding lamina dynamics; membrane_bond: A file contains the lamina bond when membrane_dynamics is on.\n",
"model.create_system(PDB_file, membrane_dynamics = True, membrane_bond = 'lamina_bond.txt') \n",
"\n",
"index_spec_spec_potential = 6\n",
"start_spec_index = model.N_chr_nuc+1\n",
"end_spec_index = model.N_chr_nuc_spec+1\n",
"N_spec = start_spec_index-end_spec_index"
Expand All @@ -81,7 +86,12 @@
"id": "07c89f5c-7839-45ae-8b98-186d5600b42e",
"metadata": {},
"source": [
"## Add the force field"
"## Add the force field\n",
"Different from the sphere nucleus situation, we used a csv file to log all the flags of interactions between chromosomes and chromosomes, or chromosomes and nuclear landmarks. \n",
"\n",
"The column from \"bond\" to \"lam_squeeze\" is boolen, which means the switches of the corresponding interactions. For example, if the spec-chrom is True, it means in the simulation, the interaction between speckle and chromosome will be present; if the inter is False, it means we exclude the interchromosomal interactions between chromosome. Remember some potentials require the corresponding parameter files, such as ideal requires ideal_param_file and spec-chrom requires the chr_spec_param, so if you turn those potentials on, you should also include the corresponding parameter files.\n",
"\n",
"In this example, we turn every interaction on, and set the strength of force squeezing the nucleus as 1.0 (k) when loading the customized force field. The users can set their specific strengths."
]
},
{
Expand Down Expand Up @@ -277,18 +287,23 @@
],
"source": [
"# Add the customized force field\n",
"# In this customized setting, I logged all the flags for different interactions (True means on, False means off, and NaN means N/A) and all the corresponding files required for interactions. \n",
"# In this customized setting, I logged all the flags for different interactions\n",
"# (True means on, False means off, and NaN means N/A)\n",
"# and all the corresponding files required for interactions. \n",
"force_field = pd.read_csv('input.csv', sep=' ', header=0, index_col=0)\n",
"force_field\n",
"model.load_customized_settings(force_field)"
"model.load_customized_settings(force_field, k = 1.0)\n",
"\n",
"index_spec_spec_potential = 6\n",
"force_field"
]
},
{
"cell_type": "markdown",
"id": "6c942879-33b9-4ddd-92bf-0ebae07561cb",
"metadata": {},
"source": [
"## Perform simulation, in this example, total step = 3,000,000, output to dcd every 2000 steps, and output the energy (similar to thermo in lammps) every 2000 steps"
"## Perform the simulation\n",
"We first created the simulation with a specific Platform, and here, we used \"CUDA\" but users can also use \"CPU\", \"Reference\", and \"OpenCL\" according to their hardware. Before the simulation, we minimized the energy to make the system much more reasonable and stable. After randomly setting velocity, we started our simulation with a total length of 3,000,000 steps and output the configuration and energy every 2000 steps, and change the speckle types every 4000 steps as we mentioned in the previous blocks."
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion tutorials/HFF_100KB/SphericalNucleus/simulation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"metadata": {},
"source": [
"## Perform the simulation\n",
"We first created the simulation with a specific Platform, and here, we used \"CUDA\" but users can also use \"CPU\", \"Reference\", and \"OpenCL\" according to their hardware. Before the simulation, we minimized the energy to make the system much more reasonable and stable. After randomly setting velocity, we started our simulation with a total length of 3,000,000 steps and output the configuration and energy every 2000 steps, and change the speckle types every 4000 steps as we mentioned in the previous blocks"
"We first created the simulation with a specific Platform, and here, we used \"CUDA\" but users can also use \"CPU\", \"Reference\", and \"OpenCL\" according to their hardware. Before the simulation, we minimized the energy to make the system much more reasonable and stable. After randomly setting velocity, we started our simulation with a total length of 3,000,000 steps and output the configuration and energy every 2000 steps, and change the speckle types every 4000 steps as we mentioned in the previous blocks."
]
},
{
Expand Down

0 comments on commit d9b3659

Please sign in to comment.