Team:BCCS-Bristol/Modeling/HowBSimWorks

From 2009.igem.org

Revision as of 10:47, 9 September 2009 by Sr8243 (Talk | contribs)

BCCS-Bristol
iGEM 2009

How BSim works

How BSim should work

particles.add(
  new Bacterium(position: 0 1 0, radius: 1),
  new Bacterium(position: 0 1 0, radius: 1),
  new Bacterium(position: 0 1 0, radius: 1),
  new Bead(position: 0 1 0),
);

b = new Bacterium()
b.grn(new GRN(dy/dx = -2x; dx/dz = y^2))
particles.add(b);

chemicalFields.add(
  new ChemicalField(chemical: aspartate),
  new ChemicalField(chemical: AHL)
)


boundaries(..)
dt(..)
simulationTime(..)

renderer(new ProcessingRenderer())

exporters.add(
  new FileExporter(),
  new MovieExporter(),
  new ScreenshotExporter()
)

gui()

How AgentCell works

A very cut down version of Example.java in agentcell.runs:

public class Example {

	private static List cellArrayList;
	
	public Example() {
        super();
    }

    // Setup and run a model.
    public static void main(String args[]) {
          
        final ChemotaxisModel model = new ChemotaxisModel();
  
        model.setDt(0.01);
        model.setStopTime(4.0); //2000.0);
        double equilibrationTime=2.0; //1000.0;

        final World world = new World();
        model.setWorld(world);
        world.setModel(model);

        
        BoundaryConditions boundaryConditions = new BoundaryConditions(world);
        world.setBoundaryConditions(boundaryConditions);

        // Set the chemical gradient.
        double aspartateGradient = 1.0E-8;  // M / micrometer
        world.setConcentrationField(new ConcentrationFieldConstantGradientWithBounds(
                Molecule.ASPARTATE, // type
                new Vect3(0, 0, 0), // origin
                0, // concentration at origin in Mol
                new Vect3(0, 0, aspartateGradient), 0, // min Level
                1.0E-2)); // max level
  
        
        //Create the cells
        cellArrayList = RunSetupUtils.findMatchingDirectories(new File(ChemotaxisModel.runDirAbsolutePath), "cell");        
        model.setAgentCellNumberOfCells(String.valueOf(cellArrayList.size()));
                
        for (int i = 0; i < cellArrayList.size(); i++) {

            double zpos = 100.0; //position chosen for the cell to be in 1 uM aspartate
            Vect position = new Vect3(0, 0, zpos);

            Orientation orientation = new Orientation(); //local and global axes are aligned 
            orientation.randomize();

            double volume = 1.41E-15;

            ChemotacticCell cell = new ChemotacticCell(world, position,
                    orientation, new Copynumber(Molecule.CHEYP), volume);
            

            cell.setPath( new File(cellArrayList.get(i).toString()).getAbsolutePath());                    
            cell.setEquilibrationTime(equilibrationTime);

            Receptors receptors = new Receptors(cell);
            receptors.getDissociationConstants().put("{asp}",new Double(1.71E-6));   
            receptors.getDissociationConstants().put("{asp*}",new Double(12E-6));              
            cell.setReceptors(receptors);

            // Create a Network
            cell.setChemotaxisNetwork( new ChemotaxisNetwork(cell, "STCHSTC.INI", 
            		(new File(cell.getPath(), "network1") + File.separator + "Input")) );
            
            cell.getChemotaxisNetwork().getCopynumber(cell.getCheYp());
                      
			 
            int initialMotorState;

            if (cell.getCheYp().getLevel() > cheYpThreshold.getLevel()) {
                initialMotorState = Motor.CW;
            } else {
                initialMotorState = Motor.CCW;
            }

            double minCWDuration = 0.1; // seconds
            double minCCWDuration = 0.1; // seconds
            double boxcarTimeWidth = 0.3; //seconds
            cell.setMotor(new AveragedCheYpThresholdMotor(cell,
                    initialMotorState, minCWDuration, minCCWDuration,
                    cheYpThreshold,
                    (int) Math.round(boxcarTimeWidth / model.getDt())));

            // Create a flagella group
            int flagellaState = Flagella.INVALIDSTATE;

            if (cell.getMotor().getState() == Motor.CCW) {
                flagellaState = Flagella.BUNDLED;
            } else {
                flagellaState = Flagella.APART;
            }

            //cell.setFlagella(new TetheredFlagellum(cell,flagellaState));
            cell.setFlagella(new SwimmingFlagella(cell, flagellaState));

            // Create a motion stepper with run and tumble states.
            RunTumbleStepper motionStepper = new RunTumbleStepper(cell);

            //Motion:
            double runSpeed = 20;
            double runRotationalDiffusion = 0.0620577;
            motionStepper.setRun(new Run(motionStepper, runSpeed,
                    runRotationalDiffusion));

            //Tumble that fits the distribution in
            //Fig. 3, p. 501 from Berg and Brown, Nature, 239, 500 (1972)
            double shape = 4;
            double scale = 18.32045567939674;
            double location = -4.606176605609249;
            motionStepper.setTumble(new TumbleGammaDistribution(motionStepper,
                    shape, scale, location));

            // motionStepper.setTumble(new TumbleCosinusDistribution(motionStepper));			
            cell.setMotionStepper(motionStepper);

            //print info about cell
            System.out.println("Initial position of cell " +
                cell.getIdentifier() + " is :" + cell.getPosition());

            // Add the new cell to the world. 			
            world.getCells().add(cell);
        }

        // Create a new time schedule.
        model.setSchedule(new Schedule());

        // Schedule each of the cells to run.
        model.getSchedule().scheduleActionAtIntervalRnd(model.getDt(),
            ((List) model.getWorld().getCells()), ChemotacticCell.class, "step");

        // Run the model.
        BatchController control = new BatchController(new Vector());
        model.setController(control);
        control.setModel(model);
        model.addSimEventListener(control);
        control.begin();
    }


}