use of org.vcell.pathway.BioPaxObject in project vcell by virtualcell.
the class BioModelEditorPathwayDiagramPanel method groupBioPaxObjects.
private void groupBioPaxObjects() {
HashSet<BioPaxObject> selected = new HashSet<BioPaxObject>();
selected.addAll(getSelectedBioPaxObjects());
if (selected.size() == 0)
return;
if (bioModel == null || bioModel.getPathwayModel() == null)
return;
PathwayGrouping pathwayGrouping = new PathwayGrouping();
ArrayList<String> names = new ArrayList<String>();
String id = pathwayGrouping.groupIdGenerator(bioModel.getPathwayModel());
String newName = null;
try {
newName = DialogUtils.showInputDialog0(this, "Name of the GroupObject", id);
} catch (UtilCancelException ex) {
// user canceled; it's ok
}
if (newName != null) {
if (newName.length() == 0) {
PopupGenerator.showErrorDialog(this, "The Name of the GroupObject should be provided.");
} else {
names.add(newName);
GroupObject groupObject = pathwayGrouping.createGroupObject(bioModel.getPathwayModel(), names, id, selected, GroupObject.Type.GROUPEDBIOPAXOBJECTS);
if (groupObject == null) {
// error message
DialogUtils.showErrorDialog(this, "The set of selected objects is a subset of one group object in the model. They will not be grouped together again.");
} else {
bioModel.getPathwayModel().add(groupObject);
bioModel.getPathwayModel().refreshGroupMap();
// set the grouped object to be selected
graphCartoonTool.getGraphModel().setSelectedObjects(new GroupObject[] { groupObject });
}
}
}
pathwayGraphModel.refreshAll();
}
use of org.vcell.pathway.BioPaxObject in project vcell by virtualcell.
the class BioModelEditorPathwayDiagramPanel method showPhysiologyLinks.
private void showPhysiologyLinks() {
BioPaxObject selectedBioPaxObject = getSelectedBioPaxObject();
if (selectedBioPaxObject != null) {
Set<RelationshipObject> relationshipSet = bioModel.getRelationshipModel().getRelationshipObjects(selectedBioPaxObject);
if (relationshipSet.size() > 0) {
ArrayList<BioModelEntityObject> selectedBioModelEntityObjects = new ArrayList<BioModelEntityObject>();
for (RelationshipObject re : relationshipSet) {
BioModelEntityObject bioModelEntityObject = re.getBioModelEntityObject();
selectedBioModelEntityObjects.add(bioModelEntityObject);
}
// if (selectedBioPaxObjects.get(0) instanceof ReactionStep) {
// selectionManager.setActiveView(new ActiveView(null,DocumentEditorTreeFolderClass.REACTIONS_NODE, ActiveViewID.reactions));
// } else if (selectedBioPaxObjects.get(0) instanceof SpeciesContext) {
// selectionManager.setActiveView(new ActiveView(null,DocumentEditorTreeFolderClass.SPECIES_NODE, ActiveViewID.species));
// }
selectionManager.followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTION_DIAGRAM_NODE, ActiveViewID.reaction_diagram), selectedBioModelEntityObjects.toArray(new BioModelEntityObject[0]));
}
}
}
use of org.vcell.pathway.BioPaxObject in project vcell by virtualcell.
the class BioPaxObjectPropertiesPanel method initialize.
private void initialize() {
try {
table = new ScrollTable();
tableModel = new BioPaxObjectPropertiesTableModel(table);
table.setModel(tableModel);
details = new JTextPane();
details.setContentType("text/html");
details.setEditable(false);
JScrollPane scrl = new JScrollPane(details);
table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
BioPaxObjectProperty property = tableModel.getValueAt(table.getSelectedRow());
if (property != null) {
final String htmlStart = "<html><font face = \"Arial\"><font size =\"-2\">";
final String htmlEnd = "</font></font></html>";
if (!property.getDetails().isEmpty()) {
details.setText(htmlStart + property.getDetails() + htmlEnd);
} else if ((property.value != null) && !property.value.isEmpty()) {
String text = FormatDetails(property);
details.setText(htmlStart + text + htmlEnd);
} else {
details.setText(htmlStart + "row: " + table.getSelectedRow() + ", col: " + table.getSelectedColumn() + htmlEnd);
}
}
}
}
});
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, table.getEnclosingScrollPane(), scrl);
splitPane.setOneTouchExpandable(true);
splitPane.setDividerLocation(150);
// provide minimum sizes for the two components in the split pane
Dimension minimumSize = new Dimension(100, 50);
table.getEnclosingScrollPane().setMinimumSize(minimumSize);
scrl.setMinimumSize(minimumSize);
setLayout(new BorderLayout());
// add(table.getEnclosingScrollPane(), BorderLayout.CENTER);
// add(details, BorderLayout.CENTER);
add(splitPane, BorderLayout.CENTER);
setBackground(Color.white);
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
// launch the browser when double click on hyperlinks
Point pt = e.getPoint();
int crow = table.rowAtPoint(pt);
int ccol = table.columnAtPoint(pt);
if (table.convertColumnIndexToModel(ccol) == BioPaxObjectPropertiesTableModel.Column_Value) {
BioPaxObjectProperty property = tableModel.getValueAt(crow);
BioPaxObject bioPaxObject = property.bioPaxObject;
if (bioPaxObject == null) {
BioModelEntityObject bioModelEntityObject = property.bioModelEntityObject;
if (bioModelEntityObject != null) {
if (bioModelEntityObject instanceof SpeciesContext) {
selectionManager.followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.REACTION_DIAGRAM_NODE, ActiveViewID.reaction_diagram), new Object[] { bioModelEntityObject });
} else if (bioModelEntityObject instanceof MolecularType) {
selectionManager.followHyperlink(new ActiveView(null, DocumentEditorTreeFolderClass.MOLECULAR_TYPES_NODE, ActiveViewID.species_definitions), new Object[] { bioModelEntityObject });
}
} else if (((Entity) BioPaxObjectPropertiesPanel.this.bioPaxObject).getFormalNames() == null || ((Entity) BioPaxObjectPropertiesPanel.this.bioPaxObject).getFormalNames().size() == 0) {
lookupFormalName(crow);
}
} else if (bioPaxObject instanceof Xref) {
// if xRef, get url
String url = ((Xref) bioPaxObject).getURL();
DialogUtils.browserLauncher(BioPaxObjectPropertiesPanel.this, url, "Wrong URL.");
} else if (bioPaxObject instanceof SBEntity) {
// TODO: kineticLaw
SBEntity sbE = (SBEntity) bioPaxObject;
if (sbE.getID().contains("kineticLaw")) {
// String url = "http://sabio.h-its.org/sabioRestWebServices/kineticLaws/" + sbE.getID().substring(sbE.getID().indexOf("kineticLaw") + 10);
String url = "http://sabiork.h-its.org/kindatadirectiframe.jsp?kinlawid=" + sbE.getID().substring(sbE.getID().indexOf("kineticLaw") + 10);
DialogUtils.browserLauncher(BioPaxObjectPropertiesPanel.this, url, "Wrong URL.");
}
}
}
}
}
});
// --- end of addMouseListener()
table.getColumnModel().getColumn(BioPaxObjectPropertiesTableModel.Column_Value).setCellRenderer(new DefaultScrollTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (column == BioPaxObjectPropertiesTableModel.Column_Value) {
BioPaxObjectProperty property = tableModel.getValueAt(row);
BioPaxObject bpObject = property.bioPaxObject;
String text = property.value;
// colorize BLUE and add surround text with <html></html> tags
if (bpObject == null) {
BioModelEntityObject bioModelEntityObject = property.bioModelEntityObject;
if (bioModelEntityObject != null) {
if (!isSelected) {
setForeground(Color.blue);
}
setText("<html><u>" + text + "</u></html>");
}
} else {
if (bpObject instanceof Xref) {
String url = ((Xref) bpObject).getURL();
if (url != null) {
setToolTipText(url);
if (!isSelected) {
setForeground(Color.blue);
}
setText("<html><u>" + text + "</u></html>");
}
} else if (bpObject instanceof SBEntity) {
String url = ((SBEntity) bpObject).getID();
if (url.contains("kineticLaw")) {
setToolTipText(url);
if (!isSelected) {
setForeground(Color.blue);
}
if (url.contains("http")) {
setText("<html><u>" + text + "</u></html>");
}
}
}
}
}
BioPaxObjectProperty property = tableModel.getValueAt(row);
if (!property.tooltip.isEmpty()) {
setToolTipText(property.tooltip);
}
return this;
}
});
// --- end of setCellRenderer()
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
use of org.vcell.pathway.BioPaxObject in project vcell by virtualcell.
the class BioModelEditorConversionTableModel method getValueAt.
public Object getValueAt(int iRow, int iCol) {
ConversionTableRow conversionTableRow = getValueAt(iRow);
BioPaxObject bpObject = conversionTableRow.getBioPaxObject();
switch(iCol) {
case iColInteraction:
{
return conversionTableRow.interactionLabel();
}
case iColParticipant:
{
return conversionTableRow.participantType();
}
case iColEntity:
{
return getLabel(bpObject);
}
case iColType:
{
return getType(bpObject);
}
case iColStoich:
{
return conversionTableRow.stoich();
}
case iColID:
{
return conversionTableRow.id();
}
case iColLocation:
{
return conversionTableRow.location();
}
default:
{
return null;
}
}
}
use of org.vcell.pathway.BioPaxObject in project vcell by virtualcell.
the class BioModelEditorConversionTableModel method refreshData.
private void refreshData() {
if (bioModel == null || bioModel.getPathwayModel() == null || bioPaxObjects == null) {
setData(null);
return;
}
// function I :: get selected objects only
// create ConversionTableRow objects
allPathwayObjectList = new ArrayList<ConversionTableRow>();
convertedBPObjects = new HashSet<BioPaxObject>();
printObjects(bioPaxObjects);
BioModel.printBpModelObjects(bioModel.getPathwayModel().getBiopaxObjects());
// BioModel.printBpRelationshipObjects(bioModel.getRelationshipModel().getBioPaxObjects()); // derived; the bpObjects that are part of a relationship
BioModel.printRelationships(bioModel.getRelationshipModel().getRelationshipObjects());
System.out.println("----------------------------------------------------------------------");
for (BioPaxObject bpo : bioPaxObjects) {
if (bpo instanceof Conversion) {
if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).size() == 0) {
Conversion conversion = (Conversion) bpo;
ArrayList<String> nameList = conversion.getName();
String interactionId = conversion.getID();
String interactionLabel = nameList.isEmpty() ? conversion.getIDShort() : nameList.get(0);
ConversionTableRow newConversionTableRow = createTableRow(conversion, interactionId, interactionLabel, "Conversion", 1.0, null);
allPathwayObjectList.add(newConversionTableRow);
convertedBPObjects.add(bpo);
ArrayList<Stoichiometry> stoichiometryList = conversion.getParticipantStoichiometry();
// stoichiometryMap problem:
// how to deal with the case that the same object occurs on both left and right sides
HashMap<PhysicalEntity, Double> stoichiometryMap = createStoichiometryMap(stoichiometryList);
// reactant
for (BioPaxObject bpObject1 : conversion.getLeft()) {
Double stoich = 1.0;
if (stoichiometryMap.get((PhysicalEntity) bpObject1) != null) {
stoich = stoichiometryMap.get((PhysicalEntity) bpObject1);
}
ConversionTableRow conversionTableRow;
if (bioModel.getRelationshipModel().getRelationshipObjects(bpObject1).isEmpty()) {
if (conversion instanceof Transport)
conversionTableRow = createTableRowForTransportParticipant(bpObject1, interactionId, interactionLabel, "Reactant", stoich, null);
else
conversionTableRow = createTableRow(bpObject1, interactionId, interactionLabel, "Reactant", stoich, null);
} else {
if (conversion instanceof Transport)
conversionTableRow = createTableRowForTransportParticipant(bpObject1, interactionId, interactionLabel, "Reactant", stoich, bioModel.getRelationshipModel().getRelationshipObjects(bpObject1));
else
conversionTableRow = createTableRow(bpObject1, interactionId, interactionLabel, "Reactant", stoich, bioModel.getRelationshipModel().getRelationshipObjects(bpObject1));
}
allPathwayObjectList.add(conversionTableRow);
convertedBPObjects.add(bpObject1);
}
// product
for (BioPaxObject bpObject1 : conversion.getRight()) {
Double stoich = 1.0;
if (stoichiometryMap.get((PhysicalEntity) bpObject1) != null) {
stoich = stoichiometryMap.get((PhysicalEntity) bpObject1);
}
ConversionTableRow conversionTableRow;
if (bioModel.getRelationshipModel().getRelationshipObjects(bpObject1).isEmpty()) {
if (conversion instanceof Transport)
conversionTableRow = createTableRowForTransportParticipant(bpObject1, interactionId, interactionLabel, "Product", stoich, null);
else
conversionTableRow = createTableRow(bpObject1, interactionId, interactionLabel, "Product", stoich, null);
} else {
if (conversion instanceof Transport)
conversionTableRow = createTableRowForTransportParticipant(bpObject1, interactionId, interactionLabel, "Product", stoich, bioModel.getRelationshipModel().getRelationshipObjects(bpObject1));
else
conversionTableRow = createTableRow(bpObject1, interactionId, interactionLabel, "Product", stoich, bioModel.getRelationshipModel().getRelationshipObjects(bpObject1));
}
allPathwayObjectList.add(conversionTableRow);
convertedBPObjects.add(bpObject1);
}
// control
for (BioPaxObject bpObject : bioModel.getPathwayModel().getBiopaxObjects()) {
if (bpObject instanceof Control) {
Control control = (Control) bpObject;
if (control instanceof Catalysis) {
// catalysis
if (BioPAXUtil.getControlledNonControlInteraction(control) == conversion) {
for (PhysicalEntity pe : ((Catalysis) control).getPhysicalControllers()) {
ConversionTableRow conversionTableRow;
if (bioModel.getRelationshipModel().getRelationshipObjects(pe).isEmpty()) {
conversionTableRow = createTableRow(pe, interactionId, interactionLabel, "Catalyst", 1.0, null);
} else {
conversionTableRow = createTableRow(pe, interactionId, interactionLabel, "Catalyst", 1.0, bioModel.getRelationshipModel().getRelationshipObjects(pe));
}
allPathwayObjectList.add(conversionTableRow);
convertedBPObjects.add(pe);
}
}
} else {
// other control types
if (BioPAXUtil.getControlledNonControlInteraction(control) == conversion) {
for (PhysicalEntity pe : control.getPhysicalControllers()) {
ConversionTableRow conversionTableRow;
if (bioModel.getRelationshipModel().getRelationshipObjects(pe).isEmpty()) {
conversionTableRow = createTableRow(pe, interactionId, interactionLabel, "Control", 1.0, null);
} else {
conversionTableRow = createTableRow(pe, interactionId, interactionLabel, "Control", 1.0, bioModel.getRelationshipModel().getRelationshipObjects(pe));
}
allPathwayObjectList.add(conversionTableRow);
convertedBPObjects.add(pe);
}
}
}
}
}
}
} else if (bpo instanceof Catalysis) {
for (PhysicalEntity pe : ((Catalysis) bpo).getPhysicalControllers()) {
if (!convertedBPObjects.contains(pe)) {
ConversionTableRow conversionTableRow;
if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).isEmpty()) {
conversionTableRow = createTableRow(pe, "", "", "Catalyst", 1.0, null);
} else {
conversionTableRow = createTableRow(pe, "", "", "Catalyst", 1.0, bioModel.getRelationshipModel().getRelationshipObjects(bpo));
}
allPathwayObjectList.add(conversionTableRow);
convertedBPObjects.add(pe);
}
}
for (Pathway pathway : ((Catalysis) bpo).getPathwayControllers()) {
// TODO
}
} else if (bpo instanceof Control) {
for (PhysicalEntity pe : ((Catalysis) bpo).getPhysicalControllers()) {
if (!convertedBPObjects.contains(pe)) {
ConversionTableRow conversionTableRow;
if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).isEmpty()) {
conversionTableRow = createTableRow(pe, "", "", "Control", 1.0, null);
} else {
conversionTableRow = createTableRow(pe, "", "", "Control", 1.0, bioModel.getRelationshipModel().getRelationshipObjects(bpo));
}
allPathwayObjectList.add(conversionTableRow);
convertedBPObjects.add(pe);
}
}
for (Pathway pathway : ((Catalysis) bpo).getPathwayControllers()) {
// TODO
}
}
}
// 2nd pass - entities selected as themselves
for (BioPaxObject bpo : bioPaxObjects) {
if (bpo instanceof PhysicalEntity) {
if (bioModel.getRelationshipModel().getRelationshipObjects(bpo).size() == 0) {
PhysicalEntity physicalEntityObject = (PhysicalEntity) bpo;
// we add standalone selected entities, only if they were not already added as part of any reaction
if (!convertedBPObjects.contains(physicalEntityObject)) {
ConversionTableRow conversionTableRow = createTableRow(physicalEntityObject, "", "", "", 1.0, null);
allPathwayObjectList.add(conversionTableRow);
convertedBPObjects.add(physicalEntityObject);
}
}
}
}
// apply text search function for particular columns
ArrayList<ConversionTableRow> pathwayObjectList = new ArrayList<ConversionTableRow>();
if (searchText == null || searchText.length() == 0) {
pathwayObjectList.addAll(allPathwayObjectList);
} else {
String lowerCaseSearchText = searchText.toLowerCase();
for (ConversionTableRow rs : allPathwayObjectList) {
BioPaxObject bpObject = rs.getBioPaxObject();
if (rs.interactionLabel().toLowerCase().contains(lowerCaseSearchText) || rs.participantType().toLowerCase().contains(lowerCaseSearchText) || getLabel(bpObject).toLowerCase().contains(lowerCaseSearchText) || getType(bpObject).toLowerCase().contains(lowerCaseSearchText)) {
pathwayObjectList.add(rs);
}
}
}
setData(pathwayObjectList);
GuiUtils.flexResizeTableColumns(ownerTable);
}
Aggregations