instantiation.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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_INSTANTIATION_H
  12. #define API_INSTANTIATION_H
  13. #include "generated/gen_instantiation.h"
  14. #include "api/api_common.h"
  15. #include "api/api_utils.h"
  16. #include "api/release_site.h"
  17. namespace BNG {
  18. class BNGData;
  19. class SeedSpecies;
  20. class Compartment;
  21. }
  22. namespace MCell {
  23. namespace API {
  24. class Instantiation: public GenInstantiation {
  25. public:
  26. INSTANTIATION_CTOR()
  27. // from generated template
  28. void add_release_site(std::shared_ptr<ReleaseSite> s) override {
  29. append_to_vec(release_sites, s);
  30. }
  31. std::shared_ptr<ReleaseSite> find_release_site(const std::string& name) override {
  32. return vec_find_by_name(release_sites, name);
  33. }
  34. void add_geometry_object(std::shared_ptr<GeometryObject> o) override {
  35. append_to_vec(geometry_objects, o);
  36. }
  37. std::shared_ptr<GeometryObject> find_geometry_object(const std::string& name) override {
  38. return vec_find_by_name(geometry_objects, name);
  39. }
  40. void load_bngl_compartments_and_seed_species(
  41. const std::string& file_name,
  42. std::shared_ptr<Region> default_release_region = nullptr,
  43. const std::map<std::string, double>& parameter_overrides = std::map<std::string, double>()
  44. ) override;
  45. std::shared_ptr<GeometryObject> find_volume_compartment_object(const std::string& name) override;
  46. std::shared_ptr<GeometryObject> find_surface_compartment_object(const std::string& name) override;
  47. // added manually
  48. void dump() const;
  49. // returns empty shared ptr if compartment was not found
  50. std::shared_ptr<Region> get_compartment_region(const std::string& name);
  51. protected:
  52. void convert_bng_data_to_instantiation(
  53. const BNG::BNGData& bng_data,
  54. std::shared_ptr<Region> default_release_region);
  55. private:
  56. void convert_compartments(
  57. const BNG::BNGData& bng_data);
  58. void convert_single_seed_species_to_release_site(
  59. const BNG::BNGData& bng_data,
  60. const BNG::SeedSpecies& bng_ss,
  61. std::shared_ptr<Region> default_release_region);
  62. };
  63. } // namespace API
  64. } // namespace MCell
  65. #endif // API_INSTANTIATION_H