Search in sources :

Example 1 with SBVocabulary

use of org.vcell.pathway.sbpax.SBVocabulary in project vcell by virtualcell.

the class PathwayReaderBiopax3 method addObjectSBVocabulary.

private SBVocabulary addObjectSBVocabulary(Element element) {
    if (element.getChildren().size() == 0) {
        SBVocabularyProxy proxy = new SBVocabularyProxy();
        addAttributes(proxy, element);
        pathwayModel.add(proxy);
        return proxy;
    }
    for (Object child : element.getChildren()) {
        if (child instanceof Element) {
            Element childElement = (Element) child;
            if (childElement.getName().equals("SBVocabulary")) {
                SBVocabulary thingie = addObjectSBVocabulary(childElement);
                pathwayModel.add(thingie);
                return thingie;
            }
        }
    }
    SBVocabulary sbVocabulary = new SBVocabulary();
    addAttributes(sbVocabulary, element);
    for (Object child : element.getChildren()) {
        if (child instanceof Element) {
            Element childElement = (Element) child;
            if (!addContentControlledVocabulary(sbVocabulary, element, childElement)) {
                showUnexpected(childElement);
            }
        }
    }
    pathwayModel.add(sbVocabulary);
    return sbVocabulary;
}
Also used : SBVocabulary(org.vcell.pathway.sbpax.SBVocabulary) Element(org.jdom.Element) GroupObject(org.vcell.pathway.GroupObject) BioPaxObject(org.vcell.pathway.BioPaxObject) SBVocabularyProxy(org.vcell.pathway.persistence.BiopaxProxy.SBVocabularyProxy)

Example 2 with SBVocabulary

use of org.vcell.pathway.sbpax.SBVocabulary in project vcell by virtualcell.

the class BioPAXSBMeasurableTreeNode method getSimplifiedLabel.

public String getSimplifiedLabel() {
    String simplifiedLabel = super.getSimplifiedLabel();
    // //		ArrayList<String> names = getEntity().getName();
    // if(names != null && !names.isEmpty() && StringUtil.notEmpty(names.get(0))) {
    // simplifiedLabel = names.get(0);
    // }
    String betterLabel = "";
    List<SBVocabulary> sbTerms = getSBMeasurable().getSBTerm();
    if (sbTerms != null && !sbTerms.isEmpty()) {
        SBVocabulary sbTerm = sbTerms.get(0);
        if (sbTerm != null) {
            List<String> terms = sbTerm.getTerm();
            if (terms != null && !terms.isEmpty()) {
                String term = terms.get(0);
                if (StringUtil.notEmpty(term)) {
                    betterLabel = term;
                }
            }
        }
    }
    List<Double> numbers = getSBMeasurable().getNumber();
    if (numbers != null && !numbers.isEmpty()) {
        Double number = numbers.get(0);
        if (number != null) {
            if (StringUtil.notEmpty(betterLabel)) {
                betterLabel = betterLabel + " ";
            }
            betterLabel = betterLabel + number;
        }
    }
    List<UnitOfMeasurement> units = getSBMeasurable().getUnit();
    if (units != null && !units.isEmpty()) {
        UnitOfMeasurement unit = units.get(0);
        if (unit != null) {
            if (StringUtil.notEmpty(betterLabel)) {
                betterLabel = betterLabel + " ";
            }
            betterLabel = betterLabel + unit.getIDShort();
        }
    }
    if (StringUtil.notEmpty(betterLabel)) {
        simplifiedLabel = betterLabel;
    }
    if (StringUtil.isEmpty(simplifiedLabel)) {
        simplifiedLabel = super.getSimplifiedLabel();
    }
    return simplifiedLabel;
}
Also used : SBVocabulary(org.vcell.pathway.sbpax.SBVocabulary) UnitOfMeasurement(org.vcell.pathway.sbpax.UnitOfMeasurement)

Example 3 with SBVocabulary

use of org.vcell.pathway.sbpax.SBVocabulary in project vcell by virtualcell.

the class PathwayProducerBiopax3 method addContentSBMeasurable.

private Element addContentSBMeasurable(BioPaxObject bpObject, Element element) {
    element = addContentUtilityClass(bpObject, element);
    SBMeasurable ob = (SBMeasurable) bpObject;
    Element tmpElement = null;
    if (ob.getUnit() != null && ob.getUnit().size() > 0) {
        List<UnitOfMeasurement> list = ob.getUnit();
        for (UnitOfMeasurement item : list) {
            tmpElement = new Element("hasUnit", sbx3);
            String id = item.getID();
            if (URIUtil.isAbsoluteURI(id)) {
                tmpElement.setAttribute("resource", context.relativizeURI(tmpElement, id), rdf);
            } else {
                tmpElement.setAttribute("nodeID", id, rdf);
            }
            mustPrintObject(item);
            element.addContent(tmpElement);
        }
    }
    if (ob.getSBTerm() != null && ob.getSBTerm().size() > 0) {
        List<SBVocabulary> list = ob.getSBTerm();
        for (SBVocabulary item : list) {
            tmpElement = new Element("sbTerm", sbx3);
            addIDToProperty(tmpElement, item);
            mustPrintObject(item);
            element.addContent(tmpElement);
        }
    }
    if (ob.getNumber() != null && ob.getNumber().size() > 0) {
        List<Double> list = ob.getNumber();
        for (Double item : list) {
            tmpElement = new Element("hasNumber", sbx3);
            tmpElement.setAttribute("datatype", schemaDouble, rdf);
            tmpElement.setText(item.toString());
            element.addContent(tmpElement);
        }
    }
    return element;
}
Also used : SBVocabulary(org.vcell.pathway.sbpax.SBVocabulary) UnitOfMeasurement(org.vcell.pathway.sbpax.UnitOfMeasurement) Element(org.jdom.Element) PathwayXMLHelper.schemaString(org.vcell.pathway.PathwayXMLHelper.schemaString) PathwayXMLHelper.schemaDouble(org.vcell.pathway.PathwayXMLHelper.schemaDouble) SBMeasurable(org.vcell.pathway.sbpax.SBMeasurable)

Example 4 with SBVocabulary

use of org.vcell.pathway.sbpax.SBVocabulary 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);
                }
            }
        }
    }
}
Also used : SBVocabulary(org.vcell.pathway.sbpax.SBVocabulary) ArrayList(java.util.ArrayList) SBOTerm(org.vcell.pathway.sbo.SBOTerm) SBEntity(org.vcell.pathway.sbpax.SBEntity) SBOParam(org.vcell.pathway.sbo.SBOParam) SBMeasurable(org.vcell.pathway.sbpax.SBMeasurable)

Example 5 with SBVocabulary

use of org.vcell.pathway.sbpax.SBVocabulary 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;
}
Also used : SBVocabulary(org.vcell.pathway.sbpax.SBVocabulary) SimpleReaction(cbit.vcell.model.SimpleReaction) HMM_IRRKinetics(cbit.vcell.model.HMM_IRRKinetics) ArrayList(java.util.ArrayList) SBOTerm(org.vcell.pathway.sbo.SBOTerm) HMM_REVKinetics(cbit.vcell.model.HMM_REVKinetics) SBEntity(org.vcell.pathway.sbpax.SBEntity) SBOParam(org.vcell.pathway.sbo.SBOParam) SBMeasurable(org.vcell.pathway.sbpax.SBMeasurable) Control(org.vcell.pathway.Control) MassActionKinetics(cbit.vcell.model.MassActionKinetics) HMM_IRRKinetics(cbit.vcell.model.HMM_IRRKinetics) Kinetics(cbit.vcell.model.Kinetics) HMM_REVKinetics(cbit.vcell.model.HMM_REVKinetics) MassActionKinetics(cbit.vcell.model.MassActionKinetics)

Aggregations

SBVocabulary (org.vcell.pathway.sbpax.SBVocabulary)7 ArrayList (java.util.ArrayList)4 SBMeasurable (org.vcell.pathway.sbpax.SBMeasurable)4 SBOTerm (org.vcell.pathway.sbo.SBOTerm)3 SBEntity (org.vcell.pathway.sbpax.SBEntity)3 Element (org.jdom.Element)2 BioPaxObject (org.vcell.pathway.BioPaxObject)2 Control (org.vcell.pathway.Control)2 GroupObject (org.vcell.pathway.GroupObject)2 SBOParam (org.vcell.pathway.sbo.SBOParam)2 UnitOfMeasurement (org.vcell.pathway.sbpax.UnitOfMeasurement)2 BioModelEntityObject (cbit.vcell.model.BioModelEntityObject)1 HMM_IRRKinetics (cbit.vcell.model.HMM_IRRKinetics)1 HMM_REVKinetics (cbit.vcell.model.HMM_REVKinetics)1 Kinetics (cbit.vcell.model.Kinetics)1 MassActionKinetics (cbit.vcell.model.MassActionKinetics)1 SimpleReaction (cbit.vcell.model.SimpleReaction)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1