Commit f6171739 authored by Piotr Gawron's avatar Piotr Gawron

Merge branch '794-boolean-logic-gate-coerced-to-the-single-type' into 'master'

Resolve "Boolean logic gate coerced to the single type"

Closes #794

See merge request !818
parents 081403b6 e36883ec
Pipeline #10728 passed with stage
in 8 minutes and 27 seconds
......@@ -55,7 +55,6 @@ import lcsb.mapviewer.model.map.reaction.ReactionNode;
import lcsb.mapviewer.model.map.reaction.SplitOperator;
import lcsb.mapviewer.model.map.reaction.TruncationOperator;
import lcsb.mapviewer.model.map.reaction.UnknownOperator;
import lcsb.mapviewer.model.map.reaction.type.BooleanLogicGateReaction;
import lcsb.mapviewer.model.map.reaction.type.DissociationReaction;
import lcsb.mapviewer.model.map.reaction.type.HeterodimerAssociationReaction;
import lcsb.mapviewer.model.map.reaction.type.SimpleReactionInterface;
......@@ -375,6 +374,7 @@ public class ReactionFromXml {
Node modifiersLinkNode = null;
Node gateMembers = null;
String type = null;
String booleanLogicGateType = null;
for (int y = 0; y < extensionNodes.getLength(); y++) {
Node nodeReaction = extensionNodes.item(y);
if (nodeReaction.getNodeType() == Node.ELEMENT_NODE) {
......@@ -430,6 +430,8 @@ public class ReactionFromXml {
}
if (gateMembers != null) {
points = gateMembersToPoints(result, gateMembers);
booleanLogicGateType = type;
type = gateMembersToReactionType(gateMembers);
}
result = createProperTypeReaction(type, result);
if (connectScheme == null) {
......@@ -438,12 +440,12 @@ public class ReactionFromXml {
if (points == null) {
points = new EditPoints();
}
if (result instanceof SimpleReactionInterface) {
createLinesForSimpleReaction(result, points, connectScheme);
} else if (result instanceof TwoReactantReactionInterface) {
createLinesForTwoReactantReaction(result, points, gateMembers != null);
if (result instanceof TwoReactantReactionInterface || booleanLogicGateType != null) {
createLinesForTwoReactantReaction(result, points);
createOperatorsForTwoReactantReaction(result, gateMembers);
} else if (result instanceof SimpleReactionInterface) {
createLinesForSimpleReaction(result, points, connectScheme);
} else if (result instanceof TwoProductReactionInterface) {
createLinesForTwoProductReaction(result, points);
createOperatorsForTwoProductReaction(result);
......@@ -504,6 +506,21 @@ public class ReactionFromXml {
}
}
private String gateMembersToReactionType(Node gateMembers) {
String result = null;
for (int y = 0; y < gateMembers.getChildNodes().getLength(); y++) {
Node node = gateMembers.getChildNodes().item(y);
if (node.getNodeType() == Node.ELEMENT_NODE) {
if (node.getNodeName().equalsIgnoreCase("celldesigner:GateMember")) {
if (!XmlParser.getNodeAttr("modificationType", node).isEmpty()) {
result = XmlParser.getNodeAttr("modificationType", node);
}
}
}
}
return result;
}
private void applyStylingToLine(LineProperties style, PolylineData line) {
if (style != null) {
line.setWidth(style.getWidth());
......@@ -551,7 +568,7 @@ public class ReactionFromXml {
if (child.getNodeName().equalsIgnoreCase("celldesigner:GateMember")) {
String type = XmlParser.getNodeAttr("type", child);
if (type.startsWith(ReactionLineData.BOOLEAN_LOGIC_GATE.getCellDesignerString())) {
if (type.startsWith("BOOLEAN_LOGIC_GATE")) {
lastMember = child;
} else {
String pointsString = XmlParser.getNodeAttr("editPoints", child);
......@@ -571,7 +588,7 @@ public class ReactionFromXml {
}
CellDesignerAnchor anchor = getAnchorFromLinkTarget(XmlParser.getNode("celldesigner:linkTarget", child));
anchorsByNodes.put(reactionNode, anchor);
anchorsByNodes.put(reactionNode, anchor);
}
} else {
throw new ReactionParserException("Unknown node type: " + child.getNodeName(), reaction);
......@@ -851,10 +868,8 @@ public class ReactionFromXml {
NodeOperator andOperator = null;
if (result instanceof HeterodimerAssociationReaction) {
andOperator = new AssociationOperator();
} else if (result instanceof BooleanLogicGateReaction) {
andOperator = new AndOperator();
} else {
throw new ReactionParserException("Unknown class type with two reactants", result);
andOperator = new AndOperator();
}
int outputs = 0;
for (AbstractNode node : result.getNodes()) {
......@@ -1036,11 +1051,17 @@ public class ReactionFromXml {
* information about points
* @param hasGateMemebers
* does the reaction has gate members
* @param rld
* @throws ReactionParserException
* thrown when data for reaction is invalid
*/
private void createLinesForTwoReactantReaction(Reaction reaction, EditPoints points, boolean hasGateMemebers)
private void createLinesForTwoReactantReaction(Reaction reaction, EditPoints points)
throws ReactionParserException {
ReactionLineData rld = null;
if (!(reaction instanceof HeterodimerAssociationReaction)) {
rld = ReactionLineData.getByReactionType(reaction.getClass());
}
Product product = reaction.getProducts().get(0);
Reactant reactant1 = reaction.getReactants().get(0);
Reactant reactant2 = reaction.getReactants().get(1);
......@@ -1051,8 +1072,8 @@ public class ReactionFromXml {
Point2D pointA = reactantConverter2.getPointCoordinates(reactant2.getElement(), anchorsByNodes.get(reactant2));
Point2D pointC = reactantConverter1.getPointCoordinates(reactant1.getElement(), anchorsByNodes.get(reactant1));
Point2D pointB = productConverter.getPointCoordinates(product.getElement(), anchorsByNodes.get(product));
if (!hasGateMemebers) { //heterodimer association computes based on different coordinates rules...
if (rld == null) { // heterodimer association computes based on different coordinates rules...
pointA = reactant2.getElement().getCenter();
pointC = reactant1.getElement().getCenter();
pointB = product.getElement().getCenter();
......@@ -1061,7 +1082,7 @@ public class ReactionFromXml {
Point2D pointP = points.getPoints().get(points.size() - 1);
Point2D centerPoint = null;
if (!hasGateMemebers && !pointA.equals(pointB)) {
if (rld == null && !pointA.equals(pointB)) {
centerPoint = pointTransformation.getCoordinatesInNormalBase(pointA, pointB, pointC, pointP);
} else {
centerPoint = pointP;
......@@ -1082,11 +1103,12 @@ public class ReactionFromXml {
List<Point2D> linePoints = new ArrayList<>(points.getPoints().subList(reactantStartId, reactantEndId));
PolylineData reactantLine = null;
if (!hasGateMemebers) {
if (rld == null) {
reactantLine = PolylineDataFactory.createPolylineDataFromEditPoints(centerPoint, p1, linePoints);
} else {
reactantLine = PolylineDataFactory.createPolylineDataFromEditPoints(p1, centerPoint, linePoints);
reactantLine = reactantLine.reverse();
reactantLine.setType(rld.getLineType());
}
p1 = reactantConverter.getAnchorPointCoordinates(reactant.getElement(), anchorsByNodes.get(reactant),
......@@ -1103,8 +1125,10 @@ public class ReactionFromXml {
Point2D p1 = productConverter.getAnchorPointCoordinates(product.getElement(), anchorsByNodes.get(product),
productLine.reverse());
productLine.setEndPoint(p1);
if (hasGateMemebers) {
productLine.getEndAtd().setArrowType(ArrowType.OPEN);
if (rld != null) {
productLine.setType(rld.getLineType());
productLine.getEndAtd().setArrowType(rld.getProductArrowType());
productLine.trimEnd(rld.getProductLineTrim());
}
product.setLine(productLine);
......
......@@ -6,7 +6,6 @@ import java.util.Map;
import lcsb.mapviewer.model.graphics.ArrowType;
import lcsb.mapviewer.model.graphics.LineType;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.reaction.type.BooleanLogicGateReaction;
import lcsb.mapviewer.model.map.reaction.type.CatalysisReaction;
import lcsb.mapviewer.model.map.reaction.type.DissociationReaction;
import lcsb.mapviewer.model.map.reaction.type.HeterodimerAssociationReaction;
......@@ -43,11 +42,6 @@ import lcsb.mapviewer.model.map.reaction.type.UnknownTransitionReaction;
*/
public enum ReactionLineData {
/**
* Information about arrows/lines for {@link BooleanLogicGateReaction} class.
*/
BOOLEAN_LOGIC_GATE(BooleanLogicGateReaction.class, "BOOLEAN_LOGIC_GATE"),
/**
* Information about arrows/lines for {@link CatalysisReaction} class.
*/
......@@ -377,7 +371,7 @@ public enum ReactionLineData {
* original data
* @return instance of {@link Reaction} represented by this enum and copies the
* data from result parameter
* @throws ReactionParserException
* @throws ReactionParserException
*/
public Reaction createReaction(Reaction result) throws ReactionParserException {
try {
......@@ -396,7 +390,7 @@ public enum ReactionLineData {
* type of the line for which are looking for {@link ReactionLineData}
* @param productArrowType
* type of the arrow for which are looking for {@link ReactionLineData}
* @return {@link ReactionLineData} that can be aplpied for lines with given
* @return {@link ReactionLineData} that can be applied for lines with given
* line type and arrow type. If there are more then one possibility, one
* of them will be returned (nothing is guaranteed)
*/
......
......@@ -252,6 +252,7 @@ public abstract class CellDesignerTestFunctions {
throws InconsistentModelException, UnsupportedEncodingException, InvalidInputDataExecption {
CellDesignerXmlParser parser = new CellDesignerXmlParser();
String xmlString = parser.model2String(model);
logger.debug(xmlString);
InputStream is = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
Model model2 = parser.createModel(new ConverterParams().inputStream(is).sizeAutoAdjust(false));
......
......@@ -19,7 +19,6 @@ import lcsb.mapviewer.model.map.reaction.Product;
import lcsb.mapviewer.model.map.reaction.Reactant;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.reaction.type.TwoProductReactionInterface;
import lcsb.mapviewer.model.map.reaction.type.TwoReactantReactionInterface;
import lcsb.mapviewer.model.map.species.GenericProtein;
import lcsb.mapviewer.model.map.species.Species;
......@@ -538,34 +537,6 @@ public class ReactionFromXmlTest extends CellDesignerTestFunctions {
}
}
@Test
public void testInvalidReaction5() throws Exception {
try {
// test situation when createProperTypeReaction returns reaction of
// unknown type that implements TwoReactantReactionInterface
ReactionFromXml parser = new ReactionFromXml(null, false) {
Reaction createProperTypeReaction(String type, Reaction reaction) {
Reaction result = Mockito.mock(Reaction.class,
Mockito.withSettings().extraInterfaces(TwoReactantReactionInterface.class));
Mockito.when(result.getReactants()).thenReturn(reaction.getReactants());
Mockito.when(result.getProducts()).thenReturn(reaction.getProducts());
return result;
}
};
parser.getReaction(super.getNodeFromXmlString(readFile("testFiles/xmlNodeTestExamples/reaction_heterodimer.xml")),
model);
fail("Exception expected");
} catch (ReactionParserException e) {
assertTrue(e.getMessage().contains("Unknown class type with two reactants"));
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testInvalidReaction7() throws Exception {
try {
......
......@@ -9,7 +9,6 @@ import static org.junit.Assert.assertTrue;
import java.awt.Color;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.io.ByteArrayInputStream;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
......@@ -22,16 +21,13 @@ import org.junit.Test;
import org.w3c.dom.Node;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.converter.ConverterParams;
import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection;
import lcsb.mapviewer.converter.model.celldesigner.CellDesignerTestFunctions;
import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser;
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerGenericProtein;
import lcsb.mapviewer.model.graphics.ArrowType;
import lcsb.mapviewer.model.graphics.LineType;
import lcsb.mapviewer.model.graphics.PolylineData;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelComparator;
import lcsb.mapviewer.model.map.model.ModelFullIndexed;
import lcsb.mapviewer.model.map.reaction.AndOperator;
import lcsb.mapviewer.model.map.reaction.AssociationOperator;
......@@ -46,16 +42,18 @@ import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.reaction.SplitOperator;
import lcsb.mapviewer.model.map.reaction.TruncationOperator;
import lcsb.mapviewer.model.map.reaction.UnknownOperator;
import lcsb.mapviewer.model.map.reaction.type.BooleanLogicGateReaction;
import lcsb.mapviewer.model.map.reaction.type.DissociationReaction;
import lcsb.mapviewer.model.map.reaction.type.HeterodimerAssociationReaction;
import lcsb.mapviewer.model.map.reaction.type.KnownTransitionOmittedReaction;
import lcsb.mapviewer.model.map.reaction.type.NegativeInfluenceReaction;
import lcsb.mapviewer.model.map.reaction.type.ReactionRect;
import lcsb.mapviewer.model.map.reaction.type.ReducedTriggerReaction;
import lcsb.mapviewer.model.map.reaction.type.StateTransitionReaction;
import lcsb.mapviewer.model.map.reaction.type.TranscriptionReaction;
import lcsb.mapviewer.model.map.reaction.type.TranslationReaction;
import lcsb.mapviewer.model.map.reaction.type.TransportReaction;
import lcsb.mapviewer.model.map.reaction.type.TruncationReaction;
import lcsb.mapviewer.model.map.reaction.type.UnknownReducedPhysicalStimulationReaction;
import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.map.species.GenericProtein;
import lcsb.mapviewer.model.map.species.Protein;
......@@ -324,6 +322,7 @@ public class ReactionParserTests extends CellDesignerTestFunctions {
assertNotNull(reaction.getReactionRect());
super.testXmlSerialization(model);
// NormalImageGenerator generator = new NormalImageGenerator(1, 0, 0,
// 1024, 1024, model, true, false, 0,false);
// generator.saveToPNG("tmp.png");
......@@ -1709,7 +1708,7 @@ public class ReactionParserTests extends CellDesignerTestFunctions {
model = getModelForFile("testFiles/reactions/logicGateAnd.xml");
assertEquals(1, model.getReactions().size());
Reaction reaction = model.getReactions().iterator().next();
assertTrue(reaction instanceof BooleanLogicGateReaction);
assertTrue(reaction instanceof ReducedTriggerReaction);
assertEquals(1, reaction.getOperators().size());
assertTrue(reaction.getOperators().get(0) instanceof AndOperator);
assertEquals(2, reaction.getReactants().size());
......@@ -1719,17 +1718,23 @@ public class ReactionParserTests extends CellDesignerTestFunctions {
assertEquals(0.0, reaction.getReactants().get(1).getLine().getEndPoint().distance(200.0, 127.0), EPSILON);
assertEquals(0.0, reaction.getOperators().get(0).getLine().getBeginPoint().distance(200.0, 127.0), EPSILON);
CellDesignerXmlParser cellDesignerXmlParser = new CellDesignerXmlParser();
model.setName(null);
String xmlString = cellDesignerXmlParser.model2String(model);
ByteArrayInputStream bais = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
Model model2 = cellDesignerXmlParser.createModel(new ConverterParams().inputStream(bais).sizeAutoAdjust(false));
super.testXmlSerialization(model);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
ModelComparator mc = new ModelComparator();
assertEquals("After CellDesigner xml serialization models are different", 0, mc.compare(model, model2));
@Test
public void testLogiGateAndWithThreeInputsReaction() throws Exception {
Model model;
try {
model = getModelForFile("testFiles/reactions/logicGateAndWithThreeInputs.xml");
assertEquals(1, model.getReactions().size());
Reaction reaction = model.getReactions().iterator().next();
assertTrue(reaction instanceof ReducedTriggerReaction);
super.testXmlSerialization(model);
} catch (Exception e) {
e.printStackTrace();
throw e;
......@@ -1743,7 +1748,7 @@ public class ReactionParserTests extends CellDesignerTestFunctions {
model = getModelForFile("testFiles/reactions/logicGateOr.xml");
assertEquals(1, model.getReactions().size());
Reaction reaction = model.getReactions().iterator().next();
assertTrue(reaction instanceof BooleanLogicGateReaction);
assertTrue(reaction instanceof NegativeInfluenceReaction);
assertEquals(1, reaction.getOperators().size());
assertTrue(reaction.getOperators().get(0) instanceof OrOperator);
assertEquals(2, reaction.getReactants().size());
......@@ -1753,6 +1758,7 @@ public class ReactionParserTests extends CellDesignerTestFunctions {
assertEquals(0.0, reaction.getReactants().get(1).getLine().getEndPoint().distance(200.0, 127.0), EPSILON);
assertEquals(0.0, reaction.getOperators().get(0).getLine().getBeginPoint().distance(200.0, 127.0), EPSILON);
super.testXmlSerialization(model);
} catch (Exception e) {
e.printStackTrace();
throw e;
......@@ -1766,7 +1772,7 @@ public class ReactionParserTests extends CellDesignerTestFunctions {
model = getModelForFile("testFiles/reactions/logicGateNot.xml");
assertEquals(1, model.getReactions().size());
Reaction reaction = model.getReactions().iterator().next();
assertTrue(reaction instanceof BooleanLogicGateReaction);
assertTrue(reaction instanceof UnknownReducedPhysicalStimulationReaction);
assertEquals(1, reaction.getOperators().size());
assertTrue(reaction.getOperators().get(0) instanceof NandOperator);
assertEquals(2, reaction.getReactants().size());
......@@ -1778,6 +1784,7 @@ public class ReactionParserTests extends CellDesignerTestFunctions {
assertNotNull(reaction.getLine());
super.testXmlSerialization(model);
} catch (Exception e) {
e.printStackTrace();
throw e;
......@@ -1791,7 +1798,7 @@ public class ReactionParserTests extends CellDesignerTestFunctions {
model = getModelForFile("testFiles/reactions/logicGateUnknown.xml");
assertEquals(1, model.getReactions().size());
Reaction reaction = model.getReactions().iterator().next();
assertTrue(reaction instanceof BooleanLogicGateReaction);
assertTrue(reaction instanceof ReducedTriggerReaction);
assertEquals(1, reaction.getOperators().size());
assertTrue(reaction.getOperators().get(0) instanceof UnknownOperator);
assertEquals(2, reaction.getReactants().size());
......@@ -1801,6 +1808,7 @@ public class ReactionParserTests extends CellDesignerTestFunctions {
assertEquals(0.0, reaction.getReactants().get(1).getLine().getEndPoint().distance(200.0, 127.0), EPSILON);
assertEquals(0.0, reaction.getOperators().get(0).getLine().getBeginPoint().distance(200.0, 127.0), EPSILON);
super.testXmlSerialization(model);
} catch (Exception e) {
e.printStackTrace();
throw e;
......@@ -1930,6 +1938,8 @@ public class ReactionParserTests extends CellDesignerTestFunctions {
assertEquals(3, r3.getLine().getPoints().size());
assertEquals(2, p.getLine().getPoints().size());
super.testXmlSerialization(model);
} catch (Exception e) {
e.printStackTrace();
throw e;
......
package lcsb.mapviewer.converter.model.celldesigner.reaction;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
......@@ -26,11 +27,14 @@ import lcsb.mapviewer.model.map.modifier.Catalysis;
import lcsb.mapviewer.model.map.reaction.AndOperator;
import lcsb.mapviewer.model.map.reaction.Modifier;
import lcsb.mapviewer.model.map.reaction.NodeOperator;
import lcsb.mapviewer.model.map.reaction.OrOperator;
import lcsb.mapviewer.model.map.reaction.Product;
import lcsb.mapviewer.model.map.reaction.Reactant;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.reaction.SplitOperator;
import lcsb.mapviewer.model.map.reaction.type.DissociationReaction;
import lcsb.mapviewer.model.map.reaction.type.TransportReaction;
import lcsb.mapviewer.model.map.reaction.type.TriggerReaction;
import lcsb.mapviewer.model.map.species.Complex;
import lcsb.mapviewer.model.map.species.GenericProtein;
import lcsb.mapviewer.model.map.species.Species;
......@@ -209,17 +213,6 @@ public class ReactionToXmlTest extends CellDesignerTestFunctions {
}
@Test
public void testGetEditPointsXmlStringForInvalidReaction() {
try {
toXmlParser.getEditPointsXmlStringForReaction(new Reaction());
fail("Exception expected");
} catch (InvalidArgumentException e) {
assertTrue(e.getMessage().contains("Unhandled reaction type"));
}
}
@Test
public void testGetConnectSchemeXmlStringForReaction() {
try {
......@@ -252,7 +245,7 @@ public class ReactionToXmlTest extends CellDesignerTestFunctions {
@Test
public void testExportColorReactionWithModifierOperator() throws Exception {
try {
Model model= getModelForFile("testFiles/colorfull_reaction_2.xml");
Model model = getModelForFile("testFiles/colorfull_reaction_2.xml");
testXmlSerialization(model);
} catch (Exception e) {
e.printStackTrace();
......@@ -265,9 +258,36 @@ public class ReactionToXmlTest extends CellDesignerTestFunctions {
// this test checks currently not used part of the code (for test coverage
// purpose)
String xml = toXmlParser.getConnectSchemeXmlStringForLines(
new PolylineData[] { new PolylineData(new Point2D.Double(0,0), new Point2D.Double(1,0)), new PolylineData() });
new PolylineData[] { new PolylineData(new Point2D.Double(0, 0), new Point2D.Double(1, 0)),
new PolylineData() });
assertTrue(xml.contains("arm"));
}
@Test
public void testGetCellDesignerReactionTypeStringForSimpleReaction() {
String type = toXmlParser.getCellDesignerReactionTypeString(new TriggerReaction());
assertFalse("BOOLEAN_LOGIC_GATE".equals(type));
}
@Test
public void testGetCellDesignerReactionTypeStringForSimpleReactionWithOrOperator() {
Reaction r = new TriggerReaction();
NodeOperator operator = new OrOperator();
operator.addInput(new Reactant());
r.addNode(operator);
String type = toXmlParser.getCellDesignerReactionTypeString(r);
assertTrue("BOOLEAN_LOGIC_GATE".equals(type));
}
@Test
public void testGetCellDesignerReactionTypeStringForSimpleReactionWithSplitOperator() {
Reaction r = new TriggerReaction();
NodeOperator operator = new SplitOperator();
operator.addOutput(new Product());
r.addNode(operator);
String type = toXmlParser.getCellDesignerReactionTypeString(r);
assertFalse("BOOLEAN_LOGIC_GATE".equals(type));
}
}
......@@ -7,7 +7,8 @@ import java.util.Set;
import javax.xml.stream.XMLStreamException;
import org.apache.commons.io.FilenameUtils;
import org.apache.logging.log4j.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.sbml.jsbml.SBMLDocument;
import org.sbml.jsbml.SBMLReader;
import org.sbml.jsbml.ext.SBasePlugin;
......@@ -34,9 +35,7 @@ import lcsb.mapviewer.model.map.model.ModelFullIndexed;
import lcsb.mapviewer.model.map.modifier.Modulation;
import lcsb.mapviewer.model.map.reaction.AbstractNode;
import lcsb.mapviewer.model.map.reaction.Modifier;
import lcsb.mapviewer.model.map.reaction.NodeOperator;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.reaction.type.BooleanLogicGateReaction;
import lcsb.mapviewer.model.map.species.Complex;
import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.map.species.Species;
......@@ -229,9 +228,7 @@ public class SbmlParser extends Converter {
if (node.getLine() == null) {
return false;
} else if (node.getLine().length() == 0) {
if (!(node instanceof NodeOperator) || !(reaction instanceof BooleanLogicGateReaction)) {
return false;
}
return false;
}
}
......
......@@ -6,7 +6,6 @@ import java.util.List;
import org.apache.logging.log4j.*;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.reaction.type.BooleanLogicGateReaction;
import lcsb.mapviewer.model.map.reaction.type.CatalysisReaction;
import lcsb.mapviewer.model.map.reaction.type.DissociationReaction;
import lcsb.mapviewer.model.map.reaction.type.HeterodimerAssociationReaction;
......@@ -35,7 +34,6 @@ import lcsb.mapviewer.model.map.reaction.type.UnknownReducedTriggerReaction;
import lcsb.mapviewer.model.map.reaction.type.UnknownTransitionReaction;
public enum SBOTermReactionType {
BOOLEAN_LOGIC_GATE(BooleanLogicGateReaction.class, new String[] { "SBO:0000547" }),
CATALYSIS(CatalysisReaction.class, new String[] { "SBO:0000013" }),
DISSOCIATION(DissociationReaction.class, new String[] { "SBO:0000180" }),
HETERODIMER_ASSOCIATION(HeterodimerAssociationReaction.class, new String[] { "SBO:0000177" }),
......
......@@ -155,9 +155,11 @@ public class ReactionComparator extends Comparator<Reaction> {
}
}
if (status != 0) {
String debugMessage = "Can't find matching node for: " + node0.getClass().getSimpleName();
String debugMessage = "Can't find matching node for: ";
if (node0 instanceof ReactionNode) {
debugMessage += " [" + ((ReactionNode) node0).getElement().getElementId() + "]";
debugMessage += node0.toString();
} else {
debugMessage += node0.getClass().getSimpleName();
}
logger.debug(debugMessage);
......
package lcsb.mapviewer.model.map.reaction.type;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.model.map.reaction.Reaction;
/**
* This class defines a reaction that as an input contains at least one boolean
* gate. This type was defined by CellDesigner.
*
* @author Piotr Gawron
*
*/
@Entity
@DiscriminatorValue("BOOLEAN_LOGIC_GATE")
public class BooleanLogicGateReaction extends Reaction implements TwoReactantReactionInterface {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Default constructor.
*/
public BooleanLogicGateReaction() {
super();
}
/**
* Constructor that makes new reaction based on the data from reaction in the
* parameter.
*
* @param result
* original reaction
*/
public BooleanLogicGateReaction(Reaction result) {
super(result);
}
@Override
public String getStringType() {
return "Boolean logic gate";
}
@Override
public ReactionRect getReactionRect() {
return null;
}
/**
* Prepares a copy of the reaction.
*
* @return copy of the reaction
*/
public BooleanLogicGateReaction copy() {
if (this.getClass() == BooleanLogicGateReaction.class) {
return new BooleanLogicGateReaction(this);
} else {
throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass());
}
}
}
......@@ -5,27 +5,27 @@ import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({ BooleanLogicGateReactionTest.class,
DissociationReactionTest.class,
HeterodimerAssociationReactionTest.class,
KnownTransitionOmittedReactionTest.class,
NegativeInfluenceReactionTest.class,
PositiveInfluenceReactionTest.class,
ReactionRectTest.class,
ReducedModulationReactionTest.class,
ReducedPhysicalStimulationReactionTest.class,
ReducedTriggerReactionTest.class,
StateTransitionReactionTest.class,
TranscriptionReactionTest.class,
TranslationReactionTest.class,
TransportReactionTest.class,
TruncationReactionTest.class,
UnknownNegativeInfluenceReactionTest.class,
UnknownPositiveInfluenceReactionTest.class,
UnknownReducedModulationReactionTest.class,
UnknownReducedPhysicalStimulationReactionTest.class,
UnknownReducedTriggerReactionTest.class,
UnknownTransitionReactionTest.class,
@SuiteClasses({
DissociationReactionTest.class,
HeterodimerAssociationReactionTest.class,
KnownTransitionOmittedReactionTest.class,
NegativeInfluenceReactionTest.class,
PositiveInfluenceReactionTest.class,
ReactionRectTest.class,
ReducedModulationReactionTest.class,
ReducedPhysicalStimulationReactionTest.class,
ReducedTriggerReactionTest.class,
StateTransitionReactionTest.class,