001package org.biopax.paxtools.query.wrapperL3undirected; 002 003import org.biopax.paxtools.model.BioPAXElement; 004import org.biopax.paxtools.model.level3.PhysicalEntity; 005import org.biopax.paxtools.query.model.AbstractNode; 006import org.biopax.paxtools.query.model.Edge; 007import org.biopax.paxtools.query.model.Graph; 008import org.biopax.paxtools.query.model.Node; 009 010import java.util.Collection; 011import java.util.Collections; 012 013/** 014 * This is the parent wrapper class for both Conversion and TemplateReaction objects. 015 * 016 * @author Ozgun Babur 017 */ 018public abstract class EventWrapper extends AbstractNode 019{ 020 /** 021 * Constructor with the owner graph. 022 * @param graph Owner graph 023 */ 024 protected EventWrapper(GraphL3Undirected graph) 025 { 026 super(graph); 027 } 028 029 /** 030 * Events are not breadth nodes. 031 * @return False 032 */ 033 public boolean isBreadthNode() 034 { 035 return false; 036 } 037 038 /** 039 * Events have a positive sign. 040 * @return POSITIVE (1) 041 */ 042 public int getSign() 043 { 044 return POSITIVE; 045 } 046 047 /** 048 * Events are not ubiquitous molecules. 049 * @return False 050 */ 051 public boolean isUbique() 052 { 053 return false; 054 } 055 056 /** 057 * Say if the event is a transcription. 058 * @return Whether the event is a transcription 059 */ 060 public abstract boolean isTranscription(); 061 062 /** 063 * Bind the wrapper of the given element to the upstream. 064 * @param ele Element to bind 065 * @param graph Owner graph. 066 */ 067 protected void addToUpstream(BioPAXElement ele, Graph graph) 068 { 069 AbstractNode node = (AbstractNode) graph.getGraphObject(ele); 070 if (node == null) return; 071 072 Edge edge = new EdgeL3(node, this, graph); 073 074 if (isTranscription()) 075 { 076 if (node instanceof ControlWrapper) 077 { 078 ((ControlWrapper) node).setTranscription(true); 079 } 080 } 081 082 node.getDownstreamNoInit().add(edge); 083 this.getUpstreamNoInit().add(edge); 084 } 085 086 /** 087 * Bind the wrapper of the given PhysicalEntity to the downstream. 088 * @param pe PhysicalEntity to bind 089 * @param graph Owner graph. 090 */ 091 protected void addToDownstream(PhysicalEntity pe, Graph graph) 092 { 093 AbstractNode node = (AbstractNode) graph.getGraphObject(pe); 094 if (node == null) return; 095 096 Edge edge = new EdgeL3(this, node, graph); 097 098 node.getUpstreamNoInit().add(edge); 099 this.getDownstreamNoInit().add(edge); 100 } 101 102 /** 103 * Events do not have equivalent objects. 104 * @return Empty set 105 */ 106 @Override 107 public Collection<Node> getUpperEquivalent() 108 { 109 return Collections.emptySet(); 110 } 111 112 /** 113 * Events do not have equivalent objects. 114 * @return Empty set 115 */ 116 @Override 117 public Collection<Node> getLowerEquivalent() 118 { 119 return Collections.emptySet(); 120 } 121}