mcell4_generator.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. // TODO: add assert after every find_* call or add a call that checks that
  12. // the thing we are searching for exists
  13. #ifndef SRC4_MCELL4_GENERATOR_H_
  14. #define SRC4_MCELL4_GENERATOR_H_
  15. #include <string>
  16. #include <fstream>
  17. #include "json/json.h"
  18. #include "generator_structs.h"
  19. #include "python_generator.h"
  20. #include "bngl_generator.h"
  21. // TODO: use a different namespace, we are not using anything from MCell
  22. // except for constants
  23. namespace MCell {
  24. class MCell4Generator {
  25. public:
  26. bool generate(const SharedGenData& opts);
  27. private:
  28. void reset();
  29. std::string get_module_name(const std::string file_suffix);
  30. std::string make_import(const std::string file_suffix);
  31. void open_and_check_file(
  32. const std::string file_suffix, std::ofstream& out,
  33. const bool for_append = false,
  34. const bool bngl = false);
  35. void generate_customization();
  36. void generate_shared();
  37. void generate_simulation_setup_parameter(std::ostream& out, const string& name, const string& value);
  38. void generate_parameters();
  39. std::string generate_species_and_mol_types(std::ostream& out, std::vector<SpeciesOrMolType>& species_and_mt_info);
  40. void generate_variable_rate(const std::string& rate_array_name, Json::Value& variable_rate_text);
  41. std::vector<IdLoc> generate_reaction_rules(std::ostream& out, const std::vector<std::string>& surf_class_names);
  42. void find_required_compartments(std::set<std::string>& compartments);
  43. void analyze_and_generate_bngl_compartments(std::ostream& out);
  44. void generate_subsystem();
  45. std::string generate_single_geometry_object(
  46. std::ofstream& out, const int index, Json::Value& object);
  47. std::vector<std::string> generate_geometry();
  48. void generate_release_sites(std::ostream& out, std::vector<std::string>& release_site_names);
  49. void generate_instantiation(const std::vector<std::string>& geometry_objects);
  50. void generate_counts(std::ostream& out, std::vector<std::string>& python_counts, bool& has_bng_observables);
  51. void generate_observables();
  52. void generate_config(std::ostream& out);
  53. void generate_model(const bool print_failed_marker);
  54. void generate_customization_template();
  55. private:
  56. BNGLGenerator* bng_gen;
  57. std::ofstream bng_out;
  58. PythonGenerator* python_gen;
  59. // parameters, subsystem, and instantiation are always generated
  60. bool geometry_generated;
  61. bool observables_generated;
  62. SharedGenData data;
  63. };
  64. } /* namespace MCell */
  65. #endif /* SRC4_MCELL4_GENERATOR_H_ */