python_generator.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /******************************************************************************
  2. *
  3. * Copyright (C) 2020 by
  4. * The Salk Institute for Biological Studies
  5. *
  6. * Use of this source code is governed by an MIT-style
  7. * license that can be found in the LICENSE file or at
  8. * https://opensource.org/licenses/MIT.
  9. *
  10. ******************************************************************************/
  11. #ifndef UTILS_DATA_MODEL_TO_PYMCELL_PYTHON_GENERATOR_H_
  12. #define UTILS_DATA_MODEL_TO_PYMCELL_PYTHON_GENERATOR_H_
  13. #include <iostream>
  14. #include <string>
  15. #include <vector>
  16. #include "generator_structs.h"
  17. namespace MCell {
  18. class MCell4Generator;
  19. class PythonGenerator {
  20. public:
  21. PythonGenerator(SharedGenData& data_)
  22. : data(data_), mcell(data_.mcell), unnamed_surf_class_counter(0)
  23. {
  24. }
  25. void generate_parameters(std::ostream& out);
  26. void generate_species_and_mol_types(std::ostream& out, std::vector<SpeciesOrMolType>& species_and_mt_info);
  27. void generate_surface_classes(std::ostream& out, std::vector<std::string>& sc_names);
  28. // the parameters file must be closed because we might append some code to it
  29. std::string generate_single_reaction_rule(std::ostream& out, Json::Value& reaction_list_item);
  30. void generate_reaction_rules(std::ostream& out, std::vector<IdLoc>& rxn_names);
  31. void generate_geometry(std::ostream& out, std::vector<std::string>& geometry_objects);
  32. void generate_release_sites(std::ostream& out, std::vector<std::string>& release_site_names);
  33. void generate_surface_classes_assignments(std::ostream& out);
  34. void generate_compartment_assignments(std::ostream& out);
  35. void generate_viz_outputs(std::ostream& out, const bool cellblender_viz, std::vector<std::string>& viz_output_names);
  36. void generate_all_bngl_reaction_rules_used_in_observables(std::ostream& out);
  37. void generate_single_count(
  38. std::ostream& out,
  39. const std::string& count_name,
  40. const std::string& observable_name,
  41. const std::string& file_name,
  42. const std::string& count_term_name,
  43. const std::string& mul_div_str,
  44. const std::string& rxn_step);
  45. std::string generate_count_terms_for_expression(
  46. ostream& out,
  47. const string& mdl_string, // may be empty, in that case we use what_to_count and where_to_count
  48. const std::string& what_to_count,
  49. const std::string& where_to_count,
  50. const std::string& orientation,
  51. const bool rxn_not_mol);
  52. std::string generate_single_molecule_release_info_array(
  53. std::ostream& out,
  54. std::string& rel_site_name,
  55. Json::Value& release_site_list,
  56. Json::Value::ArrayIndex begin,
  57. Json::Value::ArrayIndex end);
  58. void generate_release_pattern(std::ostream& out, const std::string& name, std::string& delay_string);
  59. private:
  60. void generate_single_parameter(std::ostream& out, Json::Value& parameter);
  61. std::string generate_component_type(
  62. std::ostream& out, Json::Value& bngl_component_item, const std::string& mol_type_name);
  63. std::string generate_single_species_or_mol_type(
  64. std::ostream& out, Json::Value& molecule_list_item,
  65. const bool generate_species, const std::vector<std::string>& component_names = std::vector<std::string>());
  66. SpeciesOrMolType generate_single_species_or_mol_type_w_components(
  67. std::ostream& out, Json::Value& molecule_list_item);
  68. std::string generate_single_count_term(
  69. ostream& out,
  70. const std::string& what_to_count,
  71. const std::string& where_to_count,
  72. const std::string& orientation,
  73. const bool molecules_not_species,
  74. const bool rxn_not_mol);
  75. void generate_rxn_rule_side(std::ostream& out, Json::Value& substances_node);
  76. void get_surface_class_property_info(
  77. const string& sc_name, Json::Value& property,
  78. std::string& name, std::string& type_name,
  79. std::string& affected_mols, std::string& orientation, std::string& clamp_concentration);
  80. void generate_variable_rate(const std::string& rate_array_name, Json::Value& variable_rate_text);
  81. std::string generate_single_geometry_object(
  82. std::ostream& out, const int index, Json::Value& object);
  83. bool is_volume_mol_type(const std::string& mol_type_name);
  84. std::vector<std::string> get_species_to_visualize();
  85. private:
  86. SharedGenData& data; // owned by MCell4Generator
  87. Json::Value& mcell;
  88. uint unnamed_surf_class_counter;
  89. };
  90. } /* namespace MCell */
  91. #endif /* UTILS_DATA_MODEL_TO_PYMCELL_PYTHON_GENERATOR_H_ */