Examples and clean-ups #1
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import itertools
|
||||
|
||||
|
||||
class SingleReaction:
|
||||
@@ -19,15 +20,19 @@ class SingleReaction:
|
||||
return "{" + ", ".join(self.products) + "}"
|
||||
|
||||
def __str__(self):
|
||||
return "{" + f"{self.get_reactants()}, {self.get_inhibitors()} -> {self.get_products()}" + "};"
|
||||
return (
|
||||
"{"
|
||||
+ f"{self.get_reactants()}, {self.get_inhibitors()} -> {self.get_products()}"
|
||||
+ "};"
|
||||
)
|
||||
|
||||
|
||||
class Reactions:
|
||||
def __init__(self):
|
||||
self.reactions = set()
|
||||
self.reactions = []
|
||||
|
||||
def add(self, reaction):
|
||||
self.reactions.add(reaction)
|
||||
self.reactions.append(reaction)
|
||||
|
||||
def __str__(self):
|
||||
ret = ""
|
||||
@@ -54,10 +59,19 @@ class DRSGenerator:
|
||||
rcts.add(SingleReaction(["GF"], ["h", f"RTK{i}"], ["RTK"]))
|
||||
rcts.add(SingleReaction(["RTK"], [f"ENi:1_{i}"], [f"EN:1_{i}"]))
|
||||
for j in range(1, self.x):
|
||||
rcts.add(SingleReaction([f"EN:{j}_{i}"], [f"ENi:{j+1}_{i}"], [f"EN:{j+1}_{i}"]))
|
||||
rcts.add(
|
||||
SingleReaction([f"EN:{j}_{i}"], [f"ENi:{j+1}_{i}"], [f"EN:{j+1}_{i}"])
|
||||
)
|
||||
|
||||
indices = list(range(1, self.y + 1))
|
||||
for comb in itertools.combinations(indices, self.z):
|
||||
reactants = []
|
||||
for i in comb:
|
||||
reactants.append(f"EN:{self.x}_{i}")
|
||||
rcts.add(SingleReaction(reactants, ["h"], ["TF"]))
|
||||
|
||||
def generate(self):
|
||||
for i in range(1, self.y):
|
||||
for i in range(1, self.y + 1):
|
||||
self.generate_reactions_for_component(i)
|
||||
|
||||
for proc, reactions in self.reactions.items():
|
||||
|
||||
Reference in New Issue
Block a user