diff --git a/BaseCellSimulation/BaseCellSimulation.csproj b/BaseCellSimulation/BaseCellSimulation.csproj index 125f4c9..161383e 100644 --- a/BaseCellSimulation/BaseCellSimulation.csproj +++ b/BaseCellSimulation/BaseCellSimulation.csproj @@ -6,4 +6,15 @@ enable + + + PreserveNewest + + + PreserveNewest + + + + + diff --git a/BaseCellSimulation/CellData/CellRessources.json b/BaseCellSimulation/CellData/CellRessources.json new file mode 100644 index 0000000..4e7f8fc --- /dev/null +++ b/BaseCellSimulation/CellData/CellRessources.json @@ -0,0 +1,63 @@ +{ + "$schema": "cellRessources.schema.json", + "BasicCell": { + "energy": { + "ATP": 2.5, + "ADP": 0.8, + "AMP": 0.1, + "NAD+": 1.0, + "NADH": 0.3, + "GTP": 0.5, + "GDP": 0.2 + }, + "Pi": 5.0, + "PPi": 0.1, + + "glucose": 5.0, + "G6P": 0.5, + "F6P": 0.3, + "F1,6BP": 0.2, + "GA3P": 0.2, + "1,3BPG": 0.1, + "3PG": 0.4, + "2PG": 0.3, + "PEP": 0.2, + "Pyruvate": 1.0, + "Lactate": 1.5, + + "CO2": 10.0, + "AcCoA": 0.2, + + "AminoAcids": 5.0, + "NucleicAcids": 1.0, + "Nucleotides": 2.0, + "NTP": 0.5, + "dNTP": 0.1, + + "mRNA": 0.5, + "DNA_damage": 0.0, + + "SAM": 0.05, + "MET": 0.5, + "SAH": 0.02, + "Homocysteine": 0.01, + "Adenosin": 0.1, + + "tRNA": 1.0, + "Aminocylated_tRNA": 0.3, + + "H+": 0.00004, + "Na+": 10.0, + "K+": 140.0, + + "H2O2": 0.001, + + "B12": 0.01, + "THF": 0.1, + "MethylTHF": 0.1, + + "CytoSolCA": 0.0001, + "rERCa": 0.3, + "sERCa": 0.6 + } +} diff --git a/BaseCellSimulation/CellData/cellRessources.schema.json b/BaseCellSimulation/CellData/cellRessources.schema.json new file mode 100644 index 0000000..a95cf19 --- /dev/null +++ b/BaseCellSimulation/CellData/cellRessources.schema.json @@ -0,0 +1,241 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema", + "type": "object", + "properties": { + "energy": { + "type": "object", + "properties": { + "ATP": { + "type": "number", + "minimum": 0, + "description": "Adenosine-triphosphate" + }, + "ADP": { + "type": "number", + "minimum": 0, + "description": "Adenosine-diphosphate" + }, + "AMP": { + "type": "number", + "minimum": 0, + "description": "Adenosine-monophosphate" + }, + "NAD+": { + "type": "number", + "minimum": 0, + "description": "Nicotinamide adenine dinucleotide (oxidized form)" + }, + "NADH": { + "type": "number", + "minimum": 0, + "description": "Nicotinamide adenine dinucleotide (reduced form)" + }, + "GTP": { + "type": "number", + "minimum": 0, + "description": "Guanosine-triphosphate" + }, + "GDP": { + "type": "number", + "minimum": 0, + "description": "Guanosine-diphosphate" + }, + "Pi": { + "type": "number", + "minimum": 0, + "description": "Inorganic phosphate" + }, + "PPi": { + "type": "number", + "minimum": 0, + "description": "Inorganic pyrophosphate" + } + } + }, + "glucose": { + "type": "number", + "minimum": 0, + "description": "Glucose concentration" + }, + "G6P": { + "type": "number", + "minimum": 0, + "description": "Glucose-6-phosphate concentration" + }, + "F6P": { + "type": "number", + "minimum": 0, + "description": "Fructose-6-phosphate concentration" + }, + "F1,6BP": { + "type": "number", + "minimum": 0, + "description": "Fructose-1,6-bisphosphate concentration" + }, + "GA3P": { + "type": "number", + "minimum": 0, + "description": "Glyceraldehyde-3-phosphate concentration" + }, + "1,3BPG": { + "type": "number", + "minimum": 0, + "description": "1,3-Bisphosphoglycerate concentration" + }, + "3PG": { + "type": "number", + "minimum": 0, + "description": "3-Phosphoglycerate concentration" + }, + "2PG": { + "type": "number", + "minimum": 0, + "description": "2-Phosphoglycerate concentration" + }, + "PEP": { + "type": "number", + "minimum": 0, + "description": "Phosphoenolpyruvate concentration" + }, + "Pyruvate": { + "type": "number", + "minimum": 0, + "description": "Pyruvate concentration" + }, + "Lactate": { + "type": "number", + "minimum": 0, + "description": "Lactate concentration" + }, + "CO2": { + "type": "number", + "minimum": 0, + "description": "Carbon dioxide concentration" + }, + "AcCoA": { + "type": "number", + "minimum": 0, + "description": "Acetyl-Coenzyme A concentration" + }, + "AminoAcids": { + "type": "number", + "minimum": 0, + "description": "Total amino acids concentration" + }, + "NucleicAcids": { + "type": "number", + "minimum": 0, + "description": "Total nucleic acids concentration" + }, + "Nucleotides": { + "type": "number", + "minimum": 0, + "description": "Total nucleotides concentration" + }, + "NTP": { + "type": "number", + "minimum": 0, + "description": "Total nucleoside triphosphates concentration" + }, + "dNTP": { + "type": "number", + "minimum": 0, + "description": "Total deoxynucleoside triphosphates concentration" + }, + "mRNA": { + "type": "number", + "minimum": 0, + "description": "Total messenger RNA concentration" + }, + "DNA_damage": { + "type": "number", + "minimum": 0, + "description": "Amount of DNA damage" + }, + "SAM": { + "type": "number", + "minimum": 0, + "description": "S-Adenosyl methionine concentration" + }, + "MET": { + "type": "number", + "minimum": 0, + "description": "Methionine concentration" + }, + "SAH": { + "type": "number", + "minimum": 0, + "description": "S-Adenosyl homocysteine concentration" + }, + "Homocysteine": { + "type": "number", + "minimum": 0, + "description": "Homocysteine concentration" + }, + "Adenosin": { + "type": "number", + "minimum": 0, + "description": "Adenosine concentration" + }, + "tRNA": { + "type": "number", + "minimum": 0, + "description": "Total transfer RNA concentration" + }, + "Aminocylated_tRNA": { + "type": "number", + "minimum": 0, + "description": "Total aminoacylated tRNA concentration" + }, + "H+": { + "type": "number", + "minimum": 0, + "description": "Proton concentration" + }, + "Na+": { + "type": "number", + "minimum": 0, + "description": "Sodium ion concentration" + }, + "K+": { + "type": "number", + "minimum": 0, + "description": "Potassium ion concentration" + }, + "H2O2": { + "type": "number", + "minimum": 0, + "description": "Hydrogen peroxide concentration" + }, + "B12": { + "type": "number", + "minimum": 0, + "description": "Vitamin B12 concentration" + }, + "THF": { + "type": "number", + "minimum": 0, + "description": "Tetrahydrofolate concentration" + }, + "MethylTHF": { + "type": "number", + "minimum": 0, + "description": "5-Methyltetrahydrofolate concentration" + }, + "CytoSolCA": { + "type": "number", + "minimum": 0, + "description": "Cytosolic calcium concentration" + }, + "rERCa": { + "type": "number", + "minimum": 0, + "description": "Rough endoplasmic reticulum calcium concentration" + }, + "sERCa": { + "type": "number", + "minimum": 0, + "description": "Smooth endoplasmic reticulum calcium concentration" + } + } +} diff --git a/BaseCellSimulation/EnzymData/Enzyms.json b/BaseCellSimulation/EnzymData/Enzyms.json new file mode 100644 index 0000000..c84590c --- /dev/null +++ b/BaseCellSimulation/EnzymData/Enzyms.json @@ -0,0 +1,78 @@ +{ + "$schema": "enzymes.schema.json", + "Cytosolic": [ + { + "Name": "HexokinaseI", + "Km": { + "Value": 0.05, + "Min": 0.02, + "Max": 0.1 + }, + "Vmax": { + "Value": 2.5, + "Min": 0.5, + "Max": 2.5 + }, + "Type": "MichelisMenten", + "Description": "Phosphorylates glucose to form glucose-6-phosphate." + }, + { + "Name": "HexokinaseII", + "Km": { + "Value": 0.1, + "Min": 0.05, + "Max": 0.15 + }, + "Vmax": { + "Value": 5, + "Min": 1, + "Max": 10 + }, + "Type": "MichelisMenten", + "Description": "Phosphorylates glucose to form glucose-6-phosphate." + }, + { + "Name": "HexokinaseIII", + "Km": { + "Value": 0.05, + "Min": 0.01, + "Max": 0.1 + }, + "Vmax": { + "Value": 1, + "Min": 0.1, + "Max": 2 + }, + "Type": "MichelisMenten", + "Description": "Phosphorylates glucose to form glucose-6-phosphate." + }, + { + "Name": "HexokinaseIV_Gluko", + "Km": { + "Value": 8.5, + "Min": 7, + "Max": 10 + }, + "Vmax": { + "Value": 5, + "Min": 1, + "Max": 10 + }, + "Hill": { + "Value": 1.7, + "Min": 1.6, + "Max": 1.9 + }, + "Type": "Hill", + "Description": "Phosphorylates glucose to form glucose-6-phosphate." + }, + { + "Name": "Phosphofructokinase", + "K0_5": 0.1, + "Hill": 2.0, + "Vmax": 80.0, + "Type": "Hill", + "Description": "Catalyzes the phosphorylation of fructose-6-phosphate to fructose-1,6-bisphosphate." + } + ] +} \ No newline at end of file diff --git a/BaseCellSimulation/EnzymData/enzymes.schema.json b/BaseCellSimulation/EnzymData/enzymes.schema.json new file mode 100644 index 0000000..27a653b --- /dev/null +++ b/BaseCellSimulation/EnzymData/enzymes.schema.json @@ -0,0 +1,136 @@ +{ + "$schema": "https://json-schema.org/draft-07/schema", + "title": "Enzyme Parameter Schema", + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Name": { + "type": "string" + }, + "Vmax": { + "type": "object", + "properties": { + "Value": { + "type": "number", + "minimum": 0 + }, + "Min": { + "type": "number", + "minimum": 0 + }, + "Max": { + "type": "number", + "minimum": 0 + } + } + }, + "Type": { + "type": "string", + "enum": [ "Hill", "MichelisMenten", "Linear" ] + }, + "Substrates": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Name": { "type": "string" }, + "Amount": { + "type": "number", + "minimum": 0 + }, + "Km": { + "type": "object", + "properties": { + "Value": { + "type": "number", + "minimum": 0 + }, + "Min": { + "type": "number", + "minimum": 0 + }, + "Max": { + "type": "number", + "minimum": 0 + } + } + }, + "Hill": { + "type": "object", + "properties": { + "Value": { + "type": "number", + "minimum": 0 + }, + "Min": { + "type": "number", + "minimum": 0 + }, + "Max": { + "type": "number", + "minimum": 0 + } + } + } + }, + "oneOf": [ + { "required": [ "Km" ] }, + { "required": [ "Hill" ] } + ] + } + }, + "Products": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Name": { "type": "string" }, + "Amount": { + "type": "number", + "minimum": 0 + } + } + } + }, + "ConsumATPtoADP": { + "type": "number", + "minimum": 0 + }, + "ProduceATPfromADP": { + "type": "number", + "minimum": 0 + }, + "ConsumATPtoAMP": { + "type": "number", + "minimum": 0 + }, + "ProduceATPfromAMP": { + "type": "number", + "minimum": 0 + }, + "ConsumeNADtoNADH": { + "type": "number", + "minimum": 0 + }, + "ProduceNADfromNADH": { + "type": "number", + "minimum": 0 + }, + "ConsumeGDPtoGTP": { + "type": "number", + "minimum": 0 + }, + "ProduceGDPfromGTP": { + "type": "number", + "minimum": 0 + }, + "Description": { "type": "string" } + }, + "required": [ "Vmax", "Type", "Name", "Substrates", "Products" ], + "additionalProperties": false + } + } +} \ No newline at end of file diff --git a/BaseCellSimulation/Enzyms/Cytosol/Aldolase.cs b/BaseCellSimulation/Enzyms/Cytosol/Aldolase.cs index de7b78d..bda9274 100644 --- a/BaseCellSimulation/Enzyms/Cytosol/Aldolase.cs +++ b/BaseCellSimulation/Enzyms/Cytosol/Aldolase.cs @@ -19,14 +19,14 @@ namespace BaseCellSimulation.Enzyms.Cytosol public override void ApplyChanges(CellRessources res, double dt) { - double used = Math.Min(rate * dt, res.Res.Carbon.FBP); - res.Res.Carbon.FBP -= used; - res.Res.Carbon.GAP += 2 * used; + double used = Math.Min(rate * dt, res.Res.Carbon.F1_6BP); + res.Res.Carbon.F1_6BP -= used; + res.Res.Carbon.GA3P += 2 * used; } public override void ComputeRate(Resources res) { - Michaelis_Menten(res.Carbon.FBP); + Michaelis_Menten(res.Carbon.F1_6BP); } } } diff --git a/BaseCellSimulation/Enzyms/Cytosol/GAPDH.cs b/BaseCellSimulation/Enzyms/Cytosol/GAPDH.cs index 70f0cfa..300719c 100644 --- a/BaseCellSimulation/Enzyms/Cytosol/GAPDH.cs +++ b/BaseCellSimulation/Enzyms/Cytosol/GAPDH.cs @@ -25,8 +25,8 @@ namespace BaseCellSimulation.Enzyms.Cytosol public override void ApplyChanges(CellRessources res, double dt) { - double used = Math.Min(rate * dt, Math.Min(res.Res.Carbon.GAP, res.Res.Energy.NAD)); - res.Res.Carbon.GAP -= used; + double used = Math.Min(rate * dt, Math.Min(res.Res.Carbon.GA3P, res.Res.Energy.NAD)); + res.Res.Carbon.GA3P -= used; res.Res.Carbon.PBG13 += used; res.TransferNADH(used, false); res.Res.Ions.Protons += 1.0 * used; @@ -34,7 +34,7 @@ namespace BaseCellSimulation.Enzyms.Cytosol public override void ComputeRate(Resources res) { - rate = Vmax * (res.Carbon.GAP / (Km + res.Carbon.GAP)) * (res.Energy.NAD / (Km_NAD + res.Energy.NAD)); + rate = Vmax * (res.Carbon.GA3P / (Km + res.Carbon.GA3P)) * (res.Energy.NAD / (Km_NAD + res.Energy.NAD)); } } } diff --git a/BaseCellSimulation/Enzyms/Cytosol/Hexokinasen/HK1.cs b/BaseCellSimulation/Enzyms/Cytosol/Hexokinasen/HK1.cs new file mode 100644 index 0000000..492b9d6 --- /dev/null +++ b/BaseCellSimulation/Enzyms/Cytosol/Hexokinasen/HK1.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BaseCellSimulation.Enzyms.Cytosol.Hexokinasen +{ + public class HK1 : Hexokinasis + { + public HK1() : base() + { + + } + } +} diff --git a/BaseCellSimulation/Enzyms/Cytosol/Hexokinasen/HK2.cs b/BaseCellSimulation/Enzyms/Cytosol/Hexokinasen/HK2.cs new file mode 100644 index 0000000..7a7fa85 --- /dev/null +++ b/BaseCellSimulation/Enzyms/Cytosol/Hexokinasen/HK2.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BaseCellSimulation.Enzyms.Cytosol.Hexokinasen +{ + internal class HK2 + { + } +} diff --git a/BaseCellSimulation/Enzyms/Cytosol/Hexokinasen/HK3.cs b/BaseCellSimulation/Enzyms/Cytosol/Hexokinasen/HK3.cs new file mode 100644 index 0000000..03d2632 --- /dev/null +++ b/BaseCellSimulation/Enzyms/Cytosol/Hexokinasen/HK3.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BaseCellSimulation.Enzyms.Cytosol.Hexokinasen +{ + internal class HK3 + { + } +} diff --git a/BaseCellSimulation/Enzyms/Cytosol/Hexokinasen/HK4_GK.cs b/BaseCellSimulation/Enzyms/Cytosol/Hexokinasen/HK4_GK.cs new file mode 100644 index 0000000..2913972 --- /dev/null +++ b/BaseCellSimulation/Enzyms/Cytosol/Hexokinasen/HK4_GK.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BaseCellSimulation.Enzyms.Cytosol.Hexokinasen +{ + internal class HK4_GK + { + } +} diff --git a/BaseCellSimulation/Enzyms/Cytosol/Hexokinasis.cs b/BaseCellSimulation/Enzyms/Cytosol/Hexokinasen/Hexokinasis.cs similarity index 84% rename from BaseCellSimulation/Enzyms/Cytosol/Hexokinasis.cs rename to BaseCellSimulation/Enzyms/Cytosol/Hexokinasen/Hexokinasis.cs index f33b53e..7f969b2 100644 --- a/BaseCellSimulation/Enzyms/Cytosol/Hexokinasis.cs +++ b/BaseCellSimulation/Enzyms/Cytosol/Hexokinasen/Hexokinasis.cs @@ -4,14 +4,16 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BaseCellSimulation.Enzyms.Cytosol +namespace BaseCellSimulation.Enzyms.Cytosol.Hexokinasen { - public class Hexokinasis : InternalEnzym + public abstract class Hexokinasis : InternalEnzym { public Hexokinasis() { Km = 0.05; Vmax = 5; + Type = EnzymType.MichelisMenten; + KmRange = new(0.01, 0.1); VmaxRange = new(0.5, 20); } diff --git a/BaseCellSimulation/Enzyms/Cytosol/PhosphoFructokinase.cs b/BaseCellSimulation/Enzyms/Cytosol/PhosphoFructokinase.cs index c11d16a..12d9ed7 100644 --- a/BaseCellSimulation/Enzyms/Cytosol/PhosphoFructokinase.cs +++ b/BaseCellSimulation/Enzyms/Cytosol/PhosphoFructokinase.cs @@ -27,7 +27,7 @@ namespace BaseCellSimulation.Enzyms.Cytosol { double used = Math.Min(rate * dt, Math.Min(res.Res.Energy.ATP, res.Res.Carbon.F6P)); res.Res.Carbon.F6P -= used; - res.Res.Carbon.FBP += used; + res.Res.Carbon.F1_6BP += used; res.ConsumeATP(used); res.Res.Ions.Protons += used; } diff --git a/BaseCellSimulation/Enzyms/Enzym.cs b/BaseCellSimulation/Enzyms/Enzym.cs index 0777197..eb98b78 100644 --- a/BaseCellSimulation/Enzyms/Enzym.cs +++ b/BaseCellSimulation/Enzyms/Enzym.cs @@ -3,37 +3,173 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace BaseCellSimulation.Enzyms { - public abstract class Enzym + public enum EnzymType { - /// - /// mM/S - /// - public double Vmax { get; set; } + Hill, + MichelisMenten, + Linear + } + + public struct Substrate + { + public string Name { get; set; } + public double Amount { get; set; } + /// /// mM /// - public double Km { get; set; } + [JsonPropertyName("Km")] + public ValueRange Km { get; set; } - public ValueRange VmaxRange { get; protected set; } + [JsonPropertyName("Hill")] + public ValueRange n_Hill { get; set; } + } - public ValueRange KmRange { get; protected set; } + public struct Product + { + public string Name { get; set; } + public double Amount { get; set; } + } + + public class Enzym + { + [JsonPropertyName("Name")] + public string Name { get; set; } + + /// + /// mM/S + /// + [JsonPropertyName("Vmax")] + public ValueRange Vmax { get; set; } + + [JsonPropertyName("Type")] + public EnzymType Type { get; set; } + + [JsonPropertyName("ConsumATPtoADP")] + public double ConsumATPtoADP { get; set; } + [JsonPropertyName("ProduceATPfromADP")] + public double ProduceATPfromADP { get; set; } + [JsonPropertyName("ConsumATPtoAMP")] + public double ConsumATPtoAMP { get; set; } + [JsonPropertyName("ProduceATPfromAMP")] + public double ProduceATPfromAMP { get; set; } + [JsonPropertyName("ConsumeNADtoNADH")] + public double ConsumeNADtoNADH { get; set; } + [JsonPropertyName("ProduceNADfromNADH")] + public double ProduceNADfromNADH { get; set; } + [JsonPropertyName("ConsumeGDPtoGTP")] + public double ConsumeGDPtoGTP { get; set; } + [JsonPropertyName("ProduceGDPfromGTP")] + public double ProduceGDPfromGTP { get; set; } + + [JsonPropertyName("Substrates")] + public List Substrates { get; set; } = new List(); + + [JsonPropertyName("Products")] + public List Products { get; set; } = new List(); protected double rate; - protected void Michaelis_Menten(double ressource) + + protected double Michaelis_Menten(CellRessources res) { - rate = Michaelis_Menten(ressource, Vmax, Km); + double retVar = Vmax.Value; + foreach (Substrate substrate in Substrates) + { + if (!res.Resources.TryGetValue(substrate.Name, out double ResAmount)) + return 0.0; + if (ResAmount <= 0.0) + return 0.0; + + retVar *= ResAmount / (substrate.Km.Value + ResAmount); + } + + return retVar; } - protected double Michaelis_Menten(double consumable,double vmax, double km) + protected double HillEquation(CellRessources res) { - return (vmax * consumable) / (km + consumable); + double retVar = Vmax.Value; + foreach (Substrate substrate in Substrates) + { + if (!res.Resources.TryGetValue(substrate.Name, out double ResAmount)) + return 0.0; + if (ResAmount <= 0.0) + return 0.0; + + + retVar *= Math.Pow(ResAmount, substrate.n_Hill.Value) / (Math.Pow(substrate.Km.Value, substrate.n_Hill.Value) + Math.Pow(ResAmount, substrate.n_Hill.Value)); + } + + return retVar; } - public abstract void ApplyChanges(CellRessources res, double dt); + public void ApplyChanges(CellRessources res, double dt) + { + double delta = rate * dt; + foreach (Substrate substrate in Substrates) + { + if (res.Resources.TryGetValue(substrate.Name, out double oldVal)) + { + delta = Math.Min(delta, oldVal / substrate.Amount); + } + } + foreach (Substrate substrate in Substrates) + { + if (res.Resources.TryGetValue(substrate.Name, out double oldVal)) + { + res.Resources[substrate.Name] = oldVal - substrate.Amount * delta; + } + } + foreach (Product product in Products) + { + if (res.Resources.ContainsKey(product.Name)) + { + res.Resources[product.Name] += product.Amount * delta; + } + else + { + res.Resources[product.Name] = product.Amount * delta; + } + } + + if(ConsumATPtoADP > 0.0) + res.ConsumeATP(ConsumATPtoADP * delta, false); + if(ProduceATPfromADP > 0.0) + res.RegenerateATP(ProduceATPfromADP * delta, false); + if(ConsumATPtoAMP > 0.0) + res.ConsumeATP(ConsumATPtoAMP * delta, true); + if(ProduceATPfromAMP > 0.0) + res.RegenerateATP(ProduceATPfromAMP * delta, true); + if(ConsumeNADtoNADH > 0.0) + res.TransferNADH(ConsumeNADtoNADH * delta, true); + if(ProduceNADfromNADH > 0.0) + res.TransferNADH(ProduceNADfromNADH * delta, false); + if(ConsumeGDPtoGTP > 0.0) + res.TransferGTP(ConsumeGDPtoGTP * delta, true); + if(ProduceGDPfromGTP > 0.0) + res.TransferGTP(ProduceGDPfromGTP * delta, false); + } + + public void ComputeRate(CellRessources res) + { + switch (Type) + { + case EnzymType.Hill: + rate = HillEquation(res); + break; + case EnzymType.MichelisMenten: + rate = Michaelis_Menten(res); + break; + case EnzymType.Linear: + rate = Vmax.Value * res.Resources[Substrates[0].Name]; + break; + } + } } public abstract class InternalEnzym : Enzym diff --git a/BaseCellSimulation/Organell.cs b/BaseCellSimulation/Organell.cs index f7a401c..4cdaa7a 100644 --- a/BaseCellSimulation/Organell.cs +++ b/BaseCellSimulation/Organell.cs @@ -1,4 +1,6 @@ using System; +using System.Text.Json; +using System.Text.Json.Serialization; namespace BaseCellSimulation { @@ -9,6 +11,43 @@ namespace BaseCellSimulation { public Resources Res; public EnviromentState Env = new(); + [JsonPropertyName("energy")] + public EnergyPool energyPool; + public Dictionary Resources => new Dictionary(); + + public static CellRessources LoadRessources(string jsonPath) + { + string json = File.ReadAllText(jsonPath); + using var doc = JsonDocument.Parse(json); + var root = doc.RootElement; + var result = new CellRessources(); + + // deserialice energy + if (root.TryGetProperty("energy", out JsonElement energyElement)) + { + result.energyPool = JsonSerializer.Deserialize(energyElement.GetRawText()); + } + + foreach(var property in root.EnumerateObject()) + { + if (property.NameEquals("energy")) + continue; // already handled + + if (property.Value.ValueKind == JsonValueKind.Number) + { + result.Resources[property.Name] = property.Value.GetDouble(); + } + } + + return result; + } + + public static void SaveRessources(CellRessources ressources, string jsonPath) + { + var options = new JsonSerializerOptions { WriteIndented = true }; + string json = JsonSerializer.Serialize(ressources, options); + File.WriteAllText(jsonPath, json); + } // pH in mM-basiertem Hilfsformat (vereinfachte Umrechnung): public double pH_in => 3.0 - Math.Log10(Res.Ions.Protons + 1e-12); @@ -117,6 +156,22 @@ namespace BaseCellSimulation } } + public void TransferGTP(double amount, bool toGDP) + { + if (toGDP) + { + if (Res.Energy.GTP < amount) amount = Res.Energy.GTP; + Res.Energy.GTP -= amount; + Res.Energy.GDP += amount; + } + else + { + if (Res.Energy.GDP < amount) amount = Res.Energy.GDP; + Res.Energy.GDP -= amount; + Res.Energy.GTP += amount; + } + } + // --- Initialisierung mit plausiblen Startwerten --- /// /// Erzeugt eine CellRessources-Instanz mit vernünftigen Startwerten (grobe physiologische Annahmen). @@ -143,8 +198,8 @@ namespace BaseCellSimulation cr.Res.Carbon.Glucose = 1.0; // mM intrazellulär (abhängig von Aufnahme) cr.Res.Carbon.G6P = 0.05; cr.Res.Carbon.F6P = 0.02; - cr.Res.Carbon.FBP = 0.005; - cr.Res.Carbon.GAP = 0.01; + cr.Res.Carbon.F1_6BP = 0.005; + cr.Res.Carbon.GA3P = 0.01; cr.Res.Carbon.PBG13 = 0.005; cr.Res.Carbon.PG3 = 0.02; cr.Res.Carbon.PG2 = 0.01; @@ -229,34 +284,114 @@ namespace BaseCellSimulation /// Energiemengen: ATP/ADP/AMP + NAD/NADH + GTP/GDP public struct EnergyPool { + /// + /// Adenosine-triphosphate + /// public double ATP; + /// + /// Adenosine diphosphate + /// public double ADP; + /// + /// Adenosine monophosphat + /// public double AMP; + + /// + /// Nicotinamide adenine dinucleotide + /// public double NAD; + + /// + /// Nicotinamide adenine dinucleotide + /// public double NADH; + + /// + /// Nicotinamide adenine dinucleotide phosphate + /// + public double NADPH; + + /// + /// Guanosintriphosphat + /// public double GTP; - public double GDP { get; internal set; } + + /// + /// Guanosindiphosphat + /// + public double GDP; + + /// + /// inorganic phosphate + /// + public double Pi; + + /// + /// Pyrophosphat + /// + public double PPi; } /// Inorganische Phosphate public struct Phosphate { - public double Pi; // anorganisches Phosphat - public double PPi; // Pyrophosphat + /// + /// inorganic phosphate + /// + public double Pi; + + /// + /// Pyrophosphat + /// + public double PPi; } /// Kohlenstoff- / Glykolyse-Intermediaten public struct CarbonPool { public double Glucose; + + /// + /// Glucose-6-phosphate + /// public double G6P; + + /// + /// Fructose-6-phosphate + /// public double F6P; - public double FBP; - public double GAP; + + /// + /// Fructose 1,6-bisphosphate + /// + public double F1_6BP; + + /// + /// Glycerinaldehyd-3-phosphat + /// + public double GA3P; + + /// + /// 1,3-Bisphosphoglycerat + /// public double PBG13; + + /// + /// 3-Phosphoglycerat + /// public double PG3; + + /// + /// 2-Phosphoglycerat + /// public double PG2; + + /// + /// Phosphoenolpyruvat + /// public double PEP; + public double Pyruvate; public double Lactate; public double CO2; @@ -271,14 +406,35 @@ namespace BaseCellSimulation public double Waste; public double NucleicAcids; public double Nucleotides; + + /// + /// Nukleosidtriphosphate + /// public double NTP; + + /// + /// Desoxyribonukleotidtriphosphate + /// public double dNTP; public double mRNA; public double DNA_damage; public double AcetylCoA; + + /// + /// S-Adenosylmethionin + /// public double SAM; + + /// + /// Methionine + /// public double MET; + + /// + /// S-Adenosylhomocystein + /// public double SAH; + public double Homocystein; public double Adenosin; internal double tRNA; @@ -289,9 +445,22 @@ namespace BaseCellSimulation public struct IonPool { public double Protons; // H+ (vereinfachte Einheit mM) - public double ROS; // reactive oxygen species + + /// + /// reactive oxygen species + /// + public double ROS; + + /// + /// NAtrium-Ionen + /// public double Na; + + /// + /// Kalium-Ionen + /// public double K; + public double H2O2; } @@ -302,6 +471,9 @@ namespace BaseCellSimulation public struct Folates { + /// + /// Tetrahydrofolsäure + /// public double THF { get; internal set; } public double MethylTHF { get; internal set; } } diff --git a/BaseCellSimulation/ValueRange.cs b/BaseCellSimulation/ValueRange.cs index 03985c6..059b316 100644 --- a/BaseCellSimulation/ValueRange.cs +++ b/BaseCellSimulation/ValueRange.cs @@ -3,18 +3,23 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace BaseCellSimulation { public struct ValueRange { - public double Start; - public double End; + [JsonPropertyName("Value")] + public double Value; + [JsonPropertyName("Min")] + public double Min; + [JsonPropertyName("Max")] + public double Max; public ValueRange(double start, double end) { - Start = start; - End = end; + Min = start; + Max = end; } } }