BioDynaMo script Help

38 views
Skip to first unread message

Charles Baker

unread,
Oct 28, 2024, 3:20:33 PM10/28/24
to BioDynaMo Forum
Hello,

I need help trying to run the attached script in BioDynaMo.  This script simulates the effects of biological agents in space radiation environments requires an understanding of both the biological models and the radiation exposure dynamics. The script that sets up a simulation where biological agents (cells or tissue) are subjected to different levels of radiation exposure, such as Solar Particle Events (SPEs) and Galactic Cosmic Rays (GCRs), using BioDynaMo.  Specifically, the script specifically simulates the biological effects of E. Coli (a bacterium) and Saccharomyces cerevisiae (yeast) in space radiation environments.  I need to model these organisms' response to radiation exposure based on known biological properties, such as their resistance to radiation and potential DNA repair mechanisms. This script simulates how radiation affects biological agents over time.  Can anyone run this script to verify that it works?
Thanks, Chuck
EColi-SCerevisiae.cpp

ch00918

unread,
Oct 29, 2024, 12:05:14 PM10/29/24
to BioDynaMo Forum
Hi Chuck, 

Thanks for reaching out! We have had a look at the script and it does not work. The syntax of the script is seemingly broken (reminds us of something we would see in latex). You also seem to be calling classes and declaring header files that you have not included. You are also trying to run it through a general C++ script instead of using BioDynaMo directly, so it is unclear what you are trying to use it for exactly. Have you tried running the script yourself? What issue/ error message are you getting? 

Thanks, 
Cayla

Charles Baker

unread,
Nov 1, 2024, 3:35:30 AM11/1/24
to BioDynaMo Forum
Hi Cayla,

Here are the updates to the script.  Can you see if it works now?

Thanks,
Chuck

#include "biodynamo.h"

// Define a new biology module for E. Coli and S. cerevisiae that includes radiation effects
namespace bdm {

using namespace experimental;  // To access experimental features if required

// Create an enum to differentiate between the two species
enum class Species { EColi, SCerevisiae };

// A custom module to simulate the effects of radiation on biological agents
struct RadiationEffect : public BaseBiologyModule {
  BDM_STATELESS_BM_HEADER(RadiationEffect, BaseBiologyModule, 1);

  Species species_;

  RadiationEffect(Species species) : BaseBiologyModule(gAllEventIds), species_(species) {}

  // This method is called each timestep and applies radiation damage
  void Run(SimObject* so) override {
    auto* cell = bdm_static_cast<Cell*>(so);

    // Get the radiation level
    double radiation_exposure = GetRadiationLevel();

    // Define damage thresholds for E. Coli and S. cerevisiae
    double damage_threshold_low = (species_ == Species::EColi) ? 0.05 : 0.1;    
    double damage_threshold_high = (species_ == Species::EColi) ? 0.3 : 0.5;  

    // Apply damage based on radiation exposure
    if (radiation_exposure > damage_threshold_high) {
      cell->RemoveFromSimulation();  
    } else if (radiation_exposure > damage_threshold_low) {
      cell->ChangeVolume(-0.02 * cell->GetVolume());
    }
  }

  // Simulate the radiation level based on space environment (SPE/GCR)
  double GetRadiationLevel() {
    double base_radiation_level = 0.05;    
    double spe_radiation_level = 0.25;    

    bool spe_event = (Simulation::GetRandom()->Uniform(0.0, 1.0) < 0.05);

    return spe_event ? spe_radiation_level : base_radiation_level;
  }
};

// Create the initial population of E. Coli and S. cerevisiae cells
inline int SimulateBiologicalAgentsWithRadiation(int argc, const char** argv) {
  Simulation simulation(argc, argv);

  for (size_t i = 0; i < 500; ++i) {
    Cell* ecoli = new Cell({Simulation::GetRandom()->Uniform(0, 100),
                            Simulation::GetRandom()->Uniform(0, 100),
                            Simulation::GetRandom()->Uniform(0, 100)});
    ecoli->SetDiameter(2);  
    ecoli->AddBiologyModule(new RadiationEffect(Species::EColi));  
    simulation.GetResourceManager()->AddAgent(ecoli);
  }

  for (size_t i = 0; i < 500; ++i) {
    Cell* scerevisiae = new Cell({Simulation::GetRandom()->Uniform(0, 100),
                                  Simulation::GetRandom()->Uniform(0, 100),
                                  Simulation::GetRandom()->Uniform(0, 100)});
    scerevisiae->SetDiameter(5);  
    scerevisiae->AddBiologyModule(new RadiationEffect(Species::SCerevisiae));  
    simulation.GetResourceManager()->AddAgent(scerevisiae);
  }

  simulation.GetScheduler()->Simulate(1000);

  return 0;
}

} // namespace bdm

BDM_MAIN(bdm::SimulateBiologicalAgentsWithRadiation);

ch00918

unread,
Nov 12, 2024, 12:25:00 PM11/12/24
to BioDynaMo Forum

Hi Charles, 

It seems that other than the back slashes at points in the code, not much has changed- you still seem to be calling classes and declaring header files that you have not included, and not running it through BioDynaMo directly. If you could let us know any additional information on how you are using BioDynaMo and any errors you are getting yourself when you run the script we may be able to provide more help. 

Best, Cayla
Reply all
Reply to author
Forward
0 new messages