Search in sources :

Example 1 with UnitOfMeasurement

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

the class PathwayReaderBiopax3 method addObjectUnitOfMeasurement.

private UnitOfMeasurement addObjectUnitOfMeasurement(Element element) {
    if (element.getChildren().size() == 0) {
        String id = parseIDAttributes(element);
        if (id != null) {
            return UnitOfMeasurementPool.getUnitById(id);
        } else {
            return new UnitOfMeasurement();
        }
    }
    String id = null;
    List<String> symbols = new ArrayList<String>();
    id = parseIDAttributes(element);
    for (Object childObject : element.getChildren()) {
        if (childObject instanceof Element) {
            Element childElement = (Element) childObject;
            if (childElement.getName().equals("unitSymbol")) {
                String symbol = childElement.getTextTrim();
                symbols.add(symbol);
            }
        }
    }
    UnitOfMeasurement unit = UnitOfMeasurementPool.getUnitByIdOrSymbol(id, symbols);
    addAttributes(unit, element);
    for (Object child : element.getChildren()) {
        if (!addContentUnitOfMeasurement(unit, element, (Element) child)) {
            showUnexpected((Element) child);
        }
    }
    pathwayModel.add(unit);
    return unit;
}
Also used : UnitOfMeasurement(org.vcell.pathway.sbpax.UnitOfMeasurement) Element(org.jdom.Element) ArrayList(java.util.ArrayList) GroupObject(org.vcell.pathway.GroupObject) BioPaxObject(org.vcell.pathway.BioPaxObject)

Example 2 with UnitOfMeasurement

use of org.vcell.pathway.sbpax.UnitOfMeasurement 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 UnitOfMeasurement

use of org.vcell.pathway.sbpax.UnitOfMeasurement 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)

Aggregations

UnitOfMeasurement (org.vcell.pathway.sbpax.UnitOfMeasurement)3 Element (org.jdom.Element)2 SBVocabulary (org.vcell.pathway.sbpax.SBVocabulary)2 ArrayList (java.util.ArrayList)1 BioPaxObject (org.vcell.pathway.BioPaxObject)1 GroupObject (org.vcell.pathway.GroupObject)1 PathwayXMLHelper.schemaDouble (org.vcell.pathway.PathwayXMLHelper.schemaDouble)1 PathwayXMLHelper.schemaString (org.vcell.pathway.PathwayXMLHelper.schemaString)1 SBMeasurable (org.vcell.pathway.sbpax.SBMeasurable)1