Skip to content

Commit

Permalink
Updating Tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
alatham13 committed Nov 21, 2024
1 parent 64b6f0f commit ba484a5
Show file tree
Hide file tree
Showing 30 changed files with 1,477 additions and 25 deletions.
Binary file added Jupyter/.DS_Store
Binary file not shown.
679 changes: 679 additions & 0 deletions Jupyter/.ipynb_checkpoints/Untitled-checkpoint.ipynb

Large diffs are not rendered by default.

738 changes: 738 additions & 0 deletions Jupyter/Untitled.ipynb

Large diffs are not rendered by default.

Binary file added Jupyter/images/Chi2_Table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jupyter/images/Heterogeneity_Assessment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jupyter/images/Input_heterogeneity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jupyter/images/Input_snapshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jupyter/images/Input_trajectories.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jupyter/images/Overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jupyter/images/Snapshot_Exhaust.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jupyter/images/Snapshot_sampling.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jupyter/images/Spatiotemporal_Model.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jupyter/images/static_snapshots.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Jupyter/images/static_snapshots_noCC.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# IMP spatiotemporal tutorial
NOTE: This tutorial is still in progress of being completed. Please do not use yet. In the meantime, see https://github.com/salilab/imp/tree/develop/modules/spatiotemporal/examples/toy for a worked demonstration of the spatiotemporal module

Tutorial for computing spatiotemporal integrative models in IMP. For more information please check out the related publications:
* Latham bioRxiv, 2024, https://doi.org/10.1101/2024.08.06.606842.
* Rožič et al. in preparation. (tutorial paper)
* Latham et al. in preparation. (tutorial paper)

### This tutorial explores scripts that:
* Generates snapshot models at various timepoints along a dynamic process
Expand Down
2 changes: 1 addition & 1 deletion modeling/Snapshots/Snapshots_Assessment/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### This directory contains the code necessary for analyzing static snapshot models

See https://integrativemodeling.org/tutorials/spatiotemporal/snapshot_assess.html
See https://integrativemodeling.org/tutorials/spatiotemporal/snapshots.html
2 changes: 1 addition & 1 deletion modeling/Snapshots/Snapshots_Modeling/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### This directory contains the code necessary for generating static snapshot models

See https://integrativemodeling.org/tutorials/spatiotemporal/snapshot1.html
See https://integrativemodeling.org/tutorials/spatiotemporal/snapshots.html
2 changes: 1 addition & 1 deletion modeling/Trajectories/Trajectories_Assessment/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### This directory contains the code necessary for analyzing trajectory models

See https://integrativemodeling.org/tutorials/spatiotemporal/trajectory_assess.html
See https://integrativemodeling.org/tutorials/spatiotemporal/trajectories.html
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,11 @@ def process_foxs(state_dict, custom_dat_file = None):
command6 = f"gnuplot snapshot1_{time}_{time}_exp.plt"
os.system(command6)

command7 = f"mv snapshot1_{time}_{time}_exp.plt {time}_FoXS.png"
command7 = f"mv snapshot1_{time}_{time}_exp.plt {time}_FoXS.plt"
os.system(command7)

command8 = f"mv snapshot1_{time}_{time}_exp.png {time}_FoXS.png"
os.system(command8)
else:
print(f"There is no states in this timepoint. Check stat_dict.")

Expand Down Expand Up @@ -638,7 +641,7 @@ def append_rmf_coordinates(coord_list, rmf_hierarchy, rmf_fh):
return coord_list


def RMSD(pdb_path, custom_n_plot=None, custom_output_directory=None, custom_base_path=None):
def RMSD(pdb_path, custom_n_plot=None, custom_output_directory=None, custom_base_path=None, custom_heterogeneity_path=None):
"""
This function reads a .config file generated by the imp sampcon exhaust function
for each state to determine which chains from the pdb file should be included in the calculation.
Expand All @@ -658,6 +661,7 @@ def RMSD(pdb_path, custom_n_plot=None, custom_output_directory=None, custom_base
:param custom_output_directory (optional - str): If desired, different name of output directory (where plots and .txt
files are saved) can be set. Default name: "RMSD_calculation_output"
:param custom_base_path (optional - str): Custom path to the directory where snapshot{state}_{time} created with start_sim.py are.
:param custom_heterogeneity_path (optional - str): Custom path to the directory where .config files are
"""
# create output directory where all RMSD output is gathered
if custom_output_directory:
Expand All @@ -670,18 +674,23 @@ def RMSD(pdb_path, custom_n_plot=None, custom_output_directory=None, custom_base
for time in state_dict.keys():
for state in range(1, state_dict[time] + 1):
# Construct directory path
# Base path is path to the directory where all the snapshot{state}_{time} are saved and .config files (both created with start_sim.py)
# Base path is path to the directory where all the snapshot{state}_{time} are saved (both created with start_sim.py)
if custom_base_path:
base_path = custom_base_path
else:
base_path = "../../Snapshots/Snapshots_Modeling"
# heterogeneity_path is the directory where .config files are
if custom_heterogeneity_path:
heterogeneity_path = custom_heterogeneity_path
else:
heterogeneity_path = "../../Heterogeneity/Heterogeneity_Modeling"
snapshot = f"snapshot{state}_{time}" # directory snapshot{state}_{time} is created with start_sim.py
print(f"Now we are extracting from {snapshot}")

directory_path = os.path.join(base_path, snapshot)

# Read the configuration file created with start_sim.py
config_path = os.path.join(base_path,
config_path = os.path.join(heterogeneity_path,
f"{state}_{time}.config")
if not os.path.exists(config_path):
print(f"Configuration file {config_path} not found. Check base path and output")
Expand Down
2 changes: 1 addition & 1 deletion modeling/Trajectories/Trajectories_Modeling/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### This directory contains the code necessary for generating trajectory models

See https://integrativemodeling.org/tutorials/spatiotemporal/trajectory1.html
See https://integrativemodeling.org/tutorials/spatiotemporal/trajectories.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### This directory contains the code necessary for assessing heterogeneity models

See https://integrativemodeling.org/tutorials/spatiotemporal/heterogeneity.html
3 changes: 3 additions & 0 deletions modeling_empty/Heterogeneity/Heterogeneity_Modeling/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### This directory contains the code necessary for generating heterogeneity models

See https://integrativemodeling.org/tutorials/spatiotemporal/heterogeneity.html
1 change: 1 addition & 0 deletions modeling_empty/Heterogeneity/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### This directory contains the code necessary for generating and analyzing heterogeneity models
2 changes: 1 addition & 1 deletion modeling_empty/Snapshots/Snapshots_Assessment/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### This directory contains the code necessary for analyzing static snapshot models

See https://integrativemodeling.org/tutorials/spatiotemporal/snapshot_assess.html
See https://integrativemodeling.org/tutorials/spatiotemporal/snapshots.html
2 changes: 1 addition & 1 deletion modeling_empty/Snapshots/Snapshots_Modeling/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### This directory contains the code necessary for generating static snapshot models

See https://integrativemodeling.org/tutorials/spatiotemporal/snapshot1.html
See https://integrativemodeling.org/tutorials/spatiotemporal/snapshots.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### This directory contains the code necessary for analyzing trajectory models

See https://integrativemodeling.org/tutorials/spatiotemporal/trajectory_assess.html
See https://integrativemodeling.org/tutorials/spatiotemporal/trajectories.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,29 @@
-analysis (from IMP.spatiotemporal)
"""
# 1 - copy_files_for_data (copy all relevant files into 'data' directory)
def copy_files_for_data(state_dict, custom_source_dir1 = None, custom_source_dir2 = None):
def copy_files_for_data(state_dict, custom_source_dir1 = None, custom_source_dir2 = None, custom_source_dir3 = None):
"""
Copies three types of files important to generate two independent trajectory models (A and B):
Copies three types of files important to generate trajectory models:
-.config files created with start_sim.py in Snapshot_Modeling (source_dir1)
-time-dependent stoichiometry data for each timepoint. Data should be presented in .csv file. With this function all
csv file in source_dir2 will be copied. These .csv files will be used in the exp_comp dictionary in create_DAG
function
-scoresA and scoresB for each snapshot created with imp sampcon exhaust
(source_dir1 + snapshot + good_scoring_models)
(source_dir1 + snapshot + good_scoring_models) are merged into total score .txt using merge_scores helper function.
All copied files are gathered in newly created './data/' directory, where everything is prepared for create_DAG
function.
:param state_dict (dict): state_dict: dictionary that defines the spatiotemporal model.
The keys are strings that correspond to each time point in the
stepwise temporal process. Keys should be ordered according to the
steps in the spatiotemporal process. The values are integers that
correspond to the number of possible states at that timepoint.
:param custom_source_dir1 (optional - str): Custom path to snapshot modeling dir (start_sim.py), to copy .config
files and scoresA/scoresB (custom_source_dir1 + snapshot{state}_{time} + 'good_scoring_models')
:param custom_source_dir1 (optional - str): Custom path to heterogeneity modeling dir (heterogeneity_modeling.py),
to copy .config files
:param custom_source_dir2 (optional - str): Custom path to stoichiometry data dir
:param custom_source_dir3 (optional - str): Custom path to snapshot modeling dir (start_sim.py), to copy .config
files and to access scoresA/scoresB (custom_source_dir3 + snapshot{state}_{time} + 'good_scoring_models')
"""
# Create the destination directory for all the data copied in this function
destination_dir = './data/'
Expand All @@ -60,14 +65,20 @@ def copy_files_for_data(state_dict, custom_source_dir1 = None, custom_source_dir
if custom_source_dir1:
source_dir1 = custom_source_dir1
else:
source_dir1 = '../../Snapshots/Snapshots_Modeling/'
source_dir1 = '../../Heterogeneity/Heterogeneity_Modeling/'

# path to stoichiometry data dir
if custom_source_dir2:
source_dir2 = custom_source_dir1
else:
source_dir2 = '../../Input_Information/gen_FCS/'

# path to snapshot modeling dir
if custom_source_dir3:
source_dir3 = custom_source_dir3
else:
source_dir3 = '../../Snapshots/Snapshots_Modeling/'

# Copy all .config files from the first source directory to the destination directory
try:
for file_name in os.listdir(source_dir1):
Expand All @@ -94,7 +105,7 @@ def copy_files_for_data(state_dict, custom_source_dir1 = None, custom_source_dir
try:
for time in state_dict.keys():
for state in range(1, state_dict[time] + 1):
snapshot_dir = os.path.join(source_dir1, f'snapshot{state}_{time}')
snapshot_dir = os.path.join(source_dir3, f'snapshot{state}_{time}')
good_scoring_models_dir = os.path.join(snapshot_dir, 'good_scoring_models')
if os.path.isdir(good_scoring_models_dir):
for score_file in ['scoresA.txt', 'scoresB.txt']:
Expand Down Expand Up @@ -513,8 +524,11 @@ def process_foxs(state_dict, custom_dat_file = None):
command6 = f"gnuplot snapshot1_{time}_{time}_exp.plt"
os.system(command6)

command7 = f"mv snapshot1_{time}_{time}_exp.plt {time}_FoXS.png"
command7 = f"mv snapshot1_{time}_{time}_exp.plt {time}_FoXS.plt"
os.system(command7)

command8 = f"mv snapshot1_{time}_{time}_exp.png {time}_FoXS.png"
os.system(command8)
else:
print(f"There is no states in this timepoint. Check stat_dict.")

Expand Down Expand Up @@ -627,7 +641,7 @@ def append_rmf_coordinates(coord_list, rmf_hierarchy, rmf_fh):
return coord_list


def RMSD(pdb_path, custom_n_plot=None, custom_output_directory=None, custom_base_path=None):
def RMSD(pdb_path, custom_n_plot=None, custom_output_directory=None, custom_base_path=None, custom_heterogeneity_path=None):
"""
This function reads a .config file generated by the imp sampcon exhaust function
for each state to determine which chains from the pdb file should be included in the calculation.
Expand All @@ -647,6 +661,7 @@ def RMSD(pdb_path, custom_n_plot=None, custom_output_directory=None, custom_base
:param custom_output_directory (optional - str): If desired, different name of output directory (where plots and .txt
files are saved) can be set. Default name: "RMSD_calculation_output"
:param custom_base_path (optional - str): Custom path to the directory where snapshot{state}_{time} created with start_sim.py are.
:param custom_heterogeneity_path (optional - str): Custom path to the directory where .config files are
"""
# create output directory where all RMSD output is gathered
if custom_output_directory:
Expand All @@ -659,18 +674,23 @@ def RMSD(pdb_path, custom_n_plot=None, custom_output_directory=None, custom_base
for time in state_dict.keys():
for state in range(1, state_dict[time] + 1):
# Construct directory path
# Base path is path to the directory where all the snapshot{state}_{time} are saved and .config files (both created with start_sim.py)
# Base path is path to the directory where all the snapshot{state}_{time} are saved (both created with start_sim.py)
if custom_base_path:
base_path = custom_base_path
else:
base_path = "../../Snapshots/Snapshots_Modeling"
# heterogeneity_path is the directory where .config files are
if custom_heterogeneity_path:
heterogeneity_path = custom_heterogeneity_path
else:
heterogeneity_path = "../../Heterogeneity/Heterogeneity_Modeling"
snapshot = f"snapshot{state}_{time}" # directory snapshot{state}_{time} is created with start_sim.py
print(f"Now we are extracting from {snapshot}")

directory_path = os.path.join(base_path, snapshot)

# Read the configuration file created with start_sim.py
config_path = os.path.join(base_path,
config_path = os.path.join(heterogeneity_path,
f"{state}_{time}.config")
if not os.path.exists(config_path):
print(f"Configuration file {config_path} not found. Check base path and output")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### This directory contains the code necessary for generating trajectory models

See https://integrativemodeling.org/tutorials/spatiotemporal/trajectory1.html
See https://integrativemodeling.org/tutorials/spatiotemporal/trajectories.html

0 comments on commit ba484a5

Please sign in to comment.