Skip to content

Commit

Permalink
WIP, ssld import: begin work on allosteric reactions
Browse files Browse the repository at this point in the history
  • Loading branch information
danv61 committed Aug 21, 2024
1 parent e3d6c3b commit cf66076
Showing 1 changed file with 58 additions and 37 deletions.
95 changes: 58 additions & 37 deletions vcell-core/src/main/java/org/vcell/model/ssld/SsldUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -370,38 +370,39 @@ public BioModel fromSsld(SsldModel ssldModel) throws Exception {

// ---------- Species Contexts
// the Source and the Sink species contexts, if exist
if(mtSource != null) {
for(Map.Entry<Structure, MolecularType> entry : m.structureToSourceMap.entrySet()) {
Structure struct = entry.getKey();
MolecularType mt = entry.getValue();
if(mtSource != mt) {
throw new RuntimeException("The 'Source' molecular type is duplicated");
}
MolecularTypePattern mtp = new MolecularTypePattern(mt, false); // we shouldn't have any components
SpeciesPattern sp = new SpeciesPattern();
sp.addMolecularTypePattern(mtp);
Species species = new Species(mt.getName(), mt.getName());
SpeciesContext speciesContext = new SpeciesContext(species, struct, sp);
model.addSpecies(speciesContext.getSpecies());
model.addSpeciesContext(speciesContext);
}
}
if(mtSink != null) {
for(Map.Entry<Structure, MolecularType> entry : m.structureToSinkMap.entrySet()) {
Structure struct = entry.getKey();
MolecularType mt = entry.getValue();
if(mtSink != mt) {
throw new RuntimeException("The 'Sink' molecular type is duplicated");
}
MolecularTypePattern mtp = new MolecularTypePattern(mt, false); // we shouldn't have any components
SpeciesPattern sp = new SpeciesPattern();
sp.addMolecularTypePattern(mtp);
Species species = new Species(mt.getName(), mt.getName());
SpeciesContext speciesContext = new SpeciesContext(species, struct, sp);
model.addSpecies(speciesContext.getSpecies());
model.addSpeciesContext(speciesContext);
}
}
// actually... we don't need species contextx for Sink and Source
// if(mtSource != null) {
// for(Map.Entry<Structure, MolecularType> entry : m.structureToSourceMap.entrySet()) {
// Structure struct = entry.getKey();
// MolecularType mt = entry.getValue();
// if(mtSource != mt) {
// throw new RuntimeException("The 'Source' molecular type is duplicated");
// }
// MolecularTypePattern mtp = new MolecularTypePattern(mt, false); // we shouldn't have any components
// SpeciesPattern sp = new SpeciesPattern();
// sp.addMolecularTypePattern(mtp);
// Species species = new Species(mt.getName(), mt.getName());
// SpeciesContext speciesContext = new SpeciesContext(species, struct, sp);
// model.addSpecies(speciesContext.getSpecies());
// model.addSpeciesContext(speciesContext);
// }
// }
// if(mtSink != null) {
// for(Map.Entry<Structure, MolecularType> entry : m.structureToSinkMap.entrySet()) {
// Structure struct = entry.getKey();
// MolecularType mt = entry.getValue();
// if(mtSink != mt) {
// throw new RuntimeException("The 'Sink' molecular type is duplicated");
// }
// MolecularTypePattern mtp = new MolecularTypePattern(mt, false); // we shouldn't have any components
// SpeciesPattern sp = new SpeciesPattern();
// sp.addMolecularTypePattern(mtp);
// Species species = new Species(mt.getName(), mt.getName());
// SpeciesContext speciesContext = new SpeciesContext(species, struct, sp);
// model.addSpecies(speciesContext.getSpecies());
// model.addSpeciesContext(speciesContext);
// }
// }
// make the concrete species (SpeciesContexts)
for(Molecule ssldMolecule : ssldModel.getMolecules()) {
MolecularType mt = m.get(ssldMolecule);
Expand Down Expand Up @@ -432,8 +433,24 @@ public BioModel fromSsld(SsldModel ssldModel) throws Exception {
m.put(ssldMolecule, speciesContext);
}

// ---------- Allosteric Reactions
for(AllostericReaction ssldAllostericReaction : ssldModel.getAllostericReactions()) {
m.cleanReactionsMaps();
boolean reversible = false;
// note that the transition and the condition apply to the same molecule
Molecule ssldMolecule = ssldAllostericReaction.getMolecule();
Site ssldAllostericSite = ssldAllostericReaction.getAllostericSite(); // allosteric condition
State ssldAllostericState = ssldAllostericReaction.getAllostericState();
Site ssldTransitionSite = ssldAllostericReaction.getSite(); // transitioning site
State ssldInitialTransitionState = ssldAllostericReaction.getInitialState();
State ssldFinalTransitionState = ssldAllostericReaction.getFinalState();

// TODO: continue allosteric transition work


}

// ---------- Transition Reactions
// ---------- Transition Reactions
for(TransitionReaction ssldReaction : ssldModel.getTransitionReactions()) {
m.cleanReactionsMaps();
boolean reversible = false;
Expand Down Expand Up @@ -549,8 +566,10 @@ public BioModel fromSsld(SsldModel ssldModel) throws Exception {
ReactantPattern rp = new ReactantPattern(spReactant, structure);
reactionRule.addReactant(rp);

SpeciesPattern spProduct = getSpeciesPattern(ssldMolecule, m);
// TODO: sp must not be ambiguous! it must be a concrete species! all sites must be unbound and with specified states
SpeciesContext sc = m.getSpeciesContext(ssldMolecule);
SpeciesPattern spSpeciesContext = sc.getSpeciesPattern();
// sp must not be ambiguous! it must be a concrete species! all sites must be unbound and with specified states
SpeciesPattern spProduct = new SpeciesPattern(model, spSpeciesContext);
ProductPattern pp = new ProductPattern(spProduct, structure);
reactionRule.addProduct(pp);
bioModel.getModel().getRbmModelContainer().addReactionRule(reactionRule);
Expand All @@ -573,8 +592,10 @@ public BioModel fromSsld(SsldModel ssldModel) throws Exception {
reactionRule.setKineticLaw(new RbmKineticLaw(reactionRule, rateLawType));
reactionRule.getKineticLaw().setLocalParameterValue(RbmKineticLaw.RbmKineticLawParameterType.MassActionForwardRate, kf);

SpeciesPattern spReactant = getSpeciesPattern(ssldMolecule, m);
// TODO: sp must not be ambiguous! it must be a concrete species! all sites must be unbound and with specified states
SpeciesContext sc = m.getSpeciesContext(ssldMolecule);
SpeciesPattern spSpeciesContext = sc.getSpeciesPattern();
// sp must not be ambiguous! it must be a concrete species! all sites must be unbound and with specified states
SpeciesPattern spReactant = new SpeciesPattern(model, spSpeciesContext);
ReactantPattern rp = new ReactantPattern(spReactant, structure);
reactionRule.addReactant(rp);

Expand Down

0 comments on commit cf66076

Please sign in to comment.