Package vsv

Source Code of vsv.VSVModel

package vsv;

import java.util.List;
import java.util.Vector;

import miscellaneous.Copiable;
import reaction.Item;
import reaction.Reaction;
import recorders.Recorder;
import tables.DimensionMap;

public class VSVModel implements Copiable<VSVModel> {
 
  public static String k_TRANSCRIPTION = "k_TRANSCRIPTION", ratio_TRANSCRIPTION_2_REPLICATION = "ratio_TRANSCRIPTION_2_REPLICATION", ratio_GENOME_2_ANTIGENOME = "ratio_GENOME_2_ANTIGENOME", stoich_ERROR = "stoich_ERROR",
      k_POL_FORMATION = "k_POL_FORMATION", k_CONDENSATION = "k_CONDENSATION", k_DETECTION = "k_DETECTION", pol_SPEED = "pol_SPEED", pol_SPACING = "pol_SPACING", rib_SPEED = "rib_SPEED", rib_SPACING = "rib_SPACING";
 
  public Virus virus;
  public Cell cell;
  public DimensionMap params;
  public Vector<Reaction> rxns;
  double moi = 1;
 
  public void setVirusAndCell(Virus virus, Cell cell)
  {
    this.virus = virus;
    this.cell = cell;
    this.initializeRxns();
  }
 
  public void initialize()
  {
    this.initializeVirus();
    this.initializeCell();
    this.initializeRxns();
  }
 
  public void initializeRxns()
  {
    this.rxns = new Vector<Reaction>();
    // this.initializeDegradation();
    // this.initializeDetection();
    // this.initializePackaging();
    this.initializeProteinInteractions();
    this.initializeReplication();
    this.initializeTranscription();
    this.initializeTranslation();
  }
 
  /**
   * updates parameter with a DimensionMap containing the values entered in JEX - for future use
   *
   * @param params
   */
  public void setParams(DimensionMap params)
  {
    this.params = params;
    this.virus.setParams(params);
    this.cell.setParams(params);
    this.initializeRxns();
  }
 
  // /**
  // * updates parameter with numbers entered in JEX - for future use
  // *
  // * @param PARAM_polymeraseOnRate_Transcription
  // * @param PARAM_transcriptionToReplicationRatio
  // * @param PARAM_genToAntiGenoRepRatio
  // * @param PARAM_detectableGenomeStoich
  // * @param PARAM_PLPol_rate
  // * @param PARAM_genomeMcondensationRate
  // * @param PARAM_detectionRateConstant
  // */
  // public void setParams(double PARAM_polymeraseOnRate_Transcription, double PARAM_transcriptionToReplicationRatio, double PARAM_genToAntiGenoRepRatio, double PARAM_detectableGenomeStoich, double PARAM_PLPol_rate, double
  // PARAM_genomeMcondensationRate, double PARAM_detectionRateConstant)
  // {
  // // Virus Parameters
  // this.virus.PARAM_polymeraseOnRate_Transcription = PARAM_polymeraseOnRate_Transcription;
  // this.virus.PARAM_transcriptionToReplicationRatio = PARAM_transcriptionToReplicationRatio;
  // this.virus.PARAM_genToAntiGenoRepRatio = PARAM_genToAntiGenoRepRatio;
  // this.virus.PARAM_detectableGenomeStoich = PARAM_detectableGenomeStoich;
  // this.virus.PARAM_PLPol_rate = PARAM_PLPol_rate;
  // this.virus.PARAM_genomeMcondensationRate = PARAM_genomeMcondensationRate;
  //
  // // Cell Parameters
  // this.cell.PARAM_detectionRateConstant = PARAM_detectionRateConstant;
  // this.virus.updateParams();
  // this.initializeRxns();
  // }
 
  /**
   *
   * @return reactions
   */
  public Vector<Reaction> getRxns()
  {
    return this.rxns;
  }
 
  /**
   * adds a transcription reaction to the reaction vector (rxns) with a cell pool virus genome definition (VSV) virus polymerase PARAM_polymeraseOnRate_Transcription template binding rate polymerase transcription rate on template polymerase spacing
   *
   */
  private void initializeTranscription()
  {
    // ////////////////////////////////////////////////////////////////////////////////
    // Transcription (you will need a transcription reaction for each
    // template)
    // ////////////////////////////////////////////////////////////////////////////////
    //
    // template1 + pol -> transcripts + template + pol, ktranscription
    //
    this.rxns.add(new TranscriptionRxn(this.cell, this.virus.genome, Virus.POLYMERASE, this.virus.PARAM_polymeraseOnRate_Transcription, this.virus.PARAM_polymeraseNtPerSec_Transcription, this.virus.PARAM_polymeraseSpacing));
  }
 
  /**
   * adds a translation reaction to the reaction vector (rxns) with a cell pool gene ribosome ribosome binding rate ribosome translation rate on template ribosome spacing
   */
  private void initializeTranslation()
  {
    // Translation (Each transcript must have a translation reaction, so use
    // a loop to add from each template)
    // transcript + ribosome -> protein + transcript + ribosome,
    // ktranslation
    List<Gene> proteinList = new Vector<Gene>();
    for (Gene g : this.virus.genome)
    {
     
      // if the protein has not already been added and it encodes a
      // protein
      if(!proteinList.contains(g) && g.encodesProtein)
      {
        // add gene to a list of genes to ensure no duplication
        proteinList.add(g);
       
        // add reaction to translate this gene
        this.rxns.add(new TranslationRxn(this.cell, g, Cell.PROTEIN_RIBOSOME, this.cell.ribosomeOnRate, this.cell.PARAM_ribosomeRate, this.cell.PARAM_ribosomeSpacing));
      }
    }
  }
 
  /**
   * adds a first order degradation reaction for transcripts, proteins, genomes and antigenomes
   */
  private void initializeDegradation()
  {
    // ////////////////////////////////////////////////////////////////////////////////
    // Degradation of transcripts, proteins, templates
    // ////////////////////////////////////////////////////////////////////////////////
    //
    // item --> 0, kDeg_Item
    //
    // add things in a loop to be simple
    // transcripts
    List<Gene> transcriptList = new Vector<Gene>();
    for (Gene g : this.virus.genome)
    {
      // if the transcript has not already been added and it encodes a
      // protein
      if(!transcriptList.contains(g) && g.encodesTranscript)
      {
        // add gene to a list of genes to ensure no duplication
        transcriptList.add(g);
       
        // add reaction to degrade this gene
        this.rxns.add(new FirstOrderDegradationRxn(g.name, this.cell.transcripts, Virus.transcript_degConstant));
      }
    }
    // proteins
    List<Gene> proteinList = new Vector<Gene>();
    for (Gene g : this.virus.genome)
    {
      // if the protein has not already been added and it encodes a
      // protein
      if(!proteinList.contains(g) && g.encodesProtein)
      {
        // add gene to a list of genes to ensure no duplication
        proteinList.add(g);
       
        // add reaction to translate this gene
        this.rxns.add(new FirstOrderDegradationRxn(g.name, this.cell.proteins, g.proteinDegradationRate));
      }
    }
    // genomes and templates
    this.rxns.add(new FirstOrderDegradationRxn(this.virus.genomeFullname(), this.virus.genomeName(), this.cell.templates, Virus.nucleocapsid_degConstant));
    this.rxns.add(new FirstOrderDegradationRxn(this.virus.antiGenomeFullname(), this.virus.antiGenomeName(), this.cell.templates, Virus.nucleocapsid_degConstant));
    this.rxns.add(new FirstOrderDegradationRxn(this.virus.condensedGenomeFullname(), this.virus.condensedGenomeName(), this.cell.templates, Virus.nucleocapsid_degConstant));
   
  }
 
  /**
   * adds a replication reaction with a cell virus genome virus antiGenome Virus POLYMERASE N protein polymeraseOnRate_GenomeReplication polymeraseNtPerSec_Replication polymeraseSpacing virus.errorGenomeName??? virus.PARAM_detectableGenomeStoich
   * ???
   */
  private void initializeReplication()
  {
    // ////////////////////////////////////////////////////////////////////////////////
    // Replication (must add 2 reactions for each template type)
    // ////////////////////////////////////////////////////////////////////////////////
    // genome + pol + N -> antigenome + genome + pol
    this.rxns.add(new ReplicationAndErrorRxn(this.cell, this.virus.genome, this.virus.antiGenome, Virus.POLYMERASE, Virus.N.name, this.virus.polymeraseOnRate_GenomeReplication, this.virus.polymeraseNtPerSec_Replication, this.virus.PARAM_polymeraseSpacing, this.virus.errorGenomeFullname(), this.virus.errorGenomeName(), this.virus.PARAM_detectableGenomeStoich));
    // antigenome + pol + N -> genome + antigenome + pol + detectableGenome
    this.rxns.add(new ReplicationAndErrorRxn(this.cell, this.virus.antiGenome, this.virus.genome, Virus.POLYMERASE, Virus.N.name, this.virus.polymeraseOnRate_AntiGenomeReplication, this.virus.polymeraseNtPerSec_Replication, this.virus.PARAM_polymeraseSpacing, this.virus.errorAntiGenomeFullname(), this.virus.errorAntiGenomeName(), this.virus.PARAM_detectableGenomeStoich));
  }
 
  /**
   * L and P interacts to make polymerase
   */
  private void initializeProteinInteractions()
  {
    // ////////////////////////////////////////////////////////////////////////////////
    // Protein Interactions
    // ////////////////////////////////////////////////////////////////////////////////
    // L + 3.6 P -> polymerase, krxn
    this.rxns.add(new TwoBodyOneProductRxn(Virus.L.name, this.cell.proteins, 1.0, 1.0, Virus.P.name, this.cell.proteins, 3.6, 1.0, Virus.POLYMERASE, this.cell.proteins, 1.0, this.virus.PARAM_PLPol_rate));
    // this.rxns.add(new TwoBodyOneProductRxn(Virus.M.name, this.cell.proteins, 1.0, 1.0, Cell.PROTEIN_CELLRIBOSOME, this.cell.proteins, 1.0, 1.0, Cell.PROTEIN_RIBOSOME, this.cell.proteins, 1.0, this.virus.MRibRate));
  }
 
  /**
   * initialize packaging based on the M protein and genome availability at genomeMcondensationRate (will be followed by condensation of this complex with other proteins)
   */
  private void initializePackaging()
  {
    // ////////////////////////////////////////////////////////////////////////////////
    // Packaging
    // ////////////////////////////////////////////////////////////////////////////////
    // genome + M -> genM, k (template protein reaction produce template)
    // rate = k*M^2*template
    this.rxns.add(new TwoBodyOneProductRxn(Virus.M.name, this.cell.proteins, this.virus.getComposition().get(Virus.M.name), 2.0, this.virus.genome.fullname, this.cell.templates, 1.0, 1.0, this.virus.condensedGenomeFullname(), this.cell.templates, 1.0, this.virus.PARAM_genomeMcondensationRate));
    // genM + pol -> virion, kpack
    // genM + pol + G -> virion, kpack (equal to kpack above, so G enhances
    // the packing rate) (model as 1 equation)
   
    this.rxns.add(new PackagingRxn(this.cell, Virus.POLYMERASE, Virus.G.name, this.virus.condensedGenomeFullname(), this.virus.name, this.virus.packagingRateConstant));
  }
 
  /**
   * initialize the detection reactions of detectable ("error") genomes by proteins
   */
  private void initializeDetection()
  {
    // ////////////////////////////////////////////////////////////////////////////////
    // Detection and response to bad genomes
    // ////////////////////////////////////////////////////////////////////////////////
    // detectableGenome+detectionProtein --> responseProtein
    // this.rxns.add(new TwoBodyOneProductRxn(this.virus.errorGenomeFullname(), this.cell.templates, 1.0, 1.0, Cell.PROTEIN_DETECTION, this.cell.proteins, 1.0, 1.0, Cell.PROTEIN_RESPONSE, this.cell.proteins, 1.0,
    // this.cell.PARAM_detectionRateConstant));
    // responseProtein --> AVProduct ???
    this.rxns.add(new OneBodyTwoProductRxn(this.virus.genomeFullname(), this.cell.templates, 1.0, 1.0, Cell.PROTEIN_DETECTION, this.cell.proteins, 1.0, this.virus.errorGenomeFullname(), this.cell.templates, 1.0, this.cell.PARAM_detectionRateConstant));
    this.rxns.add(new RibKillDetRxn(Cell.PROTEIN_RIBOSOME, this.cell.proteins, 1.0, 1.0, Cell.PROTEIN_DETECTION, this.cell.proteins, 1.0, 1.0, Cell.PROTEIN_RibDead, this.cell.proteins, 1.0, Cell.PROTEIN_DETECTION, this.cell.proteins, 1.0, this.cell.PARAM_ResponseConstant));
  }
 
  /**
   * initialize the virus as a list of genes. This call will do all the work in naming the virus
   */
  private void initializeVirus()
  {
    // N1 virus
    this.virus = new Virus(new Gene[] { Virus.Le, Virus.IG1, Virus.N, Virus.IG2, Virus.P, Virus.IG3, Virus.M, Virus.IG4, Virus.G, Virus.IG5, Virus.L, Virus.IG6, Virus.TrC }, "VSVN1");
    // RFP 1
    // this.virus = new Virus(new Gene[] { Virus.Le, Virus.IG1, Virus.RFP, Virus.IG1, Virus.N, Virus.IG2, Virus.P, Virus.IG3, Virus.M, Virus.IG4, Virus.G, Virus.IG5, Virus.L, Virus.IG6, Virus.TrC }, "VSVN1");
    // RFP 5
    // this.virus = new Virus(new Gene[] { Virus.Le, Virus.IG1, Virus.N, Virus.IG2, Virus.P, Virus.IG3, Virus.M, Virus.IG4, Virus.G,Virus.IG1,Virus.RFP, Virus.IG5, Virus.L, Virus.IG6, Virus.TrC }, "VSVN1");
  }
 
  /**
   * initializes a cell by initializing template and protein pools by adding viral genomes, polymerase, ribosomes and detection proteins
   */
  private void initializeCell()
  {
    this.cell = new Cell();
   
    // Load up Cell with goodies (infect the cell and add other ribosomes
    // and proteins)
    this.cell.templates.initialize(new Item(this.virus.genomeFullname(), this.moi, 0.0));
    this.cell.proteins.initialize(new Item(Virus.POLYMERASE, this.moi * this.virus.getComposition().getComponentCount(Virus.POLYMERASE), 0.0));
    this.cell.proteins.initialize(new Item(Virus.M.name, this.moi * this.virus.getComposition().getComponentCount(Virus.M.name), 0.0));
    this.cell.proteins.initialize(new Item(Cell.PROTEIN_RIBOSOME, Cell.initialRibosomes, 0.0));
  }
 
  /**
   * This method returns a value between 0 and 1 representing the decay of the cell due to a response protein The equation used to calculate the response is sigmoid - NOT IN CURRENT VERSION!!!
   *
   * @param PROTEIN_RESPONSE
   * @return
   */
  public double cellDecay(double time)
  {
    // ////////////////////////////////////////////////
    // Cell decay by threshold to detectable genomes //
    // ////////////////////////////////////////////////
   
    double templates = this.cell.templates.getCount(this.virus.genomeName());
    if(templates > 8000)
    {
      Recorder.log("Genome threshold", this);
      return 0;
    }
    else
    {
      return 1;
    }
   
    // ////////////////////////////////////////////////
    // Cell decay by response to detectable genomes //
    // ////////////////////////////////////////////////
   
    // //decay = 1/ (1 + exp( -k * responseProtein + offset))
    // double factor=0.1;
    // double offset=20;
    // double responseConc=cell.proteins.getCount(Cell.PROTEIN_RESPONSE);
    // double expTerm=-factor*responseConc+offset;
    // double decay=1/(1+Math.exp(expTerm));
    // return decay;
   
    // ////////////////////////////////////////////////
    // Cell decay according to time //
    // ////////////////////////////////////////////////
   
    // double decay;
    // try
    // {
    // decay = 1-StatisticsUtility.normalCDF(time, Cell.halfLife,
    // Cell.halfLifeSigma);
    // if(decay < 0)
    // {
    // decay = 0;
    // }
    // return decay;
    // }
    // catch (MathException e)
    // {
    // e.printStackTrace();
    // return 0.0;
    // }
   
    // ////////////////////////////////////////////////
    // Cell decay according to number of genomes //
    // ////////////////////////////////////////////////
   
    // double templates = this.cell.templates.getCount(this.virus.genomeName());// +
    // // this.cell.templates.delayedAmounts.getAll().getCount(virus.genomeName());
    // double thresh = Math.log10(templates);
    // try
    // {
    // // created sigmoidal decay function for cell activity
    // double cdfValue = StatisticsUtility.normalCDF(Math.log10(templates), Math.log10(Cell.virusProductionMean) / 2, Math.log10(Cell.virusProductionMean) / 5);
    // double decay = (1 - cdfValue);
    // if(Double.isNaN(decay) || decay < 0)
    // {
    // decay = 0;
    // }
    // return decay;
    // }
    // catch (MathException e)
    // {
    // e.printStackTrace();
    // return 0;
    // }
   
  }
 
  @Override
  public VSVModel copy()
  {
    VSVModel ret = new VSVModel();
    ret.cell = this.cell.copy();
    ret.virus = this.virus.copy();
    ret.params = this.params.copy();
    ret.initializeRxns();
    ret.moi = this.moi;
   
    return ret;
  }
}
TOP

Related Classes of vsv.VSVModel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.