Search in sources :

Example 1 with RelationshipModel

use of org.vcell.relationship.RelationshipModel in project vcell by virtualcell.

the class Xmlproducer method getXML.

/**
 * This method returns a XML representation for a Biomodel object.
 * Creation date: (2/14/2001 3:41:13 PM)
 * @return Element
 * @param param cbit.vcell.biomodel.BioModel
 */
@SuppressWarnings("deprecation")
public Element getXML(BioModel param) throws XmlParseException, ExpressionException {
    // Creation of BioModel Node
    Element biomodelnode = new Element(XMLTags.BioModelTag);
    String name = param.getName();
    // Add attributes
    biomodelnode.setAttribute(XMLTags.NameAttrTag, name);
    // Add annotation
    if (param.getDescription() != null && param.getDescription().length() > 0) {
        Element annotationElem = new Element(XMLTags.AnnotationTag);
        annotationElem.setText(mangle(param.getDescription()));
        biomodelnode.addContent(annotationElem);
    }
    // Get Model
    try {
        biomodelnode.addContent(getXML(param.getModel()));
    } catch (XmlParseException e) {
        e.printStackTrace();
        throw new XmlParseException("An error occurred while processing the BioModel " + name, e);
    }
    // Get SimulationContexts
    if (param.getSimulationContexts() != null) {
        for (int index = 0; index < param.getSimulationContexts().length; index++) {
            biomodelnode.addContent(getXML(param.getSimulationContext(index), param));
        }
    }
    // Add Database Metadata (Version) information
    if (param.getVersion() != null) {
        biomodelnode.addContent(getXML(param.getVersion(), param.getName(), param.getDescription()));
    }
    // Add bioPAX and relationship information
    if (param.getPathwayModel() != null) {
        biomodelnode.addContent(getXML(param.getPathwayModel(), new RDFXMLContext()));
    }
    RelationshipModel rm = param.getRelationshipModel();
    if (rm != null) {
        biomodelnode.addContent(getXML(rm, param));
    }
    biomodelnode.addContent(XMLMetaDataWriter.getElement(param.getVCMetaData(), param));
    return biomodelnode;
}
Also used : RDFXMLContext(org.vcell.pathway.persistence.RDFXMLContext) Element(org.jdom.Element) RelationshipModel(org.vcell.relationship.RelationshipModel)

Example 2 with RelationshipModel

use of org.vcell.relationship.RelationshipModel in project vcell by virtualcell.

the class ModelCartoon method relationshipChanged.

public void relationshipChanged(RelationshipEvent event) {
    RelationshipObject relationshipObject = event.getRelationshipObject();
    if (event.getOperationType() == event.ADDED) {
        Shape shape = getShapeFromModelObject(relationshipObject.getBioModelEntityObject());
        if (shape instanceof SpeciesContextShape) {
            SpeciesContextShape scShape = (SpeciesContextShape) shape;
            scShape.setLinkText("L");
        } else if (shape instanceof SimpleReactionShape) {
            SimpleReactionShape srShape = (SimpleReactionShape) shape;
            srShape.setLinkText("L");
        } else if (shape instanceof ReactionRuleDiagramShape) {
            ReactionRuleDiagramShape srShape = (ReactionRuleDiagramShape) shape;
            srShape.setLinkText("L");
        }
    } else if (event.getOperationType() == event.REMOVED) {
        Shape shape = getShapeFromModelObject(relationshipObject.getBioModelEntityObject());
        if (shape instanceof SpeciesContextShape) {
            SpeciesContextShape scShape = (SpeciesContextShape) shape;
            scShape.setLinkText("");
            // if the BioModelEntity Object is still linked with other BioPax objects, we add the "L" shape back
            if (((RelationshipModel) event.getSource()).getRelationshipObjects(relationshipObject.getBioModelEntityObject()).size() > 0) {
                scShape.setLinkText("L");
            }
        } else if (shape instanceof SimpleReactionShape) {
            SimpleReactionShape srShape = (SimpleReactionShape) shape;
            srShape.setLinkText("");
            if (((RelationshipModel) event.getSource()).getRelationshipObjects(relationshipObject.getBioModelEntityObject()).size() > 0) {
                srShape.setLinkText("L");
            }
        } else if (shape instanceof ReactionRuleDiagramShape) {
            ReactionRuleDiagramShape srShape = (ReactionRuleDiagramShape) shape;
            srShape.setLinkText("");
            if (((RelationshipModel) event.getSource()).getRelationshipObjects(relationshipObject.getBioModelEntityObject()).size() > 0) {
                srShape.setLinkText("L");
            }
        }
    }
}
Also used : Shape(cbit.gui.graph.Shape) RelationshipModel(org.vcell.relationship.RelationshipModel) RelationshipObject(org.vcell.relationship.RelationshipObject)

Example 3 with RelationshipModel

use of org.vcell.relationship.RelationshipModel in project vcell by virtualcell.

the class XmlReader method getBioModel.

/**
 * This method returns a Biomodel object from a XML Element.
 * Creation date: (3/13/2001 12:35:00 PM)
 * @return cbit.vcell.biomodel.BioModel
 * @param param org.jdom.Element
 */
public BioModel getBioModel(Element param, VCellSoftwareVersion docVcellSoftwareVersion) throws XmlParseException {
    this.docVCellSoftwareVersion = docVcellSoftwareVersion;
    // long l1 = System.currentTimeMillis();
    // Get metadata information Version (if available)
    Version version = getVersion(param.getChild(XMLTags.VersionTag, vcNamespace));
    // Create new biomodel
    BioModel biomodel = new BioModel(version);
    // Set name
    String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
    try {
        biomodel.setName(name);
        // String annotation = param.getAttributeValue(XMLTags.AnnotationAttrTag);
        // if (annotation!=null) {
        // biomodel.setDescription(unMangle(annotation));
        // }
        // get annotation
        String annotationText = param.getChildText(XMLTags.AnnotationTag, vcNamespace);
        if (annotationText != null && annotationText.length() > 0) {
            biomodel.setDescription(unMangle(annotationText));
        }
    } catch (java.beans.PropertyVetoException e) {
        e.printStackTrace();
        throw new XmlParseException(e);
    }
    // long l2 = System.currentTimeMillis();
    // System.out.println("biomodel-------- "+((double)(l2-l1))/1000);
    // ***Add biomodel to the dictionnary***
    // dictionnary.put(simcontext.getClass().getName()+":"+simcontext.getName(), simcontext);
    // Set model
    Model newmodel = getModel(param.getChild(XMLTags.ModelTag, vcNamespace));
    biomodel.setModel(newmodel);
    // Set simulation contexts
    java.util.List<Element> children = param.getChildren(XMLTags.SimulationSpecTag, vcNamespace);
    java.util.Iterator<Element> iterator = children.iterator();
    // System.out.println("model-------- "+((double)(l3-l2))/1000);
    while (iterator.hasNext()) {
        // long l4 = System.currentTimeMillis();
        Element tempElement = iterator.next();
        SimulationContext simContext = getSimulationContext(tempElement, biomodel);
        try {
            biomodel.addSimulationContext(simContext);
        } catch (java.beans.PropertyVetoException e) {
            e.printStackTrace();
            throw new XmlParseException("An error occurred while trying to add the SimContext " + simContext.getName() + " to the BioModel Object!", e);
        }
        // process the simulations within this Simspec
        Iterator<Element> simIterator = tempElement.getChildren(XMLTags.SimulationTag, vcNamespace).iterator();
        // System.out.println("simcontext-------- "+((double)(l5-l4))/1000);
        while (simIterator.hasNext()) {
            try {
                biomodel.addSimulation(getSimulation((Element) simIterator.next(), simContext.getMathDescription()));
            } catch (java.beans.PropertyVetoException e) {
                e.printStackTrace();
                throw new XmlParseException("A PropertyVetoException occurred when adding a Simulation entity to the BioModel " + name, e);
            }
        }
    // long l6 = System.currentTimeMillis();
    // System.out.println("sims-------- "+((double)(l6-l5))/1000);
    }
    // biomodel.getVCMetaData().setAnnotation(biomodel, param);
    // biomodel.getVCMetaData().setNotes(biomodel, param);
    boolean bMetaDataPopulated = false;
    List<Element> elementsMetaData = param.getChildren(XMLMetaData.VCMETADATA_TAG, VCMetaData.nsVCML);
    if (elementsMetaData != null && elementsMetaData.size() > 0) {
        for (Element elementMetaData : elementsMetaData) {
            XMLMetaDataReader.readFromElement(biomodel.getVCMetaData(), biomodel, elementMetaData);
        }
        bMetaDataPopulated = true;
    } else {
        // no metadata was found, populate vcMetaData from biomodel (mainly free text annotation for identifiables)
        if (!bMetaDataPopulated) {
            biomodel.populateVCMetadata(bMetaDataPopulated);
        }
    }
    Element pathwayElement = param.getChild(XMLTags.PathwayModelTag, vcNamespace);
    if (pathwayElement != null) {
        Element rdfElement = pathwayElement.getChild(XMLRDF.tagRDF, XMLRDF.nsRDF);
        if (rdfElement != null) {
            PathwayReaderBiopax3 pathwayReader = new PathwayReaderBiopax3(new RDFXMLContext());
            PathwayModel pathwayModel = pathwayReader.parse(rdfElement, false);
            // ??? is this needed ???
            pathwayModel.reconcileReferences(null);
            // we keep as lvl 1 only the objects which we want to show in the diagram
            pathwayModel.filterDiagramObjects();
            biomodel.getPathwayModel().merge(pathwayModel);
        } else {
            throw new XmlParseException("expecting RDF element as child of pathwayModel within VCML document");
        }
    }
    Element relationshipElement = param.getChild(XMLTags.RelationshipModelTag, vcNamespace);
    if (relationshipElement != null) {
        Element rmnsElement = relationshipElement.getChild("RMNS", vcNamespace);
        if (rmnsElement != null) {
            RelationshipReader relationshipReader = new RelationshipReader();
            RelationshipModel relationshipModel = relationshipReader.parse(rmnsElement, biomodel);
            biomodel.getRelationshipModel().merge(relationshipModel);
        } else {
        // throw new XmlParseException("expecting RMNS element as child of pathwayModel within VCML document");
        }
    }
    return biomodel;
}
Also used : RDFXMLContext(org.vcell.pathway.persistence.RDFXMLContext) RelationshipReader(org.vcell.relationship.persistence.RelationshipReader) Element(org.jdom.Element) RelationshipModel(org.vcell.relationship.RelationshipModel) SimulationContext(cbit.vcell.mapping.SimulationContext) PathwayModel(org.vcell.pathway.PathwayModel) PathwayReaderBiopax3(org.vcell.pathway.persistence.PathwayReaderBiopax3) PropertyVetoException(java.beans.PropertyVetoException) Version(org.vcell.util.document.Version) RedistributionVersion(cbit.vcell.solvers.mb.MovingBoundarySolverOptions.RedistributionVersion) SimulationVersion(org.vcell.util.document.SimulationVersion) VCellSoftwareVersion(org.vcell.util.document.VCellSoftwareVersion) BioModel(cbit.vcell.biomodel.BioModel) MathModel(cbit.vcell.mathmodel.MathModel) Model(cbit.vcell.model.Model) PathwayModel(org.vcell.pathway.PathwayModel) RelationshipModel(org.vcell.relationship.RelationshipModel) BioModel(cbit.vcell.biomodel.BioModel)

Aggregations

RelationshipModel (org.vcell.relationship.RelationshipModel)3 Element (org.jdom.Element)2 RDFXMLContext (org.vcell.pathway.persistence.RDFXMLContext)2 Shape (cbit.gui.graph.Shape)1 BioModel (cbit.vcell.biomodel.BioModel)1 SimulationContext (cbit.vcell.mapping.SimulationContext)1 MathModel (cbit.vcell.mathmodel.MathModel)1 Model (cbit.vcell.model.Model)1 RedistributionVersion (cbit.vcell.solvers.mb.MovingBoundarySolverOptions.RedistributionVersion)1 PropertyVetoException (java.beans.PropertyVetoException)1 PathwayModel (org.vcell.pathway.PathwayModel)1 PathwayReaderBiopax3 (org.vcell.pathway.persistence.PathwayReaderBiopax3)1 RelationshipObject (org.vcell.relationship.RelationshipObject)1 RelationshipReader (org.vcell.relationship.persistence.RelationshipReader)1 SimulationVersion (org.vcell.util.document.SimulationVersion)1 VCellSoftwareVersion (org.vcell.util.document.VCellSoftwareVersion)1 Version (org.vcell.util.document.Version)1