Exemplo n.º 1
0
    /*!
     * \brief This reaction build a PromoterReaction reaction from a PromoterProperties class
     * \param props The PromoterProperties which will serve to create the reaction
     * \return Return the new reaction or null if it fail.
     */
    public static IReaction       buildPromoterFromProps(PromoterProperties props)
    {
        if (props == null)
        {
            return(null);
        }

        PromoterParser   parser   = new PromoterParser();
        PromoterReaction reaction = new PromoterReaction();

        reaction.setName(props.name);
        reaction.setBeta(props.beta);
        reaction.setTerminatorFactor(props.terminatorFactor);
        reaction.setEnergyCost(props.energyCost);
        TreeNode <PromoterNodeData> formula = parser.Parse(props.formula);

        reaction.setFormula(formula);
        Product newProd;

        foreach (Product p in props.products)
        {
            newProd = new Product(p);
            reaction.addProduct(newProd);
        }

        return(reaction);
    }
Exemplo n.º 2
0
    public LinkedList <IReaction> getReactions()
    {
        Logger.Log("Device::getReactions(); device=" + this, Logger.Level.TRACE);

        LinkedList <IReaction>          reactions = new LinkedList <IReaction>();
        LinkedList <PromoterProperties> props     = new LinkedList <PromoterProperties>(getPromoterReactions());

        foreach (PromoterProperties promoterProps in props)
        {
            Logger.Log("Device::getReactions() adding prop " + promoterProps, Logger.Level.TRACE);
            reactions.AddLast(PromoterReaction.buildPromoterFromProps(promoterProps));
        }

        Logger.Log("Device::getReactions() with device=" + this + " returns " + Logger.ToString <IReaction>(reactions), Logger.Level.INFO);
        return(reactions);
    }
Exemplo n.º 3
0
    /* !
     * \brief Checks that two reactions have the same PromoterReaction field values.
     * \param reaction The reaction that will be compared to 'this'.
     */
    protected override bool PartialEquals(IReaction reaction)
    {
        PromoterReaction promoter = reaction as PromoterReaction;

        bool bnullProm = (promoter != null);
        bool btermFac  = (_terminatorFactor == promoter._terminatorFactor);
        bool bformula  = formulaEquals(_formula, promoter._formula);
        bool bbeta     = (_beta == promoter._beta);

        Logger.Log("PromoterReaction::PartialEquals"
                   + ", bnullProm=" + bnullProm
                   + ", btermFac=" + btermFac
                   + ", bformula=" + bformula
                   + ", bbeta=" + bbeta
                   , Logger.Level.DEBUG);

        return((promoter != null) &&
               base.PartialEquals(reaction) &&
               (_terminatorFactor == promoter._terminatorFactor)
               //&& _formula.Equals(promoter._formula)
               && formulaEquals(_formula, promoter._formula) &&
               (_beta == promoter._beta));
    }
Exemplo n.º 4
0
 //! Copy constructor
 public PromoterReaction(PromoterReaction r) : base(r)
 {
     _terminatorFactor = r._terminatorFactor;
     _formula          = r._formula;
     _beta             = r._beta;
 }
Exemplo n.º 5
0
    /*!
     * \brief Execute everything about simulation into the Medium
     */
    public void Update()
    {
        if (enableShufflingReactionOrder)
        {
            LinkedListExtensions.Shuffle <IReaction>(_reactions);
        }

        foreach (IReaction reaction in _reactions)
        {
            if (Logger.isLevel(Logger.Level.TRACE))
            {
                PromoterReaction promoter = reaction as PromoterReaction;
                if (promoter != null)
                {
                    Logger.Log("Medium::Update reaction.react(" + _molecules + ") with reaction=" + reaction, Logger.Level.TRACE);
                }
            }
            reaction.react(_molecules);
        }

        applyVariation();

        if (_enableNoise)
        {
            float noise;

            foreach (Molecule m in _molecules)
            {
                noise = _numberGenerator.getNumber();
                if (_enableSequential)
                {
                    m.addConcentration(noise);
                }
                else
                {
                    m.addNewConcentration(noise);
                }
            }
        }

        //TODO improve check that it's the medium of the hero bacterium Cellia
        //TODO refactor interactions out of medium
        if (_name == "Cellia")
        {
            manageMoleculeConcentrationWithKey("AMPI");

            if (GameStateController.isAdminMode)
            {
                //TODO manage this differently
                manageMoleculeConcentrationWithKey("AMPR");
                manageMoleculeConcentrationWithKey("ATC");
                manageMoleculeConcentrationWithKey("FLUO1");
                manageMoleculeConcentrationWithKey("FLUO2");
                manageMoleculeConcentrationWithKey("IPTG");
                manageMoleculeConcentrationWithKey("MOV");
                manageMoleculeConcentrationWithKey("REPR1");
                manageMoleculeConcentrationWithKey("REPR2");
                manageMoleculeConcentrationWithKey("REPR3");
                manageMoleculeConcentrationWithKey("REPR4");
            }
        }
    }
Exemplo n.º 6
0
  /*!
    \brief This reaction build a PromoterReaction reaction from a PromoterProperties class
    \param props The PromoterProperties which will serve to create the reaction
    \return Return the new reaction or null if it fail.
   */
  public static IReaction       buildPromoterFromProps(PromoterProperties props)
  {
    if (props == null)
      return null;

    PromoterParser parser = new PromoterParser();
    PromoterReaction reaction = new PromoterReaction();

    reaction.setName(props.name);
    reaction.setBeta(props.beta);
    reaction.setTerminatorFactor(props.terminatorFactor);
    reaction.setEnergyCost(props.energyCost);
    TreeNode<PromoterNodeData> formula = parser.Parse(props.formula);
    reaction.setFormula(formula);
    Product newProd;
    foreach (Product p in props.products)
      {
        newProd = new Product(p);
        reaction.addProduct(newProd);
      }
		
    return reaction;
  }
Exemplo n.º 7
0
 //! Copy constructor
 public PromoterReaction(PromoterReaction r) : base(r)
 {
   _terminatorFactor = r._terminatorFactor;
   _formula = r._formula;
   _beta = r._beta;
 }