package vsv;
import java.util.List;
import java.util.Vector;
import miscellaneous.StatisticsUtility;
import org.apache.commons.math.MathException;
import reaction.Item;
import reaction.Reaction;
import tables.DimensionMap;
public class DIPModel {
// Virus parameters
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";
// DIP parameters
public static String k_TRANSCRIPTION_DIP = "k_TRANSCRIPTION_DIP", ratio_TRANSCRIPTION_2_REPLICATION_DIP = "ratio_TRANSCRIPTION_2_REPLICATION_DIP", ratio_GENOME_2_ANTIGENOME_DIP = "ratio_GENOME_2_ANTIGENOME_DIP",
stoich_ERROR_DIP = "stoich_ERROR_DIP", k_CONDENSATION_DIP = "k_CONDENSATION_DIP", k_DETECTION_DIP = "k_DETECTION_DIP";
public Virus virus;
public DIP dip;
public Cell cell;
public Vector<Reaction> rxns;
double moi = 1;
double modip = 0.0;
public DIPModel()
{
this.initializeVirus();
this.initializeDIP();
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)
{
// Virus Parameters (for JEX)
this.virus.setParams(params);
// DIP Parameters (for JEX)
this.dip.setParams(params);
// Cell Parameters (for JEX)
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, double PARAM_polymeraseOnRate_Transcription_DIP, double PARAM_transcriptionToReplicationRatio_DIP, double PARAM_genToAntiGenoRepRatio_DIP, double
// PARAM_detectableGenomeStoich_DIP, double PARAM_PLPol_rate_DIP, double PARAM_genomeMcondensationRate_DIP, double PARAM_detectionRateConstant_DIP)
// {
// // 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;
//
// // DIP Parameters
// this.dip.PARAM_polymeraseOnRate_Transcription_DIP = PARAM_polymeraseOnRate_Transcription_DIP;
// this.dip.PARAM_transcriptionToReplicationRatio_DIP = PARAM_transcriptionToReplicationRatio_DIP;
// this.dip.PARAM_genToAntiGenoRepRatio_DIP = PARAM_genToAntiGenoRepRatio_DIP;
// this.dip.PARAM_detectableGenomeStoich_DIP = PARAM_detectableGenomeStoich_DIP;
// this.dip.PARAM_PLPol_rate_DIP = PARAM_PLPol_rate_DIP;
// this.dip.PARAM_genomeMcondensationRate_DIP = PARAM_genomeMcondensationRate_DIP;
//
// // Cell Parameters
// this.cell.PARAM_detectionRateConstant = PARAM_detectionRateConstant;
// this.cell.PARAM_detectionRateConstant_DIP = PARAM_detectionRateConstant_DIP;
// 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));
this.rxns.add(new TranscriptionRxn(this.cell, this.dip.genome, Virus.POLYMERASE, this.dip.PARAM_polymeraseOnRate_Transcription_DIP, this.dip.PARAM_polymeraseNtPerSec_Transcription_DIP, this.dip.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));
}
}
List<Gene> transcriptListDIP = new Vector<Gene>();
for (Gene m : this.dip.genome)
{
// if the transcript has not already been added and it encodes a protein
if(!transcriptListDIP.contains(m) && m.encodesTranscript)
{
// add gene to a list of genes to ensure no duplication
transcriptListDIP.add(m);
// add reaction to degrade this gene
this.rxns.add(new FirstOrderDegradationRxn(m.name, this.cell.transcripts, DIP.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));
this.rxns.add(new FirstOrderDegradationRxn(this.dip.genomeName(), this.cell.templates, Virus.nucleocapsid_degConstant));
this.rxns.add(new FirstOrderDegradationRxn(this.dip.antiGenomeName(), this.cell.templates, Virus.nucleocapsid_degConstant));
this.rxns.add(new FirstOrderDegradationRxn(this.dip.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));
// DIPgenome + pol + N -> DIPantigenome + DIPgenome + pol
this.rxns.add(new ReplicationAndErrorRxn(this.cell, this.dip.genome, this.dip.antiGenome, Virus.POLYMERASE, Virus.N.name, this.dip.polymeraseOnRate_GenomeReplication_DIP, this.dip.polymeraseNtPerSec_Replication_DIP, this.dip.PARAM_polymeraseSpacing, this.dip.errorGenomeName(), this.dip.errorGenomeNickname(), this.dip.PARAM_detectableGenomeStoich_DIP));
// DIPantigenome + pol + N -> DIPgenome + DIPantigenome + pol
this.rxns.add(new ReplicationAndErrorRxn(this.cell, this.dip.antiGenome, this.dip.genome, Virus.POLYMERASE, Virus.N.name, this.dip.polymeraseOnRate_AntiGenomeReplication_DIP, this.dip.polymeraseNtPerSec_Replication_DIP, this.dip.PARAM_polymeraseSpacing, this.virus.errorAntiGenomeName(), this.dip.errorAntiGenomeNickname(), this.dip.PARAM_detectableGenomeStoich_DIP));
}
/**
* 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));
}
/**
* 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));
this.rxns.add(new TwoBodyOneProductRxn(Virus.M.name, this.cell.proteins, this.virus.getComposition().get(Virus.M.name), 2.0, this.dip.genome.fullname, this.cell.templates, 1.0, 1.0, this.dip.condensedGenomeName(), this.cell.templates, 1.0, this.dip.PARAM_genomeMcondensationRate_DIP));
// genM + pol -> virion, kpack
// genM + pol + G -> virion, kpack (equal to kpack above, so G enhances the packing rate) (model as 1 equation)
// Take this out for now to help troubleshoot.
// this.rxns.add(new PackagingRxn(cell,Virus.POLYMERASE,Virus.G.name,virus.condensedGenomeName(),virus.name,virus.packagingRateConstant));
// DIPvirion!!!
}
/**
* 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));
this.rxns.add(new TwoBodyOneProductRxn(this.dip.errorGenomeName(), 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_DIP));
// responseProtein --> AVProduct ???
}
/**
* 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");
}
/**
* initializes a cell by initializing template and protein pools by adding viral genomes, polymerase, ribosomes and detection proteins
*/
/**
* initialize the virus as a list of genes. This call will do all the work in naming the virus
*/
private void initializeDIP()
{
// DIP virus
this.dip = new DIP(new Gene[] { DIP.Tr_DIP, DIP.IG1_DIP, DIP.L_DIP, DIP.IG2_DIP, DIP.TrC_DIP }, "DIP");
}
/**
* 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.templates.initialize(new Item(this.dip.genomeName(), this.modip, 0.0));
this.cell.proteins.initialize(new Item(DIP.POLYMERASE, this.modip * this.dip.getComposition().getComponentCount(DIP.POLYMERASE), 0.0));
this.cell.proteins.initialize(new Item(Cell.PROTEIN_RIBOSOME, this.cell.initialRibosomes, 0.0));
this.cell.proteins.initialize(new Item(Cell.PROTEIN_DETECTION, this.cell.initialDetectionProteins, 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 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.genomeFullname()) + this.cell.templates.getCount(this.dip.genomeName());// + this.cell.templates.delayedAmounts.getAll().getCount(virus.genomeName());
double thresh = Math.log10(templates);
try
{
// created sigmoidal decay function for cell activity
double decay = (1 - StatisticsUtility.normalCDF(templates, Cell.virusProductionMean / 2, Cell.virusProductionMean / 3));
if(decay < 0)
{
decay = 0;
}
return decay;
}
catch (MathException e)
{
e.printStackTrace();
return 0;
}
}
}