Skip to content

Commit

Permalink
moving around inner functions
Browse files Browse the repository at this point in the history
  • Loading branch information
olive004 committed Dec 14, 2023
1 parent 628b495 commit 4e6727b
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 4,181 deletions.
17 changes: 1 addition & 16 deletions explanations/8_dataset_info.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"from bioreaction.simulation.simfuncs.basic_de import bioreaction_sim_expanded\n",
"from synbio_morpher.utils.modelling.deterministic import bioreaction_sim_dfx_expanded\n",
"from synbio_morpher.utils.misc.helper import vanilla_return\n",
"from synbio_morpher.utils.misc.numerical import flatten_to_matrix\n",
"from synbio_morpher.utils.results.analytics.naming import get_analytics_types_all, get_true_names_analytics, get_true_interaction_cols\n",
"from synbio_morpher.utils.results.analytics.timeseries import generate_analytics\n",
"from synbio_morpher.utils.common.testing.shared import CONFIG\n",
Expand Down Expand Up @@ -783,22 +784,6 @@
],
"source": [
"def load_circuit(circ_row, config):\n",
"\n",
" def symmetrical_matrix_length(flattened_length):\n",
" return int((-1 + np.sqrt(1 + 8 * flattened_length)) / 2)\n",
"\n",
" def flatten_to_matrix(flattened_vector):\n",
" length = symmetrical_matrix_length(len(flattened_vector))\n",
" matrix = [[0] * length for _ in range(length)]\n",
"\n",
" index = 0\n",
" for i in range(length):\n",
" for j in range(i, length):\n",
" matrix[i][j] = flattened_vector[index]\n",
" matrix[j][i] = flattened_vector[index]\n",
" index += 1\n",
"\n",
" return np.array(matrix)\n",
" \n",
" circ_path = os.path.join(og_dir, 'circuits', circ_row['name'] + '.fasta')\n",
" interactions = {'binding_rates_association': config['molecular_params']['association_binding_rate' + '_per_molecule'],\n",
Expand Down
18 changes: 1 addition & 17 deletions notebooks/12_sensitivity_peak.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@
"from bioreaction.simulation.simfuncs.basic_de import bioreaction_sim_expanded\n",
"from synbio_morpher.utils.modelling.deterministic import bioreaction_sim_dfx_expanded\n",
"from synbio_morpher.utils.misc.helper import vanilla_return\n",
"# from synbio_morpher.utils.misc.numerical import count_monotonic_group_lengths, find_monotonic_group_idxs, is_within_range\n",
"# from synbio_morpher.utils.misc.string_handling import string_to_tuple_list\n",
"# from synbio_morpher.utils.misc.type_handling import flatten_listlike, get_first_elements\n",
"# from synbio_morpher.utils.misc.string_handling import prettify_keys_for_label\n",
"from synbio_morpher.utils.misc.numerical import flatten_to_matrix\n",
"from synbio_morpher.utils.results.analytics.naming import get_analytics_types_all, get_true_names_analytics, get_true_interaction_cols\n",
"from synbio_morpher.utils.results.analytics.timeseries import generate_analytics\n",
"from synbio_morpher.utils.common.testing.shared import CONFIG\n",
Expand Down Expand Up @@ -209,22 +209,6 @@
"outputs": [],
"source": [
"def load_circuit(circ_row, config):\n",
"\n",
" def symmetrical_matrix_length(flattened_length):\n",
" return int((-1 + np.sqrt(1 + 8 * flattened_length)) / 2)\n",
"\n",
" def flatten_to_matrix(flattened_vector):\n",
" length = symmetrical_matrix_length(len(flattened_vector))\n",
" matrix = [[0] * length for _ in range(length)]\n",
"\n",
" index = 0\n",
" for i in range(length):\n",
" for j in range(i, length):\n",
" matrix[i][j] = flattened_vector[index]\n",
" matrix[j][i] = flattened_vector[index]\n",
" index += 1\n",
"\n",
" return np.array(matrix)\n",
" \n",
" circ_path = os.path.join(og_dir, 'circuits', circ_row['name'] + '.fasta')\n",
" interactions = {'binding_rates_association': config['molecular_params']['association_binding_rate' + '_per_molecule'],\n",
Expand Down
21 changes: 1 addition & 20 deletions notebooks/13_precision_traces.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@
" __package__ = os.path.basename(module_path)\n",
"\n",
"\n",
"from synbio_morpher.utils.results.analytics.naming import get_analytics_types_all, get_true_names_analytics, get_true_interaction_cols\n",
"\n",
"from bioreaction.simulation.manager import simulate_steady_states\n",
"from synbio_morpher.utils.data.data_format_tools.common import load_json_as_dict\n",
"from synbio_morpher.utils.modelling.deterministic import bioreaction_sim_dfx_expanded\n",
"from synbio_morpher.utils.misc.helper import vanilla_return\n",
"from synbio_morpher.utils.misc.numerical import flatten_to_matrix\n",
"from synbio_morpher.utils.results.analytics.naming import get_analytics_types_all, get_true_names_analytics, get_true_interaction_cols\n",
"from synbio_morpher.utils.results.analytics.timeseries import generate_analytics\n",
"from synbio_morpher.utils.common.setup import construct_circuit_from_cfg, prepare_config\n"
Expand Down Expand Up @@ -1783,24 +1782,6 @@
"\n",
"\n",
"def load_circuit(circ_row, config):\n",
"\n",
" def symmetrical_matrix_length(flattened_length):\n",
" return int((-1 + np.sqrt(1 + 8 * flattened_length)) / 2)\n",
"\n",
" def flatten_to_matrix(flattened_vector):\n",
" length = symmetrical_matrix_length(len(flattened_vector))\n",
" if length == 1:\n",
" length = int(np.sqrt(len(flattened_vector)))\n",
" return flattened_vector.reshape((length, length))\n",
" \n",
" matrix = [[0] * length for _ in range(length)]\n",
" index = 0\n",
" for i in range(length):\n",
" for j in range(i, length):\n",
" matrix[i][j] = flattened_vector[index]\n",
" matrix[j][i] = flattened_vector[index]\n",
" index += 1\n",
" return np.array(matrix)\n",
" \n",
" circ_path = os.path.join(og_dir, 'circuits', circ_row['name'] + '.fasta')\n",
" interactions = {'binding_rates_association': config['molecular_params']['association_binding_rate' + '_per_molecule'],\n",
Expand Down
20 changes: 1 addition & 19 deletions notebooks/15_case_study_circuit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"from synbio_morpher.utils.data.data_format_tools.common import load_json_as_dict\n",
"from synbio_morpher.utils.modelling.deterministic import bioreaction_sim_dfx_expanded\n",
"from synbio_morpher.utils.misc.helper import vanilla_return\n",
"from synbio_morpher.utils.misc.numerical import add_recursively\n",
"from synbio_morpher.utils.misc.numerical import flatten_to_matrix\n",
"from synbio_morpher.utils.misc.type_handling import append_nest_dicts\n",
"from synbio_morpher.utils.results.analytics.naming import get_analytics_types_all, get_true_names_analytics, get_true_interaction_cols\n",
"from synbio_morpher.utils.results.analytics.timeseries import generate_analytics\n",
Expand Down Expand Up @@ -518,24 +518,6 @@
"\n",
"\n",
"def load_circuit(circ_row, config, og_dir: str):\n",
"\n",
" def symmetrical_matrix_length(flattened_length):\n",
" return int((-1 + np.sqrt(1 + 8 * flattened_length)) / 2)\n",
"\n",
" def flatten_to_matrix(flattened_vector):\n",
" length = symmetrical_matrix_length(len(flattened_vector))\n",
" if np.power(length, 2) == len(flattened_vector):\n",
" length = int(np.sqrt(len(flattened_vector)))\n",
" return flattened_vector.reshape((length, length))\n",
" \n",
" matrix = [[0] * length for _ in range(length)]\n",
" index = 0\n",
" for i in range(length):\n",
" for j in range(i, length):\n",
" matrix[i][j] = flattened_vector[index]\n",
" matrix[j][i] = flattened_vector[index]\n",
" index += 1\n",
" return np.array(matrix)\n",
" \n",
" circ_path = os.path.join(og_dir, 'circuits', circ_row['name'] + '.fasta')\n",
" interactions = {'binding_rates_association': config['molecular_params']['association_binding_rate' + '_per_molecule'],\n",
Expand Down
Loading

0 comments on commit 4e6727b

Please sign in to comment.