use of org.vcell.pathway.sbo.SBOParam in project vcell by virtualcell.
the class PathwayModel method ProcessKineticLaws.
/*
* For each kinetic law verify whether the SBOTerm which defines the type of kinetic law exists
* If it doesn't exist try to guesstimate it based on the type of parameters
* For example, if Km is present we assume it's Michaelis-Menten rate law, otherwise it's mass action
*/
private void ProcessKineticLaws() {
Set<Control> controls = BioPAXUtil.getAllControls(this);
Iterator<Control> iterator = controls.iterator();
while (iterator.hasNext()) {
Control control = iterator.next();
ArrayList<SBEntity> sbEntities = control.getSBSubEntity();
for (SBEntity sbE : sbEntities) {
// the only SBSubEntities allowed in a control are kinetic laws
if (sbE.getID().contains("kineticLaw")) {
// build list of the parameters of this kinetic law in sboParams
// params of this kinetic law
ArrayList<SBOParam> sboParams = new ArrayList<SBOParam>();
ArrayList<SBEntity> subEntities = sbE.getSBSubEntity();
for (SBEntity subEntity : subEntities) {
if (subEntity instanceof SBMeasurable) {
SBMeasurable m = (SBMeasurable) subEntity;
if (!m.hasTerm()) {
// we don't know what to do with a measurable with no SBTerm
break;
}
String termName = m.extractSBOTermAsString();
SBOTerm sboT = SBOListEx.sboMap.get(termName);
System.out.println(" " + sboT.getIndex() + " " + sboT.getName());
SBOParam sboParam = SBPAXKineticsExtractor.matchSBOParam(sboT);
if (m.hasNumber()) {
double number = m.getNumber().get(0);
sboParam.setNumber(number);
}
if (m.hasUnit()) {
String unit = m.extractSBOUnitAsString();
sboParam.setUnit(unit);
}
sboParams.add(sboParam);
}
}
ArrayList<SBVocabulary> sbTerms = sbE.getSBTerm();
if (sbTerms.isEmpty()) {
// we try to guesstimate kinetic law type based on params found above
SBVocabularyEx sbTerm = new SBVocabularyEx();
ArrayList<String> termNames = new ArrayList<String>();
String id;
SBOParam kMichaelis = SBPAXKineticsExtractor.extractMichaelisForwardParam(sboParams);
if (kMichaelis == null) {
// mass action rate law
id = new String("SBO:0000012");
System.out.println(" --- matched kinetic law to Mass Action");
} else {
// irreversible Henri-Michaelis-Menten rate law
id = new String("SBO:0000029");
System.out.println(" --- matched kinetic law to Henri-Michaelis-Menten");
}
sbTerm.setInferred(true);
sbTerm.setID(id);
sbTerms.add(sbTerm);
}
}
}
}
}
use of org.vcell.pathway.sbo.SBOParam in project vcell by virtualcell.
the class SBPAXKineticsExtractor method extractKineticsExactMatch.
public static boolean extractKineticsExactMatch(ReactionStep reaction, Process process) throws ExpressionException, PropertyVetoException {
// we try a perfect match first based on the existence of a SBOTerm in the kinetic law
if (process.getControl() == null) {
// no control means no kinetic law - nothing more to do
return true;
}
Control control = process.getControl();
ArrayList<SBEntity> sbEntities = control.getSBSubEntity();
for (SBEntity sbE : sbEntities) {
// the only SBSubEntities allowed in a control are kinetic laws
if (sbE.getID().contains("kineticLaw")) {
// build list of the parameters of this kinetic law in sboParams
// params of this kinetic law
ArrayList<SBOParam> sboParams = new ArrayList<SBOParam>();
ArrayList<SBEntity> subEntities = sbE.getSBSubEntity();
for (SBEntity subEntity : subEntities) {
if (subEntity instanceof SBMeasurable) {
SBMeasurable m = (SBMeasurable) subEntity;
if (!m.hasTerm()) {
// we don't know what to do with a measurable with no SBTerm
break;
}
String termName = m.extractSBOTermAsString();
SBOTerm sboT = SBOListEx.sboMap.get(termName);
System.out.println(" " + sboT.getIndex() + " " + sboT.getName());
SBOParam sboParam = matchSBOParam(sboT);
if (m.hasNumber()) {
double number = m.getNumber().get(0);
sboParam.setNumber(number);
}
if (m.hasUnit()) {
String unit = m.extractSBOUnitAsString();
sboParam.setUnit(unit);
}
sboParams.add(sboParam);
}
}
// find if a kinetic law type exists and if not guesstimate one based on parameters
// simple rule: if we have a Km param it's MM, otherwise it's mass action
ArrayList<SBVocabulary> sbTerms = sbE.getSBTerm();
if (sbTerms.isEmpty()) {
// return false;
SBVocabulary sbTerm = new SBVocabulary();
ArrayList<String> termNames = new ArrayList<String>();
String id;
SBOParam kMichaelis = extractMichaelisForwardParam(sboParams);
if (kMichaelis == null) {
// mass action rate law
id = new String("SBO:0000012");
} else {
// irreversible Henri-Michaelis-Menten rate law
id = new String("SBO:0000029");
}
// termNames.add(id);
// sbTerm.setTerm(termNames);
sbTerm.setID(id);
sbTerms.add(sbTerm);
}
System.out.println(" kinetic law ID: " + sbTerms.get(0).getID());
// identify the kinetic law type (mass action, michaelis menten, etc) and bring it in vCell
for (SBVocabulary sbv : sbTerms) {
// use for loop even though we only expect 1 SBTerm
// SBVocabulary id, used to retrieve the kinetic law type
String vocabularyID = sbv.getID();
SBOTerm sboT = SBOUtil.getSBOTermFromVocabularyId(vocabularyID);
System.out.println(vocabularyID + " " + sboT.getName());
SBOParam kForward;
SBOParam kCat;
SBOParam vM;
SBOParam kReverse;
SBOParam kMichaelis;
Kinetics kinetics;
MappedKinetics current = matchSBOKineticLaw(sboT);
switch(current) {
case SBO_0000069:
case SBO_0000432:
// some kinetic laws unknown to vCell will fall through to this category
// honestly i don't know what to do with them
System.out.println("GeneralKinetics");
// TODO: what to do here?
return true;
case SBO_0000012:
case SBO_0000078:
System.out.println("MassActionKinetics - reversible");
kForward = extractKForwardParam(sboParams);
kReverse = extractKReverseParam(sboParams);
kinetics = new MassActionKinetics(reaction);
reaction.setKinetics(kinetics);
setKForwardParam(reaction, kForward, kinetics);
setKReverseParam(reaction, kReverse, kinetics);
return true;
case SBO_0000043:
System.out.println("MassActionKinetics - zeroth order irreversible, Kr <- 0 ");
kForward = extractKForwardParam(sboParams);
kinetics = new MassActionKinetics(reaction);
// TODO: what to do here?
return true;
case SBO_0000044:
System.out.println("MassActionKinetics - first order irreversible, Kr <- 0 ");
kForward = extractKForwardParam(sboParams);
kinetics = new MassActionKinetics(reaction);
reaction.setKinetics(kinetics);
setKForwardParam(reaction, kForward, kinetics);
return true;
case SBO_0000028:
case SBO_0000029:
System.out.println("HMM_IRRKinetics");
// TODO: make kCat global variable, set its number and unit in annotation
// TODO: make vM global variable, set its number and unit in annotation
// get the numbers, if present (may be null)
kMichaelis = extractMichaelisForwardParam(sboParams);
vM = extractVMForwardParam(sboParams, process);
kCat = extractKCatForwardParam(sboParams);
kinetics = new HMM_IRRKinetics((SimpleReaction) reaction);
try {
// TODO: create expression only if kCat != null, otherwise use vM directly (if != null) otherwise ???
kinetics.reading(true);
setVMForwardParamAsExpression(reaction, kCat, kinetics);
} finally {
kinetics.reading(false);
}
reaction.setKinetics(kinetics);
setMichaelisForwardParam(reaction, kMichaelis, kinetics);
return true;
case SBO_0000438:
System.out.println("HMMREVKinetics");
kinetics = new HMM_REVKinetics((SimpleReaction) reaction);
return true;
default:
// TODO: guessing happens above - if we have nothing by now we need to raise runtime exception
// change the code below !!!
System.out.println("Unable to match the SBOTerm with any compatible kinetic law.");
// found unmapped kinetic law, we'll try to guess a match
return false;
}
}
}
}
// no SBTerm found so we cannot know for sure the kinetic law, we'll have to guess it
return false;
}
use of org.vcell.pathway.sbo.SBOParam in project vcell by virtualcell.
the class SBPAXKineticsExtractor method createEntry.
private static SBOParam createEntry(String index, String name, int role) {
SBOParam element = new SBOParam(index, name, role);
SBPAXKineticsExtractor.sboParamsEquivalenceMap.put(index, element);
return element;
}
Aggregations