use of org.vcell.pathway.PathwayModel in project vcell by virtualcell.
the class BioModelEditorSabioPanel method populateKineticLawsTree.
public void populateKineticLawsTree() {
// String category1 = (String)categoryList1.getSelectedItem();
String category1 = "AnyRole";
String category2 = (String) categoryList2.getSelectedItem();
String entity1 = entityName1.getText();
String entity2 = entityName2.getText();
// http://sabiork.h-its.org/sabioRestWebServices/searchKineticLaws/biopax?q=%28Pathway:JAK-STAT%20AND%20CellularLocation:cytosol%29
command = "";
if (entity1.isEmpty() && entity2.isEmpty()) {
DialogUtils.showWarningDialog(this, "No search criteria specified.");
return;
}
if (!entity1.isEmpty() && entity2.isEmpty()) {
command += category1 + ":" + entity1;
} else if (entity1.isEmpty() && !entity2.isEmpty()) {
command += category2 + ":" + entity2;
} else {
// both entities present
command += "%28" + category1 + ":" + entity1 + "%20AND%20" + category2 + ":" + entity2 + "%29";
}
AsynchClientTask task1 = new AsynchClientTask("Importing Kinetic Laws", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(final Hashtable<String, Object> hashTable) throws Exception {
final URL url = new URL("http://sabiork.h-its.org/sabioRestWebServices/searchKineticLaws/biopax?q=" + command);
System.out.println(url.toString());
String ERROR_CODE_TAG = "error_code";
Document jdomDocument = XmlUtil.getJDOMDocument(url, getClientTaskStatusSupport());
Element rootElement = jdomDocument.getRootElement();
String errorCode = rootElement.getChildText(ERROR_CODE_TAG);
if (errorCode != null) {
throw new RuntimeException("Failed to access " + url + " \n\nPlease try again.");
}
PathwayModel pathwayModel = PathwayIOUtil.extractPathwayFromJDOM(jdomDocument, new RDFXMLContext(), getClientTaskStatusSupport());
PathwayData pathwayData = new PathwayData("Sabio Kinetic Laws", pathwayModel);
hashTable.put("pathwayData", pathwayData);
}
};
AsynchClientTask task2 = new AsynchClientTask("showing", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
PathwayData pathwayData = (PathwayData) hashTable.get("pathwayData");
if (pathwayData != null) {
responseTreeModel.addSearchResponse("text", pathwayData);
}
}
};
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 }, true, true, null);
}
use of org.vcell.pathway.PathwayModel in project vcell by virtualcell.
the class BioModelEditorPathwayCommonsPanel method showPathway.
public void showPathway() {
final Pathway pathway = computeSelectedPathway();
if (pathway == null) {
return;
}
AsynchClientTask task1 = new AsynchClientTask("Importing pathway '" + pathway.name() + "'", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(final Hashtable<String, Object> hashTable) throws Exception {
final URL url = new URL(defaultBaseURL + "?" + PathwayCommonsKeyword.cmd + "=" + PathwayCommonsKeyword.get_record_by_cpath_id + "&" + PathwayCommonsKeyword.version + "=" + PathwayCommonsVersion.v2.name + "&" + PathwayCommonsKeyword.q + "=" + pathway.primaryId() + "&" + PathwayCommonsKeyword.output + "=" + PathwayCommonsKeyword.biopax);
System.out.println(url.toString());
String ERROR_CODE_TAG = "error_code";
// String ERROR_MSG_TAG = "error_msg";
org.jdom.Document jdomDocument = XmlUtil.getJDOMDocument(url, getClientTaskStatusSupport());
org.jdom.Element rootElement = jdomDocument.getRootElement();
String errorCode = rootElement.getChildText(ERROR_CODE_TAG);
if (errorCode != null) {
throw new RuntimeException("Failed to access " + url + " \n\nPlease try again.");
}
// String xmlText = StringUtil.textFromInputStream(connection.getInputStream());
// PathwayReader pathwayReader = new PathwayReader();
// org.jdom.Document jdomDocument = XmlUtil.stringToXML(xmlText, null);
// String xmlText = StringUtil.textFromInputStream(connection.getInputStream(), "UTF-8");
// PathwayReader pathwayReader = new PathwayReader();
// org.jdom.Document jdomDocument = XmlUtil.stringToXML(xmlText, "UTF-8");
PathwayModel pathwayModel = PathwayIOUtil.extractPathwayFromJDOM(jdomDocument, new RDFXMLContext(), getClientTaskStatusSupport());
PathwayData pathwayData = new PathwayData(pathway.name(), pathwayModel);
hashTable.put("pathwayData", pathwayData);
}
};
AsynchClientTask task2 = new AsynchClientTask("showing", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
PathwayData pathwayData = (PathwayData) hashTable.get("pathwayData");
if (pathwayData != null) {
// setActiveView(new ActiveView(null, DocumentEditorTreeFolderClass.PATHWAY_NODE, null));
setSelectedObjects(new Object[] { pathwayData });
}
}
};
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 }, true, true, null);
}
use of org.vcell.pathway.PathwayModel 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;
}
use of org.vcell.pathway.PathwayModel in project vcell by virtualcell.
the class PathwayTableModel method setPathwayModel.
public void setPathwayModel(PathwayModel newValue) {
if (this.pathwayModel == newValue) {
return;
}
PathwayModel oldValue = pathwayModel;
if (oldValue != null) {
oldValue.removePathwayListener(this);
}
if (newValue != null) {
newValue.addPathwayListener(this);
}
this.pathwayModel = newValue;
refreshData();
}
use of org.vcell.pathway.PathwayModel in project vcell by virtualcell.
the class PathwayReader method main.
public static void main(String[] args) {
try {
Document document = XmlUtil.readXML(new File("C:\\Developer\\eclipse\\workspace\\VCell_Standard\\temp.xml"));
PathwayReader pathwayReader = new PathwayReader(new RDFXMLContext());
System.out.println("starting parsing");
PathwayModel pathwayModel = pathwayReader.parse(document.getRootElement(), null);
System.out.println("ending parsing");
pathwayModel.reconcileReferences(null);
System.out.println(pathwayModel.show(true));
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
Aggregations