subsystem.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 API_SUBSYSTEM_H
  12. #define API_SUBSYSTEM_H
  13. #include <functional>
  14. #include "generated/gen_subsystem.h"
  15. #include "api/api_common.h"
  16. #include "api/api_utils.h"
  17. #include "api/species.h"
  18. #include "api/surface_class.h"
  19. #include "api/reaction_rule.h"
  20. namespace BNG {
  21. class ElemMolType;
  22. class RxnRule;
  23. class Cplx;
  24. }
  25. namespace MCell {
  26. namespace API {
  27. class Complex;
  28. class Subsystem: public GenSubsystem {
  29. public:
  30. SUBSYSTEM_CTOR()
  31. // from generated template
  32. void add_species(std::shared_ptr<Species> s) override {
  33. append_to_vec_canonical_name(species, s);
  34. }
  35. std::shared_ptr<Species> find_species(const std::string& name) override {
  36. return vec_find_by_name(species, name);
  37. }
  38. void add_reaction_rule(std::shared_ptr<ReactionRule> r) override {
  39. // reactions don't have to have name
  40. append_to_vec_canonical_name(reaction_rules, r);
  41. }
  42. std::shared_ptr<ReactionRule> find_reaction_rule(const std::string& name) override {
  43. return vec_find_by_name(reaction_rules, name);
  44. }
  45. void add_surface_class(std::shared_ptr<SurfaceClass> sc) override {
  46. append_to_vec(surface_classes, sc);
  47. }
  48. std::shared_ptr<SurfaceClass> find_surface_class(const std::string& name) override {
  49. return vec_find_by_name(surface_classes, name);
  50. }
  51. void add_elementary_molecule_type(std::shared_ptr<ElementaryMoleculeType> mt) override {
  52. append_to_vec_canonical_name(elementary_molecule_types, mt);
  53. }
  54. std::shared_ptr<ElementaryMoleculeType> find_elementary_molecule_type(const std::string& name) override {
  55. return vec_find_by_name(elementary_molecule_types, name);
  56. }
  57. void load_bngl_molecule_types_and_reaction_rules(
  58. const std::string& file_name,
  59. const std::map<std::string, double>& parameter_overrides = std::map<std::string, double>()
  60. ) override;
  61. // added manually
  62. // may return nullptr
  63. std::shared_ptr<Species> get_species_with_id(const species_id_t id);
  64. // go through all species and make sure that
  65. // 1) all identical elementary molecule type objects exist only once and
  66. // 2) all are also in the elementary_molecule_types array
  67. void unify_and_register_elementary_molecule_types();
  68. void dump() const;
  69. protected:
  70. void convert_bng_data_to_subsystem_data(const BNG::BNGData& bng_data);
  71. private:
  72. void convert_reaction_rule(const BNG::BNGData& bng_data, const BNG::RxnRule& bng_rr);
  73. };
  74. } // namespace API
  75. } // namespace MCell
  76. #endif // API_SUBSYSTEM_H