Added Json Schemas
This commit is contained in:
@@ -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<string, double> Resources => new Dictionary<string, double>();
|
||||
|
||||
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<EnergyPool>(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 ---
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// <summary>Energiemengen: ATP/ADP/AMP + NAD/NADH + GTP/GDP</summary>
|
||||
public struct EnergyPool
|
||||
{
|
||||
/// <summary>
|
||||
/// Adenosine-triphosphate
|
||||
/// </summary>
|
||||
public double ATP;
|
||||
/// <summary>
|
||||
/// Adenosine diphosphate
|
||||
/// </summary>
|
||||
public double ADP;
|
||||
/// <summary>
|
||||
/// Adenosine monophosphat
|
||||
/// </summary>
|
||||
public double AMP;
|
||||
|
||||
/// <summary>
|
||||
/// Nicotinamide adenine dinucleotide
|
||||
/// </summary>
|
||||
public double NAD;
|
||||
|
||||
/// <summary>
|
||||
/// Nicotinamide adenine dinucleotide
|
||||
/// </summary>
|
||||
public double NADH;
|
||||
|
||||
/// <summary>
|
||||
/// Nicotinamide adenine dinucleotide phosphate
|
||||
/// </summary>
|
||||
public double NADPH;
|
||||
|
||||
/// <summary>
|
||||
/// Guanosintriphosphat
|
||||
/// </summary>
|
||||
public double GTP;
|
||||
public double GDP { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Guanosindiphosphat
|
||||
/// </summary>
|
||||
public double GDP;
|
||||
|
||||
/// <summary>
|
||||
/// inorganic phosphate
|
||||
/// </summary>
|
||||
public double Pi;
|
||||
|
||||
/// <summary>
|
||||
/// Pyrophosphat
|
||||
/// </summary>
|
||||
public double PPi;
|
||||
}
|
||||
|
||||
/// <summary>Inorganische Phosphate</summary>
|
||||
public struct Phosphate
|
||||
{
|
||||
public double Pi; // anorganisches Phosphat
|
||||
public double PPi; // Pyrophosphat
|
||||
/// <summary>
|
||||
/// inorganic phosphate
|
||||
/// </summary>
|
||||
public double Pi;
|
||||
|
||||
/// <summary>
|
||||
/// Pyrophosphat
|
||||
/// </summary>
|
||||
public double PPi;
|
||||
}
|
||||
|
||||
/// <summary>Kohlenstoff- / Glykolyse-Intermediaten</summary>
|
||||
public struct CarbonPool
|
||||
{
|
||||
public double Glucose;
|
||||
|
||||
/// <summary>
|
||||
/// Glucose-6-phosphate
|
||||
/// </summary>
|
||||
public double G6P;
|
||||
|
||||
/// <summary>
|
||||
/// Fructose-6-phosphate
|
||||
/// </summary>
|
||||
public double F6P;
|
||||
public double FBP;
|
||||
public double GAP;
|
||||
|
||||
/// <summary>
|
||||
/// Fructose 1,6-bisphosphate
|
||||
/// </summary>
|
||||
public double F1_6BP;
|
||||
|
||||
/// <summary>
|
||||
/// Glycerinaldehyd-3-phosphat
|
||||
/// </summary>
|
||||
public double GA3P;
|
||||
|
||||
/// <summary>
|
||||
/// 1,3-Bisphosphoglycerat
|
||||
/// </summary>
|
||||
public double PBG13;
|
||||
|
||||
/// <summary>
|
||||
/// 3-Phosphoglycerat
|
||||
/// </summary>
|
||||
public double PG3;
|
||||
|
||||
/// <summary>
|
||||
/// 2-Phosphoglycerat
|
||||
/// </summary>
|
||||
public double PG2;
|
||||
|
||||
/// <summary>
|
||||
/// Phosphoenolpyruvat
|
||||
/// </summary>
|
||||
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;
|
||||
|
||||
/// <summary>
|
||||
/// Nukleosidtriphosphate
|
||||
/// </summary>
|
||||
public double NTP;
|
||||
|
||||
/// <summary>
|
||||
/// Desoxyribonukleotidtriphosphate
|
||||
/// </summary>
|
||||
public double dNTP;
|
||||
public double mRNA;
|
||||
public double DNA_damage;
|
||||
public double AcetylCoA;
|
||||
|
||||
/// <summary>
|
||||
/// S-Adenosylmethionin
|
||||
/// </summary>
|
||||
public double SAM;
|
||||
|
||||
/// <summary>
|
||||
/// Methionine
|
||||
/// </summary>
|
||||
public double MET;
|
||||
|
||||
/// <summary>
|
||||
/// S-Adenosylhomocystein
|
||||
/// </summary>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// reactive oxygen species
|
||||
/// </summary>
|
||||
public double ROS;
|
||||
|
||||
/// <summary>
|
||||
/// NAtrium-Ionen
|
||||
/// </summary>
|
||||
public double Na;
|
||||
|
||||
/// <summary>
|
||||
/// Kalium-Ionen
|
||||
/// </summary>
|
||||
public double K;
|
||||
|
||||
public double H2O2;
|
||||
}
|
||||
|
||||
@@ -302,6 +471,9 @@ namespace BaseCellSimulation
|
||||
|
||||
public struct Folates
|
||||
{
|
||||
/// <summary>
|
||||
/// Tetrahydrofolsäure
|
||||
/// </summary>
|
||||
public double THF { get; internal set; }
|
||||
public double MethylTHF { get; internal set; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user