diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/ModelAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/ModelAnnotator.java index bb3bede1cbe5c06fcb681a49e536cad54bb4ade9..9ee6a4f7ab1cc10b79c764cd1d7a0c9686160f14 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/ModelAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/ModelAnnotator.java @@ -241,9 +241,9 @@ public class ModelAnnotator { protected void copyAnnotationFromOtherSpecies(Model model, IProgressUpdater progressUpdater) { double counter = 0; double amount = model.getAliases().size(); - for (Species element : model.getSpeciesAliases()) { + for (Species element : model.getSpeciesList()) { if (element.getMiriamData().size() == 0) { - List<Element> speciesList = model.getAliasByName(element.getName()); + List<Element> speciesList = model.getElementsByName(element.getName()); for (Element species2 : speciesList) { if (species2.getClass().equals(element.getClass()) && species2.getMiriamData().size() > 0 && element.getMiriamData().size() == 0) { for (MiriamData md : species2.getMiriamData()) { diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/ModelAnnotatorTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/ModelAnnotatorTest.java index e2ad6b257a3d7eff7179ba0e341b7e43596360fa..b75019e872e0953b9b9ab65492622e603510acbb 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/ModelAnnotatorTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/ModelAnnotatorTest.java @@ -85,8 +85,8 @@ public class ModelAnnotatorTest extends AnnotationTestFunctions { modelAnnotator.annotateModel(model, updater, null); - assertTrue(model.getAliasByAliasId("a1").getMiriamData().size() > 0); - assertTrue(model.getAliasByAliasId("a2").getMiriamData().size() >= 1); + assertTrue(model.getElementByElementId("a1").getMiriamData().size() > 0); + assertTrue(model.getElementByElementId("a2").getMiriamData().size() >= 1); } catch (Exception e) { e.printStackTrace(); @@ -135,7 +135,7 @@ public class ModelAnnotatorTest extends AnnotationTestFunctions { modelAnnotator.copyAnnotationFromOtherSpecies(model, updater); - for (Species element : model.getSpeciesAliases()) { + for (Species element : model.getSpeciesList()) { if (element.getName().equals("s4")) assertEquals(0, element.getMiriamData().size()); else if (element.getName().equals("hello")) @@ -157,7 +157,7 @@ public class ModelAnnotatorTest extends AnnotationTestFunctions { Set<String> knowAnnotations = new HashSet<String>(); modelAnnotator.annotateModel(model, updater, null); - for (MiriamData md : model.getAliasByAliasId("sa1").getMiriamData()) { + for (MiriamData md : model.getElementByElementId("sa1").getMiriamData()) { knowAnnotations.add(md.getDataType() + ":" + md.getRelationType() + ":" + md.getResource()); } counter = 0; @@ -171,7 +171,7 @@ public class ModelAnnotatorTest extends AnnotationTestFunctions { modelAnnotator.annotateModel(model, updater, null); knowAnnotations.clear(); - for (MiriamData md : model.getAliasByAliasId("sa1").getMiriamData()) { + for (MiriamData md : model.getElementByElementId("sa1").getMiriamData()) { knowAnnotations.add(md.getDataType() + ":" + md.getRelationType() + ":" + md.getResource()); } counter = 0; @@ -192,8 +192,8 @@ public class ModelAnnotatorTest extends AnnotationTestFunctions { public void testGetAnnotationsForSYN() throws Exception { try { Model model = getModelForFile("testFiles/annotation/emptyAnnotationsSyn1.xml", true); - Element sa1 = model.getAliasByAliasId("sa1"); - Element sa2 = model.getAliasByAliasId("sa2"); + Element sa1 = model.getElementByElementId("sa1"); + Element sa2 = model.getElementByElementId("sa2"); assertFalse(sa1.getNotes().contains("Symbol")); assertFalse(sa2.getNotes().contains("Symbol")); @@ -208,7 +208,7 @@ public class ModelAnnotatorTest extends AnnotationTestFunctions { assertFalse(sa2.getNotes().contains("Symbol")); assertNull(sa2.getSymbol()); - for (Species el : model.getSpeciesAliases()) { + for (Species el : model.getSpeciesList()) { if (el.getNotes() != null) { assertFalse("Invalid notes: " + el.getNotes(), el.getNotes().contains("Symbol")); assertFalse("Invalid notes: " + el.getNotes(), el.getNotes().contains("HGNC")); diff --git a/console/src/main/java/lcsb/mapviewer/run/ConsoleConverter.java b/console/src/main/java/lcsb/mapviewer/run/ConsoleConverter.java index 13f7337c2e95aafe58f86ac5e3a77e3cbbbad405..3a237968f4f5d39d8ff7bf1ab9895e68a5d10bab 100644 --- a/console/src/main/java/lcsb/mapviewer/run/ConsoleConverter.java +++ b/console/src/main/java/lcsb/mapviewer/run/ConsoleConverter.java @@ -240,7 +240,7 @@ public class ConsoleConverter { String productString = cols[productsColumn]; for (String string : productString.split(",")) { if (!string.isEmpty()) { - Species alias = model.getAliasByAliasId(string.trim()); + Species alias = model.getElementByElementId(string.trim()); Product product = new Product(alias); products.add(product); } @@ -253,7 +253,7 @@ public class ConsoleConverter { String reactantString = cols[reactantsColumn]; for (String string : reactantString.split(",")) { if (!string.isEmpty()) { - Species element = model.getAliasByAliasId(string.trim()); + Species element = model.getElementByElementId(string.trim()); Reactant product = new Reactant(element); reactants.add(product); } @@ -266,7 +266,7 @@ public class ConsoleConverter { String modifierString = cols[modifiersColumn]; for (String string : modifierString.split(",")) { if (!string.isEmpty()) { - Species element = model.getAliasByAliasId(string.trim()); + Species element = model.getElementByElementId(string.trim()); Modifier modifier = new Catalysis(element); modifiers.add(modifier); } diff --git a/console/src/main/java/lcsb/mapviewer/run/ReactomeComparison.java b/console/src/main/java/lcsb/mapviewer/run/ReactomeComparison.java index 7b5f0f24a638a55fc958dd343df4e235df628861..c3d47ed67fbfe4f63e54a0664bb3284c0da8ef29 100644 --- a/console/src/main/java/lcsb/mapviewer/run/ReactomeComparison.java +++ b/console/src/main/java/lcsb/mapviewer/run/ReactomeComparison.java @@ -112,7 +112,7 @@ public class ReactomeComparison { Set<String> list = new HashSet<String>(); - for (Species element : model.getSpeciesAliases()) { + for (Species element : model.getSpeciesList()) { list.add(element.getName()); } logger.debug("Species: " + list.size()); diff --git a/console/src/main/java/lcsb/mapviewer/run/ReactomeExport.java b/console/src/main/java/lcsb/mapviewer/run/ReactomeExport.java index 2af675a904487e67b1528380dbfe3efc2224d75d..6e14c62feaabae0695e422172a6774775aae1601 100644 --- a/console/src/main/java/lcsb/mapviewer/run/ReactomeExport.java +++ b/console/src/main/java/lcsb/mapviewer/run/ReactomeExport.java @@ -131,7 +131,7 @@ public class ReactomeExport { addElement(a); } } else if (alias instanceof Compartment) { - for (Element a : ((Compartment) alias).getAliases()) { + for (Element a : ((Compartment) alias).getElements()) { addElement(a); } } @@ -214,7 +214,7 @@ public class ReactomeExport { } if (alias instanceof Compartment) { parameters.put("displayName", alias.getName()); - for (Element a : ((Compartment) alias).getAliases()) { + for (Element a : ((Compartment) alias).getElements()) { components.add(addElement(a)); } } diff --git a/console/src/main/java/lcsb/mapviewer/run/Statistics.java b/console/src/main/java/lcsb/mapviewer/run/Statistics.java index 90e6e1f4afc9cf9fe9172b2e11f1b1ae0853538e..52f1cf6540ed6c78f6d631d47b5d510a1f71d460 100644 --- a/console/src/main/java/lcsb/mapviewer/run/Statistics.java +++ b/console/src/main/java/lcsb/mapviewer/run/Statistics.java @@ -257,7 +257,7 @@ public class Statistics { print("Complex annotations:"); for (Element element : model.getAliases()) { if (element instanceof Complex && element.getMiriamData().size() > 0) { - print(element.getClass().getSimpleName() + ";\t\tname=" + element.getName() + ";\t\tid=" + element.getAliasId()); + print(element.getClass().getSimpleName() + ";\t\tname=" + element.getName() + ";\t\tid=" + element.getElementId()); } } print("-----------------------------"); @@ -324,7 +324,7 @@ public class Statistics { list = new ArrayList<String>(); links.put(md.getResource(), list); } - String address = "<a href =\"" + Configuration.PUBLICALY_AVAILABLE_PD_MAP + "&search=species:" + element.getAliasId() + "\">" + element.getName() + String address = "<a href =\"" + Configuration.PUBLICALY_AVAILABLE_PD_MAP + "&search=species:" + element.getElementId() + "\">" + element.getName() + "</a>"; list.add(address); } diff --git a/console/src/main/java/lcsb/mapviewer/run/VibineSnippet.java b/console/src/main/java/lcsb/mapviewer/run/VibineSnippet.java index a5c577a07e91559898f625303def92aba26f3e05..911a6e379b16c638ccb4fcc0c91691c9adbda94f 100644 --- a/console/src/main/java/lcsb/mapviewer/run/VibineSnippet.java +++ b/console/src/main/java/lcsb/mapviewer/run/VibineSnippet.java @@ -84,7 +84,7 @@ public class VibineSnippet { String speciesId = "sa7208"; String reactionId = "re332"; - Species species = model.getAliasByAliasId(speciesId); + Species species = model.getElementByElementId(speciesId); logger.debug("Element with id: " + speciesId); logger.debug("Element type: " + species.getClass()); @@ -96,7 +96,7 @@ public class VibineSnippet { logger.debug("Reaction with id: " + reactionId); logger.debug("Reaction has " + reaction.getReactionNodes().size() + " members."); for (ReactionNode node : reaction.getReactionNodes()) { - logger.debug(node.getClass().getSimpleName() + "; points to " + node.getAlias().getClass().getSimpleName() + "[" + node.getAlias().getAliasId() + "]"); + logger.debug(node.getClass().getSimpleName() + "; points to " + node.getAlias().getClass().getSimpleName() + "[" + node.getAlias().getElementId() + "]"); } logger.debug("-------------------------------"); } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerElementCollection.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerElementCollection.java index 008e12601da7ae2dbdd2368e753610762c5e8c9d..4f9f4c5a47b62a17fc4fc2df12e8c66aa91f0e4f 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerElementCollection.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerElementCollection.java @@ -26,7 +26,7 @@ public class CellDesignerElementCollection { public String getElementId(Element alias) { // TODO // silly implementation for now (if CD won't crash than we can keep it) - return "s_id_" + alias.getAliasId(); + return "s_id_" + alias.getElementId(); } public void addElements(List<? extends CellDesignerElement<?>> elements) { diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParser.java index 2c990f4f37ec49da09b42c46dd590b5233607bb3..cce1a06bd68b4ddf05241c6d0137d2135aaf2216 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParser.java @@ -497,11 +497,11 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { if (node.getNodeName().equalsIgnoreCase("celldesigner:complexSpeciesAlias")) { String aliasId = getNodeAttr("id", node); String complexId = getNodeAttr("complexSpeciesAlias", node); - Complex alias = (Complex) model.getAliasByAliasId(aliasId); + Complex alias = (Complex) model.getElementByElementId(aliasId); if (alias == null) { throw new InvalidXmlSchemaException("Alias does not exist " + aliasId); } - Complex complex = (Complex) model.getAliasByAliasId(complexId); + Complex complex = (Complex) model.getElementByElementId(complexId); if (complex != null) { complex.addAlias(alias); alias.setParent(complex); @@ -534,11 +534,11 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { if (node.getNodeName().equalsIgnoreCase("celldesigner:speciesAlias")) { String aliasId = getNodeAttr("id", node); String complexId = getNodeAttr("complexSpeciesAlias", node); - Element alias = model.getAliasByAliasId(aliasId); + Element alias = model.getElementByElementId(aliasId); if (alias == null) { throw new InvalidXmlSchemaException("Alias does not exist " + aliasId); } else if (alias instanceof Species) { - Complex complex = (Complex) model.getAliasByAliasId(complexId); + Complex complex = (Complex) model.getElementByElementId(complexId); if (complex != null) { alias.setParent(complex); complex.addAlias((Species) alias); @@ -588,7 +588,7 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { result.append(compartmentCollectionXmlParser.toXml(model.getCompartmentsAliases())); - result.append(speciesCollectionXmlParser.speciesCollectionToSbmlString(model.getSpeciesAliases())); + result.append(speciesCollectionXmlParser.speciesCollectionToSbmlString(model.getSpeciesList())); result.append(reactionCollectionXmlParser.reactionCollectionToXmlString(model.getReactions())); @@ -613,11 +613,11 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { result.append("<celldesigner:modelVersion>4.0</celldesigner:modelVersion>\n"); result.append("<celldesigner:modelDisplay sizeX=\"" + model.getWidth().intValue() + "\" sizeY=\"" + model.getHeight().intValue() + "\"/>\n"); - result.append(speciesCollectionXmlParser.speciesCollectionToXmlIncludedString(model.getSpeciesAliases())); + result.append(speciesCollectionXmlParser.speciesCollectionToXmlIncludedString(model.getSpeciesList())); result.append(aliasCollectionParser.compartmentAliasCollectionToXmlString(model.getCompartmentsAliases())); - result.append(aliasCollectionParser.complexAliasCollectionToXmlString(model.getComplexAliases())); - result.append(aliasCollectionParser.speciesAliasCollectionToXmlString(model.getNotComplexSpeciesAliases())); + result.append(aliasCollectionParser.complexAliasCollectionToXmlString(model.getComplexList())); + result.append(aliasCollectionParser.speciesAliasCollectionToXmlString(model.getNotComplexSpeciesList())); List<Protein> proteins = new ArrayList<>(); List<Gene> genes = new ArrayList<>(); diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/LayerXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/LayerXmlParser.java index c7566f716d620ab06303f9bb5359fb7009ddb7ec..17895675ac9815a17fae0e0745aba9640dcd88aa 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/LayerXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/LayerXmlParser.java @@ -172,7 +172,7 @@ public class LayerXmlParser extends XmlParser { String[] list = members.split(","); for (String string : list) { - Element alias = model.getAliasByAliasId(string); + Element alias = model.getElementByElementId(string); if (alias == null) { throw new InvalidGroupException("Group \"" + id + "\" contains alias with id: \"" + string + "\", but such alias doesn't exist in the model."); } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/CompartmentAliasXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/CompartmentAliasXmlParser.java index 47d06cb3a52278e06141dbc59fbba177800aa42e..e75dc56ef7adab3de77cfc648a78e4f00ce1f6ed 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/CompartmentAliasXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/CompartmentAliasXmlParser.java @@ -123,7 +123,7 @@ public class CompartmentAliasXmlParser extends AbstractAliasXmlParser<Compartmen StringBuilder sb = new StringBuilder(""); sb.append("<celldesigner:compartmentAlias "); - sb.append("id=\"" + alias.getAliasId() + "\" "); + sb.append("id=\"" + alias.getElementId() + "\" "); sb.append("compartment=\"" + elements.getElementId(alias) + "\">\n"); boolean bounds = true; diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/ComplexAliasXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/ComplexAliasXmlParser.java index ae29b5a2fa392aec8f1212bbd3b88581a53b27b4..e4d207986e61d1f9a75a3a089cc5871e9625eb76 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/ComplexAliasXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/ComplexAliasXmlParser.java @@ -135,7 +135,7 @@ public class ComplexAliasXmlParser extends AbstractAliasXmlParser<Complex> { result.setLineWidth(view.getSingleLine().getWidth()); result.setColor(view.getColor()); } else if (!state.equalsIgnoreCase("complexnoborder")) { - throw new InvalidXmlSchemaException("No view (" + state + ") in ComplexAlias for " + result.getAliasId()); + throw new InvalidXmlSchemaException("No view (" + state + ") in ComplexAlias for " + result.getElementId()); } result.setState(state); String compartmentAliasId = getNodeAttr("compartmentAlias", aliasNode); @@ -145,14 +145,14 @@ public class ComplexAliasXmlParser extends AbstractAliasXmlParser<Complex> { throw new InvalidXmlSchemaException("CompartmentAlias does not exist: " + compartmentAliasId); } else { result.setParent(ca); - ca.addAlias(result); + ca.addElement(result); } } String complexSpeciesAliasId = getNodeAttr("complexSpeciesAlias", aliasNode); if (!complexSpeciesAliasId.equals("")) { - parents.put(result.getAliasId(), complexSpeciesAliasId); + parents.put(result.getElementId(), complexSpeciesAliasId); } - complexAliasesMapById.put(result.getAliasId(), result); + complexAliasesMapById.put(result.getElementId(), result); return result; } @@ -176,7 +176,7 @@ public class ComplexAliasXmlParser extends AbstractAliasXmlParser<Complex> { } else if (state == null || state.isEmpty()) { return; } else { - throw new NotImplementedException("[Alias: " + alias.getAliasId() + "] Unkown alias state: " + state); + throw new NotImplementedException("[Alias: " + alias.getElementId() + "] Unkown alias state: " + state); } } @@ -188,11 +188,11 @@ public class ComplexAliasXmlParser extends AbstractAliasXmlParser<Complex> { * alias for which we want to add parent information */ public void addReference(Complex alias) { - String parentId = parents.get(alias.getAliasId()); + String parentId = parents.get(alias.getElementId()); if (parentId != null) { Complex ca = complexAliasesMapById.get(parentId); if (ca == null) { - throw new InvalidArgumentException("Parent complex alias does not exist: " + parentId + " for alias: " + alias.getAliasId()); + throw new InvalidArgumentException("Parent complex alias does not exist: " + parentId + " for alias: " + alias.getElementId()); } else { alias.setParent(ca); ca.addAlias(alias); @@ -231,17 +231,17 @@ public class ComplexAliasXmlParser extends AbstractAliasXmlParser<Complex> { String compartmentAliasId = null; if (ca != null) { - compartmentAliasId = ca.getAliasId(); + compartmentAliasId = ca.getElementId(); } StringBuilder sb = new StringBuilder(""); sb.append("<celldesigner:complexSpeciesAlias "); - sb.append("id=\"" + alias.getAliasId() + "\" "); + sb.append("id=\"" + alias.getElementId() + "\" "); sb.append("species=\"" + elements.getElementId(alias) + "\" "); if (compartmentAliasId != null) { sb.append("compartmentAlias=\"" + compartmentAliasId + "\" "); } if (complexAlias != null) { - sb.append("complexSpeciesAlias=\"" + complexAlias.getAliasId() + "\""); + sb.append("complexSpeciesAlias=\"" + complexAlias.getElementId() + "\""); } sb.append(">\n"); diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/SpeciesAliasXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/SpeciesAliasXmlParser.java index f72a2f4d4dec8937d84fbd447e63ed84367ac6a2..29e9294458037baa5429da65aa23ca4cd037a1c6 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/SpeciesAliasXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/SpeciesAliasXmlParser.java @@ -116,14 +116,14 @@ public class SpeciesAliasXmlParser extends AbstractAliasXmlParser<Species> { throw new InvalidXmlSchemaException("CompartmentAlias does not exist: " + compartmentAliasId); } else { result.setParent(ca); - ca.addAlias(result); + ca.addElement(result); } } String complexAliasId = getNodeAttr("complexSpeciesAlias", aliasNode); if (!complexAliasId.isEmpty()) { - Complex alias = (Complex) model.getAliasByAliasId(complexAliasId); + Complex alias = (Complex) model.getElementByElementId(complexAliasId); if (alias == null) { - throw new InvalidXmlSchemaException("ComplexAlias does not exist: " + complexAliasId + ", current: " + result.getAliasId()); + throw new InvalidXmlSchemaException("ComplexAlias does not exist: " + complexAliasId + ", current: " + result.getElementId()); } else { result.setParent(alias); alias.addAlias(result); @@ -152,7 +152,7 @@ public class SpeciesAliasXmlParser extends AbstractAliasXmlParser<Species> { } else if (state == null || state.isEmpty()) { return; } else { - throw new NotImplementedException("[Alias: " + alias.getAliasId() + "] Unkown alias state: " + state); + throw new NotImplementedException("[Alias: " + alias.getElementId() + "] Unkown alias state: " + state); } } @@ -185,18 +185,18 @@ public class SpeciesAliasXmlParser extends AbstractAliasXmlParser<Species> { String compartmentAliasId = null; if (ca != null) { - compartmentAliasId = ca.getAliasId(); + compartmentAliasId = ca.getElementId(); } StringBuilder sb = new StringBuilder(""); sb.append("<celldesigner:speciesAlias "); - sb.append("id=\"" + alias.getAliasId() + "\" "); + sb.append("id=\"" + alias.getElementId() + "\" "); sb.append("species=\"" + elements.getElementId(alias) + "\" "); if (compartmentAliasId != null) { sb.append("compartmentAlias=\"" + compartmentAliasId + "\" "); } if (complexAlias != null) { - sb.append("complexSpeciesAlias=\"" + complexAlias.getAliasId() + "\" "); + sb.append("complexSpeciesAlias=\"" + complexAlias.getElementId() + "\" "); } sb.append(">\n"); diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/compartment/CompartmentXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/compartment/CompartmentXmlParser.java index c1ba9e05a970c594376f71ef37e23f0f8000e5c2..0a541718d7f0b9aff553e22b271d9813b3bbcc50 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/compartment/CompartmentXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/compartment/CompartmentXmlParser.java @@ -124,7 +124,7 @@ public class CompartmentXmlParser extends AbstractElementXmlParser<CellDesignerC } // default is the top level compartment - if (!compartment.getAliasId().equals("default")) { + if (!compartment.getElementId().equals("default")) { sb.append("outside=\"" + parentName + "\" "); } sb.append(">\n"); diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionFromXml.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionFromXml.java index 3bf8dc520032e2da5a575891f3193d5f913e30b9..dbad556ddb5cdbff641cca6bcd2b8e34736bd8cb 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionFromXml.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionFromXml.java @@ -1133,7 +1133,7 @@ public class ReactionFromXml extends XmlParser { */ private Reactant getReactantLink(Node rootNode, Model model, Reaction reaction, CellDesignerElementCollection elements) throws ReactionParserException { String aliasId = getNodeAttr("alias", rootNode); - Species al = (Species) model.getAliasByAliasId(aliasId); + Species al = (Species) model.getElementByElementId(aliasId); if (al == null) { throw new ReactionParserException("Alias doesn't exist (id: " + aliasId + ")", reaction); } @@ -1232,7 +1232,7 @@ public class ReactionFromXml extends XmlParser { */ private Product getProductLink(Node rootNode, Model model, Reaction reaction, CellDesignerElementCollection elements) throws ReactionParserException { String aliasId = getNodeAttr("alias", rootNode); - Species al = (Species) model.getAliasByAliasId(aliasId); + Species al = (Species) model.getElementByElementId(aliasId); if (al == null) { throw new ReactionParserException("Alias doesn't exist (id: " + aliasId + ")", reaction); } @@ -1371,7 +1371,7 @@ public class ReactionFromXml extends XmlParser { String[] list = aliasId.split(","); for (String string : list) { - Species al = (Species) model.getAliasByAliasId(string); + Species al = (Species) model.getElementByElementId(string); if (al != null) { aliasList.add(al); } else { @@ -1571,7 +1571,7 @@ public class ReactionFromXml extends XmlParser { */ private void parseBaseReactant(Reaction result, Node reactantNode, Model model, CellDesignerElementCollection elements) throws ReactionParserException { String aliasId = getNodeAttr("alias", reactantNode); - Species alias = (Species) model.getAliasByAliasId(aliasId); + Species alias = (Species) model.getElementByElementId(aliasId); if (alias == null) { throw new ReactionParserException("Alias with id=" + aliasId + " doesn't exist.", result); } @@ -1607,7 +1607,7 @@ public class ReactionFromXml extends XmlParser { */ private void parseBaseProduct(Model model, Reaction result, Node reactantNode, CellDesignerElementCollection elements) throws ReactionParserException { String aliasId = getNodeAttr("alias", reactantNode); - Species alias = (Species) model.getAliasByAliasId(aliasId); + Species alias = (Species) model.getElementByElementId(aliasId); if (alias == null) { throw new ReactionParserException("Alias with id=" + aliasId + " doesn't exist.", result); } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionToXml.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionToXml.java index 75e72f5e0bceb19983b07a6421100d3a1c5d0c89..4c97f5884bbab54166068724b38ec81cfc856943 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionToXml.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionToXml.java @@ -187,7 +187,7 @@ public class ReactionToXml extends XmlParser { sb.append("species=\"" + elements.getElementId(alias) + "\">\n"); sb.append("<annotation>\n"); sb.append("<celldesigner:extension>\n"); - sb.append("<celldesigner:alias>" + alias.getAliasId() + "</celldesigner:alias>\n"); + sb.append("<celldesigner:alias>" + alias.getElementId() + "</celldesigner:alias>\n"); sb.append("</celldesigner:extension>\n"); sb.append("</annotation>\n"); sb.append("</modifierSpeciesReference>\n"); @@ -218,10 +218,10 @@ public class ReactionToXml extends XmlParser { Modifier mod = (Modifier) modifier; if (modifiers.equals("")) { modifiers = elements.getElementId(mod.getAlias()); - aliases = mod.getAlias().getAliasId(); + aliases = mod.getAlias().getElementId(); } else { modifiers += "," + elements.getElementId(mod.getAlias()); - aliases += "," + mod.getAlias().getAliasId(); + aliases += "," + mod.getAlias().getElementId(); } } @@ -274,7 +274,7 @@ public class ReactionToXml extends XmlParser { String type = modifierTypeUtils.getStringTypeByModifier(modifier); sb.append(" type=\"" + type + "\" "); sb.append(" modifiers=\"" + elements.getElementId(modifier.getAlias()) + "\" "); - sb.append(" aliases=\"" + modifier.getAlias().getAliasId() + "\" "); + sb.append(" aliases=\"" + modifier.getAlias().getElementId() + "\" "); sb.append(" targetLineIndex=\"" + modifierTypeUtils.getTargetLineIndexByModifier(modifier) + "\" "); PolylineData line = new PolylineData(modifier.getLine()); @@ -328,7 +328,7 @@ public class ReactionToXml extends XmlParser { */ private String getLinkTargetXmlString(Modifier modifier) { StringBuilder sb = new StringBuilder(); - sb.append("<celldesigner:linkTarget species=\"" + elements.getElementId(modifier.getAlias()) + "\" alias=\"" + modifier.getAlias().getAliasId() + "\">\n"); + sb.append("<celldesigner:linkTarget species=\"" + elements.getElementId(modifier.getAlias()) + "\" alias=\"" + modifier.getAlias().getElementId() + "\">\n"); sb.append(getAnchorXml(modifier.getAlias(), modifier.getLine().getBeginPoint())); sb.append("</celldesigner:linkTarget>\n"); @@ -354,7 +354,7 @@ public class ReactionToXml extends XmlParser { sb.append("<annotation>\n"); sb.append("<celldesigner:extension>\n"); - sb.append("<celldesigner:alias>" + product.getAlias().getAliasId() + "</celldesigner:alias>\n"); + sb.append("<celldesigner:alias>" + product.getAlias().getElementId() + "</celldesigner:alias>\n"); sb.append("</celldesigner:extension>\n"); sb.append("</annotation>\n"); sb.append("</speciesReference>\n"); @@ -395,7 +395,7 @@ public class ReactionToXml extends XmlParser { sb.append("<speciesReference species=\"" + elements.getElementId(species) + "\">\n"); sb.append("<annotation>\n"); sb.append("<celldesigner:extension>\n"); - sb.append("<celldesigner:alias>" + alias.getAliasId() + "</celldesigner:alias>\n"); + sb.append("<celldesigner:alias>" + alias.getElementId() + "</celldesigner:alias>\n"); sb.append("</celldesigner:extension>\n"); sb.append("</annotation>\n"); sb.append("</speciesReference>\n"); @@ -471,7 +471,7 @@ public class ReactionToXml extends XmlParser { // product line result.append("<celldesigner:GateMember type=\"" + type.getStringName() + "\""); - result.append(" aliases=\"" + alias1.getAliasId() + "," + alias2.getAliasId() + "\""); + result.append(" aliases=\"" + alias1.getElementId() + "," + alias2.getElementId() + "\""); result.append(" modificationType=\"" + lineData.getCellDesignerString() + "\""); CellDesignerLineTransformation clt = new CellDesignerLineTransformation(); @@ -497,7 +497,7 @@ public class ReactionToXml extends XmlParser { // reactant 1 line result.append("<celldesigner:GateMember type=\"" + lineData.getCellDesignerString() + "\""); - result.append(" aliases=\"" + alias1.getAliasId() + "\""); + result.append(" aliases=\"" + alias1.getElementId() + "\""); points = clt.getPointsFromLine(reactant1.getLine()); @@ -520,7 +520,7 @@ public class ReactionToXml extends XmlParser { // reactant 2 line result.append("<celldesigner:GateMember type=\"" + lineData.getCellDesignerString() + "\""); - result.append(" aliases=\"" + alias2.getAliasId() + "\""); + result.append(" aliases=\"" + alias2.getElementId() + "\""); points = clt.getPointsFromLine(reactant2.getLine()); @@ -600,7 +600,7 @@ public class ReactionToXml extends XmlParser { StringBuilder sb = new StringBuilder(); sb.append("<celldesigner:reactantLink "); sb.append("reactant=\"" + elements.getElementId(alias) + "\" "); - sb.append("alias=\"" + alias.getAliasId() + "\" "); + sb.append("alias=\"" + alias.getElementId() + "\" "); // targetLineIndex is missing (maybe it's unimportant :)) sb.append(">\n"); @@ -639,7 +639,7 @@ public class ReactionToXml extends XmlParser { StringBuilder sb = new StringBuilder(); sb.append("<celldesigner:productLink "); sb.append("product=\"" + elements.getElementId(alias) + "\" "); - sb.append("alias=\"" + alias.getAliasId() + "\" "); + sb.append("alias=\"" + alias.getElementId() + "\" "); // targetLineIndex is missing (maybe it's unimportant :)) sb.append(">\n"); @@ -975,7 +975,7 @@ public class ReactionToXml extends XmlParser { Element alias = product.getAlias(); sb.append("<celldesigner:baseProduct "); sb.append("species=\"" + elements.getElementId(product.getAlias()) + "\" "); - sb.append("alias=\"" + product.getAlias().getAliasId() + "\" "); + sb.append("alias=\"" + product.getAlias().getElementId() + "\" "); sb.append(">\n"); sb.append(getAnchorXml(alias, product.getLine().getEndPoint())); @@ -1005,7 +1005,7 @@ public class ReactionToXml extends XmlParser { Element alias = reactant.getAlias(); sb.append("<celldesigner:baseReactant "); sb.append("species=\"" + elements.getElementId(reactant.getAlias()) + "\" "); - sb.append("alias=\"" + reactant.getAlias().getAliasId() + "\" "); + sb.append("alias=\"" + reactant.getAlias().getElementId() + "\" "); sb.append(">\n"); sb.append(getAnchorXml(alias, reactant.getLine().getBeginPoint())); diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/AntisenseRnaXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/AntisenseRnaXmlParser.java index 0535c416c80e44f9d39b668ab9110966b8eb97b9..eed59742b21683d29f5ee8ef14eb945090c1bc57 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/AntisenseRnaXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/AntisenseRnaXmlParser.java @@ -9,10 +9,10 @@ import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection; import lcsb.mapviewer.converter.model.celldesigner.annotation.RestAnnotationParser; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerAntisenseRna; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerAntisenseRnaRegion; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerAntisenseRnaRegion; import lcsb.mapviewer.model.map.species.AntisenseRna; import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion; -import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion.AntisenseRnaRegionType; +import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegionType; /** * Class that performs parsing of the CellDesigner xml for AntisenseRna object. diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/RnaXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/RnaXmlParser.java index 025e5e3d1239baa86eb0dcaa72ee320c46171b03..04783c194b808929c8fc182ae390bd0f7e4e16ce 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/RnaXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/RnaXmlParser.java @@ -9,7 +9,7 @@ import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection; import lcsb.mapviewer.converter.model.celldesigner.annotation.RestAnnotationParser; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerRna; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerRnaRegion; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerRnaRegion; import lcsb.mapviewer.model.map.species.Rna; /** diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesSbmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesSbmlParser.java index fd0bfcbd710e909c1de6d5346a755803c34e145a..ce50c31c7efaed92d3531e8d074be82dc3b2ae5a 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesSbmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesSbmlParser.java @@ -12,16 +12,16 @@ import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection import lcsb.mapviewer.converter.model.celldesigner.annotation.RestAnnotationParser; import lcsb.mapviewer.converter.model.celldesigner.annotation.XmlAnnotationParser; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerAntisenseRna; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerAntisenseRnaRegion; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerCompartment; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerComplexSpecies; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerGene; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerProtein; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerRna; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerRnaRegion; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSimpleMolecule; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerAntisenseRnaRegion; import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerRnaRegion; import lcsb.mapviewer.converter.model.celldesigner.structure.fields.SpeciesState; import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.species.AntisenseRna; diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRna.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRna.java index 190eeac25eb0ec42d0d8e7f69c433058f4f7335f..1331d5d3c6cdba3df2b9b9903dd00110b9ebd152 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRna.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRna.java @@ -6,10 +6,11 @@ import java.util.List; import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerAntisenseRnaRegion; import lcsb.mapviewer.model.map.species.AntisenseRna; /** - * Class representing antisense rna in the model. + * Class representing CellDesigner {@link AntisenseRna}. * * @author Piotr Gawron * @@ -19,13 +20,13 @@ public class CellDesignerAntisenseRna extends CellDesignerSpecies<AntisenseRna> /** * */ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(CellDesignerAntisenseRna.class); + private static Logger logger = Logger.getLogger(CellDesignerAntisenseRna.class); /** * List of antisense rna regions (some rna sequences) in this object. @@ -72,7 +73,8 @@ public class CellDesignerAntisenseRna extends CellDesignerSpecies<AntisenseRna> /** * Addd antisense rna region (part of rna sequence that has some meaning) to * the object. If the region with given id exists then the data of this region - * is copied to the one that is already in the {@link CellDesignerAntisenseRna}. + * is copied to the one that is already in the + * {@link CellDesignerAntisenseRna}. * * * @param region diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRnaComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRnaComparator.java deleted file mode 100644 index e63de6bd26de34f5213381b8b8305ea4ce1bf664..0000000000000000000000000000000000000000 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRnaComparator.java +++ /dev/null @@ -1,102 +0,0 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; - -import java.util.Comparator; -import java.util.HashSet; -import java.util.Set; - -import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.common.comparator.StringSetComparator; -import lcsb.mapviewer.common.exception.NotImplementedException; - -/** - * This class implements comparator interface for AntisenseRna. - * - * @author Piotr Gawron - * - */ -public class CellDesignerAntisenseRnaComparator implements Comparator<CellDesignerAntisenseRna> { - - /** - * Epsilon value used for comparison of doubles. - */ - private double epsilon; - - /** - * Constructor that requires {@link #epsilon} parameter. - * - * @param epsilon - * {@link #epsilon} - */ - public CellDesignerAntisenseRnaComparator(double epsilon) { - this.epsilon = epsilon; - } - - /** - * Default constructor. - */ - public CellDesignerAntisenseRnaComparator() { - this(Configuration.EPSILON); - } - - @Override - public int compare(CellDesignerAntisenseRna arg0, CellDesignerAntisenseRna arg1) { - if (arg0 == null) { - if (arg1 == null) { - return 0; - } else { - return 1; - } - } else if (arg1 == null) { - return -1; - } - - if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(CellDesignerAntisenseRna.class)) { - return internalCompare(arg0, arg1); - } else { - throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); - } - } else { - return -1; - } - } - - /** - * This method compares only the fields that are defined in AntisenseRna class - * in inheritence tree. It also calls the comparator for super class - * (Species). - * - * @param arg0 - * first object to compare - * @param arg1 - * second object to compare - * @return if all fields are qual then returns 0. If they are different then - * -1/1 is returned. - */ - private int internalCompare(CellDesignerAntisenseRna arg0, CellDesignerAntisenseRna arg1) { - CellDesignerSpeciesComparator speciesComparator = new CellDesignerSpeciesComparator(epsilon); - int result = speciesComparator.internalCompare(arg0, arg1); - if (result != 0) { - return result; - } - StringSetComparator stringSetComparator = new StringSetComparator(); - - Set<String> set1 = new HashSet<String>(); - Set<String> set2 = new HashSet<String>(); - - for (CellDesignerAntisenseRnaRegion region : arg0.getRegions()) { - set1.add(region.toString()); - } - - for (CellDesignerAntisenseRnaRegion region : arg1.getRegions()) { - set2.add(region.toString()); - } - - if (stringSetComparator.compare(set1, set2) != 0) { - return stringSetComparator.compare(set1, set2); - } - - return 0; - } - -} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerChemical.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerChemical.java index bd53e231ea45831bad806d7d71b770fed3c30507..141a50971cfeb1fd959c40abeeaf289f520ed4a2 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerChemical.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerChemical.java @@ -3,7 +3,10 @@ package lcsb.mapviewer.converter.model.celldesigner.structure; import lcsb.mapviewer.model.map.species.Chemical; /** - * Class representing chemical in the model. + * Class representing CellDesigner {@link Chemical}. + * + * @param <T> + * model class tha corresponds to this cell designer structure * * @author Piotr Gawron * diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerCompartment.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerCompartment.java index 93bfaf9a7e5396b662a559db9db81da4b9c40c4f..5a0f4fe4b542711146a061eb23916bda83686ccf 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerCompartment.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerCompartment.java @@ -9,7 +9,7 @@ import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.compartment.Compartment; /** - * This class describes compartment element in the model. + * Class representing CellDesigner {@link Compartment}. * * @author Piotr Gawron * @@ -19,23 +19,23 @@ public class CellDesignerCompartment extends CellDesignerElement<Compartment> im /** * */ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(CellDesignerCompartment.class); + private static Logger logger = Logger.getLogger(CellDesignerCompartment.class); /** * Identifier of the compartment. Unique in the model */ - private String compartmentId = ""; + private String compartmentId = ""; /** * List of agregated elements. */ - private Set<CellDesignerElement<?>> elements = new HashSet<>(); + private Set<CellDesignerElement<?>> elements = new HashSet<>(); /** * Default constructor with identifier given as a parameter. diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerCompartmentComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerCompartmentComparator.java deleted file mode 100644 index 5cc81476185b0a508994ac0ce177e04f34b7ef4e..0000000000000000000000000000000000000000 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerCompartmentComparator.java +++ /dev/null @@ -1,89 +0,0 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; - -import java.util.Comparator; - -import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.common.exception.InvalidClassException; - -/** - * This class implements comparator interface for Compartment. - * - * @author Piotr Gawron - * - * @see CellDesignerCompartment - * - */ -public class CellDesignerCompartmentComparator implements Comparator<CellDesignerCompartment> { - - /** - * Epsilon value used for comparison of doubles. - */ - private double epsilon; - - /** - * Constructor that requires {@link #epsilon} parameter. - * - * @param epsilon - * {@link #epsilon} - */ - public CellDesignerCompartmentComparator(double epsilon) { - this.epsilon = epsilon; - } - - /** - * Default constructor. - */ - public CellDesignerCompartmentComparator() { - this(Configuration.EPSILON); - } - - @Override - public int compare(CellDesignerCompartment arg0, CellDesignerCompartment arg1) { - if (arg0 == null) { - if (arg1 == null) { - return 0; - } else { - return 1; - } - } else if (arg1 == null) { - return -1; - } - - if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(CellDesignerCompartment.class)) { - return internalCompare(arg0, arg1); - } else { - throw new InvalidClassException("Don't know how to compare classes: " + arg0.getClass()); - } - } else { - return -1; - } - } - - /** - * This method compares only the fields that are defined in Compartment class - * in inheritence tree. By the design it calls also comparator of the upper - * (Element) class. - * - * @param arg0 - * first object to compare - * @param arg1 - * second object to compare - * @return if all fields are qual then returns 0. If they are different then - * -1/1 is returned. - */ - private int internalCompare(CellDesignerCompartment arg0, CellDesignerCompartment arg1) { - CellDesignerElementComparator elementComparator = new CellDesignerElementComparator(epsilon); - - int result = elementComparator.internalCompare(arg0, arg1); - if (result != 0) { - return result; - } - - if (!arg0.getElementId().equals(arg1.getElementId())) { - return arg0.getElementId().compareTo(arg1.getElementId()); - } - return 0; - } - -} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerComplexSpecies.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerComplexSpecies.java index a4458341b8383be19bd128e1be12dd0dd240ec22..d6daf136e3bc224ef628e0712f552a567ce7a6fa 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerComplexSpecies.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerComplexSpecies.java @@ -10,7 +10,7 @@ import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.Complex; /** - * Class representing complex in the model. + * Class representing CellDesigner {@link Complex}. * * @author Piotr Gawron * @@ -20,22 +20,22 @@ public class CellDesignerComplexSpecies extends CellDesignerSpecies<Complex> { /** * */ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; /** * Default class logger. */ - private static Logger logger = Logger.getLogger(CellDesignerComplexSpecies.class.getName()); + private static Logger logger = Logger.getLogger(CellDesignerComplexSpecies.class.getName()); /** * Elements that exists in this complex. */ - private Set<CellDesignerElement<?>> elements = new HashSet<>(); + private Set<CellDesignerElement<?>> elements = new HashSet<>(); /** * State of the complex species. */ - private String structuralState = null; + private String structuralState = null; /** * Default constructor. @@ -159,6 +159,7 @@ public class CellDesignerComplexSpecies extends CellDesignerSpecies<Complex> { this.elements = elements; } + @Override public Complex createAlias(String aliasId) { Complex result = new Complex(aliasId); super.setAliasFields(result); diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerComplexSpeciesComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerComplexSpeciesComparator.java deleted file mode 100644 index d0b0c102072e48bacf7be1e4a2f40d76940f6424..0000000000000000000000000000000000000000 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerComplexSpeciesComparator.java +++ /dev/null @@ -1,188 +0,0 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; - -import java.util.Comparator; - -import org.apache.log4j.Logger; - -import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.common.comparator.IntegerComparator; -import lcsb.mapviewer.common.comparator.StringComparator; -import lcsb.mapviewer.common.exception.NotImplementedException; - -/** - * This class implements comparator interface for ComplexSpecies. - * - * @author Piotr Gawron - * - */ -public class CellDesignerComplexSpeciesComparator implements Comparator<CellDesignerComplexSpecies> { - /** - * Default class logger. - */ - private Logger logger = Logger.getLogger(CellDesignerComplexSpeciesComparator.class); - - /** - * Epsilon value used for comparison of doubles. - */ - private double epsilon; - - /** - * Constructor that requires {@link #epsilon} parameter. - * - * @param epsilon - * {@link #epsilon} - */ - public CellDesignerComplexSpeciesComparator(double epsilon) { - this.epsilon = epsilon; - } - - /** - * Default constructor. - */ - public CellDesignerComplexSpeciesComparator() { - this(Configuration.EPSILON); - } - - @Override - public int compare(CellDesignerComplexSpecies arg0, CellDesignerComplexSpecies arg1) { - if (arg0 == null) { - if (arg1 == null) { - return 0; - } else { - return 1; - } - } else if (arg1 == null) { - return -1; - } - - if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(CellDesignerComplexSpecies.class)) { - return internalCompare(arg0, arg1); - } else { - throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); - } - } else { - return -1; - } - } - - /** - * This method compares only the fields that are defined in ComplexSpecies - * class in inheritence tree. It also calls the comparator for super class - * (Species). - * - * @param arg0 - * first object to compare - * @param arg1 - * second object to compare - * @return if all fields are qual then returns 0. If they are different then - * -1/1 is returned. - */ - private int internalCompare(CellDesignerComplexSpecies arg0, CellDesignerComplexSpecies arg1) { - CellDesignerElementComparator elementComparator = new CellDesignerElementComparator(epsilon); - - CellDesignerSpeciesComparator speciesComparator = new CellDesignerSpeciesComparator(epsilon); - int result = speciesComparator.internalCompare(arg0, arg1); - if (result != 0) { - return result; - } - - IntegerComparator integerComparator = new IntegerComparator(); - StringComparator stringComparator = new StringComparator(); - - if (integerComparator.compare(arg0.getHomodimer(), arg1.getHomodimer()) != 0) { - logger.debug("Homodimer different: " + arg0.getHomodimer() + ", " + arg1.getHomodimer()); - return integerComparator.compare(arg0.getHomodimer(), arg1.getHomodimer()); - } - - if (integerComparator.compare(arg0.getElements().size(), arg1.getElements().size()) != 0) { - logger.debug("Species size different: " + arg0.getElements().size() + ", " + arg1.getElements().size()); - return integerComparator.compare(arg0.getElements().size(), arg1.getElements().size()); - } - - if (stringComparator.compare(arg0.getStructuralState(), arg1.getStructuralState()) != 0) { - logger.debug("Species structuralState different: " + arg0.getStructuralState() + ", " + arg1.getStructuralState()); - return stringComparator.compare(arg0.getStructuralState(), arg1.getStructuralState()); - } - - for (CellDesignerElement<?> element : arg0.getElements()) { - boolean found = false; - - if (element instanceof CellDesignerSpecies) { - for (CellDesignerElement<?> element1 : arg1.getElements()) { - if (element1 instanceof CellDesignerSpecies) { - if (element.getElementId().equals(element1.getElementId())) { - if (elementComparator.compare(element, element1) != 0) { - logger.debug("Species different: " + element.getElementId()); - return elementComparator.compare(element, element1); - } else { - found = true; - } - } - } - } - - } else if (element instanceof CellDesignerCompartment) { - for (CellDesignerElement<?> element1 : arg1.getElements()) { - if (element1 instanceof CellDesignerCompartment) { - if (element.getElementId().equals(element1.getElementId())) { - if (elementComparator.compare(element, element1) != 0) { - logger.debug("Compartment different: " + element.getElementId()); - return elementComparator.compare(element, element1); - } else { - found = true; - } - } - } - } - } else { - throw new NotImplementedException("Don't know how to compare: " + element.getClass()); - } - if (!found) { - if (element instanceof CellDesignerSpecies) { - logger.debug("Cannot find element: " + element.getElementId() + " in:"); - for (CellDesignerElement<?> el : arg1.getElements()) { - logger.debug(el.getElementId()); - } - } - return -1; - } - } - - for (CellDesignerElement<?> element : arg1.getElements()) { - boolean found = false; - - if (element instanceof CellDesignerSpecies) { - for (CellDesignerElement<?> element1 : arg0.getElements()) { - if (element1 instanceof CellDesignerSpecies) { - if (element.getElementId().equals(element1.getElementId())) { - if (elementComparator.compare(element, element1) == 0) { - found = true; - } - } - } - } - - } else if (element instanceof CellDesignerCompartment) { - for (CellDesignerElement<?> element1 : arg0.getElements()) { - if (element1 instanceof CellDesignerCompartment) { - if (element.getElementId().equals(element1.getElementId())) { - if (elementComparator.compare(element, element1) == 0) { - found = true; - } - } - } - } - } else { - throw new NotImplementedException("Don't know how to compare: " + element.getClass()); - } - if (!found) { - logger.debug("Cannot find element: " + element.getElementId()); - return 1; - } - } - - return 0; - } - -} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDegraded.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDegraded.java index 2289b0707f9efce0ce2491c500f55ae86b49eeee..9dce75e57f68cd711fe47135381920499b202521 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDegraded.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDegraded.java @@ -4,7 +4,7 @@ import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.Degraded; /** - * Class representing degraded objects in the model. + * Class representing CellDesigner {@link Degraded}. * * @author Piotr Gawron * diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDegradedComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDegradedComparator.java deleted file mode 100644 index a5e4b021fe4f34a70e1a3db6601e2cf7babcc16b..0000000000000000000000000000000000000000 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDegradedComparator.java +++ /dev/null @@ -1,82 +0,0 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; - -import java.util.Comparator; - -import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.common.exception.NotImplementedException; - -/** - * This class implements comparator interface for Degraded. - * - * @author Piotr Gawron - * - * @see CellDesignerDegraded - */ -public class CellDesignerDegradedComparator implements Comparator<CellDesignerDegraded> { - - /** - * Epsilon value used for comparison of doubles. - */ - private double epsilon; - - /** - * Constructor that requires {@link #epsilon} parameter. - * - * @param epsilon - * {@link #epsilon} - */ - public CellDesignerDegradedComparator(double epsilon) { - this.epsilon = epsilon; - } - - /** - * Default constructor. - */ - public CellDesignerDegradedComparator() { - this(Configuration.EPSILON); - } - - @Override - public int compare(CellDesignerDegraded arg0, CellDesignerDegraded arg1) { - if (arg0 == null) { - if (arg1 == null) { - return 0; - } else { - return 1; - } - } else if (arg1 == null) { - return -1; - } - - if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(CellDesignerDegraded.class)) { - return internalCompare(arg0, arg1); - } else { - throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); - } - } else { - return -1; - } - } - - /** - * This method compares only the fields that are defined in Degraded class in - * inheritence tree. It also calls the comparator for super class (Species). - * - * @param arg0 - * first object to compare - * @param arg1 - * second object to compare - * @return if all fields are qual then returns 0. If they are different then - * -1/1 is returned. - */ - private int internalCompare(CellDesignerDegraded arg0, CellDesignerDegraded arg1) { - CellDesignerSpeciesComparator speciesComparator = new CellDesignerSpeciesComparator(epsilon); - int result = speciesComparator.internalCompare(arg0, arg1); - if (result != 0) { - return result; - } - - return 0; - } -} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDrug.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDrug.java index b0ea4d29f9f6ed937b7b361612478d82cbc93802..aa868a43f8e7e54309116dd0c8d54c4cb7108bc8 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDrug.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDrug.java @@ -4,7 +4,7 @@ import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.Drug; /** - * Class representing drug in the model. + * Class representing CellDesigner {@link Drug}. * * @author Piotr Gawron * diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDrugComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDrugComparator.java deleted file mode 100644 index b79fd9f364019d186407d31aeecb54c5e65b9983..0000000000000000000000000000000000000000 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDrugComparator.java +++ /dev/null @@ -1,81 +0,0 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; - -import java.util.Comparator; - -import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.common.exception.NotImplementedException; - -/** - * This class implements comparator interface for Drug. - * - * @author Piotr Gawron - * - * @see CellDesignerDrug - */ -public class CellDesignerDrugComparator implements Comparator<CellDesignerDrug> { - - /** - * Epsilon value used for comparison of doubles. - */ - private double epsilon; - - /** - * Constructor that requires {@link #epsilon} parameter. - * - * @param epsilon - * {@link #epsilon} - */ - public CellDesignerDrugComparator(double epsilon) { - this.epsilon = epsilon; - } - - /** - * Default constructor. - */ - public CellDesignerDrugComparator() { - this(Configuration.EPSILON); - } - - @Override - public int compare(CellDesignerDrug arg0, CellDesignerDrug arg1) { - if (arg0 == null) { - if (arg1 == null) { - return 0; - } else { - return 1; - } - } else if (arg1 == null) { - return -1; - } - - if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(CellDesignerDrug.class)) { - return internalCompare(arg0, arg1); - } else { - throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); - } - } else { - return -1; - } - } - - /** - * This method compares only the fields that are defined in Drug class in - * inheritence tree. It also calls the comparator for super class (Species). - * - * @param arg0 - * first object to compare - * @param arg1 - * second object to compare - * @return if all fields are qual then returns 0. If they are different then - * -1/1 is returned. - */ - private int internalCompare(CellDesignerDrug arg0, CellDesignerDrug arg1) { - CellDesignerSpeciesComparator speciesComparator = new CellDesignerSpeciesComparator(epsilon); - int result = speciesComparator.internalCompare(arg0, arg1); - if (result != 0) { - return result; - } - return 0; - } -} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerElement.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerElement.java index 77aaad3138f8641f15ac33c0899b221ae54481da..0185a9279f3be0ab20da931f5c8566cf5685fe8d 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerElement.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerElement.java @@ -16,9 +16,13 @@ import lcsb.mapviewer.model.map.model.ModelData; import lcsb.mapviewer.model.map.species.Element; /** - * Generic element of the map. It is a root object in inheritence three for - * every element (Species or Compartment) in the model. + * Generic CellDesigner elementmap. It is a root object in inheritence three for + * every element ({@link CellDesignerSpecies} or {@link CellDesignerCompartment} + * ). * + * @param <T> + * type of the {@link Element} in the model that is desrbide byy this + * celldesigner class * @author Piotr Gawron * */ @@ -27,77 +31,77 @@ public abstract class CellDesignerElement<T extends Element> implements Serializ /** * */ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; /** * Maximum length of the valid synonym name. */ - private static final int MAX_SYNONYM_LENGTH = 255; + private static final int MAX_SYNONYM_LENGTH = 255; /** * Default class logger. */ - private static Logger logger = Logger.getLogger(CellDesignerElement.class); + private static Logger logger = Logger.getLogger(CellDesignerElement.class); /** * Notes describing this element. */ - private String notes; + private String notes; /** * Symbol of the element. */ - private String symbol; + private String symbol; /** * Full name of the element. */ - private String fullName; + private String fullName; /** * Abbreviation associated with the element. */ - private String abbreviation; + private String abbreviation; /** * Formula associated with the element. */ - private String formula; + private String formula; /** * Short name of the element. */ - private String name = ""; + private String name = ""; /** * Lists of all synonyms used for describing this element. */ - private List<String> synonyms = new ArrayList<>(); + private List<String> synonyms = new ArrayList<>(); /** * List of former symbols used to describe this element. */ - private List<String> formerSymbols = new ArrayList<>(); + private List<String> formerSymbols = new ArrayList<>(); /** * Where this element lies on. */ - private CellDesignerCompartment parent; + private CellDesignerCompartment parent; /** * In which complex this element is located. */ - private CellDesignerComplexSpecies complex; + private CellDesignerComplexSpecies complex; /** * In which model this element is located. */ - private ModelData model; + private ModelData model; /** * Set of miriam annotations for this element. */ - private Set<MiriamData> miriamData = new HashSet<>(); + private Set<MiriamData> miriamData = new HashSet<>(); /** * Default constructor that initialize the data with the information given in diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerElementComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerElementComparator.java deleted file mode 100644 index d56b62c7bcaba6c095b9231d06fed55edd1010a3..0000000000000000000000000000000000000000 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerElementComparator.java +++ /dev/null @@ -1,181 +0,0 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; - -import java.util.Comparator; -import java.util.HashSet; -import java.util.Set; - -import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.common.comparator.StringComparator; -import lcsb.mapviewer.common.comparator.StringListComparator; -import lcsb.mapviewer.common.comparator.StringSetComparator; -import lcsb.mapviewer.common.exception.InvalidClassException; -import lcsb.mapviewer.model.map.MiriamData; - -import org.apache.log4j.Logger; - -/** - * This class implements comparator interface for Element. It handles comparison - * of subclasses of Element class. - * - * @author Piotr Gawron - * - */ -public class CellDesignerElementComparator implements Comparator<CellDesignerElement<?>> { - /** - * Default class logger. - */ - private static Logger logger = Logger.getLogger(CellDesignerElementComparator.class); - - /** - * Epsilon value used for comparison of doubles. - */ - private double epsilon; - - /** - * Constructor that requires {@link #epsilon} parameter. - * - * @param epsilon - * {@link #epsilon} - */ - public CellDesignerElementComparator(double epsilon) { - this.epsilon = epsilon; - } - - /** - * Default constructor. - */ - public CellDesignerElementComparator() { - this(Configuration.EPSILON); - } - - /** - * This method compares only the fields that are defined in Element class in - * inheritence tree. It should be called by the super class comparators, like - * Species and Compartment. - * - * @param arg0 - * first object to compare - * @param arg1 - * second object to compare - * @return if all fields are qual then returns 0. If they are different then - * -1/1 is returned. - */ - public int internalCompare(CellDesignerElement<?> arg0, CellDesignerElement<?> arg1) { - StringComparator stringComparator = new StringComparator(); - if (arg0 == null) { - if (arg1 == null) { - return 0; - } else { - return 1; - } - } else if (arg1 == null) { - return -1; - } - - if (stringComparator.compare(arg0.getName(), arg1.getName()) != 0) { - logger.debug("Name different: " + arg0.getName() + ", " + arg1.getName()); - return stringComparator.compare(arg0.getName(), arg1.getName()); - } - - if (stringComparator.compare(arg0.getNotes(), arg1.getNotes(), true) != 0) { - logger.debug("notes different: \n\"" + arg0.getNotes() + "\"\n\"" + arg1.getNotes() + "\""); - return stringComparator.compare(arg0.getNotes(), arg1.getNotes()); - } - - if (stringComparator.compare(arg0.getSymbol(), arg1.getSymbol()) != 0) { - logger.debug("symbol different: \"" + arg0.getSymbol() + "\", \"" + arg1.getSymbol() + "\""); - return stringComparator.compare(arg0.getSymbol(), arg1.getSymbol()); - } - - if (stringComparator.compare(arg0.getFullName(), arg1.getFullName()) != 0) { - logger.debug("full name different: \"" + arg0.getFullName() + "\", \"" + arg1.getFullName() + "\""); - return stringComparator.compare(arg0.getFullName(), arg1.getFullName()); - } - - if (stringComparator.compare(arg0.getAbbreviation(), arg1.getAbbreviation()) != 0) { - logger.debug("Abbreviation different: \"" + arg0.getAbbreviation() + "\", \"" + arg1.getAbbreviation() + "\""); - return stringComparator.compare(arg0.getAbbreviation(), arg1.getAbbreviation()); - } - - if (stringComparator.compare(arg0.getFormula(), arg1.getFormula()) != 0) { - logger.debug("formula different: \"" + arg0.getFormula() + "\", \"" + arg1.getFormula() + "\""); - return stringComparator.compare(arg0.getFormula(), arg1.getFormula()); - } - - StringSetComparator stringSetComparator = new StringSetComparator(); - StringListComparator stringListComparator = new StringListComparator(); - - if (stringListComparator.compare(arg0.getSynonyms(), arg1.getSynonyms()) != 0) { - logger.debug("List of synonyms different"); - return stringListComparator.compare(arg0.getSynonyms(), arg1.getSynonyms()); - } - - if (stringListComparator.compare(arg0.getFormerSymbols(), arg1.getFormerSymbols()) != 0) { - logger.debug("List of former symbols different"); - return stringListComparator.compare(arg0.getFormerSymbols(), arg1.getFormerSymbols()); - } - - Set<String> hashCode1 = new HashSet<String>(); - Set<String> hashCode2 = new HashSet<String>(); - - if (arg0.getMiriamData().size() != arg1.getMiriamData().size()) { - logger.debug("different number of annotations: " + arg0.getMiriamData().size() + ", " + arg1.getMiriamData().size()); - return ((Integer) arg0.getMiriamData().size()).compareTo(arg1.getMiriamData().size()); - } - - for (MiriamData md : arg0.getMiriamData()) { - String hash = md.getRelationType() + " " + md.getDataType() + " " + md.getResource(); - hashCode1.add(hash); - } - - for (MiriamData md : arg1.getMiriamData()) { - String hash = md.getRelationType() + " " + md.getDataType() + " " + md.getResource(); - hashCode2.add(hash); - } - - if (stringSetComparator.compare(hashCode1, hashCode2) != 0) { - logger.debug("different annotations: "); - logger.debug("A:"); - for (String string : hashCode1) { - logger.debug("|" + string + "|"); - } - logger.debug("B:"); - for (String string : hashCode2) { - logger.debug("|" + string + "|"); - } - logger.debug("--"); - return stringSetComparator.compare(hashCode1, hashCode2); - - } - - return 0; - } - - @Override - public int compare(CellDesignerElement<?> arg0, CellDesignerElement<?> arg1) { - if (arg0 == null) { - if (arg1 == null) { - return 0; - } else { - return 1; - } - } else if (arg1 == null) { - return -1; - } - - if (arg0.getClass().equals(arg1.getClass())) { - if (arg0 instanceof CellDesignerSpecies) { - CellDesignerSpeciesComparator speciesComparator = new CellDesignerSpeciesComparator(epsilon); - return speciesComparator.compare((CellDesignerSpecies<?>) arg0, (CellDesignerSpecies<?>) arg1); - } else if (arg0 instanceof CellDesignerCompartment) { - CellDesignerCompartmentComparator compartmentComparator = new CellDesignerCompartmentComparator(epsilon); - return compartmentComparator.compare((CellDesignerCompartment) arg0, (CellDesignerCompartment) arg1); - } else { - throw new InvalidClassException("Don't know how to compare classes: " + arg0.getClass()); - } - } else { - return -1; - } - } - -} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGene.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGene.java index aae01214f4f5ab1f9bca0a59760cf04a31838c3f..f530f3f9b9b4dee72f2cc5900fd9c2d76b91d394 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGene.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGene.java @@ -8,7 +8,7 @@ import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesigner import lcsb.mapviewer.model.map.species.Gene; /** - * Class representing gene in the model. + * Class representing CellDesigner {@link Gene}. * * @author Piotr Gawron * diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGeneComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGeneComparator.java deleted file mode 100644 index 8e051533edf42419fcf628fcbbf0e4da79a319d7..0000000000000000000000000000000000000000 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGeneComparator.java +++ /dev/null @@ -1,105 +0,0 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; - -import java.util.Comparator; -import java.util.HashSet; -import java.util.Set; - -import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.common.comparator.StringSetComparator; -import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue; - -/** - * This class implements comparator interface for Gene. - * - * @author Piotr Gawron - * - * @see CellDesignerGene - */ -public class CellDesignerGeneComparator implements Comparator<CellDesignerGene> { - - /** - * Epsilon value used for comparison of doubles. - */ - private double epsilon; - - /** - * Constructor that requires {@link #epsilon} parameter. - * - * @param epsilon - * {@link #epsilon} - */ - public CellDesignerGeneComparator(double epsilon) { - this.epsilon = epsilon; - } - - /** - * Default constructor. - */ - public CellDesignerGeneComparator() { - this(Configuration.EPSILON); - } - - @Override - public int compare(CellDesignerGene arg0, CellDesignerGene arg1) { - if (arg0 == null) { - if (arg1 == null) { - return 0; - } else { - return 1; - } - } else if (arg1 == null) { - return -1; - } - - if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(CellDesignerGene.class)) { - return internalCompare(arg0, arg1); - } else { - throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); - } - } else { - return -1; - } - } - - /** - * This method compares only the fields that are defined in Gene class in - * inheritence tree. It also calls the comparator for the super class ( - * {@link CellDesignerSpecies}): {@link CellDesignerSpeciesComparator}. - * - * @param arg0 - * first object to compare - * @param arg1 - * second object to compare - * @return if all fields are qual then returns 0. If they are different then - * -1/1 is returned. - */ - private int internalCompare(CellDesignerGene arg0, CellDesignerGene arg1) { - CellDesignerSpeciesComparator speciesComparator = new CellDesignerSpeciesComparator(epsilon); - int result = speciesComparator.internalCompare(arg0, arg1); - if (result != 0) { - return result; - } - - StringSetComparator stringSetComparator = new StringSetComparator(); - - Set<String> set1 = new HashSet<String>(); - Set<String> set2 = new HashSet<String>(); - - for (CellDesignerModificationResidue region : arg0.getModificationResidues()) { - set1.add(region.toString()); - } - - for (CellDesignerModificationResidue region : arg1.getModificationResidues()) { - set2.add(region.toString()); - } - - if (stringSetComparator.compare(set1, set2) != 0) { - return stringSetComparator.compare(set1, set2); - } - - return 0; - } - -} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGenericProtein.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGenericProtein.java index 562f55a0e5eed1542cc4bb1ee325a52dcce436b9..c16c011fbcaf757520ee1202770ed1a1a7ad02ae 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGenericProtein.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGenericProtein.java @@ -4,7 +4,7 @@ import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.GenericProtein; /** - * Generic protein. + * Class representing CellDesigner {@link GenericProtein}. * * @author Piotr Gawron * diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerIon.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerIon.java index 568bc61f13af320cf946cf9451cf5bbc6af55fb1..d3db455b6d1f757d41ee9f5f1a4bd7719fe76f30 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerIon.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerIon.java @@ -4,7 +4,7 @@ import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.Ion; /** - * Class representing ion in the model. + * Class representing CellDesigner {@link Ion}. * * @author Piotr Gawron * diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerIonChannelProtein.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerIonChannelProtein.java index d73d22cf5f17d82ddcfd492076ec0c2c0a46ef8a..2c4571b9cb69cedc23f55543e4347af5315b1c49 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerIonChannelProtein.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerIonChannelProtein.java @@ -4,7 +4,7 @@ import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.IonChannelProtein; /** - * Ion channel protein. + * Class representing CellDesigner {@link IonChannelProtein}. * * @author Piotr Gawron * diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerIonComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerIonComparator.java deleted file mode 100644 index 528dc4b2ed3a2a855f43f8c7b92e2ef8a9c84f5b..0000000000000000000000000000000000000000 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerIonComparator.java +++ /dev/null @@ -1,83 +0,0 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; - -import java.util.Comparator; - -import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.common.exception.NotImplementedException; - -/** - * This class implements comparator interface for Ion. - * - * @author Piotr Gawron - * - * @see CellDesignerIon - */ -public class CellDesignerIonComparator implements Comparator<CellDesignerIon> { - - /** - * Epsilon value used for comparison of doubles. - */ - private double epsilon; - - /** - * Constructor that requires {@link #epsilon} parameter. - * - * @param epsilon - * {@link #epsilon} - */ - public CellDesignerIonComparator(double epsilon) { - this.epsilon = epsilon; - } - - /** - * Default constructor. - */ - public CellDesignerIonComparator() { - this(Configuration.EPSILON); - } - - @Override - public int compare(CellDesignerIon arg0, CellDesignerIon arg1) { - if (arg0 == null) { - if (arg1 == null) { - return 0; - } else { - return 1; - } - } else if (arg1 == null) { - return -1; - } - - if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(CellDesignerIon.class)) { - return internalCompare(arg0, arg1); - } else { - throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); - } - } else { - return -1; - } - } - - /** - * This method compares only the fields that are defined in {@link CellDesignerIon} class - * in inheritence tree. It also calls the {@link CellDesignerSpeciesComparator} for the - * super class ( {@link CellDesignerSpecies}). - * - * @param arg0 - * first object to compare - * @param arg1 - * second object to compare - * @return if all fields are qual then returns 0. If they are different then - * -1/1 is returned. - */ - private int internalCompare(CellDesignerIon arg0, CellDesignerIon arg1) { - CellDesignerSpeciesComparator speciesComparator = new CellDesignerSpeciesComparator(epsilon); - int result = speciesComparator.internalCompare(arg0, arg1); - if (result != 0) { - return result; - } - return 0; - } - -} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerPhenotype.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerPhenotype.java index 625a4f16b6d75b13288e73c24463bcd91d49c919..6b43d2473e5b0c84ee8fb18c3c72fd18f7ec6bdd 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerPhenotype.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerPhenotype.java @@ -4,7 +4,7 @@ import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.Phenotype; /** - * Class representing phenotype in the model. + * Class representing CellDesigner {@link Phenotype} object. * * @author Piotr Gawron * diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerPhenotypeComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerPhenotypeComparator.java deleted file mode 100644 index e49f8cbb7f1668e190c502d52e508f4db48e61dc..0000000000000000000000000000000000000000 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerPhenotypeComparator.java +++ /dev/null @@ -1,91 +0,0 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; - -import java.util.Comparator; - -import org.apache.log4j.Logger; - -import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.common.exception.NotImplementedException; - -/** - * This class implements comparator interface for Phenotype. - * - * @author Piotr Gawron - * - * @see CellDesignerPhenotype - */ -public class CellDesignerPhenotypeComparator implements Comparator<CellDesignerPhenotype> { - /** - * Default class logger. - */ - @SuppressWarnings("unused") - private Logger logger = Logger.getLogger(CellDesignerPhenotypeComparator.class); - - /** - * Epsilon value used for comparison of doubles. - */ - private double epsilon; - - /** - * Constructor that requires {@link #epsilon} parameter. - * - * @param epsilon - * {@link #epsilon} - */ - public CellDesignerPhenotypeComparator(double epsilon) { - this.epsilon = epsilon; - } - - /** - * Default constructor. - */ - public CellDesignerPhenotypeComparator() { - this(Configuration.EPSILON); - } - - @Override - public int compare(CellDesignerPhenotype arg0, CellDesignerPhenotype arg1) { - if (arg0 == null) { - if (arg1 == null) { - return 0; - } else { - return 1; - } - } else if (arg1 == null) { - return -1; - } - - if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(CellDesignerPhenotype.class)) { - return internalCompare(arg0, arg1); - } else { - throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); - } - } else { - return -1; - } - } - - /** - * This method compares only the fields that are defined in {@link CellDesignerPhenotype} - * class in inheritence tree. It also calls the {@link CellDesignerSpeciesComparator} for - * the super class ( {@link CellDesignerSpecies}). - * - * @param arg0 - * first object to compare - * @param arg1 - * second object to compare - * @return if all fields are qual then returns 0. If they are different then - * -1/1 is returned. - */ - private int internalCompare(CellDesignerPhenotype arg0, CellDesignerPhenotype arg1) { - CellDesignerSpeciesComparator speciesComparator = new CellDesignerSpeciesComparator(epsilon); - int result = speciesComparator.internalCompare(arg0, arg1); - if (result != 0) { - return result; - } - - return 0; - } - -} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerProtein.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerProtein.java index 4e94d37da395d8d48bd6581ddcf4b155f2739146..76908e3df15b9725bd5da2860840ad1361ca06d4 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerProtein.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerProtein.java @@ -10,8 +10,10 @@ import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesigner import lcsb.mapviewer.model.map.species.Protein; /** - * Class representing protein in the model. + * Class representing CellDesigner {@link Protein} object. * + * @param <T> + * type of a {@link Protein} modeled by this class * @author Piotr Gawron * */ @@ -19,17 +21,17 @@ public class CellDesignerProtein<T extends Protein> extends CellDesignerSpecies< /** * */ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; /** * Default class logger. */ - private static Logger logger = Logger.getLogger(CellDesignerProtein.class.getName()); + private static Logger logger = Logger.getLogger(CellDesignerProtein.class.getName()); /** * State of the protein. */ - private String structuralState = null; + private String structuralState = null; /** * List of modifications for the Protein. diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerProteinComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerProteinComparator.java deleted file mode 100644 index 681761fd54edae94ecbff7bbf50202276a090f1b..0000000000000000000000000000000000000000 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerProteinComparator.java +++ /dev/null @@ -1,120 +0,0 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; - -import java.util.Comparator; -import java.util.HashSet; -import java.util.Set; - -import org.apache.log4j.Logger; - -import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.common.comparator.IntegerComparator; -import lcsb.mapviewer.common.comparator.StringComparator; -import lcsb.mapviewer.common.comparator.StringSetComparator; -import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue; - -/** - * This class implements comparator interface for Protein. - * - * @author Piotr Gawron - * - * @see CellDesignerProtein - */ -public class CellDesignerProteinComparator implements Comparator<CellDesignerProtein<?>> { - /** - * Default class logger. - */ - private Logger logger = Logger.getLogger(CellDesignerProteinComparator.class); - - /** - * Epsilon value used for comparison of doubles. - */ - private double epsilon; - - /** - * Constructor that requires {@link #epsilon} parameter. - * - * @param epsilon - * {@link #epsilon} - */ - public CellDesignerProteinComparator(double epsilon) { - this.epsilon = epsilon; - } - - /** - * Default constructor. - */ - public CellDesignerProteinComparator() { - this(Configuration.EPSILON); - } - - @Override - public int compare(CellDesignerProtein<?> arg0, CellDesignerProtein<?> arg1) { - if (arg0 == null) { - if (arg1 == null) { - return 0; - } else { - return 1; - } - } else if (arg1 == null) { - return -1; - } - - if (arg0.getClass().equals(arg1.getClass())) { - return internalCompare(arg0, arg1); - } else { - return -1; - } - } - - /** - * This method compares only the fields that are defined in {@link CellDesignerProtein} - * class in inheritence tree. It also calls the {@link CellDesignerSpeciesComparator} for - * the super class ( {@link CellDesignerSpecies}). - * - * @param arg0 - * first object to compare - * @param arg1 - * second object to compare - * @return if all fields are qual then returns 0. If they are different then - * -1/1 is returned. - */ - private int internalCompare(CellDesignerProtein<?> arg0, CellDesignerProtein<?> arg1) { - CellDesignerSpeciesComparator speciesComparator = new CellDesignerSpeciesComparator(epsilon); - int result = speciesComparator.internalCompare(arg0, arg1); - if (result != 0) { - return result; - } - - StringComparator stringComparator = new StringComparator(); - IntegerComparator integerComparator = new IntegerComparator(); - StringSetComparator stringSetComparator = new StringSetComparator(); - - if (integerComparator.compare(arg0.getHomodimer(), arg1.getHomodimer()) != 0) { - logger.debug("homodimer different: " + arg0.getHomodimer() + ", " + arg1.getHomodimer()); - return integerComparator.compare(arg0.getHomodimer(), arg1.getHomodimer()); - } - - if (stringComparator.compare(arg0.getStructuralState(), arg1.getStructuralState()) != 0) { - logger.debug("structural state different: " + arg0.getStructuralState() + ", " + arg1.getStructuralState()); - return stringComparator.compare(arg0.getStructuralState(), arg1.getStructuralState()); - } - - Set<String> set1 = new HashSet<String>(); - Set<String> set2 = new HashSet<String>(); - - for (CellDesignerModificationResidue region : arg0.getModificationResidues()) { - set1.add(region.toString()); - } - - for (CellDesignerModificationResidue region : arg1.getModificationResidues()) { - set2.add(region.toString()); - } - - if (stringSetComparator.compare(set1, set2) != 0) { - logger.debug("modification residues different"); - return stringSetComparator.compare(set1, set2); - } - - return 0; - } -} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerReceptorProtein.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerReceptorProtein.java index 8473383ecd53452888293fec93b276eb58356a5a..7c3cf684e30dc17402ce3e1806bb3c123decc000 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerReceptorProtein.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerReceptorProtein.java @@ -4,7 +4,7 @@ import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.ReceptorProtein; /** - * Receptor protein. + * Class representing CellDesigner {@link ReceptorProtein}. * * @author Piotr Gawron * diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRna.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRna.java index 4a59e2bc09bdc103f20b1dbd6f3d3f4c56b1bfa6..3438630752205b8b1dd40ae5a3b9ea6bf21e3d89 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRna.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRna.java @@ -6,10 +6,11 @@ import java.util.List; import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerRnaRegion; import lcsb.mapviewer.model.map.species.Rna; /** - * Class representing rna in the model. + * Class representing CellDesigner {@link Rna}. * * @author Piotr Gawron * @@ -19,18 +20,18 @@ public class CellDesignerRna extends CellDesignerSpecies<Rna> { /** * */ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(CellDesignerRna.class.getName()); + private static Logger logger = Logger.getLogger(CellDesignerRna.class.getName()); /** * List of rna regions (some rna sequences) in this object. */ - private List<CellDesignerRnaRegion> regions = new ArrayList<>(); + private List<CellDesignerRnaRegion> regions = new ArrayList<>(); /** * Constructor that initializes rna with the data passed in the argument. diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRnaComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRnaComparator.java deleted file mode 100644 index 52b674dd77a154a748d8bbd1db35f6e00291339c..0000000000000000000000000000000000000000 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRnaComparator.java +++ /dev/null @@ -1,104 +0,0 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; - -import java.util.Comparator; -import java.util.HashSet; -import java.util.Set; - -import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.common.comparator.StringSetComparator; -import lcsb.mapviewer.common.exception.NotImplementedException; - -/** - * This class implements comparator interface for Rna. - * - * @author Piotr Gawron - * - * @see CellDesignerRna - */ -public class CellDesignerRnaComparator implements Comparator<CellDesignerRna> { - - /** - * Epsilon value used for comparison of doubles. - */ - private double epsilon; - - /** - * Constructor that requires {@link #epsilon} parameter. - * - * @param epsilon - * {@link #epsilon} - */ - public CellDesignerRnaComparator(double epsilon) { - this.epsilon = epsilon; - } - - /** - * Default constructor. - */ - public CellDesignerRnaComparator() { - this(Configuration.EPSILON); - } - - @Override - public int compare(CellDesignerRna arg0, CellDesignerRna arg1) { - if (arg0 == null) { - if (arg1 == null) { - return 0; - } else { - return 1; - } - } else if (arg1 == null) { - return -1; - } - - if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(CellDesignerRna.class)) { - return internalCompare(arg0, arg1); - } else { - throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); - } - } else { - return -1; - } - } - - /** - * This method compares only the fields that are defined in {@link CellDesignerRna} class - * in inheritence tree. It also calls the {@link CellDesignerSpeciesComparator} for the - * super class ({@link CellDesignerSpecies}). - * - * @param arg0 - * first object to compare - * @param arg1 - * second object to compare - * @return if all fields are qual then returns 0. If they are different then - * -1/1 is returned. - */ - private int internalCompare(CellDesignerRna arg0, CellDesignerRna arg1) { - CellDesignerSpeciesComparator speciesComparator = new CellDesignerSpeciesComparator(epsilon); - int result = speciesComparator.internalCompare(arg0, arg1); - if (result != 0) { - return result; - } - - StringSetComparator stringSetComparator = new StringSetComparator(); - - Set<String> set1 = new HashSet<String>(); - Set<String> set2 = new HashSet<String>(); - - for (CellDesignerRnaRegion region : arg0.getRegions()) { - set1.add(region.toString()); - } - - for (CellDesignerRnaRegion region : arg1.getRegions()) { - set2.add(region.toString()); - } - - if (stringSetComparator.compare(set1, set2) != 0) { - return stringSetComparator.compare(set1, set2); - } - - return 0; - } - -} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSimpleMolecule.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSimpleMolecule.java index 45521fc3ab1cec48abd8acdc48921662b6653997..74abe84f0a70738ef830444886e71b8d2a5fbf5d 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSimpleMolecule.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSimpleMolecule.java @@ -6,7 +6,7 @@ import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.SimpleMolecule; /** - * Class representing molecule in the model. + * Class representing CellDesigner {@link SimpleMolecule}. * * @author Piotr Gawron * diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSimpleMoleculeComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSimpleMoleculeComparator.java deleted file mode 100644 index c6e47e7eee6f977b01fed3e55c902f260ba9853e..0000000000000000000000000000000000000000 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSimpleMoleculeComparator.java +++ /dev/null @@ -1,112 +0,0 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; - -import java.util.Comparator; - -import org.apache.log4j.Logger; - -import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.common.comparator.StringComparator; -import lcsb.mapviewer.common.exception.NotImplementedException; - -/** - * This class implements comparator interface for SimpleMolecule. - * - * @author Piotr Gawron - * - * @see CellDesignerSimpleMolecule - */ -public class CellDesignerSimpleMoleculeComparator implements Comparator<CellDesignerSimpleMolecule> { - /** - * Default class logger. - */ - private Logger logger = Logger.getLogger(CellDesignerSimpleMoleculeComparator.class); - - /** - * Epsilon value used for comparison of doubles. - */ - private double epsilon; - - /** - * Constructor that requires {@link #epsilon} parameter. - * - * @param epsilon - * {@link #epsilon} - */ - public CellDesignerSimpleMoleculeComparator(double epsilon) { - this.epsilon = epsilon; - } - - /** - * Default constructor. - */ - public CellDesignerSimpleMoleculeComparator() { - this(Configuration.EPSILON); - } - - @Override - public int compare(CellDesignerSimpleMolecule arg0, CellDesignerSimpleMolecule arg1) { - if (arg0 == null) { - if (arg1 == null) { - return 0; - } else { - return 1; - } - } else if (arg1 == null) { - return -1; - } - - if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(CellDesignerSimpleMolecule.class)) { - return internalCompare(arg0, arg1); - } else { - throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); - } - } else { - return -1; - } - } - - /** - * This method compares only the fields that are defined in - * {@link CellDesignerSimpleMolecule} class in inheritence tree. It also calls the - * {@link CellDesignerSpeciesComparator} for the super class ( {@link CellDesignerSpecies}). - * - * @param arg0 - * first object to compare - * @param arg1 - * second object to compare - * @return if all fields are qual then returns 0. If they are different then - * -1/1 is returned. - */ - private int internalCompare(CellDesignerSimpleMolecule arg0, CellDesignerSimpleMolecule arg1) { - CellDesignerSpeciesComparator speciesComparator = new CellDesignerSpeciesComparator(epsilon); - int result = speciesComparator.internalCompare(arg0, arg1); - if (result != 0) { - return result; - } - - if (((Integer) arg0.getHomodimer()).compareTo(arg1.getHomodimer()) != 0) { - logger.debug("Homodimer different: " + arg0.getHomodimer() + ", " + arg1.getHomodimer()); - return ((Integer) arg0.getHomodimer()).compareTo(arg1.getHomodimer()); - } - - StringComparator stringComparator = new StringComparator(); - - if (stringComparator.compare(arg0.getSmiles(), arg1.getSmiles()) != 0) { - logger.debug("Smiles different: " + arg0.getSmiles() + ", " + arg1.getSmiles()); - return stringComparator.compare(arg0.getSmiles(), arg1.getSmiles()); - } - - if (stringComparator.compare(arg0.getInChIKey(), arg1.getInChIKey()) != 0) { - logger.debug("InChIKey different: " + arg0.getInChIKey() + ", " + arg1.getInChIKey()); - return stringComparator.compare(arg0.getInChIKey(), arg1.getInChIKey()); - } - - if (stringComparator.compare(arg0.getInChI(), arg1.getInChI()) != 0) { - logger.debug("InChI different: " + arg0.getInChI() + ", " + arg1.getInChI()); - return stringComparator.compare(arg0.getInChI(), arg1.getInChI()); - } - return 0; - } - -} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSpecies.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSpecies.java index f776c8f4177e4a26648fc17361b056a56075d16c..9bacb5acfd75e717c74cba3d153f5db19095325b 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSpecies.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSpecies.java @@ -9,12 +9,15 @@ import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.model.map.species.field.PositionToCompartment; /** - * Generic species of the map. + * Generic CellDesigner element. * + * @param <T> + * model class tha corresponds to this cell designer structure * @author Piotr Gawron * */ public class CellDesignerSpecies<T extends Species> extends CellDesignerElement<T> { + /** * */ diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSpeciesComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSpeciesComparator.java deleted file mode 100644 index 2604e8c88f9cbc0ef6a9364088122189027414d0..0000000000000000000000000000000000000000 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSpeciesComparator.java +++ /dev/null @@ -1,231 +0,0 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; - -import java.util.Comparator; - -import org.apache.log4j.Logger; - -import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.common.comparator.BooleanComparator; -import lcsb.mapviewer.common.comparator.IntegerComparator; -import lcsb.mapviewer.common.comparator.StringComparator; -import lcsb.mapviewer.common.exception.InvalidClassException; - -/** - * This class implements comparator interface for Species. It calls comparator - * implementation for all known subclases of Species class when necessary. - * - * @author Piotr Gawron - * - * @see CellDesignerSpecies - */ -public class CellDesignerSpeciesComparator implements Comparator<CellDesignerSpecies<?>> { - /** - * Default class logger. - */ - private static Logger logger = Logger.getLogger(CellDesignerSpeciesComparator.class); - - /** - * Comparator for {@link CellDesignerAntisenseRna}. - */ - private CellDesignerAntisenseRnaComparator antisenseRnaComparator; - - /** - * Comparator for {@link CellDesignerComplexSpecies}. - */ - private CellDesignerComplexSpeciesComparator complexSpeciesComparator; - - /** - * Comparator for {@link CellDesignerDegraded}. - */ - private CellDesignerDegradedComparator degradedComparator; - - /** - * Comparator for {@link CellDesignerDrug}. - */ - private CellDesignerDrugComparator drugComparator; - - /** - * Comparator for {@link CellDesignerGene}. - */ - private CellDesignerGeneComparator geneComparator; - - /** - * Comparator for {@link CellDesignerIon}. - */ - private CellDesignerIonComparator ionComparator; - - /** - * Comparator for {@link CellDesignerPhenotype}. - */ - private CellDesignerPhenotypeComparator phenotypeComparator; - - /** - * Comparator for {@link CellDesignerProtein}. - */ - private CellDesignerProteinComparator proteinComparator; - - /** - * Comparator for {@link CellDesignerRna}. - */ - private CellDesignerRnaComparator rnaComparator; - - /** - * Comparator for {@link CellDesignerSimpleMolecule}. - */ - private CellDesignerSimpleMoleculeComparator simpleMoleculeComparator; - - /** - * Comparator for {@link CellDesignerUnknown}. - */ - private CellDesignerUnknownComparator unknownComparator; - - /** - * Epsilon value used for comparison of doubles. - */ - private double epsilon; - - /** - * Constructor that requires {@link #epsilon} parameter. - * - * @param epsilon - * {@link #epsilon} - */ - public CellDesignerSpeciesComparator(double epsilon) { - this.epsilon = epsilon; - antisenseRnaComparator = new CellDesignerAntisenseRnaComparator(epsilon); - complexSpeciesComparator = new CellDesignerComplexSpeciesComparator(epsilon); - degradedComparator = new CellDesignerDegradedComparator(epsilon); - drugComparator = new CellDesignerDrugComparator(epsilon); - geneComparator = new CellDesignerGeneComparator(epsilon); - ionComparator = new CellDesignerIonComparator(epsilon); - phenotypeComparator = new CellDesignerPhenotypeComparator(epsilon); - proteinComparator = new CellDesignerProteinComparator(epsilon); - rnaComparator = new CellDesignerRnaComparator(epsilon); - simpleMoleculeComparator = new CellDesignerSimpleMoleculeComparator(epsilon); - unknownComparator = new CellDesignerUnknownComparator(epsilon); - - } - - /** - * Default constructor. - */ - public CellDesignerSpeciesComparator() { - this(Configuration.EPSILON); - } - - @Override - public int compare(CellDesignerSpecies<?> arg0, CellDesignerSpecies<?> arg1) { - if (arg0 == null) { - if (arg1 == null) { - return 0; - } else { - return 1; - } - } else if (arg1 == null) { - return -1; - } - - if (arg0.getClass().equals(arg1.getClass())) { - if (arg0 instanceof CellDesignerAntisenseRna) { - return antisenseRnaComparator.compare((CellDesignerAntisenseRna) arg0, (CellDesignerAntisenseRna) arg1); - } else if (arg0 instanceof CellDesignerComplexSpecies) { - return complexSpeciesComparator.compare((CellDesignerComplexSpecies) arg0, (CellDesignerComplexSpecies) arg1); - } else if (arg0 instanceof CellDesignerDegraded) { - return degradedComparator.compare((CellDesignerDegraded) arg0, (CellDesignerDegraded) arg1); - } else if (arg0 instanceof CellDesignerDrug) { - return drugComparator.compare((CellDesignerDrug) arg0, (CellDesignerDrug) arg1); - } else if (arg0 instanceof CellDesignerGene) { - return geneComparator.compare((CellDesignerGene) arg0, (CellDesignerGene) arg1); - } else if (arg0 instanceof CellDesignerIon) { - return ionComparator.compare((CellDesignerIon) arg0, (CellDesignerIon) arg1); - } else if (arg0 instanceof CellDesignerPhenotype) { - return phenotypeComparator.compare((CellDesignerPhenotype) arg0, (CellDesignerPhenotype) arg1); - } else if (arg0 instanceof CellDesignerProtein) { - return proteinComparator.compare((CellDesignerProtein<?>) arg0, (CellDesignerProtein<?>) arg1); - } else if (arg0 instanceof CellDesignerRna) { - return rnaComparator.compare((CellDesignerRna) arg0, (CellDesignerRna) arg1); - } else if (arg0 instanceof CellDesignerSimpleMolecule) { - return simpleMoleculeComparator.compare((CellDesignerSimpleMolecule) arg0, (CellDesignerSimpleMolecule) arg1); - } else if (arg0 instanceof CellDesignerUnknown) { - return unknownComparator.compare((CellDesignerUnknown) arg0, (CellDesignerUnknown) arg1); - } else { - throw new InvalidClassException("Don't know how to compare classes: " + arg0.getClass()); - } - } else { - logger.debug("class different: " + arg0.getClass() + ", " + arg1.getClass()); - return -1; - } - } - - /** - * This method compares only the fields that are defined in {@link CellDesignerSpecies} - * class in inheritence tree. It also calls the {@link CellDesignerElementComparator} for - * the super class ({@link lcsb.mapviewer.db.model.map.CellDesignerElement Element}). - * - * @param arg0 - * first object to compare - * @param arg1 - * second object to compare - * @return if all fields are qual then returns 0. If they are different then - * -1/1 is returned. - */ - public int internalCompare(CellDesignerSpecies<?> arg0, CellDesignerSpecies<?> arg1) { - CellDesignerElementComparator elementComparator = new CellDesignerElementComparator(epsilon); - StringComparator stringComparator = new StringComparator(); - IntegerComparator integerComparator = new IntegerComparator(); - BooleanComparator booleanComparator = new BooleanComparator(); - - int result = elementComparator.internalCompare(arg0, arg1); - if (result != 0) { - return result; - } - - if (stringComparator.compare(arg0.getElementId(), arg1.getElementId()) != 0) { - logger.debug("Id species different: " + arg0.getElementId() + ", " + arg1.getElementId()); - return stringComparator.compare(arg0.getElementId(), arg1.getElementId()); - } - - if (integerComparator.compare(arg0.getInitialAmount(), arg1.getInitialAmount()) != 0) { - logger.debug("Initial amount different: " + arg0.getInitialAmount() + ", " + arg1.getInitialAmount()); - return integerComparator.compare(arg0.getInitialAmount(), arg1.getInitialAmount()); - } - - if (integerComparator.compare(arg0.getCharge(), arg1.getCharge()) != 0) { - logger.debug("Charge different: " + arg0.getCharge() + ", " + arg1.getCharge()); - return integerComparator.compare(arg0.getCharge(), arg1.getCharge()); - } - - if (integerComparator.compare(arg0.getInitialConcentration(), arg1.getInitialConcentration()) != 0) { - logger.debug("Initial concentration different: " + arg0.getInitialConcentration() + ", " + arg1.getInitialConcentration()); - return integerComparator.compare(arg0.getInitialConcentration(), arg1.getInitialConcentration()); - } - - if (booleanComparator.compare(arg0.hasOnlySubstanceUnits(), arg1.hasOnlySubstanceUnits()) != 0) { - logger.debug("OnlySubstanceUnits different: " + arg0.hasOnlySubstanceUnits() + ", " + arg1.hasOnlySubstanceUnits()); - return booleanComparator.compare(arg0.hasOnlySubstanceUnits(), arg1.hasOnlySubstanceUnits()); - } - - if (arg0.getPositionToCompartment() != null || arg1.getPositionToCompartment() != null) { - Integer pos0 = null; - Integer pos1 = null; - if (arg0.getPositionToCompartment() != null) { - pos0 = arg0.getPositionToCompartment().ordinal(); - } - if (arg1.getPositionToCompartment() != null) { - pos1 = arg1.getPositionToCompartment().ordinal(); - } - if (integerComparator.compare(pos0, pos1) != 0) { - logger.debug("PositionToCompartment different: \"" + arg0.getPositionToCompartment() + "\", \"" + arg1.getPositionToCompartment() + "\""); - return integerComparator.compare(pos0, pos1); - } - } - - if (booleanComparator.compare(arg0.isHypothetical(), arg1.isHypothetical()) != 0) { - logger.debug("Hypothetical different: \"" + arg0.isHypothetical() + "\", \"" + arg1.isHypothetical() + "\""); - return booleanComparator.compare(arg0.isHypothetical(), arg1.isHypothetical()); - } - - return 0; - } - -} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerTruncatedProtein.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerTruncatedProtein.java index c26379a941f0d20e68c8f259290423e0d51061d1..5256979b554e3df89bdc8a95caed442af174dad0 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerTruncatedProtein.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerTruncatedProtein.java @@ -4,7 +4,7 @@ import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.TruncatedProtein; /** - * Truncated protein. + * Class representing CellDesigner {@link TruncatedProtein}. * * @author Piotr Gawron * diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerUnknown.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerUnknown.java index 6e66e20ef82907bded2ffa30eb71b5009f9edefa..c17a7d5bba21b76bdf649ad8bb56b22305a69602 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerUnknown.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerUnknown.java @@ -4,7 +4,7 @@ import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.Unknown; /** - * Class representing unknown element in the model. + * Class representing CellDesigner {@link Unknown} element. * * @author Piotr Gawron * diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerUnknownComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerUnknownComparator.java deleted file mode 100644 index c80d46491c7141221cc2d326f9a591ec5d331f8c..0000000000000000000000000000000000000000 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerUnknownComparator.java +++ /dev/null @@ -1,82 +0,0 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; - -import java.util.Comparator; - -import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.common.exception.NotImplementedException; - -/** - * This class implements comparator interface for Unknown. - * - * @author Piotr Gawron - * - * @see CellDesignerUnknown - */ -public class CellDesignerUnknownComparator implements Comparator<CellDesignerUnknown> { - /** - * Epsilon value used for comparison of doubles. - */ - private double epsilon; - - /** - * Constructor that requires {@link #epsilon} parameter. - * - * @param epsilon - * {@link #epsilon} - */ - public CellDesignerUnknownComparator(double epsilon) { - this.epsilon = epsilon; - } - - /** - * Default constructor. - */ - public CellDesignerUnknownComparator() { - this(Configuration.EPSILON); - } - - @Override - public int compare(CellDesignerUnknown arg0, CellDesignerUnknown arg1) { - if (arg0 == null) { - if (arg1 == null) { - return 0; - } else { - return 1; - } - } else if (arg1 == null) { - return -1; - } - - if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(CellDesignerUnknown.class)) { - return internalCompare(arg0, arg1); - } else { - throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); - } - } else { - return -1; - } - } - - /** - * This method compares only the fields that are defined in {@link CellDesignerUnknown} - * class in inheritence tree. It also calls the {@link CellDesignerSpeciesComparator} for - * the super class ({@link CellDesignerSpecies}). - * - * @param arg0 - * first object to compare - * @param arg1 - * second object to compare - * @return if all fields are qual then returns 0. If they are different then - * -1/1 is returned. - */ - private int internalCompare(CellDesignerUnknown arg0, CellDesignerUnknown arg1) { - CellDesignerSpeciesComparator speciesComparator = new CellDesignerSpeciesComparator(epsilon); - int result = speciesComparator.internalCompare(arg0, arg1); - if (result != 0) { - return result; - } - - return 0; - } -} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRnaRegion.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerAntisenseRnaRegion.java similarity index 93% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRnaRegion.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerAntisenseRnaRegion.java index e2c933ab7dba0093a5d3326a8574c53fbfd26ba6..4861bdbb14a68ee56775f4c709569486857b5efc 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRnaRegion.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerAntisenseRnaRegion.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.converter.model.celldesigner.structure.fields; import java.io.Serializable; @@ -6,9 +6,10 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerAntisenseRna; import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion; +import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegionType; import lcsb.mapviewer.model.map.species.field.ModificationState; -import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion.AntisenseRnaRegionType; /** * This structure contains information about antisense rna region (rna fragment diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRnaRegion.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerRnaRegion.java similarity index 92% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRnaRegion.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerRnaRegion.java index b67c6ec9199fbb1e7684470bd5287210d9e763fa..3917251077e4359bff2d0e736437e043d1b9cb8c 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRnaRegion.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerRnaRegion.java @@ -1,10 +1,11 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.converter.model.celldesigner.structure.fields; import java.io.Serializable; import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.InvalidArgumentException; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerRna; import lcsb.mapviewer.model.map.species.field.ModificationState; import lcsb.mapviewer.model.map.species.field.RnaRegion; diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParserTest.java index 5ae846b9b2b2c2235843ebeb50436e2fe2ee7a54..4f050579438dca2838e5367a03bca20be4f7114d 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParserTest.java @@ -646,7 +646,7 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions { CellDesignerXmlParser parser = new CellDesignerXmlParser(); Model model = parser.createModel(new ConverterParams().filename("testFiles/notes_with_html_coding.xml")); - Element p = model.getAliasByAliasId("sa1"); + Element p = model.getElementByElementId("sa1"); assertEquals(">symbol<", p.getSymbol()); @@ -938,7 +938,7 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions { try { CellDesignerXmlParser parser = new CellDesignerXmlParser(); Model model = parser.createModel(new ConverterParams().filename("testFiles/problematic/problematic_notes.xml")); - Element element = model.getAliasByAliasId("sa2338"); + Element element = model.getElementByElementId("sa2338"); assertFalse("Element note cannot contain head html tag", element.getNotes().contains("</head>")); } catch (Exception e) { e.printStackTrace(); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/ComplexParserTests.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/ComplexParserTests.java index f8834afcbc882c308bbf924cd27dad2917bd42ed..53828971c03b0941d9dadb0b0f599d1d6c8589e7 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/ComplexParserTests.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/ComplexParserTests.java @@ -68,7 +68,7 @@ public class ComplexParserTests extends CellDesignerTestFunctions { try { model = getModelForFile("testFiles/bubbles.xml"); - Element species = model.getAliasByAliasId("sa6"); + Element species = model.getElementByElementId("sa6"); assertNotNull(species); Protein protein = (Protein) species; assertTrue(protein.getModificationResidues().size() > 0); @@ -88,27 +88,27 @@ public class ComplexParserTests extends CellDesignerTestFunctions { model = getModelForFile("testFiles/problematic/elements_in_compartments.xml"); List<Element> aliases = new ArrayList<>(); - aliases.add(model.getAliasByAliasId("csa3")); - aliases.add(model.getAliasByAliasId("csa4")); - aliases.add(model.getAliasByAliasId("csa5")); - aliases.add(model.getAliasByAliasId("csa6")); - aliases.add(model.getAliasByAliasId("sa3")); - aliases.add(model.getAliasByAliasId("sa5")); - aliases.add(model.getAliasByAliasId("sa6")); - aliases.add(model.getAliasByAliasId("sa7")); - aliases.add(model.getAliasByAliasId("sa8")); - aliases.add(model.getAliasByAliasId("sa9")); - aliases.add(model.getAliasByAliasId("sa10")); - aliases.add(model.getAliasByAliasId("sa11")); - aliases.add(model.getAliasByAliasId("sa12")); - aliases.add(model.getAliasByAliasId("sa13")); - aliases.add(model.getAliasByAliasId("sa14")); - aliases.add(model.getAliasByAliasId("sa15")); - aliases.add(model.getAliasByAliasId("sa16")); - aliases.add(model.getAliasByAliasId("sa17")); - aliases.add(model.getAliasByAliasId("sa18")); - aliases.add(model.getAliasByAliasId("sa19")); - aliases.add(model.getAliasByAliasId("sa20")); + aliases.add(model.getElementByElementId("csa3")); + aliases.add(model.getElementByElementId("csa4")); + aliases.add(model.getElementByElementId("csa5")); + aliases.add(model.getElementByElementId("csa6")); + aliases.add(model.getElementByElementId("sa3")); + aliases.add(model.getElementByElementId("sa5")); + aliases.add(model.getElementByElementId("sa6")); + aliases.add(model.getElementByElementId("sa7")); + aliases.add(model.getElementByElementId("sa8")); + aliases.add(model.getElementByElementId("sa9")); + aliases.add(model.getElementByElementId("sa10")); + aliases.add(model.getElementByElementId("sa11")); + aliases.add(model.getElementByElementId("sa12")); + aliases.add(model.getElementByElementId("sa13")); + aliases.add(model.getElementByElementId("sa14")); + aliases.add(model.getElementByElementId("sa15")); + aliases.add(model.getElementByElementId("sa16")); + aliases.add(model.getElementByElementId("sa17")); + aliases.add(model.getElementByElementId("sa18")); + aliases.add(model.getElementByElementId("sa19")); + aliases.add(model.getElementByElementId("sa20")); for (Element alias : aliases) { assertNotNull(eu.getElementTag(alias) + " does not contain info about compartment", alias.getParent()); } @@ -138,7 +138,7 @@ public class ComplexParserTests extends CellDesignerTestFunctions { // of residues assertEquals(2, residues.size()); - assertEquals(ModificationState.ACETYLATED, ((Protein) model.getAliasByAliasId("sa2")).getModificationResidues().get(0).getState()); + assertEquals(ModificationState.ACETYLATED, ((Protein) model.getElementByElementId("sa2")).getModificationResidues().get(0).getState()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -150,7 +150,7 @@ public class ComplexParserTests extends CellDesignerTestFunctions { Model model; try { model = getModelForFile("testFiles/includedSpecies.xml"); - Element species = model.getAliasByAliasId("sa1"); + Element species = model.getElementByElementId("sa1"); assertNotNull(species); assertNotNull(species.getNotes()); assertTrue("Wrong notes: " + species.getNotes(), species.getNotes().contains("hello world")); @@ -165,7 +165,7 @@ public class ComplexParserTests extends CellDesignerTestFunctions { Model model; try { model = getModelForFile("testFiles/problematic/hypothetical_complex.xml"); - Complex species = (Complex) model.getAliasByAliasId("csa1"); + Complex species = (Complex) model.getElementByElementId("csa1"); assertTrue(species.isHypothetical()); } catch (Exception e) { e.printStackTrace(); @@ -178,8 +178,8 @@ public class ComplexParserTests extends CellDesignerTestFunctions { Model model; try { model = getModelForFile("testFiles/problematic/problematic_acetylation.xml"); - Protein p1 = (Protein) model.getAliasByAliasId("sa73"); - Protein p2 = (Protein) model.getAliasByAliasId("sa27"); + Protein p1 = (Protein) model.getElementByElementId("sa73"); + Protein p2 = (Protein) model.getElementByElementId("sa27"); assertEquals(ModificationState.ACETYLATED, p1.getModificationResidues().get(0).getState()); assertFalse(ModificationState.ACETYLATED.equals(p2.getModificationResidues().get(0).getState())); @@ -194,7 +194,7 @@ public class ComplexParserTests extends CellDesignerTestFunctions { Model model; try { model = getModelForFile("testFiles/problematic/duplicated_miriam.xml"); - Protein p1 = (Protein) model.getAliasByAliasId("sa1"); + Protein p1 = (Protein) model.getElementByElementId("sa1"); Set<String> ids = new HashSet<>(); assertTrue(p1.getMiriamData().size() > 0); @@ -217,7 +217,7 @@ public class ComplexParserTests extends CellDesignerTestFunctions { try { Model model = getModelForFile("testFiles/problematic/kappa_example.xml"); - Element species = model.getAliasByAliasId("sa1"); + Element species = model.getElementByElementId("sa1"); assertFalse(species.getName().toLowerCase().contains("kappa")); @@ -232,14 +232,14 @@ public class ComplexParserTests extends CellDesignerTestFunctions { try { Model model = getModelForFile("testFiles/missing_xml_nodes.xml"); - assertTrue(((Species) model.getAliasByAliasId("sa3")).isHypothetical()); - assertTrue(((Species) model.getAliasByAliasId("sa4")).isHypothetical()); - assertTrue(((Species) model.getAliasByAliasId("sa5")).isHypothetical()); + assertTrue(((Species) model.getElementByElementId("sa3")).isHypothetical()); + assertTrue(((Species) model.getElementByElementId("sa4")).isHypothetical()); + assertTrue(((Species) model.getElementByElementId("sa5")).isHypothetical()); - assertFalse(((Species) model.getAliasByAliasId("sa12")).isHypothetical()); - assertFalse(((Species) model.getAliasByAliasId("sa13")).isHypothetical()); - assertFalse(((Species) model.getAliasByAliasId("sa14")).isHypothetical()); - assertFalse(((Species) model.getAliasByAliasId("sa15")).isHypothetical()); + assertFalse(((Species) model.getElementByElementId("sa12")).isHypothetical()); + assertFalse(((Species) model.getElementByElementId("sa13")).isHypothetical()); + assertFalse(((Species) model.getElementByElementId("sa14")).isHypothetical()); + assertFalse(((Species) model.getElementByElementId("sa15")).isHypothetical()); } catch (Exception e) { e.printStackTrace(); @@ -322,7 +322,7 @@ public class ComplexParserTests extends CellDesignerTestFunctions { public void testRnaWithRegion() throws Exception { try { Model model = getModelForFile("testFiles/rnaWithRegion.xml"); - for (Element species : model.getNotComplexSpeciesAliases()) { + for (Element species : model.getNotComplexSpeciesList()) { Rna rna = (Rna) species; assertEquals(1, rna.getRegions().size()); } @@ -336,7 +336,7 @@ public class ComplexParserTests extends CellDesignerTestFunctions { public void testProtinWithModifications() throws Exception { try { Model model = getModelForFile("testFiles/proteinWithEverPossibleModification.xml"); - Protein protein = (Protein) model.getAliasByAliasId("sa1"); + Protein protein = (Protein) model.getElementByElementId("sa1"); assertEquals(14, protein.getModificationResidues().size()); } catch (Exception e) { e.printStackTrace(); @@ -348,7 +348,7 @@ public class ComplexParserTests extends CellDesignerTestFunctions { public void testAntisenseRnaWithRegion() throws Exception { try { Model model = getModelForFile("testFiles/antisenseRnaWithRegion.xml"); - for (Species species : model.getNotComplexSpeciesAliases()) { + for (Species species : model.getNotComplexSpeciesList()) { AntisenseRna rna = (AntisenseRna) species; assertEquals(1, rna.getRegions().size()); } diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/NestedComplexParsingTests.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/NestedComplexParsingTests.java index 5c3a6edf023d9aa1626c6fec4e654c5362258d68..78dbdab8bb16dc56f63b7d734e53a6ac4337f059 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/NestedComplexParsingTests.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/NestedComplexParsingTests.java @@ -29,18 +29,18 @@ public class NestedComplexParsingTests extends CellDesignerTestFunctions { try { model = getModelForFile("testFiles/xmlNodeTestExamples/nested_complex.xml"); - Element s1 = model.getAliasByAliasId("csa1"); - Element s2 = model.getAliasByAliasId("csa2"); - Element s3 = model.getAliasByAliasId("csa3"); - Element s4 = model.getAliasByAliasId("csa4"); - Element s5 = model.getAliasByAliasId("csa5"); - Element s6 = model.getAliasByAliasId("csa6"); - Element s7 = model.getAliasByAliasId("sa1"); - Element s8 = model.getAliasByAliasId("sa2"); - Element s9 = model.getAliasByAliasId("sa3"); - Element s10 = model.getAliasByAliasId("sa4"); - Element s11 = model.getAliasByAliasId("sa5"); - Element s12 = model.getAliasByAliasId("sa6"); + Element s1 = model.getElementByElementId("csa1"); + Element s2 = model.getElementByElementId("csa2"); + Element s3 = model.getElementByElementId("csa3"); + Element s4 = model.getElementByElementId("csa4"); + Element s5 = model.getElementByElementId("csa5"); + Element s6 = model.getElementByElementId("csa6"); + Element s7 = model.getElementByElementId("sa1"); + Element s8 = model.getElementByElementId("sa2"); + Element s9 = model.getElementByElementId("sa3"); + Element s10 = model.getElementByElementId("sa4"); + Element s11 = model.getElementByElementId("sa5"); + Element s12 = model.getElementByElementId("sa6"); assertTrue(s1 instanceof Complex); assertTrue(s2 instanceof Complex); assertTrue(s3 instanceof Complex); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/ReconDataInCellDesignerXmlParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/ReconDataInCellDesignerXmlParserTest.java index 37e3ba1d2910240f9b4871f54c9c0514a5293bd7..397d38c229c2c7dd84e34ab2cd3f2220d98720a4 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/ReconDataInCellDesignerXmlParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/ReconDataInCellDesignerXmlParserTest.java @@ -31,7 +31,7 @@ public class ReconDataInCellDesignerXmlParserTest extends CellDesignerTestFuncti CellDesignerXmlParser parser = new CellDesignerXmlParser(); Model model = parser.createModel(new ConverterParams().filename("testFiles/annotation/recon_annotation_example.xml")); assertNotNull(model); - Species species = (Species)model.getAliasByAliasId("sa1"); + Species species = (Species)model.getElementByElementId("sa1"); assertNotNull(species); assertEquals("S1_SYMB",species.getSymbol()); assertEquals("ABREVIATION",species.getAbbreviation()); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/alias/AliasCollectionXmlParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/alias/AliasCollectionXmlParserTest.java index 9a2ac88f381b0b7ce0eb8ff95159421879e628e1..bb1aa8ad256fc01d935a4357b9d2369aa76e6425 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/alias/AliasCollectionXmlParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/alias/AliasCollectionXmlParserTest.java @@ -64,13 +64,13 @@ public class AliasCollectionXmlParserTest extends CellDesignerTestFunctions { Species aliasSa10 = null; Species aliasSa11 = null; for (Species alias : list) { - if (alias.getAliasId().equals("sa8")) + if (alias.getElementId().equals("sa8")) aliasSa8 = alias; - if (alias.getAliasId().equals("sa9")) + if (alias.getElementId().equals("sa9")) aliasSa9 = alias; - if (alias.getAliasId().equals("sa10")) + if (alias.getElementId().equals("sa10")) aliasSa10 = alias; - if (alias.getAliasId().equals("sa11")) + if (alias.getElementId().equals("sa11")) aliasSa11 = alias; } assertNotNull(aliasSa8); @@ -159,13 +159,13 @@ public class AliasCollectionXmlParserTest extends CellDesignerTestFunctions { Species aliasSa10 = null; Species aliasSa11 = null; for (Species alias : list) { - if (alias.getAliasId().equals("sa8")) + if (alias.getElementId().equals("sa8")) aliasSa8 = alias; - if (alias.getAliasId().equals("sa9")) + if (alias.getElementId().equals("sa9")) aliasSa9 = alias; - if (alias.getAliasId().equals("sa10")) + if (alias.getElementId().equals("sa10")) aliasSa10 = alias; - if (alias.getAliasId().equals("sa11")) + if (alias.getElementId().equals("sa11")) aliasSa11 = alias; } assertNotNull(aliasSa8); @@ -195,11 +195,11 @@ public class AliasCollectionXmlParserTest extends CellDesignerTestFunctions { Complex aliasSa2 = null; Complex aliasSa3 = null; for (Complex alias : list) { - if (alias.getAliasId().equals("csa1")) + if (alias.getElementId().equals("csa1")) aliasSa1 = alias; - if (alias.getAliasId().equals("csa2")) + if (alias.getElementId().equals("csa2")) aliasSa2 = alias; - if (alias.getAliasId().equals("csa3")) + if (alias.getElementId().equals("csa3")) aliasSa3 = alias; } assertNotNull(aliasSa1); @@ -239,11 +239,11 @@ public class AliasCollectionXmlParserTest extends CellDesignerTestFunctions { Complex aliasSa2 = null; Complex aliasSa3 = null; for (Complex alias : list) { - if (alias.getAliasId().equals("csa1")) + if (alias.getElementId().equals("csa1")) aliasSa1 = alias; - if (alias.getAliasId().equals("csa2")) + if (alias.getElementId().equals("csa2")) aliasSa2 = alias; - if (alias.getAliasId().equals("csa3")) + if (alias.getElementId().equals("csa3")) aliasSa3 = alias; } assertNotNull(aliasSa1); @@ -272,11 +272,11 @@ public class AliasCollectionXmlParserTest extends CellDesignerTestFunctions { Compartment aliasCa2 = null; Compartment aliasCa3 = null; for (Compartment alias : list) { - if (alias.getAliasId().equals("ca1")) + if (alias.getElementId().equals("ca1")) aliasCa1 = alias; - if (alias.getAliasId().equals("ca2")) + if (alias.getElementId().equals("ca2")) aliasCa2 = alias; - if (alias.getAliasId().equals("ca3")) + if (alias.getElementId().equals("ca3")) aliasCa3 = alias; } assertNotNull(aliasCa1); @@ -319,11 +319,11 @@ public class AliasCollectionXmlParserTest extends CellDesignerTestFunctions { Compartment aliasSa2 = null; Compartment aliasSa3 = null; for (Compartment alias : list) { - if (alias.getAliasId().equals("ca1")) + if (alias.getElementId().equals("ca1")) aliasSa1 = alias; - if (alias.getAliasId().equals("ca2")) + if (alias.getElementId().equals("ca2")) aliasSa2 = alias; - if (alias.getAliasId().equals("ca3")) + if (alias.getElementId().equals("ca3")) aliasSa3 = alias; } assertNotNull(aliasSa1); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/alias/CompartmentAliasXmlParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/alias/CompartmentAliasXmlParserTest.java index 39ec8b24402630fef9dcc0923ee356268527c33b..04cb68566b35811c92a0ffadbb29fb249040ef87 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/alias/CompartmentAliasXmlParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/alias/CompartmentAliasXmlParserTest.java @@ -61,7 +61,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions { Compartment alias2 = parser.parseXmlAlias(xmlString2); assertEquals(0, getWarnings().size()); - assertEquals(alias.getAliasId(), alias2.getAliasId()); + assertEquals(alias.getElementId(), alias2.getElementId()); assertNotNull(alias.getName()); assertEquals(alias.getFontSize(), alias2.getFontSize(), 1e-6); assertEquals(alias.getHeight(), alias2.getHeight(), 1e-6); @@ -158,7 +158,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions { Compartment alias = (Compartment) parser.parseXmlAlias(xmlString); assertEquals(0, getWarnings().size()); assertNotNull(alias); - assertEquals("ca1", alias.getAliasId()); + assertEquals("ca1", alias.getElementId()); assertNotNull(alias.getName()); assertTrue(alias instanceof SquareCompartment); assertEquals(139.0, alias.getX(), 1e-6); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/alias/ComplexAliasXmlParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/alias/ComplexAliasXmlParserTest.java index f59f2c1826df84fbf4ecf5fd51514553fac32faa..c129a0ac831f606afdc65ccf413ba1f4e41d80f6 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/alias/ComplexAliasXmlParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/alias/ComplexAliasXmlParserTest.java @@ -44,7 +44,7 @@ public class ComplexAliasXmlParserTest extends CellDesignerTestFunctions { Complex alias2 = (Complex) parser.parseXmlAlias(xmlString2); assertEquals(0, getWarnings().size()); - assertEquals(alias.getAliasId(), alias2.getAliasId()); + assertEquals(alias.getElementId(), alias2.getElementId()); assertNotNull(alias.getName()); assertEquals(alias.getFontSize(), alias2.getFontSize(), 1e-6); assertEquals(alias.getHeight(), alias2.getHeight(), 1e-6); @@ -66,7 +66,7 @@ public class ComplexAliasXmlParserTest extends CellDesignerTestFunctions { Complex alias = (Complex) parser.parseXmlAlias(xmlString); assertEquals(0, getWarnings().size()); assertEquals(false, alias.getActivity()); - assertEquals("csa1", alias.getAliasId()); + assertEquals("csa1", alias.getElementId()); assertEquals(12.0, alias.getFontSize(), 1e-6); assertEquals(120.0, alias.getHeight(), 1e-6); assertEquals(100.0, alias.getWidth(), 1e-6); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/alias/SpeciesAliasXmlParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/alias/SpeciesAliasXmlParserTest.java index ec07f044b6ef169c058f012fd71ebd9e78780405..90cc28dac5f072b1a25302c0d3995a24461aff45 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/alias/SpeciesAliasXmlParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/alias/SpeciesAliasXmlParserTest.java @@ -71,13 +71,13 @@ public class SpeciesAliasXmlParserTest extends CellDesignerTestFunctions { Species alias = parser.parseXmlAlias(xmlString); assertEquals(0, getWarnings().size()); assertEquals(false, alias.getActivity()); - assertEquals("sa36", alias.getAliasId()); + assertEquals("sa36", alias.getElementId()); assertEquals(16.0, alias.getFontSize(), 1e-6); assertEquals(25.0, alias.getHeight(), 1e-6); assertEquals(80, alias.getWidth(), 1e-6); assertEquals(11813.0, alias.getX(), 1e-6); assertEquals(2840.5, alias.getY(), 1e-6); - assertEquals("ca1", alias.getParent().getAliasId()); + assertEquals("ca1", alias.getParent().getElementId()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -114,13 +114,13 @@ public class SpeciesAliasXmlParserTest extends CellDesignerTestFunctions { assertEquals(0, getWarnings().size()); assertEquals(alias.getActivity(), alias2.getActivity()); - assertEquals(alias.getAliasId(), alias2.getAliasId()); + assertEquals(alias.getElementId(), alias2.getElementId()); assertEquals(alias.getFontSize(), alias2.getFontSize(), 1e-6); assertEquals(alias.getHeight(), alias2.getHeight(), 1e-6); assertEquals(alias.getWidth(), alias2.getWidth(), 1e-6); assertEquals(alias.getX(), alias2.getX(), 1e-6); assertEquals(alias.getY(), alias2.getY(), 1e-6); - assertEquals(alias.getParent().getAliasId(), alias2.getParent().getAliasId()); + assertEquals(alias.getParent().getElementId(), alias2.getParent().getElementId()); assertEquals("Alias state label different", alias.getAliasStateLabel(), alias2.getAliasStateLabel()); assertEquals("Alias state prefix different", alias.getAliasStatePrefix(), alias2.getAliasStatePrefix()); } catch (Exception e) { @@ -278,14 +278,14 @@ public class SpeciesAliasXmlParserTest extends CellDesignerTestFunctions { md.setModel(model); Compartment ca2 = new Compartment(testCompartmentAliasId2); - ca2.setAliasId(testCompartmentAliasId2); + ca2.setElementId(testCompartmentAliasId2); ca2.setX(6); ca2.setY(6); ca2.setWidth(190); ca2.setHeight(190); Compartment ca = new Compartment(testCompartmentAliasId); - ca.setAliasId(testCompartmentAliasId); + ca.setElementId(testCompartmentAliasId); ca.setX(5); ca.setY(5); ca.setWidth(200); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionParserTests.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionParserTests.java index a0fe14ccff0e123f54f1ed9b352e04f13bdecde3..c9f057780d165dbdaa7a38b788ab89cfa5be7b93 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionParserTests.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionParserTests.java @@ -100,7 +100,7 @@ public class ReactionParserTests extends CellDesignerTestFunctions { Model model; try { model = getModelForFile("testFiles/problematic/pd_map_with_problematic_reaction_line.xml"); - assertTrue(model.getAliasByAliasId("sa5003") instanceof GenericProtein); + assertTrue(model.getElementByElementId("sa5003") instanceof GenericProtein); Set<Reaction> list = model.getReactions(); for (Reaction reaction : list) { // reaction re1607 in this model was problematic, but in fact the @@ -855,10 +855,10 @@ public class ReactionParserTests extends CellDesignerTestFunctions { Modifier sa3 = null; Modifier sa4 = null; for (Modifier modifier : modifiers) { - if (modifier.getAlias().getAliasId().equals("sa3")) { + if (modifier.getAlias().getElementId().equals("sa3")) { sa3 = modifier; } - if (modifier.getAlias().getAliasId().equals("sa4")) { + if (modifier.getAlias().getElementId().equals("sa4")) { sa4 = modifier; } } diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/AntisenseRnaXmlParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/AntisenseRnaXmlParserTest.java index d89c8ac11506b95bf4bd416637bd46c68c8b41ac..e014668ec7db73eed8476bdb86855a08d87ef15f 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/AntisenseRnaXmlParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/AntisenseRnaXmlParserTest.java @@ -22,8 +22,8 @@ import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerTestFunctions; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerAntisenseRna; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerAntisenseRnaRegion; -import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion.AntisenseRnaRegionType; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerAntisenseRnaRegion; +import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegionType; public class AntisenseRnaXmlParserTest extends CellDesignerTestFunctions { protected Logger logger = Logger.getLogger(AntisenseRnaXmlParserTest.class.getName()); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/ComplexParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/ComplexParserTest.java index fbaa3f24815d8772751abd605ace78128f58f968..9416efdc86f9b9167d0478126d7aae021f555349 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/ComplexParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/ComplexParserTest.java @@ -54,7 +54,7 @@ public class ComplexParserTest extends CellDesignerTestFunctions { public void testComplexState() throws Exception { try { Model model = getModelForFile("testFiles/problematic/complex_with_state.xml"); - Complex complex = (Complex) model.getAliasByAliasId("csa1"); + Complex complex = (Complex) model.getElementByElementId("csa1"); assertEquals("test state", complex.getStructuralState()); } catch (Exception e) { e.printStackTrace(); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/GeneXmlParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/GeneXmlParserTest.java index 6bbec677457298518a54803f5d616cd2c3f174fb..eb41d7c3e51d2ff279b021a759b61bef73203737 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/GeneXmlParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/GeneXmlParserTest.java @@ -90,7 +90,7 @@ public class GeneXmlParserTest extends CellDesignerTestFunctions { public void testParsePhosphorylatedGene() throws Exception { try { Model model = getModelForFile("testFiles/problematic/phosphorylated_gene.xml"); - Gene gene = (Gene) model.getAliasByAliasId("sa1"); + Gene gene = (Gene) model.getElementByElementId("sa1"); assertEquals(1, gene.getModificationResidues().size()); ModificationResidue residue = gene.getModificationResidues().get(0); assertEquals(ModificationState.PHOSPHORYLATED, residue.getState()); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesSbmlParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesSbmlParserTest.java index 5e35e8399e0a2fd04b872ba4d6115377f7776ff4..a1c2c9bd7ec3b27df8f37248f0f3c07d0d2900ce 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesSbmlParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesSbmlParserTest.java @@ -27,7 +27,6 @@ import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerTestFunctions; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerAntisenseRna; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerAntisenseRnaRegion; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerComplexSpecies; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerDegraded; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerDrug; @@ -37,11 +36,12 @@ import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerIon; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerPhenotype; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerProtein; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerRna; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerRnaRegion; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSimpleMolecule; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerUnknown; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerAntisenseRnaRegion; import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerRnaRegion; import lcsb.mapviewer.converter.model.celldesigner.structure.fields.SpeciesState; import lcsb.mapviewer.model.map.species.Gene; import lcsb.mapviewer.model.map.species.GenericProtein; diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/AllStructureTests.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/AllStructureTests.java index 9259b9a4ee172437798b822f4ede1a4ec870b1b8..4c2e37e4e31766879a4330d91193336684f44c6f 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/AllStructureTests.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/AllStructureTests.java @@ -4,13 +4,28 @@ import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; +import lcsb.mapviewer.model.map.species.AntisenseRnaComparatorTest; +import lcsb.mapviewer.model.map.species.ComplexComparatorTest; +import lcsb.mapviewer.model.map.species.DegradedComparatorTest; +import lcsb.mapviewer.model.map.species.DrugComparatorTest; +import lcsb.mapviewer.model.map.species.ElementComparatorTest; +import lcsb.mapviewer.model.map.species.GeneComparatorTest; +import lcsb.mapviewer.model.map.species.IonChannelProteinTest; +import lcsb.mapviewer.model.map.species.PhenotypeComparatorTest; +import lcsb.mapviewer.model.map.species.ProteinComparatorTest; +import lcsb.mapviewer.model.map.species.ReceptorProteinTest; +import lcsb.mapviewer.model.map.species.RnaComparatorTest; +import lcsb.mapviewer.model.map.species.SimpleMoleculeComparatorTest; +import lcsb.mapviewer.model.map.species.SpeciesComparatorTest; +import lcsb.mapviewer.model.map.species.TruncatedProteinTest; +import lcsb.mapviewer.model.map.species.UnknownComparatorTest; + @RunWith(Suite.class) @SuiteClasses({ AntisenseRnaComparatorTest.class, // AntisenseRnaRegionTest.class, // AntisenseRnaTest.class, // - CompartmentComparatorTest.class, // CompartmentTest.class, // - ComplexSpeciesComparatorTest.class, // + ComplexComparatorTest.class, // ComplexSpeciesTest.class, // ConnectSchemeTest.class, // DegradedComparatorTest.class, // @@ -23,7 +38,6 @@ import org.junit.runners.Suite.SuiteClasses; GenericProteinTest.class, // GeneTest.class, // IonChannelProteinTest.class, // - IonComparatorTest.class, // IonTest.class, // LinePropertiesTest.class, // ModificationResidueTest.class, // diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRnaRegionTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRnaRegionTest.java index ac90daa0150b7d262144d08e25b2ec10db85a0c5..cd76043886a476571ec90aee9f216e071317acc5 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRnaRegionTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRnaRegionTest.java @@ -13,8 +13,9 @@ import org.junit.Test; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerAntisenseRnaRegion; +import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegionType; import lcsb.mapviewer.model.map.species.field.ModificationState; -import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion.AntisenseRnaRegionType; public class AntisenseRnaRegionTest { @@ -36,34 +37,6 @@ public class AntisenseRnaRegionTest { } } - @Test - public void testEnum() { - try { - for (AntisenseRnaRegionType type : AntisenseRnaRegionType.values()) { - assertNotNull(type); - - // for coverage tests - AntisenseRnaRegionType.valueOf(type.name()); - assertNotNull(type.getName()); - - } - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testEnumGetTypeByString() { - try { - assertNotNull(AntisenseRnaRegionType.getTypeByString("proteinBindingDomain")); - assertNull(AntisenseRnaRegionType.getTypeByString("antisenseRnaDomainzz")); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - @Test public void testConstructor1() { try { diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRnaTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRnaTest.java index c6b3142eae327159a45707739dd1bd0a7644748e..06f0f87d3e8e0885e7e5cc9379e9ea09ab0af3f3 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRnaTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRnaTest.java @@ -14,6 +14,7 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerAntisenseRnaRegion; import lcsb.mapviewer.model.map.species.AntisenseRna; import lcsb.mapviewer.model.map.species.field.ModificationState; diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/CompartmentComparatorTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/CompartmentComparatorTest.java deleted file mode 100644 index 28971eabb404931fb38b7230c302412be73541bc..0000000000000000000000000000000000000000 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/CompartmentComparatorTest.java +++ /dev/null @@ -1,117 +0,0 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import lcsb.mapviewer.common.exception.InvalidClassException; - -public class CompartmentComparatorTest { - - CellDesignerCompartmentComparator comparator = new CellDesignerCompartmentComparator(); - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testEquals() { - try { - CellDesignerCompartment comp1 = createCompartment(); - CellDesignerCompartment comp2 = createCompartment(); - - assertEquals(0, comparator.compare(comp1, comp1)); - - assertEquals(0, comparator.compare(comp1, comp2)); - assertEquals(0, comparator.compare(comp2, comp1)); - - } catch (Exception e) { - e.printStackTrace(); - fail("Unknowne exception occurred"); - } - } - - @Test - public void testDifferent() { - try { - CellDesignerCompartment compartment1 = createCompartment(); - CellDesignerCompartment compartment2 = createCompartment(); - compartment1.setElementId("id2"); - assertTrue(comparator.compare(compartment1, compartment2) != 0); - assertTrue(comparator.compare(compartment2, compartment1) != 0); - - compartment1 = createCompartment(); - compartment2 = createCompartment(); - compartment1.setName("id2asd"); - assertTrue(comparator.compare(compartment1, compartment2) != 0); - assertTrue(comparator.compare(compartment2, compartment1) != 0); - - compartment1 = createCompartment(); - compartment2 = createCompartment(); - assertTrue(comparator.compare(null, compartment2) != 0); - assertTrue(comparator.compare(compartment2, null) != 0); - assertTrue(comparator.compare(null, null) == 0); - - } catch (Exception e) { - e.printStackTrace(); - fail("Unknowne exception occurred"); - } - } - - public CellDesignerCompartment createCompartment() { - CellDesignerCompartment result = new CellDesignerCompartment(); - result.setElementId("id1"); - result.setName("bla"); - return result; - } - - @Test - public void testInvalid() { - try { - CellDesignerCompartment compartment1 = new CellDesignerCompartment(); - CellDesignerCompartment compartment2 = new CellDesignerCompartment() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }; - - assertTrue(comparator.compare(compartment1, compartment2) != 0); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - - } - - @Test - public void testInvalid2() { - try { - CellDesignerCompartment compartment2 = new CellDesignerCompartment() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }; - - comparator.compare(compartment2, compartment2); - fail("Exception expected"); - - } catch (InvalidClassException e) { - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - -} diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ComplexSpeciesComparatorTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ComplexSpeciesComparatorTest.java deleted file mode 100644 index 2d12d5c2928b0a81f466e9a9e6543dde31930195..0000000000000000000000000000000000000000 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ComplexSpeciesComparatorTest.java +++ /dev/null @@ -1,259 +0,0 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.apache.log4j.Logger; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; - -import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerCompartment; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerComplexSpecies; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerComplexSpeciesComparator; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerElement; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerGenericProtein; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerProtein; - -public class ComplexSpeciesComparatorTest { - Logger logger = Logger.getLogger(ComplexSpeciesComparatorTest.class); - - CellDesignerComplexSpeciesComparator comparator = new CellDesignerComplexSpeciesComparator(); - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testEquals() { - try { - CellDesignerComplexSpecies complex1 = createComplexSpecies(); - CellDesignerComplexSpecies complex2 = createComplexSpecies(); - - assertEquals(0, comparator.compare(complex1, complex1)); - - assertEquals(0, comparator.compare(complex1, complex2)); - assertEquals(0, comparator.compare(complex2, complex1)); - - complex2.addElement(new CellDesignerCompartment("test")); - complex1.addElement(new CellDesignerCompartment("test")); - assertEquals(0, comparator.compare(complex1, complex2)); - assertEquals(0, comparator.compare(complex2, complex1)); - } catch (Exception e) { - e.printStackTrace(); - fail("Unknowne exception occurred"); - } - } - - @Test - public void testInvalidComp() throws Exception { - try { - class Tmp extends CellDesignerComplexSpecies { - private static final long serialVersionUID = 1L; - } - - comparator.compare(new Tmp(), new Tmp()); - fail("Exception expected"); - } catch (NotImplementedException e) { - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - - } - - @Test - public void testInvalidComp2() throws Exception { - try { - CellDesignerComplexSpecies complex1 = createComplexSpecies(); - CellDesignerComplexSpecies complex2 = createComplexSpecies(); - - complex2.addElement(new CellDesignerCompartment("test")); - complex1.addElement(Mockito.mock(CellDesignerElement.class)); - comparator.compare(complex1, complex2); - comparator.compare(complex2, complex1); - fail("Exception expected"); - } catch (NotImplementedException e) { - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - - } - - @Test - public void testInvalidComp3() throws Exception { - try { - CellDesignerComplexSpecies complex1 = createComplexSpecies(); - CellDesignerComplexSpecies complex2 = createComplexSpecies(); - CellDesignerCompartment c = new CellDesignerCompartment("test"); - c.setName("a"); - complex2.addElement(c); - c.setName(""); - complex2.addElement(new CellDesignerCompartment("test")); - complex1.addElement(new CellDesignerCompartment("test")); - complex1.addElement(Mockito.mock(CellDesignerElement.class)); - comparator.compare(complex2, complex1); - fail("Exception expected"); - } catch (NotImplementedException e) { - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - - } - - @Test - public void testDifferent() throws Exception { - try { - CellDesignerComplexSpecies complex1 = createComplexSpecies(); - CellDesignerComplexSpecies complex2 = createComplexSpecies(); - complex1.setHomodimer(123); - assertTrue(comparator.compare(complex1, complex2) != 0); - assertTrue(comparator.compare(complex2, complex1) != 0); - - complex1 = createComplexSpecies(); - complex2 = createComplexSpecies(); - complex1.getElements().iterator().next().setNotes("bla"); - assertTrue(comparator.compare(complex1, complex2) != 0); - assertTrue(comparator.compare(complex2, complex1) != 0); - - complex1 = createComplexSpecies(); - complex2 = createComplexSpecies(); - complex1.getElements().clear(); - assertTrue(comparator.compare(complex1, complex2) != 0); - assertTrue(comparator.compare(complex2, complex1) != 0); - - complex1 = createComplexSpecies(); - complex2 = createComplexSpecies(); - assertTrue(comparator.compare(null, complex2) != 0); - assertTrue(comparator.compare(complex2, null) != 0); - assertTrue(comparator.compare(null, null) == 0); - - complex1 = createComplexSpecies(); - complex2 = createComplexSpecies(); - CellDesignerComplexSpecies child = (CellDesignerComplexSpecies) complex1.getElements().iterator().next(); - child.getElements().iterator().next().setNotes("grand child notes"); - assertTrue(comparator.compare(complex1, complex2) != 0); - assertTrue(comparator.compare(complex2, complex1) != 0); - - complex1 = createComplexSpecies(); - complex2 = createComplexSpecies(); - CellDesignerProtein<?> prot = new CellDesignerGenericProtein(); - prot.setElementId("test"); - complex1.addElement(prot); - assertTrue(comparator.compare(complex1, complex2) != 0); - assertTrue(comparator.compare(complex2, complex1) != 0); - - complex1 = createComplexSpecies(); - complex2 = createComplexSpecies(); - complex1.setStructuralState("str"); - assertTrue(comparator.compare(complex1, complex2) != 0); - assertTrue(comparator.compare(complex2, complex1) != 0); - - assertTrue(comparator.compare(new CellDesignerComplexSpecies(), new CellDesignerComplexSpecies() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }) != 0); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testDifferent3() throws Exception { - try { - CellDesignerComplexSpecies complex1 = createComplexSpecies(); - CellDesignerComplexSpecies complex2 = createComplexSpecies(); - CellDesignerGenericProtein prot = new CellDesignerGenericProtein(); - prot.setElementId("test"); - complex1.addElement(prot); - prot = new CellDesignerGenericProtein(); - prot.setElementId("test2"); - complex2.addElement(prot); - assertTrue(comparator.compare(complex1, complex2) != 0); - assertTrue(comparator.compare(complex2, complex1) != 0); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testDifferent4() throws Exception { - try { - CellDesignerComplexSpecies complex1 = createComplexSpecies(); - CellDesignerComplexSpecies complex2 = createComplexSpecies(); - CellDesignerCompartment c = new CellDesignerCompartment("test"); - c.setName("a"); - complex2.addElement(c); - complex2.addElement(new CellDesignerCompartment("test")); - c.setName(""); - - complex1.addElement(new CellDesignerCompartment("test")); - CellDesignerCompartment d = new CellDesignerCompartment("test2"); - d.setName("a"); - complex1.addElement(d); - assertTrue(comparator.compare(complex1, complex2) != 0); - assertTrue(comparator.compare(complex2, complex1) != 0); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testDifferent2() throws Exception { - try { - CellDesignerComplexSpecies complex1 = createComplexSpecies(); - CellDesignerComplexSpecies complex2 = createComplexSpecies(); - CellDesignerCompartment comp = new CellDesignerCompartment(); - comp.setElementId("test"); - comp.setFullName("X"); - complex1.addElement(comp); - complex2.addElement(new CellDesignerCompartment("test")); - assertTrue(comparator.compare(complex1, complex2) != 0); - assertTrue(comparator.compare(complex2, complex1) != 0); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - public CellDesignerComplexSpecies createComplexSpecies() { - CellDesignerComplexSpecies result = new CellDesignerComplexSpecies(); - - result.setHypothetical(true); - result.setHomodimer(3); - - CellDesignerComplexSpecies child = new CellDesignerComplexSpecies(); - result.addElement(child); - child.setCharge(12); - child.setName("buu"); - child.setNotes("hey, hi, hello"); - - CellDesignerComplexSpecies grandChild = new CellDesignerComplexSpecies(); - child.addElement(grandChild); - child.setCharge(123); - child.setName("buus"); - child.setNotes("hey, hi, hello !!"); - - return result; - } - -} diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ReceptorProteinTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ReceptorProteinTest.java index 6f0c2b58b868d97e696f57edb01aeb5c0437fd69..9713ddd4f5ec33ca340ff80b86d3f9ce6712f907 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ReceptorProteinTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ReceptorProteinTest.java @@ -9,6 +9,8 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerReceptorProtein; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; import lcsb.mapviewer.model.map.species.ReceptorProtein; public class ReceptorProteinTest { diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/RnaRegionTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/RnaRegionTest.java index ac16a87425ca6b86a1e1b7ad008940a54bcc408e..0ab0de88d9e272ff9f38d460d082d727e370e8d1 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/RnaRegionTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/RnaRegionTest.java @@ -11,6 +11,7 @@ import org.junit.Test; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.InvalidArgumentException; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerRnaRegion; import lcsb.mapviewer.model.map.species.field.ModificationState; public class RnaRegionTest { diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/RnaTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/RnaTest.java index 6ec2c5cb3cbd066e3290d740c838b9cfaae62330..c5cc495f63f5aa43ed229c2e896ccb86947883de 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/RnaTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/RnaTest.java @@ -15,6 +15,7 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerRnaRegion; import lcsb.mapviewer.model.map.species.Rna; import lcsb.mapviewer.model.map.species.field.ModificationState; diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SpeciesComparatorTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SpeciesComparatorTest.java deleted file mode 100644 index fb7c8858919bc453bc84600ece04dc152774ff74..0000000000000000000000000000000000000000 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SpeciesComparatorTest.java +++ /dev/null @@ -1,160 +0,0 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.junit.Test; -import org.mockito.Mockito; - -import lcsb.mapviewer.common.exception.InvalidClassException; -import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.MiriamRelationType; -import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.species.field.PositionToCompartment; - -public class SpeciesComparatorTest { - - CellDesignerSpeciesComparator comparator = new CellDesignerSpeciesComparator(); - - @Test - public void testException() { - try { - CellDesignerSpecies<?> mock = Mockito.mock(CellDesignerSpecies.class); - comparator.compare(mock, mock); - - fail("Exception should occur"); - } catch (InvalidClassException e) { - - } catch (Exception e) { - e.printStackTrace(); - fail("Unkowne exception"); - } - } - - @Test - public void testEquals() { - try { - CellDesignerSimpleMolecule species1 = createSimpleMolecule(); - CellDesignerSimpleMolecule species2 = createSimpleMolecule(); - assertEquals(0, comparator.compare(species1, species2)); - - assertEquals(0, comparator.compare(null, null)); - - assertEquals(0, comparator.compare(new CellDesignerAntisenseRna(), new CellDesignerAntisenseRna())); - assertEquals(0, comparator.compare(new CellDesignerDegraded(), new CellDesignerDegraded())); - assertEquals(0, comparator.compare(new CellDesignerDrug(), new CellDesignerDrug())); - assertEquals(0, comparator.compare(new CellDesignerIon(), new CellDesignerIon())); - assertEquals(0, comparator.compare(new CellDesignerPhenotype(), new CellDesignerPhenotype())); - assertEquals(0, comparator.compare(new CellDesignerRna(), new CellDesignerRna())); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testDifferent() { - try { - CellDesignerSimpleMolecule species1 = createSimpleMolecule(); - CellDesignerSimpleMolecule species2 = createSimpleMolecule(); - - species1.setCharge(99); - assertTrue(comparator.compare(species1, species2) != 0); - assertTrue(comparator.compare(species2, species1) != 0); - assertTrue(comparator.compare(null, species1) != 0); - assertTrue(comparator.compare(species1, null) != 0); - - species1 = createSimpleMolecule(); - species2 = createSimpleMolecule(); - species1.setHomodimer(1233); - assertTrue(comparator.compare(species1, species2) != 0); - assertTrue(comparator.compare(species2, species1) != 0); - - species1 = createSimpleMolecule(); - species2 = createSimpleMolecule(); - species1.setElementId(""); - species1.setElementId("ASD"); - assertTrue(comparator.compare(species1, species2) != 0); - assertTrue(comparator.compare(species2, species1) != 0); - - species1 = createSimpleMolecule(); - species2 = createSimpleMolecule(); - species1.setNotes("ASD"); - assertTrue(comparator.compare(species1, species2) != 0); - assertTrue(comparator.compare(species2, species1) != 0); - - species1 = createSimpleMolecule(); - species2 = createSimpleMolecule(); - species1.setPositionToCompartment(PositionToCompartment.TRANSMEMBRANE); - assertTrue(comparator.compare(species1, species2) != 0); - assertTrue(comparator.compare(species2, species1) != 0); - - species1 = createSimpleMolecule(); - species2 = createSimpleMolecule(); - species1.getMiriamData().clear(); - assertTrue(comparator.compare(species1, species2) != 0); - assertTrue(comparator.compare(species2, species1) != 0); - - species1 = createSimpleMolecule(); - species2 = createSimpleMolecule(); - species1.setInitialAmount(4); - assertTrue(comparator.compare(species1, species2) != 0); - assertTrue(comparator.compare(species2, species1) != 0); - - species1 = createSimpleMolecule(); - species2 = createSimpleMolecule(); - species1.setInitialConcentration(4); - assertTrue(comparator.compare(species1, species2) != 0); - assertTrue(comparator.compare(species2, species1) != 0); - - species1 = createSimpleMolecule(); - species2 = createSimpleMolecule(); - species1.setOnlySubstanceUnits(false); - assertTrue(comparator.compare(species1, species2) != 0); - assertTrue(comparator.compare(species2, species1) != 0); - - species1 = createSimpleMolecule(); - species2 = createSimpleMolecule(); - species1.setHypothetical(true); - assertTrue(comparator.compare(species1, species2) != 0); - assertTrue(comparator.compare(species2, species1) != 0); - - species1 = createSimpleMolecule(); - species2 = createSimpleMolecule(); - species1.getMiriamData().iterator().next().setRelationType(MiriamRelationType.BQ_BIOL_IS); - assertTrue(comparator.compare(species1, species2) != 0); - assertTrue(comparator.compare(species2, species1) != 0); - - species1 = createSimpleMolecule(); - species2 = createSimpleMolecule(); - species1.addMiriamData(new MiriamData()); - assertTrue(comparator.compare(species1, species2) != 0); - assertTrue(comparator.compare(species2, species1) != 0); - - assertTrue(comparator.compare(new CellDesignerRna(), new CellDesignerDrug()) != 0); - - } catch (Exception e) { - e.printStackTrace(); - fail("Unkowne exception"); - } - } - - public CellDesignerSimpleMolecule createSimpleMolecule() { - CellDesignerSimpleMolecule result = new CellDesignerSimpleMolecule(); - result.setHomodimer(12); - result.setElementId("id"); - result.setName("id"); - result.setInitialAmount("12"); - result.setCharge("13"); - result.setInitialConcentration("14"); - result.setOnlySubstanceUnits("true"); - result.setPositionToCompartment(PositionToCompartment.INSIDE); - result.setNotes("id"); - MiriamData md = new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.UNKNOWN, "c"); - result.addMiriamData(md); - return result; - } - -} diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/TruncatedProteinTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/TruncatedProteinTest.java index 6f3882334ded61ad5016956484405a110b6c65cc..3c62798bc54e6b2693f1889f9472e10e8b101ad5 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/TruncatedProteinTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/TruncatedProteinTest.java @@ -9,6 +9,8 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerTruncatedProtein; import lcsb.mapviewer.model.map.species.TruncatedProtein; public class TruncatedProteinTest { diff --git a/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlExporter.java b/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlExporter.java index 551f51b2af830f66a85934abc612ca8ae58949ed..58f19ce531271f4480fd9c2538a59d5f6cf1e959 100644 --- a/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlExporter.java +++ b/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlExporter.java @@ -156,7 +156,7 @@ public class SbgnmlXmlExporter { map.setLanguage(Language.PD.getName()); Sbgn sbgnData = new Sbgn(); - List<Species> aliases = model.getSpeciesAliases(); + List<Species> aliases = model.getSpeciesList(); for (Species a : aliases) { if (a.getComplexAlias() == null) { @@ -198,14 +198,14 @@ public class SbgnmlXmlExporter { Glyph newGlyph = new Glyph(); boolean idIsANumber = true; try { - Integer.parseInt(alias.getAliasId().substring(0, 1)); + Integer.parseInt(alias.getElementId().substring(0, 1)); } catch (NumberFormatException e) { idIsANumber = false; } if (idIsANumber) { - newGlyph.setId(RandomStringUtils.randomAlphabetic(ID_RANDOM_STRING_LENGTH).concat(alias.getAliasId())); + newGlyph.setId(RandomStringUtils.randomAlphabetic(ID_RANDOM_STRING_LENGTH).concat(alias.getElementId())); } else { - newGlyph.setId(alias.getAliasId()); + newGlyph.setId(alias.getElementId()); } newGlyph.setClazz(getGlyphClazzFromElement(alias).getClazz()); newGlyph.setLabel(getGlyphLabelFromAlias(alias)); @@ -540,7 +540,7 @@ public class SbgnmlXmlExporter { if (!uoiText.equals("")) { uoiGlyph = new Glyph(); uoiGlyph.setClazz(GlyphClazz.UNIT_OF_INFORMATION.getClazz()); - uoiGlyph.setId(alias.getAliasId().concat("uoi")); + uoiGlyph.setId(alias.getElementId().concat("uoi")); Label label = new Label(); label.setText(uoiText); @@ -720,8 +720,8 @@ public class SbgnmlXmlExporter { logger.warn("Found Phenotype being a reactant in process. That is discouraged"); } - arc.setSource(sourceTargetMap.get(reaction.getReactants().get(0).getAlias().getAliasId())); - arc.setTarget(sourceTargetMap.get(reaction.getProducts().get(0).getAlias().getAliasId())); + arc.setSource(sourceTargetMap.get(reaction.getReactants().get(0).getAlias().getElementId())); + arc.setTarget(sourceTargetMap.get(reaction.getProducts().get(0).getAlias().getElementId())); List<Point2D> pointList = reaction.getReactants().get(0).getLine().getPoints(); pointList.addAll(reaction.getProducts().get(0).getLine().getPoints()); @@ -870,13 +870,13 @@ public class SbgnmlXmlExporter { } if (node instanceof Reactant) { - arc.setSource(sourceTargetMap.get(((Reactant) node).getAlias().getAliasId())); + arc.setSource(sourceTargetMap.get(((Reactant) node).getAlias().getElementId())); arc.setTarget(sourceTargetMap.get(node.getReaction().getIdReaction().concat(".1"))); } else if (node instanceof Product) { arc.setSource(sourceTargetMap.get(node.getReaction().getIdReaction().concat(".2"))); - arc.setTarget(sourceTargetMap.get(((Product) node).getAlias().getAliasId())); + arc.setTarget(sourceTargetMap.get(((Product) node).getAlias().getElementId())); } else if (node instanceof Modifier) { - arc.setSource(sourceTargetMap.get(((Modifier) node).getAlias().getAliasId())); + arc.setSource(sourceTargetMap.get(((Modifier) node).getAlias().getElementId())); if (!node.getLine().getEndAtd().getArrowType().equals(ArrowType.NONE)) { arc.setTarget(sourceTargetMap.get(node.getReaction().getIdReaction())); } else { diff --git a/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParser.java b/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParser.java index 521f433ccfa081c74f45121bb21ea002d850d751..14c9a29591c2a33b15f6f987b4064f44cfaeabed 100644 --- a/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParser.java +++ b/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParser.java @@ -487,7 +487,7 @@ public class SbgnmlXmlParser { if (a.getSource() instanceof Glyph) { Glyph sourceGlyph = (Glyph) a.getSource(); if (GlyphClazz.fromClazz(sourceGlyph.getClazz()).equals(GlyphClazz.PHENOTYPE) - && (model.getAliasByAliasId(targetGlyph.getId()) instanceof Species)) { + && (model.getElementByElementId(targetGlyph.getId()) instanceof Species)) { try { parsePhenotypeArc(a, model); } catch (InvalidArgumentException ex) { @@ -543,7 +543,7 @@ public class SbgnmlXmlParser { Reactant reactant = new Reactant(); reactant.setReaction(reaction); Glyph source = (Glyph) a.getSource(); - reactant.setAlias(model.getAliasByAliasId(source.getId())); + reactant.setAlias(model.getElementByElementId(source.getId())); List<Point2D> reactantPointList = new ArrayList<>(); reactantPointList.add(new Point2D.Double(a.getStart().getX(), a.getStart().getY())); reactantPointList.add(new Point2D.Double(a.getStart().getX(), a.getStart().getY())); @@ -558,7 +558,7 @@ public class SbgnmlXmlParser { Product product = new Product(); product.setReaction(reaction); Glyph target = (Glyph) a.getTarget(); - product.setAlias(model.getAliasByAliasId(target.getId())); + product.setAlias(model.getElementByElementId(target.getId())); List<Point2D> productPointList = getLinePoints(a); PolylineData productLine = parseLine(a, productPointList); product.setLine(productLine); @@ -648,7 +648,7 @@ public class SbgnmlXmlParser { Compartment compartmentAlias = model.getCompartmentAliasByCompartmentAliasId(compartmentGlyph.getId()); newAlias.setParent(compartmentAlias); newAlias.setCompartmentAlias(compartmentAlias); - compartmentAlias.addAlias(newAlias); + compartmentAlias.addElement(newAlias); } else if (newAlias.getComplexAlias() == null) { // If the alias is in any compartment, assign it to that compartment for (Compartment compartmentAlias : model.getCompartmentsAliases()) { @@ -659,7 +659,7 @@ public class SbgnmlXmlParser { if (dx1 && dx2 && dy1 && dy2) { newAlias.setCompartmentAlias(compartmentAlias); newAlias.setParent(compartmentAlias); - compartmentAlias.addAlias(newAlias); + compartmentAlias.addElement(newAlias); } } } @@ -836,7 +836,7 @@ public class SbgnmlXmlParser { } parseSpecies(complexGlyph, complexSpecies, isHomodimer, model); - Complex complexAlias = (Complex) model.getAliasByAliasId(complexGlyph.getId()); + Complex complexAlias = (Complex) model.getElementByElementId(complexGlyph.getId()); for (Glyph child : complexGlyph.getGlyph()) { Species newSpecies; switch (GlyphClazz.fromClazz(child.getClazz())) { @@ -884,7 +884,7 @@ public class SbgnmlXmlParser { default: break; } - Element newAlias = model.getAliasByAliasId(child.getId()); + Element newAlias = model.getElementByElementId(child.getId()); if (newAlias != null) { newAlias.setParent(complexAlias); complexAlias.addAlias((Species) newAlias); @@ -1199,7 +1199,7 @@ public class SbgnmlXmlParser { Reactant reactant = new Reactant(); reactant.setReaction(reaction); Glyph source = (Glyph) a.getSource(); - reactant.setAlias(model.getAliasByAliasId(source.getId())); + reactant.setAlias(model.getElementByElementId(source.getId())); List<Point2D> pointList = getLinePoints(a); if (p.getReagentArcs().size() == 1) { pointList.add(getCenterPointFromProcess(p)); @@ -1220,7 +1220,7 @@ public class SbgnmlXmlParser { Product product = new Product(); product.setReaction(reaction); Glyph target = (Glyph) a.getTarget(); - product.setAlias(model.getAliasByAliasId(target.getId())); + product.setAlias(model.getElementByElementId(target.getId())); List<Point2D> pointList = getLinePoints(a); if (p.getRevProductArcs().size() >= 1) { pointList.add(0, getCenterPointFromProcess(p)); @@ -1238,7 +1238,7 @@ public class SbgnmlXmlParser { Reactant reactant = new Reactant(); reactant.setReaction(reaction); Glyph source = (Glyph) a.getTarget(); - reactant.setAlias(model.getAliasByAliasId(source.getId())); + reactant.setAlias(model.getElementByElementId(source.getId())); List<Point2D> pointList = getLinePoints(a); if (p.getRevReagentArcs().size() <= 1) { pointList.add(0, getCenterPointFromProcess(p)); @@ -1265,7 +1265,7 @@ public class SbgnmlXmlParser { } if (a.getSource() instanceof Glyph) { Glyph sourceGlyph = (Glyph) a.getSource(); - Species modifierAlias = (Species) model.getAliasByAliasId(sourceGlyph.getId()); + Species modifierAlias = (Species) model.getElementByElementId(sourceGlyph.getId()); modifier.setAlias(modifierAlias); List<Point2D> pointList = getLinePoints(a); pointList.remove(pointList.size() - 1); @@ -1459,7 +1459,7 @@ public class SbgnmlXmlParser { } Glyph sourceGlyph = (Glyph) logicArc.getSource(); - Species modifierAlias = (Species) model.getAliasByAliasId(sourceGlyph.getId()); + Species modifierAlias = (Species) model.getElementByElementId(sourceGlyph.getId()); modifier.setAlias(modifierAlias); List<Point2D> pointList = getLinePoints(logicArc); pointList.add(operatorCenterPoint); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/AbstractImageGenerator.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/AbstractImageGenerator.java index 33a4974fe471963230ab0291f1b0ae76644ed927..21cbca904fad6ab1122eebf780312336aacb4ab7 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/AbstractImageGenerator.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/AbstractImageGenerator.java @@ -562,7 +562,7 @@ public abstract class AbstractImageGenerator { // or layers if they should be solid and hide complexity behind it // draw all aliases - for (Element alias : params.getModel().getSortedAliases()) { + for (Element alias : params.getModel().getSortedSpeciesList()) { // draw only aliases that don't have parents (aren't included in any // compartment/complexes) if (alias.getParent() == null && alias instanceof Species) { @@ -657,7 +657,7 @@ public abstract class AbstractImageGenerator { try { converter.drawAlias(compAlias, graphics, compartmentParams, visibleLayouts); } catch (Exception e) { - throw new DrawingException("Problem with drawing alias \"" + compAlias.getAliasId() + "\" (name: \"" + compAlias.getName() + "\").", e); + throw new DrawingException("Problem with drawing alias \"" + compAlias.getElementId() + "\" (name: \"" + compAlias.getName() + "\").", e); } } @@ -668,7 +668,7 @@ public abstract class AbstractImageGenerator { return; } List<Element> result = new ArrayList<Element>(); - result.addAll(compAlias.getAliases()); + result.addAll(compAlias.getElements()); Collections.sort(result, Element.SIZE_COMPARATOR); // draw all children of this compartment @@ -739,7 +739,7 @@ public abstract class AbstractImageGenerator { try { converter.drawAlias(alias, graphics, new ConverterParams().scale(customScale).textCentered(rescale).level(level).sbgnFormat(sbgnFormat), visibleLayouts); } catch (Exception e) { - throw new DrawingException("Problem with drawing alias \"" + alias.getAliasId() + "\".", e); + throw new DrawingException("Problem with drawing alias \"" + alias.getElementId() + "\".", e); } // if the alias is a complex alias then we may want to draw children diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/AliasConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/AliasConverter.java index a60ff0cd60ccedf6eacf9e2c767a767f7ae3abd7..1a16acb1e47488a4f637628e0099d9f5167b4996 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/AliasConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/AliasConverter.java @@ -173,7 +173,7 @@ public class AliasConverter implements IAliasConverter<Element> { // if we don't know which converter to use then throw an exception if (aliasConverter == null) { - throw new InvalidArgumentException("Unknown converter for class: " + alias.getClass() + ". Alias id: " + alias.getAliasId()); + throw new InvalidArgumentException("Unknown converter for class: " + alias.getClass() + ". Alias id: " + alias.getElementId()); } } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/CompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/CompartmentConverter.java index cf4088bb9b598b469d10bcf949250915b85267d9..0c13be576a94d63084d3ce6c71666edb38080af4 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/CompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/CompartmentConverter.java @@ -88,7 +88,7 @@ public abstract class CompartmentConverter<T extends Compartment> implements IAl public void drawText(final T alias, final Graphics2D graphics, final ConverterParams params) { if (alias.getWidth() < Configuration.EPSILON || alias.getHeight() < Configuration.EPSILON) { throw new InvalidArgumentException( - "Dimension of the alias must be bigger than 0. Alias id: " + alias.getAliasId() + " (name: \"" + alias.getName() + "\")"); + "Dimension of the alias must be bigger than 0. Alias id: " + alias.getElementId() + " (name: \"" + alias.getName() + "\")"); } Rectangle2D border = alias.getBorder(); if (params.getLevel() >= alias.getVisibilityLevel() && params.getLevel() < alias.getTransparencyLevel()) { diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/placefinder/AllPlaceFinderTest.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/placefinder/AllPlaceFinderTest.java index d9d071ebc1fbdabf9695f489a31c1f9cc18e472d..aee2aa52a3ae0a7e718e3d171ea7acf1105b0ed2 100644 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/placefinder/AllPlaceFinderTest.java +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/placefinder/AllPlaceFinderTest.java @@ -119,8 +119,7 @@ public class AllPlaceFinderTest { } private Compartment createCompartmentAlias(double x, double y, double width, double height) { - Compartment result = new SquareCompartment(); - result.setAliasId("" + id++); + Compartment result = new SquareCompartment("" + id++); result.setX(x); result.setY(y); result.setWidth(width); diff --git a/converter/src/main/java/lcsb/mapviewer/converter/ComplexZipConverter.java b/converter/src/main/java/lcsb/mapviewer/converter/ComplexZipConverter.java index ab1c2c2f808e7bc95b6827ad0fb5e08356135bb0..b330bbf2b873457ffa80bcce66ca2b57cefad4f0 100644 --- a/converter/src/main/java/lcsb/mapviewer/converter/ComplexZipConverter.java +++ b/converter/src/main/java/lcsb/mapviewer/converter/ComplexZipConverter.java @@ -241,13 +241,13 @@ public class ComplexZipConverter<T extends IConverter> { } else if (toModel == null) { throw new InvalidArgumentException("Mapping file references to " + toName + " submodel. But such model doesn't exist"); } - Element source = fromModel.getAliasByAliasId(fromAlias.getName()); + Element source = fromModel.getElementByElementId(fromAlias.getName()); if (source == null) { throw new InvalidArgumentException("Mapping file references to element with alias: " + fromAlias.getName() + ". But such element doesn't exist"); } Element dest = null; if (!(toAlias instanceof Complex)) { - dest = fromModel.getAliasByAliasId(toAlias.getName()); + dest = fromModel.getElementByElementId(toAlias.getName()); } SubmodelType type = SubmodelType.UNKNOWN; if (fromAlias instanceof Protein) { diff --git a/converter/src/test/java/lcsb/mapviewer/converter/ComplexZipConverterTest.java b/converter/src/test/java/lcsb/mapviewer/converter/ComplexZipConverterTest.java index 84e13e4ee8f0a13d1dcaacf0ab3988c9da47bb2d..62f7709fc9877db178245bb43bee2cd50f6773f1 100644 --- a/converter/src/test/java/lcsb/mapviewer/converter/ComplexZipConverterTest.java +++ b/converter/src/test/java/lcsb/mapviewer/converter/ComplexZipConverterTest.java @@ -234,20 +234,20 @@ public class ComplexZipConverterTest { assertNotNull(s2Model); assertNotNull(s3Model); - Element al1 = model.getAliasByAliasId("sa1"); + Element al1 = model.getElementByElementId("sa1"); assertNotNull(al1.getSubmodel()); assertEquals(SubmodelType.DOWNSTREAM_TARGETS, al1.getSubmodel().getType()); assertEquals(s1Model, al1.getSubmodel().getSubmodel().getModel()); - Element al2 = model.getAliasByAliasId("sa2"); + Element al2 = model.getElementByElementId("sa2"); assertNull(al2.getSubmodel()); - Element al4 = model.getAliasByAliasId("sa4"); + Element al4 = model.getElementByElementId("sa4"); assertNotNull(al4.getSubmodel()); assertEquals(SubmodelType.PATHWAY, al4.getSubmodel().getType()); assertEquals(s2Model, al4.getSubmodel().getSubmodel().getModel()); - Element s1_al1 = s1Model.getAliasByAliasId("sa1"); + Element s1_al1 = s1Model.getElementByElementId("sa1"); assertNotNull(s1_al1.getSubmodel()); assertEquals(SubmodelType.DOWNSTREAM_TARGETS, s1_al1.getSubmodel().getType()); assertEquals(s3Model, s1_al1.getSubmodel().getSubmodel().getModel()); @@ -294,20 +294,20 @@ public class ComplexZipConverterTest { assertNotNull(s2Model); assertNotNull(s3Model); - Element al1 = model.getAliasByAliasId("sa1"); + Element al1 = model.getElementByElementId("sa1"); assertNotNull(al1.getSubmodel()); assertEquals(SubmodelType.DOWNSTREAM_TARGETS, al1.getSubmodel().getType()); assertEquals(s1Model, al1.getSubmodel().getSubmodel().getModel()); - Element al2 = model.getAliasByAliasId("sa2"); + Element al2 = model.getElementByElementId("sa2"); assertNull(al2.getSubmodel()); - Element al4 = model.getAliasByAliasId("sa4"); + Element al4 = model.getElementByElementId("sa4"); assertNotNull(al4.getSubmodel()); assertEquals(SubmodelType.PATHWAY, al4.getSubmodel().getType()); assertEquals(s2Model, al4.getSubmodel().getSubmodel().getModel()); - Element s1_al1 = s1Model.getAliasByAliasId("sa1"); + Element s1_al1 = s1Model.getElementByElementId("sa1"); assertNotNull(s1_al1.getSubmodel()); assertEquals(SubmodelType.DOWNSTREAM_TARGETS, s1_al1.getSubmodel().getType()); assertEquals(s3Model, s1_al1.getSubmodel().getSubmodel().getModel()); diff --git a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/ElementDetailsPanel.java b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/ElementDetailsPanel.java index 0cf93582a16c2891cded9d1ff4ae742d28ff9fdf..06f4b6fbf9ae972da28ac8854e79874495de25ac 100644 --- a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/ElementDetailsPanel.java +++ b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/ElementDetailsPanel.java @@ -588,13 +588,13 @@ public class ElementDetailsPanel extends JPanel { add(idLabel, createLayoutConstraints(0, row)); add(idText, createLayoutConstraints(1, row)); - idText.setText(alias.getAliasId()); + idText.setText(alias.getElementId()); row++; add(complexLabel, createLayoutConstraints(0, row)); add(complexText, createLayoutConstraints(1, row)); if (alias.getParent() instanceof Complex) { - complexText.setText(alias.getParent().getAliasId()); + complexText.setText(alias.getParent().getElementId()); } else { complexText.setText("N/A"); } @@ -603,7 +603,7 @@ public class ElementDetailsPanel extends JPanel { add(compartmentLabel, createLayoutConstraints(0, row)); add(compartmentText, createLayoutConstraints(1, row)); if (alias.getCompartmentAlias() instanceof Compartment) { - compartmentText.setText(alias.getCompartmentAlias().getAliasId()); + compartmentText.setText(alias.getCompartmentAlias().getElementId()); } else { compartmentText.setText("N/A"); } diff --git a/minerva-big/51/allMis1.2bit b/minerva-big/51/allMis1.2bit deleted file mode 100644 index 92e8f1b7af0a4207a0453799ae70b5f42723e422..0000000000000000000000000000000000000000 Binary files a/minerva-big/51/allMis1.2bit and /dev/null differ diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java index bdc922d6a76e803d76a65760b70a55735871e573..527c666146188e44350644fd5328f1a1a5b1a55b 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java @@ -264,7 +264,7 @@ public class ColorModelCommand extends ModelCommand { for (Element alias : model2.getAliases()) { if (match(alias, schema)) { if (result.get(alias) != null && !result.get(alias).getNormalizedColor().equals(Color.WHITE)) { - throw new InvalidColorSchemaException("Alias " + alias.getAliasId() + " is colored by more than one rule."); + throw new InvalidColorSchemaException("Alias " + alias.getElementId() + " is colored by more than one rule."); } result.put(alias, schema); } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/CopyCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/CopyCommand.java index f9613dda3f11f1e5fdabc3f5a9204637ff00785d..70253198c1036db13ecceec2beb3c28ac92a889b 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/CopyCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/CopyCommand.java @@ -151,11 +151,11 @@ public class CopyCommand extends NewModelCommand { // copy information about original alias if (connection.getFromAlias() != null) { - connection.setFromAlias(modelCopy.getAliasByAliasId(connection.getFromAlias().getAliasId())); + connection.setFromAlias(modelCopy.getElementByElementId(connection.getFromAlias().getElementId())); } // copy information about reference alias if (connection.getToAlias() != null) { - connection.setToAlias(modelCopy.getAliasByAliasId(connection.getToAlias().getAliasId())); + connection.setToAlias(modelCopy.getElementByElementId(connection.getToAlias().getElementId())); } } } @@ -177,7 +177,7 @@ public class CopyCommand extends NewModelCommand { for (Element alias : model.getAliases()) { if (alias instanceof Compartment) { Compartment copy = ((Compartment) alias).copy(); - copy.getAliases().clear(); + copy.getElements().clear(); result.addAlias(copy); } @@ -197,12 +197,12 @@ public class CopyCommand extends NewModelCommand { result.addAlias(copy); if (ca != null) { - ca = result.getCompartmentAliasByCompartmentAliasId(ca.getAliasId()); + ca = result.getCompartmentAliasByCompartmentAliasId(ca.getElementId()); copy.setCompartmentAlias(ca); } if (parent instanceof Compartment) { ca = (Compartment) parent; - ca = result.getCompartmentAliasByCompartmentAliasId(ca.getAliasId()); + ca = result.getCompartmentAliasByCompartmentAliasId(ca.getElementId()); copy.setParent(ca); } } else if (alias instanceof Compartment) { @@ -348,7 +348,7 @@ public class CopyCommand extends NewModelCommand { private void updateReactionReferences(Reaction reaction, Model model) { reaction.setModel(model); for (ReactionNode rNode : reaction.getReactionNodes()) { - rNode.setAlias(model.getAliasByAliasId(rNode.getAlias().getAliasId())); + rNode.setAlias(model.getElementByElementId(rNode.getAlias().getElementId())); } } @@ -367,42 +367,42 @@ public class CopyCommand extends NewModelCommand { private void updateAliasReferences(Element alias, Model model, Model originalModel) { if (alias instanceof Compartment) { Compartment compartmentAlias = (Compartment) alias; - Compartment original = originalModel.getCompartmentAliasByCompartmentAliasId(alias.getAliasId()); - for (Element a : original.getAliases()) { - compartmentAlias.addAlias(model.getAliasByAliasId(a.getAliasId())); + Compartment original = originalModel.getCompartmentAliasByCompartmentAliasId(alias.getElementId()); + for (Element a : original.getElements()) { + compartmentAlias.addElement(model.getElementByElementId(a.getElementId())); } } if (alias instanceof Complex) { Complex ca = (Complex) alias; for (int i = 0; i < ca.getAliases().size(); i++) { - Species newAlias = (Species) model.getAliasByAliasId(ca.getAliases().get(i).getAliasId()); + Species newAlias = (Species) model.getElementByElementId(ca.getAliases().get(i).getElementId()); ca.getAliases().set(i, newAlias); } } if (alias instanceof Species) { - Species originalAlias = (Species) originalModel.getAliasByAliasId(alias.getAliasId()); + Species originalAlias = (Species) originalModel.getElementByElementId(alias.getElementId()); Species sa = (Species) alias; if (sa.getComplexAlias() != null) { - sa.setComplexAlias((Complex) model.getAliasByAliasId(sa.getComplexAlias().getAliasId())); + sa.setComplexAlias((Complex) model.getElementByElementId(sa.getComplexAlias().getElementId())); } if (originalAlias.getParent() != null) { Element parent = null; - parent = model.getAliasByAliasId(originalAlias.getParent().getAliasId()); + parent = model.getElementByElementId(originalAlias.getParent().getElementId()); sa.setParent(parent); } } if (alias.getParent() != null) { - alias.setParent(model.getAliasByAliasId(alias.getParent().getAliasId())); + alias.setParent(model.getElementByElementId(alias.getParent().getElementId())); } alias.setModel(model); if (alias.getCompartmentAlias() != null) { - alias.setCompartmentAlias(model.getCompartmentAliasByCompartmentAliasId(alias.getCompartmentAlias().getAliasId())); + alias.setCompartmentAlias(model.getCompartmentAliasByCompartmentAliasId(alias.getCompartmentAlias().getElementId())); } } } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/CreateHierarchyCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/CreateHierarchyCommand.java index 897797cda664ecdce321f2db5b0c75ab9309b389..98ff78e39a5e89a58ebbf5f04162ffe6bc491feb 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/CreateHierarchyCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/CreateHierarchyCommand.java @@ -129,7 +129,7 @@ public class CreateHierarchyCommand extends ModelCommand { Set<PathwayCompartment> toRemove = new HashSet<>(); for (Compartment alias : getModel().getCompartmentsAliases()) { alias.setParent(null); - alias.getAliases().clear(); + alias.getElements().clear(); if (alias instanceof PathwayCompartment) { toRemove.add((PathwayCompartment) alias); } @@ -199,7 +199,7 @@ public class CreateHierarchyCommand extends ModelCommand { } } if (alias instanceof Compartment) { - for (Element specAlias : ((Compartment) alias).getAliases()) { + for (Element specAlias : ((Compartment) alias).getElements()) { if (list.contains(specAlias)) { throw new InvalidStateException("Some aliases are in few Structures"); } @@ -223,8 +223,8 @@ public class CreateHierarchyCommand extends ModelCommand { for (Compartment compartment2 : getModel().getCompartmentsAliases()) { if (!compartment1.equals(compartment2)) { if (compartment1.contains(compartment2)) { - Set<Element> duplicates = compartment2.getAliases(); - compartment1.getAliases().removeAll(duplicates); + Set<Element> duplicates = compartment2.getElements(); + compartment1.getElements().removeAll(duplicates); } } } @@ -267,7 +267,7 @@ public class CreateHierarchyCommand extends ModelCommand { int maxVisibilityLevel = Integer.MAX_VALUE; double rate = computeRate(compartment, Configuration.MAX_VISIBLE_OBJECT_SIZE); maxVisibilityLevel = (int) ((int) Math.ceil(Math.log(rate)) / LOG_4); - for (Element child : compartment.getAliases()) { + for (Element child : compartment.getElements()) { maxVisibilityLevel = Math.min(maxVisibilityLevel, child.getVisibilityLevel()); } if (maxVisibilityLevel >= zoomLevels) { @@ -277,7 +277,7 @@ public class CreateHierarchyCommand extends ModelCommand { maxVisibilityLevel = 1; } compartment.setTransparencyLevel(maxVisibilityLevel); - for (Element child : compartment.getAliases()) { + for (Element child : compartment.getElements()) { child.setVisibilityLevel(compartment.getTransparencyLevel()); } } @@ -335,12 +335,12 @@ public class CreateHierarchyCommand extends ModelCommand { for (Element compartment : sortedAliases) { if (compartment instanceof Compartment) { Set<Element> removable = new HashSet<Element>(); - for (Element alias : ((Compartment) compartment).getAliases()) { + for (Element alias : ((Compartment) compartment).getElements()) { if (alias.getParent() != compartment) { removable.add(alias); } } - ((Compartment) compartment).getAliases().removeAll(removable); + ((Compartment) compartment).getElements().removeAll(removable); } } } @@ -364,7 +364,7 @@ public class CreateHierarchyCommand extends ModelCommand { if (alias.getParent() == null) { for (Element compartment : sortedAliases) { if (compartment instanceof Compartment) { - if (((Compartment) compartment).getAliases().contains(alias)) { + if (((Compartment) compartment).getElements().contains(alias)) { alias.setParent(compartment); } } @@ -392,13 +392,13 @@ public class CreateHierarchyCommand extends ModelCommand { for (Compartment alias : getModel().getCompartmentsAliases()) { for (Compartment alias2 : getModel().getCompartmentsAliases()) { if (alias.contains(alias2)) { - alias.addAlias(alias2); + alias.addElement(alias2); } } for (Element alias2 : getModel().getAliases()) { if (!(alias2 instanceof Compartment)) { if (alias.contains(alias2)) { - alias.addAlias(alias2); + alias.addElement(alias2); } } } @@ -448,7 +448,7 @@ public class CreateHierarchyCommand extends ModelCommand { for (Element complex : getModel().getAliases()) { if (complex instanceof Complex) { List<Species> duplicates = ((Complex) complex).getAliases(); - compartment.getAliases().removeAll(duplicates); + compartment.getElements().removeAll(duplicates); } } } diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java b/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java index b56126bae3cea9d3e37133fabd74f2e8824b3b34..e4972598fac3f1912be32d96b162f0e87a08d37e 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java @@ -60,7 +60,7 @@ public class ColorModelCommandTest extends CommandTestFunctions { schemas.add(schema); ColorModelCommand factory = new ColorModelCommand(coloredModel, schemas); - assertFalse(Color.RED.equals(coloredModel.getAliasByAliasId("sa14").getColor())); + assertFalse(Color.RED.equals(coloredModel.getElementByElementId("sa14").getColor())); factory.execute(); @@ -68,7 +68,7 @@ public class ColorModelCommandTest extends CommandTestFunctions { assertFalse(comparator.compare(model, coloredModel) == 0); - assertEquals(Color.RED, coloredModel.getAliasByAliasId("sa14").getColor()); + assertEquals(Color.RED, coloredModel.getElementByElementId("sa14").getColor()); } catch (Exception e) { e.printStackTrace(); @@ -221,8 +221,8 @@ public class ColorModelCommandTest extends CommandTestFunctions { Model coloredModel2 = coloredModel.getSubmodelConnections().iterator().next().getSubmodel().getModel(); Model coloredModel3 = coloredModel.getSubmodelByConnectionName("BLA"); - assertFalse(coloredModel2.getAliasByAliasId("sa2").getColor().equals(model2.getAliasByAliasId("sa2").getColor())); - assertFalse(coloredModel3.getAliasByAliasId("sa2").getColor().equals(model2.getAliasByAliasId("sa2").getColor())); + assertFalse(coloredModel2.getElementByElementId("sa2").getColor().equals(model2.getElementByElementId("sa2").getColor())); + assertFalse(coloredModel3.getElementByElementId("sa2").getColor().equals(model2.getElementByElementId("sa2").getColor())); } catch (Exception e) { e.printStackTrace(); diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/CopyCommandTest.java b/model-command/src/test/java/lcsb/mapviewer/commands/CopyCommandTest.java index 0789519d9cfbda3ac706411cf1620d6f3b115687..6336703fe6bec7af4721530baeaa0f2fcffeea0a 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/CopyCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/CopyCommandTest.java @@ -206,7 +206,7 @@ public class CopyCommandTest extends CommandTestFunctions { Model model3 = getModel(); model3.setNotes("ASDSA"); model.addSubmodelConnection(new ModelSubmodelConnection(model3, SubmodelType.DOWNSTREAM_TARGETS, "name b")); - Element alias = model2.getAliasByAliasId("a_id"); + Element alias = model2.getElementByElementId("a_id"); alias.setSubmodel(new AliasSubmodelConnection(model3, SubmodelType.DOWNSTREAM_TARGETS, "name c")); Model copy = new CopyCommand(model2).execute(); @@ -227,7 +227,7 @@ public class CopyCommandTest extends CommandTestFunctions { model2.setNotes("ASDSA2"); model.addSubmodelConnection(new ModelSubmodelConnection(model2, SubmodelType.DOWNSTREAM_TARGETS)); - model.getAliasByAliasId("a_id").setSubmodel(new AliasSubmodelConnection(model2, SubmodelType.DOWNSTREAM_TARGETS)); + model.getElementByElementId("a_id").setSubmodel(new AliasSubmodelConnection(model2, SubmodelType.DOWNSTREAM_TARGETS)); Model copy = new CopyCommand(model).execute(); ModelComparator comparator = new ModelComparator(); @@ -263,7 +263,7 @@ public class CopyCommandTest extends CommandTestFunctions { Model model2 = getModel(); model2.setNotes("ASDSA2"); - model.getAliasByAliasId("a_id").setSubmodel(new AliasSubmodelConnection(model2, SubmodelType.DOWNSTREAM_TARGETS)); + model.getElementByElementId("a_id").setSubmodel(new AliasSubmodelConnection(model2, SubmodelType.DOWNSTREAM_TARGETS)); try { new CopyCommand(model).execute(); fail("Exception expected"); diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/CreateHierarchyCommandTest.java b/model-command/src/test/java/lcsb/mapviewer/commands/CreateHierarchyCommandTest.java index f6f07bd0f357700ace18852efd68fca89495ced4..def0925b156ea878f3d9249cc7b42bc93e586b35 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/CreateHierarchyCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/CreateHierarchyCommandTest.java @@ -44,7 +44,7 @@ public class CreateHierarchyCommandTest extends CommandTestFunctions { new CreateHierarchyCommand(model, 8, 80).execute(); - Element alias = model.getAliasByAliasId("sa5033"); + Element alias = model.getElementByElementId("sa5033"); Set<Element> parents = new HashSet<Element>(); while (alias.getParent() instanceof Complex) { @@ -136,7 +136,7 @@ public class CreateHierarchyCommandTest extends CommandTestFunctions { for (Element alias : model.getAliases()) { if (alias.getParent() == null) { - assertTrue("Alias " + alias.getAliasId() + " is not visible at levels highers than " + alias.getVisibilityLevel(), alias.getVisibilityLevel() <= 1); + assertTrue("Alias " + alias.getElementId() + " is not visible at levels highers than " + alias.getVisibilityLevel(), alias.getVisibilityLevel() <= 1); } } @@ -158,7 +158,7 @@ public class CreateHierarchyCommandTest extends CommandTestFunctions { for (Element alias : model.getAliases()) { assertTrue( - "Alias " + alias.getAliasId() + " is not visible even at the bottom level (visibility: " + alias.getVisibilityLevel() + ") ", + "Alias " + alias.getElementId() + " is not visible even at the bottom level (visibility: " + alias.getVisibilityLevel() + ") ", alias.getVisibilityLevel() <= levels); } @@ -173,7 +173,7 @@ public class CreateHierarchyCommandTest extends CommandTestFunctions { Model model; try { model = getModelForFile("testFiles/problematic/compact_complex_view_problem.xml", false); - Element alias = model.getAliasByAliasId("sa1"); + Element alias = model.getElementByElementId("sa1"); Object parent1 = alias.getParent(); new CreateHierarchyCommand(model, 3, 16).execute(); Object parent2 = alias.getParent(); @@ -218,7 +218,7 @@ public class CreateHierarchyCommandTest extends CommandTestFunctions { } for (Compartment alias : model.getCompartmentsAliases()) { assertNull(alias.getParent()); - assertTrue(alias.getAliases().isEmpty()); + assertTrue(alias.getElements().isEmpty()); } } catch (Exception e) { diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/MoveElementsCommandTest.java b/model-command/src/test/java/lcsb/mapviewer/commands/MoveElementsCommandTest.java index 51eeefd2e5efb948f5382a31313708def6e85e18..8b7637362c677b1543c644ba5f42c9a39cb41b6a 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/MoveElementsCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/MoveElementsCommandTest.java @@ -38,8 +38,8 @@ public class MoveElementsCommandTest extends CommandTestFunctions { try { Model model = getModelForFile("testFiles/spliting_test_Case.xml", false); Model model2 = getModelForFile("testFiles/spliting_test_Case.xml", false); - Element alias = model.getAliasByAliasId("sa2"); - Element alias2 = model.getAliasByAliasId("sa1"); + Element alias = model.getElementByElementId("sa2"); + Element alias2 = model.getElementByElementId("sa1"); double anotherAliasX = alias2.getX(); double anotherAliasY = alias2.getY(); @@ -69,7 +69,7 @@ public class MoveElementsCommandTest extends CommandTestFunctions { assertEquals(anotherAliasY, alias2.getY(), Configuration.EPSILON); list = new ArrayList<>(); - list.add(model2.getAliasByAliasId("sa2")); + list.add(model2.getElementByElementId("sa2")); MoveElementsCommand moveCommand2 = new MoveElementsCommand(model2, list, dx, dy); moveCommand2.execute(); @@ -106,8 +106,8 @@ public class MoveElementsCommandTest extends CommandTestFunctions { try { Model model = getModelForFile("testFiles/spliting_test_Case.xml", false); Model model2 = getModelForFile("testFiles/spliting_test_Case.xml", false); - Element alias = model.getAliasByAliasId("sa1"); - Element alias2 = model.getAliasByAliasId("sa2"); + Element alias = model.getElementByElementId("sa1"); + Element alias2 = model.getElementByElementId("sa2"); double anotherAliasX = alias2.getX(); double anotherAliasY = alias2.getY(); Reaction reaction = model.getReactionByReactionId("re1"); @@ -138,7 +138,7 @@ public class MoveElementsCommandTest extends CommandTestFunctions { assertEquals(anotherAliasY, alias2.getY(), Configuration.EPSILON); list = new ArrayList<>(); - list.add(model2.getAliasByAliasId("sa1")); + list.add(model2.getElementByElementId("sa1")); MoveElementsCommand moveCommand2 = new MoveElementsCommand(model2, list, dx, dy); moveCommand2.execute(); @@ -155,7 +155,7 @@ public class MoveElementsCommandTest extends CommandTestFunctions { public void testMoveReaction() throws Exception { try { Model model = getModelForFile("testFiles/spliting_test_Case.xml", false); - Element alias2 = model.getAliasByAliasId("sa1"); + Element alias2 = model.getElementByElementId("sa1"); double anotherAliasX = alias2.getX(); double anotherAliasY = alias2.getY(); Reaction reaction = model.getReactionByReactionId("re1"); @@ -196,7 +196,7 @@ public class MoveElementsCommandTest extends CommandTestFunctions { try { Model model = getModelForFile("testFiles/spliting_test_Case.xml", false); Model model2 = getModelForFile("testFiles/spliting_test_Case.xml", false); - Element alias = model.getAliasByAliasId("sa2"); + Element alias = model.getElementByElementId("sa2"); List<Object> list = new ArrayList<>(); list.add(alias); @@ -234,7 +234,7 @@ public class MoveElementsCommandTest extends CommandTestFunctions { public void testGetAffectedRegion() throws Exception { try { Model model = getModelForFile("testFiles/spliting_test_Case.xml", false); - Element alias = model.getAliasByAliasId("sa2"); + Element alias = model.getElementByElementId("sa2"); List<Object> list = new ArrayList<>(); list.add(alias); diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/SubModelCommandTest.java b/model-command/src/test/java/lcsb/mapviewer/commands/SubModelCommandTest.java index b2385adea314c0934aec81a3a36ed25a7e334557..b455827cef3e09d575cd31e991ff06d3eee70894 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/SubModelCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/SubModelCommandTest.java @@ -92,8 +92,8 @@ public class SubModelCommandTest extends CommandTestFunctions { new MoveCommand(copy, dx, dy).execute(); - assertEquals(model.getAliasByAliasId("sa3").getCenterX(), copy.getAliasByAliasId("sa3").getCenterX() - dx, EPSILON); - assertEquals(model.getAliasByAliasId("sa3").getCenterY(), copy.getAliasByAliasId("sa3").getCenterY() - dy, EPSILON); + assertEquals(model.getElementByElementId("sa3").getCenterX(), copy.getElementByElementId("sa3").getCenterX() - dx, EPSILON); + assertEquals(model.getElementByElementId("sa3").getCenterY(), copy.getElementByElementId("sa3").getCenterY() - dy, EPSILON); assertEquals(model.getReactionByReactionId("re3").getLines().get(0).getX2(), copy.getReactionByReactionId("re3").getLines().get(0).getX2() - dx, EPSILON); assertEquals(model.getReactionByReactionId("re3").getLines().get(0).getY2(), copy.getReactionByReactionId("re3").getLines().get(0).getY2() - dy, EPSILON); diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementAbbreviationCommandTest.java b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementAbbreviationCommandTest.java index e5c9676f368955ad322a99edde21c9f10d5c3370..3d571c0d55ebb22a2e8a7c2a3bf7efaf54b9d1fb 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementAbbreviationCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementAbbreviationCommandTest.java @@ -28,7 +28,7 @@ public class ChangeElementAbbreviationCommandTest extends CommandTestFunctions{ @Test public void testChangeAliasAbbreviation() throws Exception { try { - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); ChangeElementAbbreviationCommand command = new ChangeElementAbbreviationCommand(model, alias, "test"); assertFalse("test".equalsIgnoreCase(alias.getAbbreviation())); command.execute(); @@ -44,7 +44,7 @@ public class ChangeElementAbbreviationCommandTest extends CommandTestFunctions{ public void testUndo() throws Exception { try { Model model2 = createSimpleModel(); - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); // models should be equal before move assertEquals(0, modelComparator.compare(model, model2)); diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementColorCommandTest.java b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementColorCommandTest.java index 421f6c59644d11f5f630170782d5a0b966b39c43..f42942a0dca94ef319c04156d9143b5e75c184b7 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementColorCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementColorCommandTest.java @@ -31,7 +31,7 @@ public class ChangeElementColorCommandTest extends CommandTestFunctions { @Test public void testChangeAliasColor() throws Exception { try { - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); ChangeElementColorCommand command = new ChangeElementColorCommand(model, alias, Color.PINK); assertFalse(alias.getColor().equals(Color.PINK)); command.execute(); @@ -47,7 +47,7 @@ public class ChangeElementColorCommandTest extends CommandTestFunctions { public void testUndo() throws Exception { try { Model model2 = createSimpleModel(); - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); // models should be equal before move assertEquals(0, modelComparator.compare(model, model2)); diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementFontSizeCommandTest.java b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementFontSizeCommandTest.java index df14ff8a59075da16d23f9b287e985f80b1eae8c..99570345e33119c7f3e4fd6cd53fafa5cd1c185d 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementFontSizeCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementFontSizeCommandTest.java @@ -28,7 +28,7 @@ public class ChangeElementFontSizeCommandTest extends CommandTestFunctions{ @Test public void testChangeAliasFontSize() throws Exception { try { - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); ChangeElementFontSizeCommand command = new ChangeElementFontSizeCommand(model, alias, 15.0); assertFalse(alias.getFontSize().equals(15.0)); command.execute(); @@ -44,7 +44,7 @@ public class ChangeElementFontSizeCommandTest extends CommandTestFunctions{ public void testUndo() throws Exception { try { Model model2 = createSimpleModel(); - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); // models should be equal before move assertEquals(0, modelComparator.compare(model, model2)); diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementFormerSymbolCommandTest.java b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementFormerSymbolCommandTest.java index 73272e8c961b8950d9853a61b63ead32fda7a992..acebff81a69d55dfbaf9bf7a4a3e95b3be2e35d6 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementFormerSymbolCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementFormerSymbolCommandTest.java @@ -29,7 +29,7 @@ public class ChangeElementFormerSymbolCommandTest extends CommandTestFunctions { @Test public void testChangeToTheSame() throws Exception { try { - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); ChangeElementFormerSymbolCommand command = new ChangeElementFormerSymbolCommand(model, alias, "f_symbol","f_symbol"); assertTrue(alias.getFormerSymbols().contains("f_symbol")); command.execute(); diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementFormulaCommandTest.java b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementFormulaCommandTest.java index 165351ea16ce3e1c15aba80402238694303cb76e..3417b371cc8493b5de3a916a85ada3f16b27ece9 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementFormulaCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementFormulaCommandTest.java @@ -28,7 +28,7 @@ public class ChangeElementFormulaCommandTest extends CommandTestFunctions{ @Test public void testChangeAliasFormula() throws Exception { try { - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); ChangeElementFormulaCommand command = new ChangeElementFormulaCommand(model, alias, "test"); assertFalse("test".equals(alias.getFormula())); command.execute(); @@ -44,7 +44,7 @@ public class ChangeElementFormulaCommandTest extends CommandTestFunctions{ public void testUndo() throws Exception { try { Model model2 = createSimpleModel(); - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); // models should be equal before move assertEquals(0, modelComparator.compare(model, model2)); diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementFullNameCommandTest.java b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementFullNameCommandTest.java index 1f87e26d860a0af84647e12adf8d33843e68b7eb..2be5eb71b5e255c8a3d859aca03101fc5aa435b4 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementFullNameCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementFullNameCommandTest.java @@ -28,7 +28,7 @@ public class ChangeElementFullNameCommandTest extends CommandTestFunctions{ @Test public void testChangeAliasFullName() throws Exception { try { - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); ChangeElementFullNameCommand command = new ChangeElementFullNameCommand(model, alias, "test"); assertFalse("test".equals(alias.getFullName())); command.execute(); @@ -44,7 +44,7 @@ public class ChangeElementFullNameCommandTest extends CommandTestFunctions{ public void testUndo() throws Exception { try { Model model2 = createSimpleModel(); - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); // models should be equal before move assertEquals(0, modelComparator.compare(model, model2)); diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementMiriamDataCommandTest.java b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementMiriamDataCommandTest.java index 89a69905b95bb45a92027a42a953e03b0313ee76..423ae611213d3b9344bffe7765979aacef0d4072 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementMiriamDataCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementMiriamDataCommandTest.java @@ -28,7 +28,7 @@ public class ChangeElementMiriamDataCommandTest extends CommandTestFunctions { @Test public void testWithoutChange() throws Exception { try { - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); MiriamData md = new MiriamData(MiriamType.HGNC_SYMBOL, "SNCA"); MiriamData md2 = new MiriamData(MiriamType.HGNC_SYMBOL, "SNCA"); alias.addMiriamData(md); @@ -46,7 +46,7 @@ public class ChangeElementMiriamDataCommandTest extends CommandTestFunctions { @Test public void testInvalidChange() throws Exception { try { - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); MiriamData md = new MiriamData(MiriamType.HGNC_SYMBOL, "SNCA"); MiriamData md2 = new MiriamData(MiriamType.HGNC_SYMBOL, "SNCA2"); alias.addMiriamData(md); @@ -69,7 +69,7 @@ public class ChangeElementMiriamDataCommandTest extends CommandTestFunctions { @Test public void testChange() throws Exception { try { - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); MiriamData md = new MiriamData(MiriamType.HGNC_SYMBOL, "SNCA"); MiriamData md2 = new MiriamData(MiriamType.HGNC_SYMBOL, "SNCA2"); MiriamData md3 = new MiriamData(MiriamType.HGNC_SYMBOL, "SNCA"); diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementNameCommandTest.java b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementNameCommandTest.java index 4f1512b344269bd76e50fbd67830c301781f186b..c4a801bdd4080ac6842e359d1888803fa2ff5643 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementNameCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementNameCommandTest.java @@ -30,7 +30,7 @@ public class ChangeElementNameCommandTest extends CommandTestFunctions { @Test public void testChangeAliasName() throws Exception { try { - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); ChangeElementNameCommand command = new ChangeElementNameCommand(model, alias, "test"); assertFalse(alias.getName().equalsIgnoreCase("test")); command.execute(); @@ -46,7 +46,7 @@ public class ChangeElementNameCommandTest extends CommandTestFunctions { public void testUndo() throws Exception { try { Model model2 = createSimpleModel(); - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); // models should be equal before move assertEquals(0, modelComparator.compare(model, model2)); diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementNotesCommandTest.java b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementNotesCommandTest.java index 1dc3eb230d4b6525ac4ee176d02c527c79d15bf9..e14108358e8adec1fcfdcdfe4231f6ec27ae089e 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementNotesCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementNotesCommandTest.java @@ -28,7 +28,7 @@ public class ChangeElementNotesCommandTest extends CommandTestFunctions{ @Test public void testChangeAliasNotes() throws Exception { try { - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); ChangeElementNotesCommand command = new ChangeElementNotesCommand(model, alias, "test"); assertFalse("test".equals(alias.getNotes())); command.execute(); @@ -44,7 +44,7 @@ public class ChangeElementNotesCommandTest extends CommandTestFunctions{ public void testUndo() throws Exception { try { Model model2 = createSimpleModel(); - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); // models should be equal before move assertEquals(0, modelComparator.compare(model, model2)); diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementSymbolCommandTest.java b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementSymbolCommandTest.java index cae8426700e76b557776b1b4fb550b620e691c9e..091ca65d9bade04bf45e68d2ca4a10e0fc631f96 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementSymbolCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementSymbolCommandTest.java @@ -28,7 +28,7 @@ public class ChangeElementSymbolCommandTest extends CommandTestFunctions{ @Test public void testChangeAliasSymbol() throws Exception { try { - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); ChangeElementSymbolCommand command = new ChangeElementSymbolCommand(model, alias, "test"); assertFalse("test".equals(alias.getSymbol())); command.execute(); @@ -44,7 +44,7 @@ public class ChangeElementSymbolCommandTest extends CommandTestFunctions{ public void testUndo() throws Exception { try { Model model2 = createSimpleModel(); - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); // models should be equal before move assertEquals(0, modelComparator.compare(model, model2)); diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementSynonymCommandTest.java b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementSynonymCommandTest.java index 90c858494a4daa680d8f64dae01b909f0d3a768d..5ff47be58ed7dfd7bb2eed2ce2176ec35b97d472 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementSynonymCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/properties/ChangeElementSynonymCommandTest.java @@ -28,7 +28,7 @@ public class ChangeElementSynonymCommandTest extends CommandTestFunctions { @Test public void testChangeAliasSynonym() throws Exception { try { - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); ChangeElementSynonymCommand command = new ChangeElementSynonymCommand(model, alias, "test","synonym"); assertFalse(alias.getSynonyms().contains("test")); command.execute(); @@ -43,7 +43,7 @@ public class ChangeElementSynonymCommandTest extends CommandTestFunctions { @Test public void testChangeToTheSame() throws Exception { try { - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); ChangeElementSynonymCommand command = new ChangeElementSynonymCommand(model, alias, "synonym","synonym"); assertTrue(alias.getSynonyms().contains("synonym")); command.execute(); @@ -59,7 +59,7 @@ public class ChangeElementSynonymCommandTest extends CommandTestFunctions { public void testUndo() throws Exception { try { Model model2 = createSimpleModel(); - Element alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getElementByElementId("alias_id"); // models should be equal before move assertEquals(0, modelComparator.compare(model, model2)); diff --git a/model/src/main/java/lcsb/mapviewer/model/map/MiriamType.java b/model/src/main/java/lcsb/mapviewer/model/map/MiriamType.java index 7b65e7e495783ce05af3ea0c129c2c3bf18475c2..08822f4c560be5df25a892d7dd681ddfa7e48314 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/MiriamType.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/MiriamType.java @@ -20,6 +20,7 @@ import lcsb.mapviewer.model.map.species.Rna; * @author Piotr Gawron * */ +@SuppressWarnings("unchecked") public enum MiriamType { /** * Chemical Abstracts Service database: http://commonchemistry.org. diff --git a/model/src/main/java/lcsb/mapviewer/model/map/compartment/Compartment.java b/model/src/main/java/lcsb/mapviewer/model/map/compartment/Compartment.java index 019d17705b4c32f2d3520db5bb979159e09579fd..08937710b57b921d5d97c87820df4befeeaed527 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/compartment/Compartment.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/compartment/Compartment.java @@ -23,7 +23,7 @@ import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Species; /** - * This class defines alias for compartment in the model. + * This class defines compartment in the model. * * @author Piotr Gawron * @@ -31,13 +31,14 @@ import lcsb.mapviewer.model.map.species.Species; @Entity @DiscriminatorValue("Compartment Alias") public class Compartment extends Element { + /** * */ private static final long serialVersionUID = 1L; /** - * Default color of the compartment alias. + * Default color of the compartment. */ private static final Color DEFAULT_COLOR = Color.BLACK; @@ -59,7 +60,7 @@ public class Compartment extends Element { /** * Default class logger. */ - private static Logger logger = Logger.getLogger(Compartment.class.getName()); + private static Logger logger = Logger.getLogger(Compartment.class); /** * Thickness of the compartment border. @@ -82,15 +83,15 @@ public class Compartment extends Element { private Point2D namePoint = new Point2D.Double(); /** - * Aliases that are directly inside this compartment alias. + * {@link Element Elements} that are directly inside this compartment. */ @Cascade({ CascadeType.ALL }) @OneToMany(fetch = FetchType.EAGER, mappedBy = "compartmentAlias") - private Set<Element> aliases = new HashSet<>(); + private Set<Element> elements = new HashSet<>(); /** - * Constructor that creates an alias which is initialized by the data from the - * parameter object. + * Constructor that creates a compartment which is initialized by the data + * from the parameter object. * * @param original * object from which this object is initialized @@ -101,8 +102,8 @@ public class Compartment extends Element { thickness = original.thickness; outerWidth = original.outerWidth; innerWidth = original.innerWidth; - for (Element alias : original.aliases) { - addAlias(alias.copy()); + for (Element element : original.elements) { + addElement(element.copy()); } } @@ -118,8 +119,14 @@ public class Compartment extends Element { setColor(DEFAULT_COLOR); } - public Compartment(String aliasId) { - setAliasId(aliasId); + /** + * Default constructor. + * + * @param elementId + * identifier of the compartment + */ + public Compartment(String elementId) { + setElementId(elementId); } /** @@ -162,38 +169,38 @@ public class Compartment extends Element { } /** - * Add alias into the compartment alias. In case alias already exists in the - * compartment alias InvaliArgumentException is thrown. + * Add element into the compartment. In case element already exists in the + * compartment {@link InvalidArgumentException} is thrown. * - * @param aliasToAdd - * alias that should be added + * @param elementToAdd + * element that should be added */ - public void addAlias(Element aliasToAdd) { - for (Element alias : aliases) { - if (alias.getAliasId().equals(aliasToAdd.getAliasId())) { - if (alias.equals(aliasToAdd)) { + public void addElement(Element elementToAdd) { + for (Element element : elements) { + if (element.getElementId().equals(elementToAdd.getElementId())) { + if (element.equals(elementToAdd)) { return; } else { - throw new InvalidArgumentException("Alias " + aliasToAdd.getAliasId() + " already on the list of compartment " + getAliasId() + " children"); + throw new InvalidArgumentException("Alias " + elementToAdd.getElementId() + " already on the list of compartment " + getElementId() + " children"); } } } - aliases.add(aliasToAdd); - aliasToAdd.setCompartmentAlias(this); + elements.add(elementToAdd); + elementToAdd.setCompartmentAlias(this); } /** - * Return set of all aliases inside the compartment alias (not necessery - * directly in the comaprtment alias). + * Return set of all {@link Element elements} inside the compartment alias + * (not necessery directly in the compartment). * - * @return list of all aliases in the compartment alias - */ - public Set<Element> getAllSubAliases() { - Set<Element> result = new HashSet<Element>(); - result.addAll(getAliases()); - for (Element abstractAlias : getAliases()) { - if (abstractAlias instanceof Compartment) { - result.addAll(((Compartment) abstractAlias).getAllSubAliases()); + * @return list of all elements in the compartment + */ + public Set<Element> getAllSubElements() { + Set<Element> result = new HashSet<>(); + result.addAll(getElements()); + for (Element subelement : getElements()) { + if (subelement instanceof Compartment) { + result.addAll(((Compartment) subelement).getAllSubElements()); } } @@ -201,30 +208,30 @@ public class Compartment extends Element { } /** - * Check if alias given in the parameter has a common part with this - * compartment alias. In case alias2 lies inside complex the check with - * complex alias is made. + * Check if element given in the parameter has a common part with this + * compartment. In case element2 lies inside complex the check with complex is + * made. * - * @param alias2 - * alias to be checked - * @return true if the alias2 cross this compartment alias, <code>false</code> + * @param element2 + * element to be checked + * @return true if the element2 cross this compartment, <code>false</code> * otherwise */ - public boolean cross(Element alias2) { - Set<Element> parents = new HashSet<Element>(); + public boolean cross(Element element2) { + Set<Element> parents = new HashSet<>(); // in case of elements in complexes we have to check if the top level - // complex cross alias - while (alias2.getParent() != null && alias2.getParent() instanceof Complex) { - alias2 = alias2.getParent(); - if (parents.contains(alias2)) { - throw new InvalidStateException("Cycled nesting in complex parents: " + alias2.getName()); + // complex cross element + while (element2.getParent() != null && element2.getParent() instanceof Complex) { + element2 = element2.getParent(); + if (parents.contains(element2)) { + throw new InvalidStateException("Cycled nesting in complex parents: " + element2.getName()); } else { - parents.add(alias2); + parents.add(element2); } } - Point2D argumentTopLeftCorner = new Point2D.Double(alias2.getX(), alias2.getY()); - Point2D argumentBottomRightCorner = new Point2D.Double(alias2.getX() + alias2.getWidth(), alias2.getY() + alias2.getHeight()); + Point2D argumentTopLeftCorner = new Point2D.Double(element2.getX(), element2.getY()); + Point2D argumentBottomRightCorner = new Point2D.Double(element2.getX() + element2.getWidth(), element2.getY() + element2.getHeight()); Point2D topLeftCorner = new Point2D.Double(getX(), getY()); Point2D bottomRightCorner = new Point2D.Double(getX() + getWidth(), getY() + getHeight()); @@ -235,16 +242,15 @@ public class Compartment extends Element { } /** - * Checks if there is a species alias with the same name inside the - * compartment alias. + * Checks if there is a species with the same name inside the compartment. * - * @return <code>true</code> if there is alias with the same name inside - * compartment, <code>false</code> otherwise + * @return <code>true</code> if there is {@link Species} with the same name + * inside compartment, <code>false</code> otherwise */ public boolean containsIdenticalSpecies() { - for (Element innerAlias : aliases) { - if (innerAlias instanceof Species) { - String name = innerAlias.getName(); + for (Element innerElement : elements) { + if (innerElement instanceof Species) { + String name = innerElement.getName(); if (name.equalsIgnoreCase(getName())) { return true; } @@ -254,7 +260,7 @@ public class Compartment extends Element { } /** - * Creates a copy of this CompartmentAlias. + * Creates a copy of this {@link Compartment}. * * @return copy of the object */ @@ -267,18 +273,18 @@ public class Compartment extends Element { } /** - * Removes alias from the compartment alias. + * Removes element from the {@link Compartment}. * - * @param alias + * @param element * object to be removed */ - public void removeAlias(Element alias) { - aliases.remove(alias); - if (alias.getCompartmentAlias() != null) { - if (alias.getCompartmentAlias() == this) { - alias.setCompartmentAlias(null); + public void removeElement(Element element) { + elements.remove(element); + if (element.getCompartmentAlias() != null) { + if (element.getCompartmentAlias() == this) { + element.setCompartmentAlias(null); } else { - logger.warn("Removing alias from compartment that might not belong there"); + logger.warn("Removing element from compartment that might not belong there"); } } } @@ -296,11 +302,11 @@ public class Compartment extends Element { } /** - * @param aliases - * the aliases to set + * @param elements + * the elements to set */ - public void setAliases(Set<Element> aliases) { - this.aliases = aliases; + public void setElements(Set<Element> elements) { + this.elements = elements; } /** @@ -372,11 +378,11 @@ public class Compartment extends Element { } /** - * @return the aliases - * @see #aliases + * @return the elements + * @see #elements */ - public Set<Element> getAliases() { - return aliases; + public Set<Element> getElements() { + return elements; } @Override diff --git a/model/src/main/java/lcsb/mapviewer/model/map/compartment/CompartmentComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/compartment/CompartmentComparator.java index 2a1769a6716b46a801959832473856da11c7bf3b..aa8860039eb4e3ab54016754864477d8dbebcba7 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/compartment/CompartmentComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/compartment/CompartmentComparator.java @@ -111,33 +111,33 @@ public class CompartmentComparator implements Comparator<Compartment> { return pointComparator.compare(arg0.getNamePoint(), arg1.getNamePoint()); } - if (integerComparator.compare(arg0.getAliases().size(), arg1.getAliases().size()) != 0) { - logger.debug("Aliases number different: " + arg0.getAliases().size() + ", " + arg1.getAliases().size()); - return integerComparator.compare(arg0.getAliases().size(), arg1.getAliases().size()); + if (integerComparator.compare(arg0.getElements().size(), arg1.getElements().size()) != 0) { + logger.debug("Aliases number different: " + arg0.getElements().size() + ", " + arg1.getElements().size()); + return integerComparator.compare(arg0.getElements().size(), arg1.getElements().size()); } Map<String, Element> map1 = new HashMap<>(); Map<String, Element> map2 = new HashMap<>(); - for (Element alias : arg0.getAliases()) { - if (map1.get(alias.getAliasId()) != null) { - throw new InvalidArgumentException("Few aliases with the same id: " + alias.getAliasId()); + for (Element alias : arg0.getElements()) { + if (map1.get(alias.getElementId()) != null) { + throw new InvalidArgumentException("Few aliases with the same id: " + alias.getElementId()); } - map1.put(alias.getAliasId(), alias); + map1.put(alias.getElementId(), alias); } - for (Element alias : arg1.getAliases()) { - if (map2.get(alias.getAliasId()) != null) { - throw new InvalidArgumentException("Few aliases with the same id: " + alias.getAliasId()); + for (Element alias : arg1.getElements()) { + if (map2.get(alias.getElementId()) != null) { + throw new InvalidArgumentException("Few aliases with the same id: " + alias.getElementId()); } - map2.put(alias.getAliasId(), alias); + map2.put(alias.getElementId(), alias); } - for (Element alias : arg0.getAliases()) { - Element alias2 = map2.get(alias.getAliasId()); + for (Element alias : arg0.getElements()) { + Element alias2 = map2.get(alias.getElementId()); int status = aliasComparator.compare(alias, alias2); if (status != 0) { - logger.debug("Couldn't match alias: " + alias.getAliasId() + ", " + alias2); + logger.debug("Couldn't match alias: " + alias.getElementId() + ", " + alias2); return status; } } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/compartment/PathwayCompartment.java b/model/src/main/java/lcsb/mapviewer/model/map/compartment/PathwayCompartment.java index eec7511320090a24053f0e2849aace1e6cf20025..8330145fc588dcc4e8f88cd5c2ca164a1e982482 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/compartment/PathwayCompartment.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/compartment/PathwayCompartment.java @@ -6,7 +6,7 @@ import javax.persistence.Entity; import lcsb.mapviewer.common.exception.NotImplementedException; /** - * Alias of compartment/pathway element created artifitially. + * Compartment that represents a pathway. * * @author Piotr Gawron * @@ -23,13 +23,19 @@ public class PathwayCompartment extends Compartment { /** * Default constructor. */ - public PathwayCompartment() { + PathwayCompartment() { super(); } + /** + * Default constructor. + * + * @param aliasId + * identifier of the compartment + */ public PathwayCompartment(String aliasId) { super(); - setAliasId(aliasId); + setElementId(aliasId); } /** diff --git a/model/src/main/java/lcsb/mapviewer/model/map/compartment/SquareCompartment.java b/model/src/main/java/lcsb/mapviewer/model/map/compartment/SquareCompartment.java index d87ba0c7601353f00cef4ac4495719ed3e99c8d8..e6dc926017e16349135a750acca6b8965701bdf0 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/compartment/SquareCompartment.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/compartment/SquareCompartment.java @@ -23,7 +23,7 @@ public class SquareCompartment extends Compartment { /** * Default constructor. */ - public SquareCompartment() { + SquareCompartment() { super(); } @@ -38,9 +38,15 @@ public class SquareCompartment extends Compartment { super(originalAlias); } + /** + * Default constructor. + * + * @param aliasId + * identifier of the compartment + */ public SquareCompartment(String aliasId) { super(); - setAliasId(aliasId); + setElementId(aliasId); } @Override diff --git a/model/src/main/java/lcsb/mapviewer/model/map/compartment/package-info.java b/model/src/main/java/lcsb/mapviewer/model/map/compartment/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..9133cd1cfcc6fac96c217bb677390b26ab9c7908 --- /dev/null +++ b/model/src/main/java/lcsb/mapviewer/model/map/compartment/package-info.java @@ -0,0 +1,4 @@ +/** + * Contains structures used for compartment modeling. + */ +package lcsb.mapviewer.model.map.compartment; \ No newline at end of file diff --git a/model/src/main/java/lcsb/mapviewer/model/map/model/Model.java b/model/src/main/java/lcsb/mapviewer/model/map/model/Model.java index 25d9a3641634f364cb24f391d17eeeb5265b77a2..66e27206acc91fd07697557005355fee839a9753 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/model/Model.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/model/Model.java @@ -19,8 +19,8 @@ import lcsb.mapviewer.model.map.layout.ElementGroup; import lcsb.mapviewer.model.map.layout.Layout; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.reaction.Reaction; -import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Species; /** @@ -123,11 +123,13 @@ public interface Model { /** * Returns alias with the given alias identfier ({@link Element#aliasId}). * - * @param idAlias - * alias identifier - * @return alias with the given id + * @param idElement + * element identifier + * @param <T> + * type of the object to be returned + * @return {@link Element} with the given id */ - <T extends Element> T getAliasByAliasId(String idAlias); + <T extends Element> T getElementByElementId(String idElement); /** * Adds reaction to the model. @@ -331,23 +333,28 @@ public interface Model { * * @return list of aliases sorted by the size */ - List<Element> getSortedAliases(); + List<Element> getSortedSpeciesList(); /** - * Returns collection of species aliases (excluding complexes). + * Returns collection of all {@link Species} excluding {@link Complex}. * - * @return collection of species aliases + * @return collection of all {@link Species} excluding {@link Complex}. */ - Collection<Species> getNotComplexSpeciesAliases(); + Collection<Species> getNotComplexSpeciesList(); - List<Species> getSpeciesAliases(); + /** + * Returns list of all {@link Species} in the model. + * + * @return list of all {@link Species} in the model + */ + List<Species> getSpeciesList(); /** - * Returns collection of complex aliases. + * Returns collection of {@link Complex}. * - * @return collection of complex aliases + * @return collection of {@link Complex} */ - Collection<Complex> getComplexAliases(); + Collection<Complex> getComplexList(); /** * Adds reactions to model. @@ -366,7 +373,14 @@ public interface Model { */ Set<AnnotatedObject> getElementsByAnnotation(MiriamData miriamData); - List<Element> getAliasByName(String name); + /** + * Returns list of elements with given name. + * + * @param name + * name of the element + * @return list of elements with given name + */ + List<Element> getElementsByName(String name); /** * diff --git a/model/src/main/java/lcsb/mapviewer/model/map/model/ModelComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/model/ModelComparator.java index eea5155dd21b4c7fc15f4768b547de50578d68b4..794fab0ab62ace9ca9cd39e58e74bd4ccc34dea8 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/model/ModelComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/model/ModelComparator.java @@ -356,25 +356,25 @@ public class ModelComparator implements Comparator<Model> { } for (Element alias : aliases) { - map1.put(alias.getAliasId(), alias); + map1.put(alias.getElementId(), alias); } for (Element alias : aliases2) { - map2.put(alias.getAliasId(), alias); + map2.put(alias.getElementId(), alias); } for (Element alias : aliases) { - int status = aliasComparator.compare(alias, map2.get(alias.getAliasId())); + int status = aliasComparator.compare(alias, map2.get(alias.getElementId())); if (status != 0) { - logger.debug("Alias doesn't have a match: " + alias.getAliasId() + ", " + map2.get(alias.getAliasId())); + logger.debug("Alias doesn't have a match: " + alias.getElementId() + ", " + map2.get(alias.getElementId())); return status; } } for (Element alias : aliases2) { - int status = aliasComparator.compare(alias, map1.get(alias.getAliasId())); + int status = aliasComparator.compare(alias, map1.get(alias.getElementId())); if (status != 0) { - logger.debug("Alias doesn't have a match: " + alias.getAliasId() + ", " + map2.get(alias.getAliasId())); + logger.debug("Alias doesn't have a match: " + alias.getElementId() + ", " + map2.get(alias.getElementId())); return status; } } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/model/ModelData.java b/model/src/main/java/lcsb/mapviewer/model/map/model/ModelData.java index b6b01244929f6e951ec1fc9824c5aeecc4edb693..8fa62226070c1507104588688cfcd95e1786050a 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/model/ModelData.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/model/ModelData.java @@ -456,7 +456,7 @@ public class ModelData implements Serializable { throw new InvalidArgumentException("Cannot remove null"); } if (!aliases.contains(alias)) { - logger.warn("Alias doesn't exist in the map: " + alias.getAliasId()); + logger.warn("Alias doesn't exist in the map: " + alias.getElementId()); return; } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/model/ModelFullIndexed.java b/model/src/main/java/lcsb/mapviewer/model/map/model/ModelFullIndexed.java index fbace68fe2bd035fab407668a5ec2f2d5ebe21de..84004ea609ed3bacb5ebb79bcae089526ebe85e4 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/model/ModelFullIndexed.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/model/ModelFullIndexed.java @@ -87,7 +87,7 @@ public class ModelFullIndexed implements Model { } else { this.modelData = model; for (Element alias : model.getAliases()) { - aliasByAliasId.put(alias.getAliasId(), alias); + aliasByAliasId.put(alias.getElementId(), alias); aliasByDbId.put(alias.getId(), alias); } for (Reaction reaction : model.getReactions()) { @@ -131,17 +131,17 @@ public class ModelFullIndexed implements Model { * alias to add */ private void addSpeciesAlias(Species al) { - if (al.getAliasId() == null || al.getAliasId().isEmpty()) { + if (al.getElementId() == null || al.getElementId().isEmpty()) { throw new InvalidArgumentException("Alias identifier cannot be empty"); } modelData.addAlias(al); - Element alias2 = aliasByAliasId.get(al.getAliasId()); + Element alias2 = aliasByAliasId.get(al.getElementId()); if (alias2 == null) { - aliasByAliasId.put(al.getAliasId(), al); + aliasByAliasId.put(al.getElementId(), al); aliasByDbId.put(al.getId(), al); } else { - throw new InvalidArgumentException("Alias with duplicated id: " + al.getAliasId()); + throw new InvalidArgumentException("Alias with duplicated id: " + al.getElementId()); } } @@ -192,7 +192,7 @@ public class ModelFullIndexed implements Model { @SuppressWarnings("unchecked") @Override - public <T extends Element> T getAliasByAliasId(String idAlias) { + public <T extends Element> T getElementByElementId(String idAlias) { return (T) aliasByAliasId.get(idAlias); } @@ -216,12 +216,12 @@ public class ModelFullIndexed implements Model { */ private void addCompartmentAlias(Compartment al) { modelData.addAlias(al); - Element alias2 = aliasByAliasId.get(al.getAliasId()); + Element alias2 = aliasByAliasId.get(al.getElementId()); if (alias2 == null) { - aliasByAliasId.put(al.getAliasId(), al); + aliasByAliasId.put(al.getElementId(), al); aliasByDbId.put(al.getId(), al); } else { - throw new InvalidArgumentException("Try to add CompartmentAlias with duplicated alias id: " + al.getAliasId()); + throw new InvalidArgumentException("Try to add CompartmentAlias with duplicated alias id: " + al.getElementId()); } } @@ -381,7 +381,7 @@ public class ModelFullIndexed implements Model { } @Override - public Collection<Complex> getComplexAliases() { + public Collection<Complex> getComplexList() { List<Complex> result = new ArrayList<Complex>(); for (Element alias : modelData.getAliases()) { if (alias instanceof Complex) { @@ -392,7 +392,7 @@ public class ModelFullIndexed implements Model { } @Override - public Collection<Species> getNotComplexSpeciesAliases() { + public Collection<Species> getNotComplexSpeciesList() { List<Species> result = new ArrayList<Species>(); for (Element alias : modelData.getAliases()) { if (alias instanceof Species && !(alias instanceof Complex)) { @@ -410,7 +410,7 @@ public class ModelFullIndexed implements Model { } @Override - public List<Element> getSortedAliases() { + public List<Element> getSortedSpeciesList() { List<Element> result = new ArrayList<Element>(); result.addAll(getAliases()); Collections.sort(result, Element.SIZE_COMPARATOR); @@ -448,13 +448,13 @@ public class ModelFullIndexed implements Model { @Override public void removeAlias(Element alias) { modelData.removeAlias(alias); - aliasByAliasId.remove(alias.getAliasId()); + aliasByAliasId.remove(alias.getElementId()); aliasByDbId.remove(alias.getId()); if (alias.getParent() != null) { if (alias.getParent() instanceof Compartment) { Compartment ca = (Compartment) alias.getParent(); - ca.removeAlias(alias); + ca.removeElement(alias); } else if (alias.getParent() instanceof Complex) { Complex ca = (Complex) alias.getParent(); ca.removeAlias((Species) alias); @@ -465,7 +465,7 @@ public class ModelFullIndexed implements Model { if (alias.getCompartmentAlias() != null) { Compartment ca = alias.getCompartmentAlias(); - ca.removeAlias(alias); + ca.removeElement(alias); } if (alias instanceof Species) { @@ -758,7 +758,7 @@ public class ModelFullIndexed implements Model { } @Override - public List<Element> getAliasByName(String name) { + public List<Element> getElementsByName(String name) { List<Element> result = new ArrayList<>(); for (Element element : getAliases()) { if (element.getName().equalsIgnoreCase(name)) { @@ -769,7 +769,7 @@ public class ModelFullIndexed implements Model { } @Override - public List<Species> getSpeciesAliases() { + public List<Species> getSpeciesList() { List<Species> result = new ArrayList<Species>(); for (Element alias : modelData.getAliases()) { if (alias instanceof Species) { diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRna.java b/model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRna.java index 6910928f81f26c3579db4b054b033db1be4fbd86..386f48cd6d4b5a170478396f38082784d0cd7764 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRna.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRna.java @@ -45,7 +45,7 @@ public class AntisenseRna extends Species { } public AntisenseRna(String aliasId) { - setAliasId(aliasId); + setElementId(aliasId); } @Override diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparator.java index 3929ee6149ea985a5f3528549a4bf76d593ba093..f886d20073838c3577c5b72e8d2b2eaaabde5976 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparator.java @@ -1,11 +1,15 @@ package lcsb.mapviewer.model.map.species; import java.util.Comparator; +import java.util.HashSet; +import java.util.Set; import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; +import lcsb.mapviewer.common.comparator.StringSetComparator; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion; public class AntisenseRnaComparator implements Comparator<AntisenseRna> { @@ -78,6 +82,23 @@ public class AntisenseRnaComparator implements Comparator<AntisenseRna> { if (result != 0) { return result; } + StringSetComparator stringSetComparator = new StringSetComparator(); + + Set<String> set1 = new HashSet<String>(); + Set<String> set2 = new HashSet<String>(); + + for (AntisenseRnaRegion region : arg0.getRegions()) { + set1.add(region.toString()); + } + + for (AntisenseRnaRegion region : arg1.getRegions()) { + set2.add(region.toString()); + } + + if (stringSetComparator.compare(set1, set2) != 0) { + return stringSetComparator.compare(set1, set2); + } + return 0; } } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Complex.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Complex.java index 0a1fffc9bdb663c1a950d441d5f88d299fd34585..3e3d0b78d6ae7b6acdcabe721404d56551f4a322 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Complex.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Complex.java @@ -91,7 +91,7 @@ public class Complex extends Species { public void addAlias(Species alias) { boolean contains = false; for (Species alias2 : aliases) { - if (alias.getAliasId().equals(alias2.getAliasId())) { + if (alias.getElementId().equals(alias2.getElementId())) { contains = true; } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/ComplexComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/ComplexComparator.java index 844f08650a720596b7ecc10c4352dd65bf18e251..992a54475f1bb3782e857b9c702d5f1f0a06e449 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/ComplexComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/ComplexComparator.java @@ -8,6 +8,7 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.comparator.IntegerComparator; +import lcsb.mapviewer.common.comparator.StringComparator; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.NotImplementedException; @@ -99,31 +100,35 @@ public class ComplexComparator implements Comparator<Complex> { Map<String, Element> map2 = new HashMap<>(); for (Element alias : arg0.getAliases()) { - if (map1.get(alias.getAliasId()) != null) { - for (Element alias2 : arg0.getAliases()) { - logger.debug(alias2.getAliasId()); - } - throw new InvalidArgumentException("Few aliases with the same id: " + alias.getAliasId()); + if (map1.get(alias.getElementId()) != null) { + throw new InvalidArgumentException("Few aliases with the same id: " + alias.getElementId()); } - map1.put(alias.getAliasId(), alias); + map1.put(alias.getElementId(), alias); } for (Element alias : arg1.getAliases()) { - if (map2.get(alias.getAliasId()) != null) { - throw new InvalidArgumentException("Few aliases with the same id: " + alias.getAliasId()); + if (map2.get(alias.getElementId()) != null) { + throw new InvalidArgumentException("Few aliases with the same id: " + alias.getElementId()); } - map2.put(alias.getAliasId(), alias); + map2.put(alias.getElementId(), alias); } for (Element alias : arg0.getAliases()) { - Element alias2 = map2.get(alias.getAliasId()); + Element alias2 = map2.get(alias.getElementId()); int status = aliasComparator.compare(alias, alias2); if (status != 0) { - logger.debug("child doesn't have a match: " + alias.getAliasId()); + logger.debug("child doesn't have a match: " + alias.getElementId()); return status; } } + StringComparator stringComparator = new StringComparator(); + + if (stringComparator.compare(arg0.getStructuralState(), arg1.getStructuralState()) != 0) { + logger.debug("Species structuralState different: " + arg0.getStructuralState() + ", " + arg1.getStructuralState()); + return stringComparator.compare(arg0.getStructuralState(), arg1.getStructuralState()); + } + return 0; } } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Degraded.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Degraded.java index 790b82fe0e9aa7132dbb72877679c164df9161af..0fcb066a1406aa32ffd64d9a4f488acd02779693 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Degraded.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Degraded.java @@ -21,7 +21,7 @@ public class Degraded extends Species { } public Degraded(String aliasId) { - super.setAliasId(aliasId); + super.setElementId(aliasId); } @Override diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Drug.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Drug.java index 1cfa4f2d2de80909da9bbc8db788b2a2e6077aef..82b2735f038cd8a3644e753d5914235f9ae576f9 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Drug.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Drug.java @@ -21,7 +21,7 @@ public class Drug extends Species { } public Drug(String aliasId) { - setAliasId(aliasId); + setElementId(aliasId); } @Override diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Element.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Element.java index 949081c1b2344ff06dbf3d473b89eb0e9d41e8f7..7f165e052d300aa230a3cc1abfddab02380c2311 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Element.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Element.java @@ -143,10 +143,10 @@ public abstract class Element implements AnnotatedObject, Serializable { private Compartment compartmentAlias; /** - * Unique string alias identifier within one model object (usually importet + * Unique string identifier within one model object (usually imported * from external source from which map was imported). */ - private String aliasId; + private String elementId; /** * X coordinate on the map where alias is located (top left corner). @@ -275,7 +275,7 @@ public abstract class Element implements AnnotatedObject, Serializable { * source alias */ protected Element(Element param) { - aliasId = param.getAliasId(); + elementId = param.getElementId(); x = param.getX(); y = param.getY(); width = param.getWidth(); @@ -312,7 +312,7 @@ public abstract class Element implements AnnotatedObject, Serializable { */ protected Element() { super(); - aliasId = ""; + elementId = ""; x = 0.0; y = 0.0; width = 0.0; @@ -657,19 +657,19 @@ public abstract class Element implements AnnotatedObject, Serializable { /** * @return the aliasId - * @see #aliasId + * @see #elementId */ - public String getAliasId() { - return aliasId; + public String getElementId() { + return elementId; } /** - * @param aliasId - * the aliasId to set - * @see #aliasId + * @param elementId + * the elementId to set + * @see #elementId */ - public void setAliasId(String aliasId) { - this.aliasId = aliasId; + public void setElementId(String elementId) { + this.elementId = elementId; } /** @@ -1029,7 +1029,7 @@ public abstract class Element implements AnnotatedObject, Serializable { @Override public void addMiriamData(MiriamData md) { if (this.miriamData.contains(md)) { - logger.warn("Miriam data (" + md.getDataType() + ": " + md.getResource() + ") for " + getAliasId() + " already exists. Ignoring..."); + logger.warn("Miriam data (" + md.getDataType() + ": " + md.getResource() + ") for " + getElementId() + " already exists. Ignoring..."); } else { this.miriamData.add(md); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/ElementComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/ElementComparator.java index 382f342c6c30916392070f8dcad1be7befc21843..72c7ed786161c9034801bd51bd4f44c4f8a1569d 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/ElementComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/ElementComparator.java @@ -96,13 +96,23 @@ public class ElementComparator implements Comparator<Element> { * -1/1 is returned. */ public int internalCompare(Element arg0, Element arg1) { + if (arg0 == null) { + if (arg1 == null) { + return 0; + } else { + return 1; + } + } else if (arg1 == null) { + return -1; + } + StringComparator stringComparator = new StringComparator(); IntegerComparator integerComparator = new IntegerComparator(); DoubleComparator doubleComparator = new DoubleComparator(epsilon); - if (stringComparator.compare(arg0.getAliasId(), arg1.getAliasId()) != 0) { - logger.debug("AliasId different: " + arg0.getAliasId() + ", " + arg1.getAliasId()); - return stringComparator.compare(arg0.getAliasId(), arg1.getAliasId()); + if (stringComparator.compare(arg0.getElementId(), arg1.getElementId()) != 0) { + logger.debug("AliasId different: " + arg0.getElementId() + ", " + arg1.getElementId()); + return stringComparator.compare(arg0.getElementId(), arg1.getElementId()); } if (doubleComparator.compare(arg0.getX(), arg1.getX()) != 0) { @@ -192,8 +202,8 @@ public class ElementComparator implements Comparator<Element> { return stringListComparator.compare(arg0.getFormerSymbols(), arg1.getFormerSymbols()); } - Set<String> hashCode1 = new HashSet<String>(); - Set<String> hashCode2 = new HashSet<String>(); + Set<String> hashCode1 = new HashSet<>(); + Set<String> hashCode2 = new HashSet<>(); if (arg0.getMiriamData().size() != arg1.getMiriamData().size()) { logger.debug("different number of annotations: " + arg0.getMiriamData().size() + ", " + arg1.getMiriamData().size()); diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Gene.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Gene.java index 12b015a77b44c6f64bad6d29d213a084cd9cf0df..da92b8f45ff3503c7df0be1730e427c32dfbc203 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Gene.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Gene.java @@ -49,7 +49,7 @@ public class Gene extends Species { } public Gene(String aliasId) { - setAliasId(aliasId); + setElementId(aliasId); } @Override diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/GeneComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/GeneComparator.java index 0481515dbf18319e14bdd73471bfeb36b2ae1120..d67f46e73a91689c464f394d926cfdd47ae6600a 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/GeneComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/GeneComparator.java @@ -1,14 +1,18 @@ package lcsb.mapviewer.model.map.species; import java.util.Comparator; +import java.util.HashSet; +import java.util.Set; import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; +import lcsb.mapviewer.common.comparator.StringSetComparator; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; public class GeneComparator implements Comparator<Gene> { - + /** * Default class logger. */ @@ -61,9 +65,9 @@ public class GeneComparator implements Comparator<Gene> { } /** - * This method compares only the fields that are defined in GeneAlias - * class in inheritence tree. By the design it calls also comparator of the - * upper (SpeciesAlias) class. + * This method compares only the fields that are defined in GeneAlias class in + * inheritence tree. By the design it calls also comparator of the upper + * (SpeciesAlias) class. * * @param arg0 * first object to compare @@ -78,6 +82,24 @@ public class GeneComparator implements Comparator<Gene> { if (result != 0) { return result; } + + StringSetComparator stringSetComparator = new StringSetComparator(); + + Set<String> set1 = new HashSet<>(); + Set<String> set2 = new HashSet<>(); + + for (ModificationResidue region : arg0.getModificationResidues()) { + set1.add(region.toString()); + } + + for (ModificationResidue region : arg1.getModificationResidues()) { + set2.add(region.toString()); + } + + if (stringSetComparator.compare(set1, set2) != 0) { + return stringSetComparator.compare(set1, set2); + } + return 0; } } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Ion.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Ion.java index 88bcd9956d0da649e516418100531e2b862cc766..23ab6180dbe59a6b5e1bd6692e4f42ac2398e0c1 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Ion.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Ion.java @@ -21,7 +21,7 @@ public class Ion extends Chemical { } public Ion(String aliasId) { - setAliasId(aliasId); + setElementId(aliasId); } @Override diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/IonChannelProtein.java b/model/src/main/java/lcsb/mapviewer/model/map/species/IonChannelProtein.java index 56463dfcb0ebd678e4c28653e7c2f7152e39e74e..73d4ca35c9fdd7ee56ae3b2df1b3f4ca211072b2 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/IonChannelProtein.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/IonChannelProtein.java @@ -21,7 +21,7 @@ public class IonChannelProtein extends Protein { } public IonChannelProtein(String aliasId) { - setAliasId(aliasId); + setElementId(aliasId); } @Override diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Phenotype.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Phenotype.java index c360b50a3f6c1513b19bb084445e9da8cc296186..0fd1e4ce0e2b4a33c07320b16bbf83cbc77f9111 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Phenotype.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Phenotype.java @@ -22,7 +22,7 @@ public class Phenotype extends Species { } public Phenotype(String aliasId) { - setAliasId(aliasId); + setElementId(aliasId); } @Override diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/ProteinComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/ProteinComparator.java index 5b0840457e714a0b2ab1ad60c570e2f1aaf55369..158be0cb0e19a79b6aa077b5953827d6cb3e2bb3 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/ProteinComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/ProteinComparator.java @@ -1,11 +1,17 @@ package lcsb.mapviewer.model.map.species; import java.util.Comparator; +import java.util.HashSet; +import java.util.Set; import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; +import lcsb.mapviewer.common.comparator.IntegerComparator; +import lcsb.mapviewer.common.comparator.StringComparator; +import lcsb.mapviewer.common.comparator.StringSetComparator; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; public class ProteinComparator implements Comparator<Protein> { @@ -13,17 +19,17 @@ public class ProteinComparator implements Comparator<Protein> { * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(ProteinComparator.class); + private static Logger logger = Logger.getLogger(ProteinComparator.class); /** * Epsilon value used for comparison of doubles. */ - private double epsilon; + private double epsilon; - private GenericProteinComparator genericProteinAliasComparator; - private IonChannelProteinComparator ionChannelProteinAliasComparator; - private ReceptorProteinComparator receptorProteinAliasComparator; - private TruncatedProteinComparator truncatedProteinAliasComparator; + private GenericProteinComparator genericProteinAliasComparator; + private IonChannelProteinComparator ionChannelProteinAliasComparator; + private ReceptorProteinComparator receptorProteinAliasComparator; + private TruncatedProteinComparator truncatedProteinAliasComparator; /** * Constructor that requires {@link #epsilon} parameter. @@ -95,6 +101,37 @@ public class ProteinComparator implements Comparator<Protein> { if (result != 0) { return result; } + + StringComparator stringComparator = new StringComparator(); + IntegerComparator integerComparator = new IntegerComparator(); + StringSetComparator stringSetComparator = new StringSetComparator(); + + if (integerComparator.compare(arg0.getHomodimer(), arg1.getHomodimer()) != 0) { + logger.debug("homodimer different: " + arg0.getHomodimer() + ", " + arg1.getHomodimer()); + return integerComparator.compare(arg0.getHomodimer(), arg1.getHomodimer()); + } + + if (stringComparator.compare(arg0.getStructuralState(), arg1.getStructuralState()) != 0) { + logger.debug("structural state different: " + arg0.getStructuralState() + ", " + arg1.getStructuralState()); + return stringComparator.compare(arg0.getStructuralState(), arg1.getStructuralState()); + } + + Set<String> set1 = new HashSet<>(); + Set<String> set2 = new HashSet<>(); + + for (ModificationResidue region : arg0.getModificationResidues()) { + set1.add(region.toString()); + } + + for (ModificationResidue region : arg1.getModificationResidues()) { + set2.add(region.toString()); + } + + if (stringSetComparator.compare(set1, set2) != 0) { + logger.debug("modification residues different"); + return stringSetComparator.compare(set1, set2); + } + return 0; } } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Rna.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Rna.java index a06bcb114b72a56734a94f402fde146872fad960..c738ee367e7400be0329a15e9d05a9a05694cf00 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Rna.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Rna.java @@ -44,7 +44,7 @@ public class Rna extends Species { public Rna(String aliasId) { super(); - setAliasId(aliasId); + setElementId(aliasId); } public void addRegion(RnaRegion rnaRegionAlias) { diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/RnaComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/RnaComparator.java index d5d3e6086a38214bfc7c824fd224223781da131d..bf6b8bc99109348679e77f8859ab02dc5f4ab8a6 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/RnaComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/RnaComparator.java @@ -1,14 +1,18 @@ package lcsb.mapviewer.model.map.species; import java.util.Comparator; +import java.util.HashSet; +import java.util.Set; import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; +import lcsb.mapviewer.common.comparator.StringSetComparator; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.species.field.RnaRegion; public class RnaComparator implements Comparator<Rna> { - + /** * Default class logger. */ @@ -61,9 +65,9 @@ public class RnaComparator implements Comparator<Rna> { } /** - * This method compares only the fields that are defined in RnaAlias - * class in inheritence tree. By the design it calls also comparator of the - * upper (SpeciesAlias) class. + * This method compares only the fields that are defined in RnaAlias class in + * inheritence tree. By the design it calls also comparator of the upper + * (SpeciesAlias) class. * * @param arg0 * first object to compare @@ -78,6 +82,24 @@ public class RnaComparator implements Comparator<Rna> { if (result != 0) { return result; } + + StringSetComparator stringSetComparator = new StringSetComparator(); + + Set<String> set1 = new HashSet<>(); + Set<String> set2 = new HashSet<>(); + + for (RnaRegion region : arg0.getRegions()) { + set1.add(region.toString()); + } + + for (RnaRegion region : arg1.getRegions()) { + set2.add(region.toString()); + } + + if (stringSetComparator.compare(set1, set2) != 0) { + return stringSetComparator.compare(set1, set2); + } + return 0; } } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMolecule.java b/model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMolecule.java index fbd3920c923fd4bba130d3a507b5328b2a799343..f14b3c55addff3d6d90c2600df4a9720727a21f1 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMolecule.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMolecule.java @@ -21,7 +21,7 @@ public class SimpleMolecule extends Chemical { } public SimpleMolecule(String aliasId) { - setAliasId(aliasId); + setElementId(aliasId); } @Override diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMoleculeComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMoleculeComparator.java index 46cbd69a10dfc258a0dc7143f0ee3557a6c14714..e276ddd99455b7f935f4722231805e39ec298fb1 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMoleculeComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMoleculeComparator.java @@ -5,6 +5,7 @@ import java.util.Comparator; import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; +import lcsb.mapviewer.common.comparator.StringComparator; import lcsb.mapviewer.common.exception.NotImplementedException; public class SimpleMoleculeComparator implements Comparator<SimpleMolecule> { @@ -78,6 +79,24 @@ public class SimpleMoleculeComparator implements Comparator<SimpleMolecule> { if (result != 0) { return result; } + + StringComparator stringComparator = new StringComparator(); + + if (stringComparator.compare(arg0.getSmiles(), arg1.getSmiles()) != 0) { + logger.debug("Smiles different: " + arg0.getSmiles() + ", " + arg1.getSmiles()); + return stringComparator.compare(arg0.getSmiles(), arg1.getSmiles()); + } + + if (stringComparator.compare(arg0.getInChIKey(), arg1.getInChIKey()) != 0) { + logger.debug("InChIKey different: " + arg0.getInChIKey() + ", " + arg1.getInChIKey()); + return stringComparator.compare(arg0.getInChIKey(), arg1.getInChIKey()); + } + + if (stringComparator.compare(arg0.getInChI(), arg1.getInChI()) != 0) { + logger.debug("InChI different: " + arg0.getInChI() + ", " + arg1.getInChI()); + return stringComparator.compare(arg0.getInChI(), arg1.getInChI()); + } + return 0; } } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Species.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Species.java index 0683317e47cb16a7998d2fa6257c577e4069c72f..37eb0ce5fc335b33cde56e7e3d0a759a9086611f 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Species.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Species.java @@ -130,7 +130,7 @@ public abstract class Species extends Element { */ public Species(String aliasId) { this(); - setAliasId(aliasId); + setElementId(aliasId); } /** diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/SpeciesComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/SpeciesComparator.java index bf38449447c4c4df82f2372c57cc5f636b42e580..4ce6963c781062b99d94f870f36eb50f33e74651 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/SpeciesComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/SpeciesComparator.java @@ -100,8 +100,6 @@ public class SpeciesComparator implements Comparator<Species> { return rnaAliasComparator.compare((Rna) arg0, (Rna) arg1); } else if (arg0.getClass().equals(Unknown.class)) { return unknownAliasComparator.compare((Unknown) arg0, (Unknown) arg1); - } else if (arg0.getClass().equals(Species.class)) { - return internalCompare(arg0, arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); } @@ -163,6 +161,11 @@ public class SpeciesComparator implements Comparator<Species> { return integerComparator.compare(arg0.getCharge(), arg1.getCharge()); } + if (integerComparator.compare(arg0.getHomodimer(), arg1.getHomodimer()) != 0) { + logger.debug("Homodimer different: " + arg0.getHomodimer() + ", " + arg1.getHomodimer()); + return integerComparator.compare(arg0.getHomodimer(), arg1.getHomodimer()); + } + if (integerComparator.compare(arg0.getInitialConcentration(), arg1.getInitialConcentration()) != 0) { logger.debug("Initial concentration different: " + arg0.getInitialConcentration() + ", " + arg1.getInitialConcentration()); return integerComparator.compare(arg0.getInitialConcentration(), arg1.getInitialConcentration()); diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Unknown.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Unknown.java index 39e4ccaae6a178b1d726b6b1332a2cf7e3cd7fce..389c116073789269ef5353779d5c21bd537b30d9 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Unknown.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Unknown.java @@ -22,7 +22,7 @@ public class Unknown extends Species { } public Unknown(String aliasId) { - setAliasId(aliasId); + setElementId(aliasId); } @Override diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegion.java b/model/src/main/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegion.java index 1b0dfbac41f41c0e7d946eedede493ec5af7b7aa..7a91806d349cfb777e60f3d5c7c28b7a5c9d4f70 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegion.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegion.java @@ -37,70 +37,6 @@ public class AntisenseRnaRegion implements Serializable { */ private static final long serialVersionUID = 1L; - /** - * Enum that enlists types of available modification regions in - * {@link AntisenseRna}. - * - * @author Piotr Gawron - * - */ - public enum AntisenseRnaRegionType { - - /** - * Modification site. - */ - MODIFICATION_SITE("Modification Site"), // - - /** - * Coding region. - */ - CODING_REGION("CodingRegion"), // - - /** - * Protein binding domain. - */ - PROTEIN_BINDING_DOMAIN("proteinBindingDomain"); - - /** - * Name of the type. - */ - private String name; - - /** - * Default constructor. - * - * @param name - * name of the type - */ - AntisenseRnaRegionType(String name) { - this.name = name; - } - - /** - * @return the name - * @see #name - */ - public String getName() { - return name; - } - - /** - * Returns {@link AntisenseRnaRegionType} identified by name. - * - * @param name - * name of the region - * @return {@link AntisenseRnaRegionType} identified by name - */ - public static AntisenseRnaRegionType getTypeByString(String name) { - for (AntisenseRnaRegionType type : values()) { - if (type.getName().equalsIgnoreCase(name)) { - return type; - } - } - return null; - } - } - /** * Default size of the object (in graphical representation). */ diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegionType.java b/model/src/main/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegionType.java new file mode 100644 index 0000000000000000000000000000000000000000..727ad5d4c831018249c9a185d943573f29d03f0e --- /dev/null +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegionType.java @@ -0,0 +1,67 @@ +package lcsb.mapviewer.model.map.species.field; + +import lcsb.mapviewer.model.map.species.AntisenseRna; + +/** + * Enum that enlists types of available modification regions in + * {@link AntisenseRna}. + * + * @author Piotr Gawron + * + */ +public enum AntisenseRnaRegionType { + + /** + * Modification site. + */ + MODIFICATION_SITE("Modification Site"), // + + /** + * Coding region. + */ + CODING_REGION("CodingRegion"), // + + /** + * Protein binding domain. + */ + PROTEIN_BINDING_DOMAIN("proteinBindingDomain"); + + /** + * Name of the type. + */ + private String name; + + /** + * Default constructor. + * + * @param name + * name of the type + */ + AntisenseRnaRegionType(String name) { + this.name = name; + } + + /** + * @return the name + * @see #name + */ + public String getName() { + return name; + } + + /** + * Returns {@link AntisenseRnaRegionType} identified by name. + * + * @param name + * name of the region + * @return {@link AntisenseRnaRegionType} identified by name + */ + public static AntisenseRnaRegionType getTypeByString(String name) { + for (AntisenseRnaRegionType type : values()) { + if (type.getName().equalsIgnoreCase(name)) { + return type; + } + } + return null; + } +} \ No newline at end of file diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/field/ModificationResidue.java b/model/src/main/java/lcsb/mapviewer/model/map/species/field/ModificationResidue.java index fda2fe6567347a294a7dcf742aee2554f33bb62e..cdf6422224bb2fe1ac1122aaf72fe46bf9efe219 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/field/ModificationResidue.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/field/ModificationResidue.java @@ -14,7 +14,6 @@ import javax.persistence.Table; import org.apache.log4j.Logger; -import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.Species; @@ -86,7 +85,7 @@ public class ModificationResidue implements Serializable { */ @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "idSpeciesDb", nullable = false) - private Species species; + private Species species; /** * Default constructor. @@ -109,31 +108,6 @@ public class ModificationResidue implements Serializable { this.state = mr.state; } - /** - * Updates fields in the object with the data given in the parameter - * modification. - * - * @param mr - * modification residue from which data will be used to update - */ - public void update(ModificationResidue mr) { - if (mr.getName() != null && !mr.getName().equals("")) { - this.name = mr.name; - } - if (mr.getAngle() != null) { - this.angle = mr.angle; - } - if (mr.getSize() != null) { - this.size = mr.size; - } - if (mr.getSide() != null && !mr.getSide().equals("")) { - this.side = mr.side; - } - if (mr.getState() != null) { - this.state = mr.state; - } - } - @Override public String toString() { String result = getIdModificationResidue() + "," + getName() + "," + getState() + "," + getAngle() + "," + getSize() + "," + getSide() + ","; @@ -153,43 +127,6 @@ public class ModificationResidue implements Serializable { } } - /** - * Sets {@link #angle} . - * - * @param text - * angle in text format - */ - public void setAngle(String text) { - try { - if (text != null && !text.equals("")) { - angle = Double.parseDouble(text); - } else { - angle = null; - } - } catch (NumberFormatException e) { - throw new InvalidArgumentException("Invalid angle: " + text, e); - } - - } - - /** - * Sets {@link #size}. - * - * @param text - * size in text format. - */ - public void setSize(String text) { - try { - if (text != null && !text.equals("")) { - size = Double.parseDouble(text); - } else { - size = null; - } - } catch (NumberFormatException e) { - throw new InvalidArgumentException("Invalid size: " + text, e); - } - } - /** * @return the idModificationResidue * @see #id diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/field/PositionToCompartment.java b/model/src/main/java/lcsb/mapviewer/model/map/species/field/PositionToCompartment.java index b9e143acd1f2d307378022f7483b9ccdffc3aa61..b03ba01d9724aec9234126603d15e3e6814f309d 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/field/PositionToCompartment.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/field/PositionToCompartment.java @@ -3,7 +3,8 @@ package lcsb.mapviewer.model.map.species.field; /** * Defines possible position of * {@link lcsb.mapviewer.converter.model.celldesigner.structure.Species} on - * {@link lcsb.mapviewer.model.map.agregator.converter.model.celldesigner.structure.Compartment}. + * {@link lcsb.mapviewer.model.map.agregator.converter.model.celldesigner.structure.Compartment} + * . * * @author Piotr Gawron * diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/field/package-info.java b/model/src/main/java/lcsb/mapviewer/model/map/species/field/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..2a4ed87d92243b989c2703e5b9d4da61f3ef7e35 --- /dev/null +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/field/package-info.java @@ -0,0 +1,7 @@ +/** + * Provides data structure for complicated + * {@link lcsb.mapviewer.model.map.species.Species Species} implementation. + * These structures contain some additional structural information about + * elements. + */ +package lcsb.mapviewer.model.map.species.field; \ No newline at end of file diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/package-info.java b/model/src/main/java/lcsb/mapviewer/model/map/species/package-info.java index 274edba7f6d52465281f53fd16ce0323c52fbfd4..b4478e672a0c4463398e9febc781224734308708 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/package-info.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/package-info.java @@ -1,6 +1,10 @@ /** - * This package provides data structures that stores information about aliases - * for the map elements. + * Provides data structure for elements on the map. The generic class from which + * all element classes inherit data is + * {@link lcsb.mapviewer.db.model.map.species.Element Element}. However, for + * species there is another class that inherits from this class: + * {@link lcsb.mapviewer.model.map.species.Species}. The package also contains + * comparators for these elements that compare the data of the structures, but + * ignore database-related information (like identifiers). */ -package lcsb.mapviewer.model.map.species; - +package lcsb.mapviewer.model.map.species; \ No newline at end of file diff --git a/model/src/main/java/lcsb/mapviewer/modelutils/map/ElementUtils.java b/model/src/main/java/lcsb/mapviewer/modelutils/map/ElementUtils.java index dfa46de1b5ffc4a8cd965b1c55145a0a59cd4263..faf995c2baa41a88c78066b6bddfa72be39d2dec 100644 --- a/model/src/main/java/lcsb/mapviewer/modelutils/map/ElementUtils.java +++ b/model/src/main/java/lcsb/mapviewer/modelutils/map/ElementUtils.java @@ -74,7 +74,7 @@ public final class ElementUtils { public String getElementTag(AnnotatedObject element, Object annotator) { String id = null; if (element instanceof Element) { - id = ((Element) element).getAliasId(); + id = ((Element) element).getElementId(); } else if (element instanceof Reaction) { id = ((Reaction) element).getIdReaction(); } else { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/AllMapTests.java b/model/src/test/java/lcsb/mapviewer/model/map/AllMapTests.java index 262bc7b6ac41149021db51c4854caf9ffea93eab..5670e7eb01948b7e34b96be7f12dfc3206f37825 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/AllMapTests.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/AllMapTests.java @@ -11,6 +11,7 @@ import lcsb.mapviewer.model.map.layout.graphics.AllGraphicsTests; import lcsb.mapviewer.model.map.model.AllModelTests; import lcsb.mapviewer.model.map.modifier.AllModifierTests; import lcsb.mapviewer.model.map.reaction.AllReactionTests; +import lcsb.mapviewer.model.map.species.AllSpeciesTests; import lcsb.mapviewer.model.map.statistics.AllStatisticsTests; @RunWith(Suite.class) @@ -22,6 +23,7 @@ import lcsb.mapviewer.model.map.statistics.AllStatisticsTests; AllModelTests.class, // AllModifierTests.class, // AllReactionTests.class, // + AllSpeciesTests.class, // AllStatisticsTests.class, // CommentTest.class, // InconsistentModelExceptionTest.class, // @@ -38,7 +40,10 @@ import lcsb.mapviewer.model.map.statistics.AllStatisticsTests; OverviewLinkTest.class, // OverviewModelLinkComparatorTest.class, // OverviewModelLinkTest.class, // - OverviewSearchLinkTest.class }) + OverviewSearchLinkTest.class, // + SearchIndexTest.class,// +}) + public class AllMapTests { } diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/SearchIndexTest.java b/model/src/test/java/lcsb/mapviewer/model/map/SearchIndexTest.java similarity index 89% rename from model/src/test/java/lcsb/mapviewer/model/map/species/SearchIndexTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/SearchIndexTest.java index c32f503d9a0494dfb0979a75f216399374b8d4c7..d9be1175f5c44c1937651d58ab98e4da8b23a350 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/SearchIndexTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/SearchIndexTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.species; +package lcsb.mapviewer.model.map; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -104,7 +104,7 @@ public class SearchIndexTest { int id = 54; int weight = 8; String value = "val5"; - Element alias = new Gene(); + Element element = new Gene("gene_id"); SearchIndex index = new SearchIndex(); index.setId(id); @@ -113,8 +113,8 @@ public class SearchIndexTest { index.setValue(value); assertEquals(value, index.getValue()); - index.setSource(alias); - assertEquals(alias, index.getSource()); + index.setSource(element); + assertEquals(element, index.getSource()); index.setWeight(weight); assertEquals((Integer) weight, index.getWeight()); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/compartment/AllCompartmentTests.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/AllCompartmentTests.java index fd6f1897ceb976307658dbd792b7084a71c59a72..0c68c92a16e86872780f630b5125fed59d559aef 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/compartment/AllCompartmentTests.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/AllCompartmentTests.java @@ -5,12 +5,15 @@ import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) -@SuiteClasses({ BottomSquareCompartmentAliasTest.class, // - CompartmentAliasComparatorTest.class, // - CompartmentAliasTest.class, // - LeftSquareCompartmentAliasTest.class, // - RightSquareCompartmentAliasTest.class, // - TopSquareCompartmentAliasTest.class, // +@SuiteClasses({ BottomSquareCompartmentTest.class, // + CompartmentComparatorTest.class, // + CompartmentTest.class, // + LeftSquareCompartmentTest.class, // + OvalCompartmentTest.class, // + PathwayCompartmentTest.class, // + RightSquareCompartmentTest.class, // + SquareCompartmentTest.class, // + TopSquareCompartmentTest.class, // }) public class AllCompartmentTests { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/compartment/BottomSquareCompartmentAliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/BottomSquareCompartmentTest.java similarity index 93% rename from model/src/test/java/lcsb/mapviewer/model/map/compartment/BottomSquareCompartmentAliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/compartment/BottomSquareCompartmentTest.java index 2c60d8f85db9f84c15578b270ed24580bba94ae9..34e53d6e94d7be1259b545e0854468a9527c3ffd 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/compartment/BottomSquareCompartmentAliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/BottomSquareCompartmentTest.java @@ -14,7 +14,7 @@ import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; -public class BottomSquareCompartmentAliasTest { +public class BottomSquareCompartmentTest { @Before public void setUp() throws Exception { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentAliasComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentComparatorTest.java similarity index 84% rename from model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentAliasComparatorTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentComparatorTest.java index 023498e2199cc1d428192e654d8dfc690a6d543d..c4d2f9627d5e7ca709bf2f8623c395f97ee1256d 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentAliasComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentComparatorTest.java @@ -18,7 +18,7 @@ import lcsb.mapviewer.model.map.compartment.PathwayCompartment; import lcsb.mapviewer.model.map.species.GenericProtein; import lcsb.mapviewer.model.map.species.Species; -public class CompartmentAliasComparatorTest { +public class CompartmentComparatorTest { CompartmentComparator comparator = new CompartmentComparator(); @@ -42,7 +42,7 @@ public class CompartmentAliasComparatorTest { } catch (Exception e) { e.printStackTrace(); - fail("Unkowne exception"); + throw e; } } @@ -66,12 +66,12 @@ public class CompartmentAliasComparatorTest { Compartment alias2 = createCompartmentAlias(); GenericProtein alias = new GenericProtein("1"); - alias1.getAliases().add(alias); + alias1.getElements().add(alias); alias = new GenericProtein("1"); - alias1.getAliases().add(alias); + alias1.getElements().add(alias); - alias2.getAliases().add(new GenericProtein("b")); - alias2.getAliases().add(new GenericProtein("a")); + alias2.getElements().add(new GenericProtein("b")); + alias2.getElements().add(new GenericProtein("a")); comparator.compare(alias1, alias2); fail("Exception expected"); @@ -90,12 +90,12 @@ public class CompartmentAliasComparatorTest { Compartment alias2 = createCompartmentAlias(); Species alias = new GenericProtein("1"); - alias1.getAliases().add(alias); + alias1.getElements().add(alias); alias = new GenericProtein("1"); - alias1.getAliases().add(alias); + alias1.getElements().add(alias); - alias2.getAliases().add(new GenericProtein("A")); - alias2.getAliases().add(new GenericProtein("B")); + alias2.getElements().add(new GenericProtein("A")); + alias2.getElements().add(new GenericProtein("B")); comparator.compare(alias2, alias1); fail("Exception expected"); @@ -110,7 +110,7 @@ public class CompartmentAliasComparatorTest { private Compartment createCompartmentAlias() { Compartment result = new Compartment(); - result.setAliasId("asd"); + result.setElementId("asd"); result.setX(12.0); result.setY(123.0); result.setWidth(4); @@ -125,7 +125,7 @@ public class CompartmentAliasComparatorTest { GenericProtein alias = new GenericProtein("S"); alias.setName("a"); - result.addAlias(alias); + result.addElement(alias); return result; } @@ -142,7 +142,7 @@ public class CompartmentAliasComparatorTest { alias1 = createCompartmentAlias(); alias2 = createCompartmentAlias(); - alias1.setAliasId("tmp"); + alias1.setElementId("tmp"); assertTrue(comparator.compare(alias1, alias2) != 0); assertTrue(comparator.compare(alias2, alias1) != 0); @@ -166,7 +166,7 @@ public class CompartmentAliasComparatorTest { alias1 = createCompartmentAlias(); alias2 = createCompartmentAlias(); - alias1.addAlias(new GenericProtein("idd")); + alias1.addElement(new GenericProtein("idd")); assertTrue(comparator.compare(alias1, alias2) != 0); assertTrue(comparator.compare(alias2, alias1) != 0); @@ -174,7 +174,7 @@ public class CompartmentAliasComparatorTest { alias1 = createCompartmentAlias(); alias2 = createCompartmentAlias(); - alias1.getAliases().iterator().next().setAliasId("bnu"); + alias1.getElements().iterator().next().setElementId("bnu"); assertTrue(comparator.compare(alias1, alias2) != 0); assertTrue(comparator.compare(alias2, alias1) != 0); @@ -182,7 +182,7 @@ public class CompartmentAliasComparatorTest { alias1 = createCompartmentAlias(); alias2 = createCompartmentAlias(); - Species speciesAlias = (Species) alias1.getAliases().iterator().next(); + Species speciesAlias = (Species) alias1.getElements().iterator().next(); speciesAlias.setName("new namne"); assertTrue(comparator.compare(alias1, alias2) != 0); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentAliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentTest.java similarity index 75% rename from model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentAliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentTest.java index 92c7be7d4d73967357f69d26139e6eee99e2f184..4fb5698713a158f0238a4552b62144b017aea5fb 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentAliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentTest.java @@ -28,8 +28,8 @@ import lcsb.mapviewer.model.map.species.GenericProtein; import lcsb.mapviewer.model.map.species.SimpleMolecule; import lcsb.mapviewer.model.map.species.Species; -public class CompartmentAliasTest { - Logger logger = Logger.getLogger(CompartmentAliasTest.class); +public class CompartmentTest { + Logger logger = Logger.getLogger(CompartmentTest.class); int identifierCounter = 1; @@ -45,12 +45,12 @@ public class CompartmentAliasTest { public void testCross() throws Exception { try { Model model = createCrossModel(); - Element ldhbAlias1 = model.getAliasByAliasId("sa1115"); - Element ldhbAlias2 = model.getAliasByAliasId("sa1117"); - Element ldhbAlias3 = model.getAliasByAliasId("sa1119"); - Element ldhbAlias4 = model.getAliasByAliasId("sa1121"); + Element ldhbAlias1 = model.getElementByElementId("sa1115"); + Element ldhbAlias2 = model.getElementByElementId("sa1117"); + Element ldhbAlias3 = model.getElementByElementId("sa1119"); + Element ldhbAlias4 = model.getElementByElementId("sa1121"); - Compartment cytosolAlias = (Compartment) model.getAliasByAliasId("ca1"); + Compartment cytosolAlias = (Compartment) model.getElementByElementId("ca1"); assertTrue(cytosolAlias.cross(ldhbAlias1)); assertTrue(cytosolAlias.cross(ldhbAlias2)); @@ -142,7 +142,7 @@ public class CompartmentAliasTest { Species sAlias = new GenericProtein("idd"); sAlias.setName("AS"); - alias.addAlias(sAlias); + alias.addElement(sAlias); assertTrue(alias.containsIdenticalSpecies()); @@ -179,7 +179,7 @@ public class CompartmentAliasTest { private Compartment createCompartmentAlias(double x, double y, double width, double height, String aliasId) { Compartment alias = new Compartment(aliasId); - alias.setAliasId(aliasId); + alias.setElementId(aliasId); alias.setX(x); alias.setY(y); alias.setWidth(width); @@ -209,10 +209,10 @@ public class CompartmentAliasTest { public void testCrossWithComplexElements() throws Exception { try { Model model = createCrossModel(); - Element ldhbAlias1 = model.getAliasByAliasId("sa1422"); - Element ldhbAlias2 = model.getAliasByAliasId("sa1419"); + Element ldhbAlias1 = model.getElementByElementId("sa1422"); + Element ldhbAlias2 = model.getElementByElementId("sa1419"); - Compartment cytosolAlias = (Compartment) model.getAliasByAliasId("ca1"); + Compartment cytosolAlias = (Compartment) model.getElementByElementId("ca1"); assertTrue(cytosolAlias.cross(ldhbAlias1)); assertTrue(cytosolAlias.cross(ldhbAlias2)); @@ -237,7 +237,7 @@ public class CompartmentAliasTest { public void testConstructor() { try { Compartment alias = new Compartment(); - alias.addAlias(new GenericProtein("idd")); + alias.addElement(new GenericProtein("idd")); Compartment copy = new Compartment(alias); assertNotNull(copy); } catch (Exception e) { @@ -247,44 +247,46 @@ public class CompartmentAliasTest { } @Test - public void testSetters() { + public void testGetters() { try { - Compartment alias = new Compartment(); + Compartment compartment = new Compartment(); String invalidVal = "a1.6"; String val = "1.6"; Double dVal = 1.6; - alias.setLineThickness(val); - alias.setLineOuterWidth(val); - alias.setLineInnerWidth(val); + compartment.setLineThickness(val); + compartment.setLineOuterWidth(val); + compartment.setLineInnerWidth(val); - assertEquals(dVal, alias.getThickness(), Configuration.EPSILON); - assertEquals(dVal, alias.getOuterWidth(), Configuration.EPSILON); - assertEquals(dVal, alias.getInnerWidth(), Configuration.EPSILON); + assertEquals(dVal, compartment.getThickness(), Configuration.EPSILON); + assertEquals(dVal, compartment.getOuterWidth(), Configuration.EPSILON); + assertEquals(dVal, compartment.getInnerWidth(), Configuration.EPSILON); try { - alias.setLineThickness(invalidVal); + compartment.setLineThickness(invalidVal); fail("Exception expected"); } catch (InvalidArgumentException e) { } try { - alias.setLineOuterWidth(invalidVal); + compartment.setLineOuterWidth(invalidVal); fail("Exception expected"); } catch (InvalidArgumentException e) { } try { - alias.setLineInnerWidth(invalidVal); + compartment.setLineInnerWidth(invalidVal); fail("Exception expected"); } catch (InvalidArgumentException e) { } - alias.setNamePoint(2, 3); - assertEquals(0, alias.getNamePoint().distance(2, 3), Configuration.EPSILON); + compartment.setNamePoint(2, 3); + assertEquals(0, compartment.getNamePoint().distance(2, 3), Configuration.EPSILON); - Set<Element> aliases = new HashSet<>(); + Set<Element> elements = new HashSet<>(); - alias.setAliases(aliases); - assertEquals(aliases, alias.getAliases()); + compartment.setElements(elements); + assertEquals(elements, compartment.getElements()); + + assertNotNull(compartment.getStringType()); } catch (Exception e) { e.printStackTrace(); @@ -299,10 +301,10 @@ public class CompartmentAliasTest { Species child = new GenericProtein("id"); - alias.addAlias(child); - alias.addAlias(child); + alias.addElement(child); + alias.addElement(child); - assertEquals(1, alias.getAliases().size()); + assertEquals(1, alias.getElements().size()); } catch (Exception e) { e.printStackTrace(); @@ -318,8 +320,8 @@ public class CompartmentAliasTest { Species child = new GenericProtein("id"); Species child2 = new GenericProtein("id"); - alias.addAlias(child); - alias.addAlias(child2); + alias.addElement(child); + alias.addElement(child2); fail("Exception expected"); @@ -337,10 +339,10 @@ public class CompartmentAliasTest { Species child = new GenericProtein("id"); Compartment child2 = new Compartment(); - child2.addAlias(child); - alias.addAlias(child2); + child2.addElement(child); + alias.addElement(child2); - assertEquals(2, alias.getAllSubAliases().size()); + assertEquals(2, alias.getAllSubElements().size()); } catch (Exception e) { e.printStackTrace(); @@ -363,13 +365,13 @@ public class CompartmentAliasTest { public void testRemoveAlias() { try { Compartment comp = new Compartment(); - Species alias = new GenericProtein("idd"); - comp.addAlias(alias); - alias.setCompartmentAlias(new Compartment()); + Species protein = new GenericProtein("idd"); + comp.addElement(protein); + protein.setCompartmentAlias(new Compartment()); - comp.removeAlias(alias); + comp.removeElement(protein); - assertEquals(0, comp.getAliases().size()); + assertEquals(0, comp.getElements().size()); } catch (Exception e) { e.printStackTrace(); throw e; diff --git a/model/src/test/java/lcsb/mapviewer/model/map/compartment/LeftSquareCompartmentAliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/LeftSquareCompartmentTest.java similarity index 93% rename from model/src/test/java/lcsb/mapviewer/model/map/compartment/LeftSquareCompartmentAliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/compartment/LeftSquareCompartmentTest.java index 84f18497c9d17d1451ae491c72524c81fc1ebf82..be0eae8f0ac3f103d173054b832c2330ef3c6b43 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/compartment/LeftSquareCompartmentAliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/LeftSquareCompartmentTest.java @@ -14,7 +14,7 @@ import lcsb.mapviewer.model.map.compartment.LeftSquareCompartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; -public class LeftSquareCompartmentAliasTest { +public class LeftSquareCompartmentTest { @Before public void setUp() throws Exception { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/OvalCompartmentAliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/OvalCompartmentTest.java similarity index 89% rename from model/src/test/java/lcsb/mapviewer/model/map/species/OvalCompartmentAliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/compartment/OvalCompartmentTest.java index 728f9f04f8af88cd9190d7fd8b5b96bdb25ae706..7034f15507592fa4dc85e70b1ecf1ca1bb72ceb0 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/OvalCompartmentAliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/OvalCompartmentTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.species; +package lcsb.mapviewer.model.map.compartment; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; @@ -11,7 +11,7 @@ import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.compartment.OvalCompartment; -public class OvalCompartmentAliasTest { +public class OvalCompartmentTest { @Before public void setUp() throws Exception { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/ArtifitialCompartmentAliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/PathwayCompartmentTest.java similarity index 74% rename from model/src/test/java/lcsb/mapviewer/model/map/species/ArtifitialCompartmentAliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/compartment/PathwayCompartmentTest.java index 2150eef721ab1ba96344dde640da11a6794a1e58..611b1414992371e91ec6114d1aef6374b132db35 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/ArtifitialCompartmentAliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/PathwayCompartmentTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.species; +package lcsb.mapviewer.model.map.compartment; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -8,13 +8,14 @@ import org.apache.commons.lang3.SerializationUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.compartment.CompartmentComparator; import lcsb.mapviewer.model.map.compartment.PathwayCompartment; -public class ArtifitialCompartmentAliasTest { +public class PathwayCompartmentTest { @Before public void setUp() throws Exception { @@ -28,7 +29,7 @@ public class ArtifitialCompartmentAliasTest { public void test() throws Exception { try { CompartmentComparator comparator = new CompartmentComparator(); - Compartment alias = new PathwayCompartment(); + Compartment alias = new PathwayCompartment("id"); Compartment copy = alias.copy(); assertEquals(0, comparator.compare(alias, copy)); @@ -42,7 +43,7 @@ public class ArtifitialCompartmentAliasTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new PathwayCompartment()); + SerializationUtils.serialize(new PathwayCompartment("id")); } catch (Exception e) { e.printStackTrace(); throw e; @@ -52,7 +53,7 @@ public class ArtifitialCompartmentAliasTest { @Test public void testGetters() { try { - PathwayCompartment alias = new PathwayCompartment(); + PathwayCompartment alias = new PathwayCompartment("id"); String title = "tit27"; alias.setName(title); assertEquals(title, alias.getName()); @@ -62,17 +63,11 @@ public class ArtifitialCompartmentAliasTest { } } - @Test public void testInvalidCopy() { try { - new PathwayCompartment() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); + PathwayCompartment comp = Mockito.spy(PathwayCompartment.class); + comp.copy(); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { @@ -84,7 +79,7 @@ public class ArtifitialCompartmentAliasTest { @Test public void testCopy() { try { - PathwayCompartment degraded = new PathwayCompartment().copy(); + PathwayCompartment degraded = new PathwayCompartment("id").copy(); assertNotNull(degraded); } catch (Exception e) { e.printStackTrace(); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/compartment/RightSquareCompartmentAliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/RightSquareCompartmentTest.java similarity index 93% rename from model/src/test/java/lcsb/mapviewer/model/map/compartment/RightSquareCompartmentAliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/compartment/RightSquareCompartmentTest.java index c0ab3d37100164ebc211aff427c65501bd4b1d43..4d303ceeec31e11fa14d3f0162dca52a30a0f9c1 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/compartment/RightSquareCompartmentAliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/RightSquareCompartmentTest.java @@ -15,7 +15,7 @@ import lcsb.mapviewer.model.map.compartment.RightSquareCompartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; -public class RightSquareCompartmentAliasTest { +public class RightSquareCompartmentTest { @Before public void setUp() throws Exception { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/SquareCompartmentAliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/SquareCompartmentTest.java similarity index 86% rename from model/src/test/java/lcsb/mapviewer/model/map/species/SquareCompartmentAliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/compartment/SquareCompartmentTest.java index 609af84b7b1860d6ead060842536ffc93f26dfbb..643499af11da8828e81959ed10c6279b1a49fd00 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/SquareCompartmentAliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/SquareCompartmentTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.species; +package lcsb.mapviewer.model.map.compartment; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; @@ -11,7 +11,7 @@ import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.compartment.SquareCompartment; -public class SquareCompartmentAliasTest { +public class SquareCompartmentTest { @Before public void setUp() throws Exception { @@ -34,7 +34,7 @@ public class SquareCompartmentAliasTest { @Test public void testConstructor() { try { - SquareCompartment original = new SquareCompartment(); + SquareCompartment original = new SquareCompartment("id"); SquareCompartment copy = new SquareCompartment(original); assertNotNull(copy); } catch (Exception e) { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/compartment/TopSquareCompartmentAliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/TopSquareCompartmentTest.java similarity index 93% rename from model/src/test/java/lcsb/mapviewer/model/map/compartment/TopSquareCompartmentAliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/compartment/TopSquareCompartmentTest.java index fc6a019068b33636ec96d6dc526c41bc8173d25a..40aba67fbe361e170edad63e446dc60e9a43a37f 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/compartment/TopSquareCompartmentAliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/TopSquareCompartmentTest.java @@ -14,7 +14,7 @@ import lcsb.mapviewer.model.map.compartment.TopSquareCompartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; -public class TopSquareCompartmentAliasTest { +public class TopSquareCompartmentTest { @Before public void setUp() throws Exception { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/AllLayoutTests.java b/model/src/test/java/lcsb/mapviewer/model/map/layout/AllLayoutTests.java index 8f9daf11793644de482119760886f2d343c6ff24..10a1e3535ad2e4b87ef7f69853d2a1f3192a337a 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/AllLayoutTests.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/layout/AllLayoutTests.java @@ -1,16 +1,15 @@ package lcsb.mapviewer.model.map.layout; -import lcsb.mapviewer.model.map.layout.graphics.AllGraphicsTests; -import lcsb.mapviewer.model.map.species.AllSpeciesTests; - import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; +import lcsb.mapviewer.model.map.layout.graphics.AllGraphicsTests; + @RunWith(Suite.class) -@SuiteClasses({ AllSpeciesTests.class, // - AllGraphicsTests.class, // +@SuiteClasses({ AllGraphicsTests.class, // ColorSchemaTest.class, // + ElementGroupTest.class, // GenericColorSchemaTest.class, // GeneVariationTest.class, // GeneVariationColorSchemaTest.class, // @@ -18,7 +17,7 @@ import org.junit.runners.Suite.SuiteClasses; LayoutStatusTest.class, // LayoutTest.class, // ReferenceGenomeGeneMappingTest.class, // - ReferenceGenomeTest.class,// + ReferenceGenomeTest.class, // ReferenceGenomeTypeTest.class,// }) public class AllLayoutTests { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/AliasGroupTest.java b/model/src/test/java/lcsb/mapviewer/model/map/layout/ElementGroupTest.java similarity index 87% rename from model/src/test/java/lcsb/mapviewer/model/map/species/AliasGroupTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/layout/ElementGroupTest.java index 058e4f8f561737fa7ee3ca517149c458bae38212..2d8274519446950734aea50c0299d8ad7f97cc8d 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/AliasGroupTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/layout/ElementGroupTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.species; +package lcsb.mapviewer.model.map.layout; import static org.junit.Assert.assertEquals; @@ -14,7 +14,7 @@ import lcsb.mapviewer.model.map.layout.ElementGroup; import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.GenericProtein; -public class AliasGroupTest { +public class ElementGroupTest { @Before public void setUp() throws Exception { @@ -56,7 +56,7 @@ public class AliasGroupTest { public void testAddAlias() { try { ElementGroup group = new ElementGroup(); - group.addAlias(new GenericProtein()); + group.addAlias(new GenericProtein("id")); assertEquals(1, group.getAliases().size()); } catch (Exception e) { e.printStackTrace(); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelComparatorTest.java index 83c038e0d1c7f496a5acb2264e86f10ba52945e1..47c0b2969ad6fc9e8c4f2f89fdbbd0ae641520ea 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelComparatorTest.java @@ -84,20 +84,16 @@ public class ModelComparatorTest { Model model1 = getModel(); Model model2 = getModel(); - Compartment alias = new PathwayCompartment(); - alias.setAliasId("1"); - Compartment alias2 = new PathwayCompartment(); - alias2.setAliasId("12"); + Compartment alias = new PathwayCompartment("1"); + Compartment alias2 = new PathwayCompartment("12"); model1.addAlias(alias); model1.addAlias(alias2); - alias = new PathwayCompartment(); - alias.setAliasId("1"); - alias2 = new PathwayCompartment(); - alias2.setAliasId("12"); + alias = new PathwayCompartment("1"); + alias2 = new PathwayCompartment("12"); model2.addAlias(alias); model2.addAlias(alias2); - alias2.setAliasId("1"); + alias2.setElementId("1"); assertTrue(comparator.compare(model1, model2) != 0); assertTrue(comparator.compare(model2, model1) != 0); @@ -146,7 +142,7 @@ public class ModelComparatorTest { Model model2 = getModel(); Species mockAlias = Mockito.mock(Species.class); - when(mockAlias.getAliasId()).thenReturn("1"); + when(mockAlias.getElementId()).thenReturn("1"); model1.addAlias(mockAlias); model2.addAlias(mockAlias); @@ -202,7 +198,7 @@ public class ModelComparatorTest { model1 = getModel(); model2 = getModel(); - model1.getAliases().iterator().next().setAliasId("sdfsd"); + model1.getAliases().iterator().next().setElementId("sdfsd"); assertTrue(comparator.compare(model1, model2) != 0); assertTrue(comparator.compare(model2, model1) != 0); @@ -218,7 +214,7 @@ public class ModelComparatorTest { model1 = getModel(); model2 = getModel(); - model1.getAliasByAliasId("default").setName("tmpxx"); + model1.getElementByElementId("default").setName("tmpxx"); assertTrue(comparator.compare(model1, model2) != 0); assertTrue(comparator.compare(model2, model1) != 0); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelFullIndexedTest.java b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelFullIndexedTest.java index 968d063f215bff4c63063f8861101a0c80ab69f3..d192167efdf4a2792fa7b02beb67606e93c4df06 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelFullIndexedTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelFullIndexedTest.java @@ -65,8 +65,7 @@ public class ModelFullIndexedTest { Element compartmentAlias = new Compartment("aaa"); Element compartmentAlias3 = new Compartment("aaa3"); - Element compartmentAlias2 = new PathwayCompartment(); - compartmentAlias2.setAliasId("aaa2"); + Element compartmentAlias2 = new PathwayCompartment("aaa2"); model.addAlias(proteinAlias); model.addAlias(proteinAlias2); model.addAlias(proteinAlias3); @@ -176,7 +175,7 @@ public class ModelFullIndexedTest { Complex alias = new Complex("1"); Element proteinAlias = new GenericProtein("asd"); - proteinAlias.setAliasId("zz"); + proteinAlias.setElementId("zz"); proteinAlias.setParent(alias); model.addAlias(alias); @@ -203,7 +202,7 @@ public class ModelFullIndexedTest { alias.setParent(compAlias); Element proteinAlias = new GenericProtein("asd"); - proteinAlias.setAliasId("zz"); + proteinAlias.setElementId("zz"); proteinAlias.setParent(alias); model.addAlias(alias); @@ -223,13 +222,13 @@ public class ModelFullIndexedTest { try { ModelFullIndexed model = new ModelFullIndexed(null); - assertNull(model.getAliasByAliasId("id")); + assertNull(model.getElementByElementId("id")); Species alias = new GenericProtein("asd"); - alias.setAliasId("id"); + alias.setElementId("id"); model.addAlias(alias); - assertNotNull(model.getAliasByAliasId("id")); + assertNotNull(model.getElementByElementId("id")); } catch (Exception e) { e.printStackTrace(); @@ -384,10 +383,10 @@ public class ModelFullIndexedTest { assertEquals(0, model.getCompartmentsAliases().size()); model.addAliases(aliases); assertEquals(1, model.getCompartmentsAliases().size()); - assertEquals(1, model.getComplexAliases().size()); - assertEquals(1, model.getNotComplexSpeciesAliases().size()); + assertEquals(1, model.getComplexList().size()); + assertEquals(1, model.getNotComplexSpeciesList().size()); - List<Element> sortedAliases = model.getSortedAliases(); + List<Element> sortedAliases = model.getSortedSpeciesList(); assertEquals(alias, sortedAliases.get(0)); assertEquals(sAlias, sortedAliases.get(1)); @@ -432,7 +431,7 @@ public class ModelFullIndexedTest { Complex alias = new Complex("b"); alias.setParent(parentAlias); - alias.setAliasId("1"); + alias.setElementId("1"); alias.setCompartmentAlias(new Compartment("comp_alias")); alias.setComplexAlias(new Complex("d")); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelTest.java b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelTest.java index 7aa22330bb49b44a4e66702b314c2e3c6a781ef2..120e2ecc904a6b6a3f138dc963941ca44f0ab21f 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelTest.java @@ -52,9 +52,9 @@ public class ModelTest { public void testAddAlias() { try { model.addAlias(alias); - Element sAlias = model.getAliasByAliasId(alias.getAliasId()); + Element sAlias = model.getElementByElementId(alias.getElementId()); assertNotNull(sAlias); - sAlias = model.getAliasByAliasId(alias.getAliasId() + "blbla"); + sAlias = model.getElementByElementId(alias.getElementId() + "blbla"); assertNull(sAlias); } catch (Exception e) { @@ -71,17 +71,17 @@ public class ModelTest { model.addAlias(alias); assertEquals(1, aliases.size()); - Element sAlias = model.getAliasByAliasId(alias.getAliasId()); + Element sAlias = model.getElementByElementId(alias.getElementId()); assertNotNull(sAlias); - sAlias = model.getAliasByAliasId(alias.getAliasId() + "blbla"); + sAlias = model.getElementByElementId(alias.getElementId() + "blbla"); assertNull(sAlias); - sAlias = model.getAliasByAliasId(cAlias.getAliasId()); + sAlias = model.getElementByElementId(cAlias.getElementId()); assertNull(sAlias); model.addAlias(cAlias); assertEquals(2, aliases.size()); - sAlias = model.getAliasByAliasId(cAlias.getAliasId()); + sAlias = model.getElementByElementId(cAlias.getElementId()); assertNotNull(sAlias); } catch (Exception e) { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/model/SubmodelConnectionComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/model/SubmodelConnectionComparatorTest.java index dbf30972ba3d935820b11474988f1baac27141c9..858fc735fea87d46344d1f2ee30dcbffdb8c7ea4 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/model/SubmodelConnectionComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/model/SubmodelConnectionComparatorTest.java @@ -167,7 +167,7 @@ public class SubmodelConnectionComparatorTest { Species alias = new GenericProtein("a_id"); alias.setName("ad"); - alias.setAliasId("a_id"); + alias.setElementId("a_id"); model.addAlias(alias); model.addAlias(new Compartment("default")); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/reaction/ReactionComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/reaction/ReactionComparatorTest.java index e6c1ceb06fcb33c2471e1e8d7ec236cc26897fd9..db8a868e06b1a41e5a38bf67d0cdc4c371210731 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/reaction/ReactionComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/reaction/ReactionComparatorTest.java @@ -194,7 +194,7 @@ public class ReactionComparatorTest { reaction1 = createReaction(); reaction2 = createReaction(); - reaction1.getModifiers().get(0).getAlias().setAliasId("dfshkj"); + reaction1.getModifiers().get(0).getAlias().setElementId("dfshkj"); assertTrue(comparator.compare(reaction1, reaction2) != 0); assertTrue(comparator.compare(reaction2, reaction1) != 0); @@ -208,7 +208,7 @@ public class ReactionComparatorTest { reaction1 = createReaction(); reaction2 = createReaction(); - reaction1.getReactants().get(0).getAlias().setAliasId("dfshkj"); + reaction1.getReactants().get(0).getAlias().setElementId("dfshkj"); assertTrue(comparator.compare(reaction1, reaction2) != 0); assertTrue(comparator.compare(reaction2, reaction1) != 0); @@ -222,7 +222,7 @@ public class ReactionComparatorTest { reaction1 = createReaction(); reaction2 = createReaction(); - reaction1.getProducts().get(0).getAlias().setAliasId("dfshkj"); + reaction1.getProducts().get(0).getAlias().setElementId("dfshkj"); assertTrue(comparator.compare(reaction1, reaction2) != 0); assertTrue(comparator.compare(reaction2, reaction1) != 0); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/AliasComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/AliasComparatorTest.java deleted file mode 100644 index 768b5697b472723176762da088be398e1d2be5ee..0000000000000000000000000000000000000000 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/AliasComparatorTest.java +++ /dev/null @@ -1,167 +0,0 @@ -package lcsb.mapviewer.model.map.species; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.awt.Color; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; - -import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.compartment.Compartment; -import lcsb.mapviewer.model.map.layout.graphics.Layer; -import lcsb.mapviewer.model.map.model.AliasSubmodelConnection; -import lcsb.mapviewer.model.map.model.Model; -import lcsb.mapviewer.model.map.model.ModelFullIndexed; -import lcsb.mapviewer.model.map.model.SubmodelType; -import lcsb.mapviewer.model.map.reaction.Reaction; -import lcsb.mapviewer.model.map.species.Element; -import lcsb.mapviewer.model.map.species.ElementComparator; -import lcsb.mapviewer.model.map.species.Complex; -import lcsb.mapviewer.model.map.species.GenericProtein; -import lcsb.mapviewer.model.map.species.Protein; -import lcsb.mapviewer.model.map.species.Species; - -public class AliasComparatorTest { - - ElementComparator comparator = new ElementComparator(); - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testCompareException() throws Exception { - try { - comparator.compare(Mockito.mock(Element.class), Mockito.mock(Element.class)); - - fail("Exception should occur"); - } catch (NotImplementedException e) { - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testEquals() throws Exception { - try { - assertEquals(0, comparator.compare(new GenericProtein("id2"), new GenericProtein("id2"))); - assertEquals(0, comparator.compare(new Complex(), new Complex())); - assertEquals(0, comparator.compare(null, null)); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testDifferent() throws Exception { - try { - assertTrue(comparator.compare(new GenericProtein("id2"), new GenericProtein("id1")) != 0); - - assertTrue(comparator.compare(null, new GenericProtein()) != 0); - assertTrue(comparator.compare(new GenericProtein(), null) != 0); - assertTrue(comparator.compare(new GenericProtein(), new Complex()) != 0); - - Species sa1 = new GenericProtein("id2"); - Species sa2 = new GenericProtein("id2"); - sa2.setY(2); - assertTrue(comparator.compare(sa1, sa2) != 0); - - sa1 = new GenericProtein("id2"); - sa2 = new GenericProtein("id2"); - sa2.setY(2); - assertTrue(comparator.compare(sa1, sa2) != 0); - - sa1 = new GenericProtein("id2"); - sa2 = new GenericProtein("id2"); - sa2.setHeight(2); - assertTrue(comparator.compare(sa1, sa2) != 0); - - sa1 = new GenericProtein("id2"); - sa2 = new GenericProtein("id2"); - sa2.setFontSize(2); - assertTrue(comparator.compare(sa1, sa2) != 0); - - sa1 = new GenericProtein("id2"); - sa2 = new GenericProtein("id2"); - sa2.setColor(Color.BLUE); - assertTrue(comparator.compare(sa1, sa2) != 0); - - sa1 = new GenericProtein("id2"); - sa2 = new GenericProtein("id2"); - sa2.setVisibilityLevel(6); - assertTrue(comparator.compare(sa1, sa2) != 0); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testCompareSubmodel() throws Exception { - try { - Element alias1 = createAlias(); - Element alias2 = createAlias(); - assertEquals(0, comparator.compare(alias1, alias2)); - - alias1.setSubmodel(null); - assertTrue(comparator.compare(alias1, alias2) != 0); - assertTrue(comparator.compare(alias2, alias1) != 0); - - alias1 = createAlias(); - alias2 = createAlias(); - - alias1.getSubmodel().setName("Na"); - - assertTrue(comparator.compare(alias1, alias2) != 0); - assertTrue(comparator.compare(alias2, alias1) != 0); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - private Element createAlias() { - Element result = new GenericProtein("id2"); - AliasSubmodelConnection submodel = new AliasSubmodelConnection(getModel(), SubmodelType.DOWNSTREAM_TARGETS); - result.setSubmodel(submodel); - return result; - } - - private Model getModel() { - Model model = new ModelFullIndexed(null); - - model.setNotes("Some description"); - GenericProtein protein = new GenericProtein("A"); - protein.setName("ad"); - model.addAlias(protein); - - Protein alias = new GenericProtein("a_id"); - alias.setName("ad"); - model.addAlias(alias); - - model.addAlias(new Compartment("default")); - - Layer layer = new Layer(); - layer.setName("layer name"); - model.addLayer(layer); - - model.addReaction(new Reaction()); - return model; - } - -} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/AllSpeciesTests.java b/model/src/test/java/lcsb/mapviewer/model/map/species/AllSpeciesTests.java index 851a16e81f037fdfaa4d5bf2fa4114cbe24a7d2d..e788f454435cf74cda0eb62ef7a75ecaa4695c7e 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/AllSpeciesTests.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/AllSpeciesTests.java @@ -4,23 +4,39 @@ import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; -import lcsb.mapviewer.model.map.compartment.BottomSquareCompartmentAliasTest; -import lcsb.mapviewer.model.map.compartment.CompartmentAliasComparatorTest; -import lcsb.mapviewer.model.map.compartment.CompartmentAliasTest; -import lcsb.mapviewer.model.map.compartment.LeftSquareCompartmentAliasTest; -import lcsb.mapviewer.model.map.compartment.RightSquareCompartmentAliasTest; -import lcsb.mapviewer.model.map.compartment.TopSquareCompartmentAliasTest; +import lcsb.mapviewer.model.map.species.field.AllFieldTests; @RunWith(Suite.class) -@SuiteClasses({ - AliasGroupTest.class, // - AliasTest.class, // - ArtifitialCompartmentAliasTest.class, // - ComplexAliasComparatorTest.class, // - ComplexAliasTest.class, // - SearchIndexTest.class, // - SpeciesAliasComparatorTest.class, // - SpeciesAliasTest.class, // +@SuiteClasses({ AllFieldTests.class, // + AntisenseRnaComparatorTest.class, // + AntisenseRnaTest.class, // + ComplexComparatorTest.class, // + ComplexTest.class, // + DegradedComparatorTest.class, // + DegradedTest.class, // + DrugComparatorTest.class, // + DrugTest.class, // + ElementComparatorTest.class, // + ElementTest.class, // + GeneComparatorTest.class, // + GeneTest.class, // + IonChannelProteinTest.class, // + IonComparatorTest.class, // + IonTest.class, // + PhenotypeComparatorTest.class, // + PhenotypeTest.class, // + ProteinComparatorTest.class, // + ProteinTest.class, // + ReceptorProteinTest.class, // + RnaComparatorTest.class, // + RnaTest.class, // + SimpleMoleculeComparatorTest.class, // + SimpleMoleculeTest.class, // + SpeciesComparatorTest.class, // + SpeciesTest.class, // + TruncatedProteinTest.class, // + UnknownComparatorTest.class, // + UnknownTest.class, // }) public class AllSpeciesTests { diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRnaComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparatorTest.java similarity index 65% rename from converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRnaComparatorTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparatorTest.java index 0b09958461600cac3b45d14fb49e332cb68ad94e..6668697f82eb369b5b14cb767e92eeff50ba32df 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRnaComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparatorTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -9,14 +9,12 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerAntisenseRna; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerAntisenseRnaComparator; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerAntisenseRnaRegion; -import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion.AntisenseRnaRegionType; +import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion; +import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegionType; public class AntisenseRnaComparatorTest { - CellDesignerAntisenseRnaComparator comparator = new CellDesignerAntisenseRnaComparator(); + AntisenseRnaComparator comparator = new AntisenseRnaComparator(); @Before public void setUp() throws Exception { @@ -29,8 +27,8 @@ public class AntisenseRnaComparatorTest { @Test public void testEquals() { try { - CellDesignerAntisenseRna aRna1 = createAntisenseRna(); - CellDesignerAntisenseRna aRna2 = createAntisenseRna(); + AntisenseRna aRna1 = createAntisenseRna(); + AntisenseRna aRna2 = createAntisenseRna(); assertEquals(0, comparator.compare(aRna1, aRna1)); @@ -46,8 +44,8 @@ public class AntisenseRnaComparatorTest { @Test public void testDifferent() { try { - CellDesignerAntisenseRna aRna1 = createAntisenseRna(); - CellDesignerAntisenseRna aRna2 = createAntisenseRna(); + AntisenseRna aRna1 = createAntisenseRna(); + AntisenseRna aRna2 = createAntisenseRna(); aRna1.getRegions().get(0).setName("bla"); assertTrue(comparator.compare(aRna1, aRna2) != 0); assertTrue(comparator.compare(aRna2, aRna1) != 0); @@ -64,11 +62,11 @@ public class AntisenseRnaComparatorTest { assertTrue(comparator.compare(aRna2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - CellDesignerAntisenseRna unknown = createAntisenseRna(); + AntisenseRna unknown = createAntisenseRna(); unknown.setName("n"); assertTrue(comparator.compare(unknown, aRna2) != 0); - assertTrue(comparator.compare(unknown, new CellDesignerAntisenseRna() { + assertTrue(comparator.compare(unknown, new AntisenseRna() { private static final long serialVersionUID = 1L; }) != 0); } catch (Exception e) { @@ -77,10 +75,10 @@ public class AntisenseRnaComparatorTest { } } - public CellDesignerAntisenseRna createAntisenseRna() { - CellDesignerAntisenseRna result = new CellDesignerAntisenseRna(); + public AntisenseRna createAntisenseRna() { + AntisenseRna result = new AntisenseRna(); - CellDesignerAntisenseRnaRegion region1 = new CellDesignerAntisenseRnaRegion(); + AntisenseRnaRegion region1 = new AntisenseRnaRegion(); result.addRegion(region1); region1.setIdAntisenseRnaRegion("a"); region1.setName("name"); @@ -90,11 +88,10 @@ public class AntisenseRnaComparatorTest { return result; } - @Test public void testInvalid() { try { - class Tmp extends CellDesignerAntisenseRna { + class Tmp extends AntisenseRna { private static final long serialVersionUID = 1L; } Tmp object = new Tmp(); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/AntisenseRnaTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/AntisenseRnaTest.java new file mode 100644 index 0000000000000000000000000000000000000000..797200f2ec6146649c73c6036185b0591e2ee59d --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/AntisenseRnaTest.java @@ -0,0 +1,97 @@ +package lcsb.mapviewer.model.map.species; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.SerializationUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion; + +public class AntisenseRnaTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new AntisenseRna()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testConstructor1() { + try { + AntisenseRna original = new AntisenseRna(); + original.addRegion(new AntisenseRnaRegion()); + AntisenseRna aRna = new AntisenseRna(original); + assertNotNull(aRna); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testGetters() { + try { + AntisenseRna aRna = new AntisenseRna("id"); + assertNotNull(aRna.getStringType()); + + List<AntisenseRnaRegion> regions = new ArrayList<>(); + + aRna.setRegions(regions); + + assertEquals(regions, aRna.getRegions()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testCopy() { + try { + AntisenseRna aRna = new AntisenseRna().copy(); + assertNotNull(aRna); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testInvalidCopy() { + try { + new AntisenseRna() { + + /** + * + */ + private static final long serialVersionUID = 1L; + }.copy(); + fail("Exception expected"); + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + +} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexAliasComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexAliasComparatorTest.java deleted file mode 100644 index 9c63b53a900a1915b37b5d1c99b3c63bd2fb22ae..0000000000000000000000000000000000000000 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexAliasComparatorTest.java +++ /dev/null @@ -1,196 +0,0 @@ -package lcsb.mapviewer.model.map.species; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.awt.Color; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.species.Complex; -import lcsb.mapviewer.model.map.species.ComplexComparator; -import lcsb.mapviewer.model.map.species.GenericProtein; -import lcsb.mapviewer.model.map.species.Species; - -public class ComplexAliasComparatorTest { - - ComplexComparator comparator = new ComplexComparator(); - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testEquals() { - try { - Complex alias1 = createComplexAlias(); - Complex alias2 = createComplexAlias(); - - assertEquals(0, comparator.compare(alias1, alias2)); - - assertEquals(0, comparator.compare(null, null)); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - private Complex createComplexAlias() { - Complex result = new Complex(); - result.setName("complex"); - - result.setAliasId("asd"); - result.setX(12.0); - result.setY(123.0); - result.setWidth(4); - result.setHeight(5); - result.setFontSize(9.0); - result.setColor(Color.BLUE); - result.setVisibilityLevel(14); - - Species alias = new GenericProtein("S"); - alias.setName("a"); - result.addAlias(alias); - - return result; - } - - @Test - public void testDifferent() { - try { - Complex alias1 = createComplexAlias(); - Complex alias2 = createComplexAlias(); - - assertTrue(comparator.compare(alias1, null) != 0); - assertTrue(comparator.compare(null, alias1) != 0); - - alias1 = createComplexAlias(); - alias2 = createComplexAlias(); - - alias1.setAliasId("tmp"); - - assertTrue(comparator.compare(alias1, alias2) != 0); - assertTrue(comparator.compare(alias2, alias1) != 0); - - alias1 = createComplexAlias(); - alias2 = createComplexAlias(); - - alias1.addAlias(new GenericProtein("id")); - - assertTrue(comparator.compare(alias1, alias2) != 0); - assertTrue(comparator.compare(alias2, alias1) != 0); - - alias1 = createComplexAlias(); - alias2 = createComplexAlias(); - - alias1.getAliases().iterator().next().setAliasId("bnu"); - - assertTrue(comparator.compare(alias1, alias2) != 0); - assertTrue(comparator.compare(alias2, alias1) != 0); - - alias1 = createComplexAlias(); - alias2 = createComplexAlias(); - - Species speciesAlias = (Species) alias1.getAliases().iterator().next(); - speciesAlias.setName("new namne"); - - assertTrue(comparator.compare(alias1, alias2) != 0); - assertTrue(comparator.compare(alias2, alias1) != 0); - - alias1 = createComplexAlias(); - alias2 = createComplexAlias(); - - alias1.setName("new namne"); - - assertTrue(comparator.compare(alias1, alias2) != 0); - assertTrue(comparator.compare(alias2, alias1) != 0); - - assertTrue(comparator.compare(alias2, new Complex() { - private static final long serialVersionUID = 1L; - }) != 0); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testInvalid() { - try { - Complex alias1 = createComplexAlias(); - Complex alias2 = createComplexAlias(); - - GenericProtein alias = new GenericProtein("1"); - alias1.getAliases().add(alias); - alias = new GenericProtein("1"); - alias1.getAliases().add(alias); - - alias2.getAliases().add(new GenericProtein("b")); - alias2.getAliases().add(new GenericProtein("a")); - - comparator.compare(alias1, alias2); - fail("Exception expected"); - - } catch (InvalidArgumentException e) { - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testInvalid3() { - try { - class Tmp extends Complex { - private static final long serialVersionUID = 1L; - } - ; - Tmp alias1 = new Tmp(); - Tmp alias2 = new Tmp(); - - comparator.compare(alias1, alias2); - fail("Exception expected"); - - } catch (NotImplementedException e) { - } catch (Exception e) { - e.printStackTrace(); - fail("Unkowne exception"); - } - } - - @Test - public void testInvalid2() { - try { - Complex alias1 = createComplexAlias(); - Complex alias2 = createComplexAlias(); - - Species alias = new GenericProtein("1"); - alias1.getAliases().add(alias); - alias = new GenericProtein("1"); - alias1.getAliases().add(alias); - - alias2.getAliases().add(new GenericProtein("A")); - alias2.getAliases().add(new GenericProtein("B")); - - comparator.compare(alias2, alias1); - fail("Exception expected"); - - } catch (InvalidArgumentException e) { - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - -} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexComparatorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..487cc2f5bb93857e6c19792406a2d5f555cf159b --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexComparatorTest.java @@ -0,0 +1,424 @@ +package lcsb.mapviewer.model.map.species; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.when; + +import java.awt.Color; + +import org.apache.log4j.Logger; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; + +import lcsb.mapviewer.common.exception.InvalidArgumentException; +import lcsb.mapviewer.common.exception.NotImplementedException; + +public class ComplexComparatorTest { + + Logger logger = Logger.getLogger(ComplexComparatorTest.class); + ComplexComparator comparator = new ComplexComparator(); + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testEquals() { + try { + Complex alias1 = createComplexAlias(); + Complex alias2 = createComplexAlias(); + + assertEquals(0, comparator.compare(alias1, alias2)); + + assertEquals(0, comparator.compare(null, null)); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + private Complex createComplexAlias() { + Complex result = new Complex(); + result.setName("complex"); + + result.setElementId("asd"); + result.setX(12.0); + result.setY(123.0); + result.setWidth(4); + result.setHeight(5); + result.setFontSize(9.0); + result.setColor(Color.BLUE); + result.setVisibilityLevel(14); + + Species alias = new GenericProtein("S"); + alias.setName("a"); + result.addAlias(alias); + + return result; + } + + @Test + public void testDifferent() { + try { + Complex alias1 = createComplexAlias(); + Complex alias2 = createComplexAlias(); + + assertTrue(comparator.compare(alias1, null) != 0); + assertTrue(comparator.compare(null, alias1) != 0); + + alias1 = createComplexAlias(); + alias2 = createComplexAlias(); + + alias1.setElementId("tmp"); + + assertTrue(comparator.compare(alias1, alias2) != 0); + assertTrue(comparator.compare(alias2, alias1) != 0); + + alias1 = createComplexAlias(); + alias2 = createComplexAlias(); + + alias1.addAlias(new GenericProtein("id")); + + assertTrue(comparator.compare(alias1, alias2) != 0); + assertTrue(comparator.compare(alias2, alias1) != 0); + + alias1 = createComplexAlias(); + alias2 = createComplexAlias(); + + alias1.getAliases().iterator().next().setElementId("bnu"); + + assertTrue(comparator.compare(alias1, alias2) != 0); + assertTrue(comparator.compare(alias2, alias1) != 0); + + alias1 = createComplexAlias(); + alias2 = createComplexAlias(); + + Species speciesAlias = (Species) alias1.getAliases().iterator().next(); + speciesAlias.setName("new namne"); + + assertTrue(comparator.compare(alias1, alias2) != 0); + assertTrue(comparator.compare(alias2, alias1) != 0); + + alias1 = createComplexAlias(); + alias2 = createComplexAlias(); + + alias1.setName("new namne"); + + assertTrue(comparator.compare(alias1, alias2) != 0); + assertTrue(comparator.compare(alias2, alias1) != 0); + + assertTrue(comparator.compare(alias2, new Complex() { + private static final long serialVersionUID = 1L; + }) != 0); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testInvalid() { + try { + Complex alias1 = createComplexAlias(); + Complex alias2 = createComplexAlias(); + + GenericProtein alias = new GenericProtein("1"); + alias1.getAliases().add(alias); + alias = new GenericProtein("1"); + alias1.getAliases().add(alias); + + alias2.getAliases().add(new GenericProtein("b")); + alias2.getAliases().add(new GenericProtein("a")); + + comparator.compare(alias1, alias2); + fail("Exception expected"); + + } catch (InvalidArgumentException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testInvalid3() { + try { + class Tmp extends Complex { + private static final long serialVersionUID = 1L; + } + ; + Tmp alias1 = new Tmp(); + Tmp alias2 = new Tmp(); + + comparator.compare(alias1, alias2); + fail("Exception expected"); + + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + fail("Unkowne exception"); + } + } + + @Test + public void testInvalid2() { + try { + Complex alias1 = createComplexAlias(); + Complex alias2 = createComplexAlias(); + + Species alias = new GenericProtein("1"); + alias1.getAliases().add(alias); + alias = new GenericProtein("1"); + alias1.getAliases().add(alias); + + alias2.getAliases().add(new GenericProtein("A")); + alias2.getAliases().add(new GenericProtein("B")); + + comparator.compare(alias2, alias1); + fail("Exception expected"); + + } catch (InvalidArgumentException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testEquals2() { + try { + Complex complex1 = createComplex(); + Complex complex2 = createComplex(); + + assertEquals(0, comparator.compare(complex1, complex1)); + + assertEquals(0, comparator.compare(complex1, complex2)); + assertEquals(0, comparator.compare(complex2, complex1)); + + complex2.addAlias(new GenericProtein("test")); + complex1.addAlias(new GenericProtein("test")); + assertEquals(0, comparator.compare(complex1, complex2)); + assertEquals(0, comparator.compare(complex2, complex1)); + } catch (Exception e) { + e.printStackTrace(); + fail("Unknowne exception occurred"); + } + } + + @Test + public void testInvalidComp() throws Exception { + try { + class Tmp extends Complex { + private static final long serialVersionUID = 1L; + } + + comparator.compare(new Tmp(), new Tmp()); + fail("Exception expected"); + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + + } + + @Test + public void testInvalidComp2() throws Exception { + try { + Complex complex1 = createComplex(); + Complex complex2 = createComplex(); + + Species mock = Mockito.mock(Species.class); + when(mock.getElementId()).thenReturn("id"); + complex1.addAlias(mock); + complex2.addAlias(mock); + comparator.compare(complex1, complex2); + comparator.compare(complex2, complex1); + fail("Exception expected"); + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + + } + + @Test + public void testInvalidComp3() throws Exception { + try { + Complex complex1 = createComplex(); + Complex complex2 = createComplex(); + GenericProtein c = new GenericProtein("test"); + c.setName("a"); + complex2.addAlias(c); + c.setName(""); + complex1.addAlias(new GenericProtein("test")); + Species mock = Mockito.mock(Species.class); + when(mock.getElementId()).thenReturn("id"); + complex1.addAlias(mock); + complex2.addAlias(mock); + comparator.compare(complex2, complex1); + fail("Exception expected"); + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + + } + + @Test + public void testDifferent5() throws Exception { + try { + Complex complex1 = createComplex(); + Complex complex2 = createComplex(); + complex1.setHomodimer(123); + assertTrue(comparator.compare(complex1, complex2) != 0); + assertTrue(comparator.compare(complex2, complex1) != 0); + + complex1 = createComplex(); + complex2 = createComplex(); + complex1.getAliases().iterator().next().setNotes("bla"); + assertTrue(comparator.compare(complex1, complex2) != 0); + assertTrue(comparator.compare(complex2, complex1) != 0); + + complex1 = createComplex(); + complex2 = createComplex(); + complex1.getAliases().clear(); + assertTrue(comparator.compare(complex1, complex2) != 0); + assertTrue(comparator.compare(complex2, complex1) != 0); + + complex1 = createComplex(); + complex2 = createComplex(); + assertTrue(comparator.compare(null, complex2) != 0); + assertTrue(comparator.compare(complex2, null) != 0); + assertTrue(comparator.compare(null, null) == 0); + + complex1 = createComplex(); + complex2 = createComplex(); + Complex child = (Complex) complex1.getAliases().iterator().next(); + child.getAliases().iterator().next().setNotes("grand child notes"); + assertTrue(comparator.compare(complex1, complex2) != 0); + assertTrue(comparator.compare(complex2, complex1) != 0); + + complex1 = createComplex(); + complex2 = createComplex(); + Protein prot = new GenericProtein(); + prot.setElementId("test"); + complex1.addAlias(prot); + assertTrue(comparator.compare(complex1, complex2) != 0); + assertTrue(comparator.compare(complex2, complex1) != 0); + + complex1 = createComplex(); + complex2 = createComplex(); + complex1.setStructuralState("str"); + assertTrue(comparator.compare(complex1, complex2) != 0); + assertTrue(comparator.compare(complex2, complex1) != 0); + + assertTrue(comparator.compare(new Complex(), new Complex() { + + /** + * + */ + private static final long serialVersionUID = 1L; + }) != 0); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testDifferent3() throws Exception { + try { + Complex complex1 = createComplex(); + Complex complex2 = createComplex(); + GenericProtein prot = new GenericProtein(); + prot.setElementId("test"); + complex1.addAlias(prot); + prot = new GenericProtein(); + prot.setElementId("test2"); + complex2.addAlias(prot); + assertTrue(comparator.compare(complex1, complex2) != 0); + assertTrue(comparator.compare(complex2, complex1) != 0); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testDifferent4() throws Exception { + try { + Complex complex1 = createComplex(); + Complex complex2 = createComplex(); + GenericProtein c = new GenericProtein("test"); + c.setName("a"); + complex2.addAlias(c); + complex2.addAlias(new GenericProtein("test")); + c.setName(""); + + complex1.addAlias(new GenericProtein("test")); + GenericProtein d = new GenericProtein("test2"); + d.setName("a"); + complex1.addAlias(d); + assertTrue(comparator.compare(complex1, complex2) != 0); + assertTrue(comparator.compare(complex2, complex1) != 0); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testDifferent2() throws Exception { + try { + Complex complex1 = createComplex(); + Complex complex2 = createComplex(); + GenericProtein comp = new GenericProtein("test"); + comp.setFullName("X"); + complex1.addAlias(comp); + complex2.addAlias(new GenericProtein("test")); + assertTrue(comparator.compare(complex1, complex2) != 0); + assertTrue(comparator.compare(complex2, complex1) != 0); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + public Complex createComplex() { + Complex result = new Complex(); + + result.setHypothetical(true); + result.setHomodimer(3); + + Complex child = new Complex(); + result.addAlias(child); + child.setCharge(12); + child.setName("buu"); + child.setNotes("hey, hi, hello"); + + Complex grandChild = new Complex(); + child.addAlias(grandChild); + child.setCharge(123); + child.setName("buus"); + child.setNotes("hey, hi, hello !!"); + + return result; + } + +} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexAliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexTest.java similarity index 94% rename from model/src/test/java/lcsb/mapviewer/model/map/species/ComplexAliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/ComplexTest.java index 6019ce77f2adcd3b17048269a917dab57d4b7711..ba80d636149572c88b82fbe1ff9e5e7deae9b783 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexAliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexTest.java @@ -14,7 +14,7 @@ import lcsb.mapviewer.model.map.species.Complex; import lcsb.mapviewer.model.map.species.GenericProtein; import lcsb.mapviewer.model.map.species.Species; -public class ComplexAliasTest { +public class ComplexTest { @Before public void setUp() throws Exception { diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DegradedComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/DegradedComparatorTest.java similarity index 67% rename from converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DegradedComparatorTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/DegradedComparatorTest.java index 5725351d961076ffe90260f945d95f95f891c1e9..fcd2c76542a52d6ef1b32a28a6e89c64925d7d9f 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DegradedComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/DegradedComparatorTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -9,12 +9,10 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerDegraded; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerDegradedComparator; public class DegradedComparatorTest { - CellDesignerDegradedComparator comparator = new CellDesignerDegradedComparator(); + DegradedComparator comparator = new DegradedComparator(); @Before public void setUp() throws Exception { @@ -27,8 +25,8 @@ public class DegradedComparatorTest { @Test public void testEquals() { try { - CellDesignerDegraded degraded1 = createDegraded(); - CellDesignerDegraded degraded2 = createDegraded(); + Degraded degraded1 = createDegraded(); + Degraded degraded2 = createDegraded(); assertEquals(0, comparator.compare(degraded1, degraded1)); @@ -44,8 +42,8 @@ public class DegradedComparatorTest { @Test public void testDifferent() { try { - CellDesignerDegraded degraded1 = createDegraded(); - CellDesignerDegraded degraded2 = createDegraded(); + Degraded degraded1 = createDegraded(); + Degraded degraded2 = createDegraded(); degraded1 = createDegraded(); degraded2 = createDegraded(); degraded1.setCharge(54); @@ -58,11 +56,11 @@ public class DegradedComparatorTest { assertTrue(comparator.compare(degraded2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - CellDesignerDegraded degraded = createDegraded(); + Degraded degraded = createDegraded(); degraded.setName("n"); assertTrue(comparator.compare(degraded, degraded1) != 0); - assertTrue(comparator.compare(degraded, new CellDesignerDegraded() { + assertTrue(comparator.compare(degraded, new Degraded() { private static final long serialVersionUID = 1L; }) != 0); } catch (Exception e) { @@ -71,8 +69,8 @@ public class DegradedComparatorTest { } } - public CellDesignerDegraded createDegraded() { - CellDesignerDegraded result = new CellDesignerDegraded(); + public Degraded createDegraded() { + Degraded result = new Degraded(); result.setCharge(12); return result; } @@ -80,7 +78,7 @@ public class DegradedComparatorTest { @Test public void testInvalid() { try { - class Tmp extends CellDesignerDegraded{ + class Tmp extends Degraded { private static final long serialVersionUID = 1L; } Tmp object = new Tmp(); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/DegradedTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/DegradedTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7936da6c4874e1a913b3cc0ff654a42681f29ce2 --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/DegradedTest.java @@ -0,0 +1,36 @@ +package lcsb.mapviewer.model.map.species; + +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; + +public class DegradedTest { + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testConstructor() { + try { + String id = "id"; + Degraded degraded = new Degraded(id); + assertEquals(id, degraded.getElementId()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + +} diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DrugComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/DrugComparatorTest.java similarity index 66% rename from converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DrugComparatorTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/DrugComparatorTest.java index 90c53377539a285d4e15be9f6b0224fc47d41a7a..058e18c95e065b7f93efc405ed26848efeaab643 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DrugComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/DrugComparatorTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -9,12 +9,10 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerDrug; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerDrugComparator; public class DrugComparatorTest { - CellDesignerDrugComparator comparator = new CellDesignerDrugComparator(); + DrugComparator comparator = new DrugComparator(); @Before public void setUp() throws Exception { @@ -27,8 +25,8 @@ public class DrugComparatorTest { @Test public void testEquals() { try { - CellDesignerDrug drug1 = createDrug(); - CellDesignerDrug drug2 = createDrug(); + Drug drug1 = createDrug(); + Drug drug2 = createDrug(); assertEquals(0, comparator.compare(drug1, drug1)); @@ -44,16 +42,16 @@ public class DrugComparatorTest { @Test public void testDifferent() { try { - CellDesignerDrug drug2 = createDrug(); + Drug drug2 = createDrug(); assertTrue(comparator.compare(null, drug2) != 0); assertTrue(comparator.compare(drug2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - CellDesignerDrug drug = createDrug(); + Drug drug = createDrug(); drug.setName("n"); assertTrue(comparator.compare(drug, drug2) != 0); - assertTrue(comparator.compare(drug, new CellDesignerDrug() { + assertTrue(comparator.compare(drug, new Drug() { private static final long serialVersionUID = 1L; }) != 0); @@ -63,15 +61,15 @@ public class DrugComparatorTest { } } - public CellDesignerDrug createDrug() { - CellDesignerDrug result = new CellDesignerDrug(); + public Drug createDrug() { + Drug result = new Drug(); return result; } @Test public void testInvalid() { try { - class Tmp extends CellDesignerDrug{ + class Tmp extends Drug { private static final long serialVersionUID = 1L; } Tmp object = new Tmp(); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/DrugTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/DrugTest.java new file mode 100644 index 0000000000000000000000000000000000000000..cad4f1a371395c65e6c523c693012171bc63bd1a --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/DrugTest.java @@ -0,0 +1,84 @@ +package lcsb.mapviewer.model.map.species; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import org.apache.commons.lang3.SerializationUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import lcsb.mapviewer.common.exception.NotImplementedException; + +public class DrugTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new Drug()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testConstructor1() { + try { + Drug degraded = new Drug(""); + assertNotNull(degraded); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testGetters() { + try { + Drug degraded = new Drug(new Drug()); + assertNotNull(degraded.getStringType()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testCopy() { + try { + Drug degraded = new Drug().copy(); + assertNotNull(degraded); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testInvalidCopy() { + try { + new Drug() { + + /** + * + */ + private static final long serialVersionUID = 1L; + }.copy(); + fail("Exception expected"); + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + +} diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ElementComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/ElementComparatorTest.java similarity index 53% rename from converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ElementComparatorTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/ElementComparatorTest.java index 2682e00a74a58e718da9fbbfa19d75651f8d70a4..a9225cc0a55d8e2f5023f537fa632f5676ecbb57 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ElementComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/ElementComparatorTest.java @@ -1,23 +1,33 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import java.awt.Color; + import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; import lcsb.mapviewer.common.exception.InvalidClassException; +import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamRelationType; import lcsb.mapviewer.model.map.MiriamType; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.layout.graphics.Layer; +import lcsb.mapviewer.model.map.model.AliasSubmodelConnection; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.model.SubmodelType; +import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.species.field.PositionToCompartment; public class ElementComparatorTest { - CellDesignerElementComparator comparator = new CellDesignerElementComparator(); + ElementComparator comparator = new ElementComparator(); @Before public void setUp() throws Exception { @@ -28,52 +38,138 @@ public class ElementComparatorTest { } @Test - public void testException() { + public void testCompareException() throws Exception { try { - CellDesignerElement<?> el = Mockito.mock(CellDesignerElement.class); - comparator.compare(el, el); + comparator.compare(Mockito.mock(Element.class), Mockito.mock(Element.class)); fail("Exception should occur"); - } catch (InvalidClassException e) { + } catch (NotImplementedException e) { } catch (Exception e) { e.printStackTrace(); - fail("Unkowne exception"); + throw e; } } @Test - public void testException2() { + public void testDifferent() throws Exception { try { - assertEquals(0, comparator.compare(new CellDesignerCompartment(), new CellDesignerCompartment())); + assertTrue(comparator.compare(new GenericProtein("id2"), new GenericProtein("id1")) != 0); + + assertTrue(comparator.compare(null, new GenericProtein()) != 0); + assertTrue(comparator.compare(new GenericProtein(), null) != 0); + assertTrue(comparator.compare(new GenericProtein(), new Complex()) != 0); + + Species sa1 = new GenericProtein("id2"); + Species sa2 = new GenericProtein("id2"); + sa2.setX(2); + assertTrue(comparator.compare(sa1, sa2) != 0); + + sa1 = new GenericProtein("id2"); + sa2 = new GenericProtein("id2"); + sa2.setY(2); + assertTrue(comparator.compare(sa1, sa2) != 0); + + sa1 = new GenericProtein("id2"); + sa2 = new GenericProtein("id2"); + sa2.setHeight(2); + assertTrue(comparator.compare(sa1, sa2) != 0); + + sa1 = new GenericProtein("id2"); + sa2 = new GenericProtein("id2"); + sa2.setFontSize(2); + assertTrue(comparator.compare(sa1, sa2) != 0); + + sa1 = new GenericProtein("id2"); + sa2 = new GenericProtein("id2"); + sa2.setColor(Color.BLUE); + assertTrue(comparator.compare(sa1, sa2) != 0); + + sa1 = new GenericProtein("id2"); + sa2 = new GenericProtein("id2"); + sa2.setVisibilityLevel(6); + assertTrue(comparator.compare(sa1, sa2) != 0); } catch (Exception e) { e.printStackTrace(); - fail("Unkowne exception"); + throw e; } } @Test - public void testEquals() { + public void testCompareSubmodel() throws Exception { try { - CellDesignerSimpleMolecule species1 = createSimpleMolecule(); - CellDesignerSimpleMolecule species2 = createSimpleMolecule(); - assertEquals(0, comparator.compare(species1, species2)); + Element alias1 = createAlias(); + Element alias2 = createAlias(); + assertEquals(0, comparator.compare(alias1, alias2)); - assertEquals(0, comparator.compare(null, null)); + alias1.setSubmodel(null); + assertTrue(comparator.compare(alias1, alias2) != 0); + assertTrue(comparator.compare(alias2, alias1) != 0); - } catch (InvalidClassException e) { + alias1 = createAlias(); + alias2 = createAlias(); + + alias1.getSubmodel().setName("Na"); + + assertTrue(comparator.compare(alias1, alias2) != 0); + assertTrue(comparator.compare(alias2, alias1) != 0); } catch (Exception e) { e.printStackTrace(); - fail("Unkowne exception"); + throw e; + } + } + + private Element createAlias() { + Element result = new GenericProtein("id2"); + AliasSubmodelConnection submodel = new AliasSubmodelConnection(getModel(), SubmodelType.DOWNSTREAM_TARGETS); + result.setSubmodel(submodel); + return result; + } + + private Model getModel() { + Model model = new ModelFullIndexed(null); + + model.setNotes("Some description"); + GenericProtein protein = new GenericProtein("A"); + protein.setName("ad"); + model.addAlias(protein); + + Protein alias = new GenericProtein("a_id"); + alias.setName("ad"); + model.addAlias(alias); + + model.addAlias(new Compartment("default")); + + Layer layer = new Layer(); + layer.setName("layer name"); + model.addLayer(layer); + + model.addReaction(new Reaction()); + return model; + } + + + @Test + public void testException() { + try { + Element el = Mockito.mock(Element.class); + comparator.compare(el, el); + + fail("Exception should occur"); + } catch (NotImplementedException e) { + + } catch (Exception e) { + e.printStackTrace(); + throw e; } } @Test public void testInternalCompare() { try { - CellDesignerSimpleMolecule species1 = createSimpleMolecule(); + SimpleMolecule species1 = createSimpleMolecule(); assertTrue(comparator.internalCompare(species1, null) != 0); assertTrue(comparator.internalCompare(null, species1) != 0); @@ -83,15 +179,15 @@ public class ElementComparatorTest { } catch (Exception e) { e.printStackTrace(); - fail("Unkowne exception"); + throw e; } } @Test - public void testDifferent() { + public void testDifferent2() { try { - CellDesignerSimpleMolecule species1 = createSimpleMolecule(); - CellDesignerSimpleMolecule species2 = createSimpleMolecule(); + SimpleMolecule species1 = createSimpleMolecule(); + SimpleMolecule species2 = createSimpleMolecule(); species1.setCharge(99); assertTrue(comparator.compare(species1, species2) != 0); @@ -158,8 +254,8 @@ public class ElementComparatorTest { @Test public void testDifferentNewFields() throws Exception { try { - CellDesignerSimpleMolecule species1 = createSimpleMolecule(); - CellDesignerSimpleMolecule species2 = createSimpleMolecule(); + SimpleMolecule species1 = createSimpleMolecule(); + SimpleMolecule species2 = createSimpleMolecule(); species1.setSymbol("some symbol"); assertTrue(comparator.compare(species1, species2) != 0); @@ -192,15 +288,14 @@ public class ElementComparatorTest { } } - public CellDesignerSimpleMolecule createSimpleMolecule() { - CellDesignerSimpleMolecule result = new CellDesignerSimpleMolecule(); + public SimpleMolecule createSimpleMolecule() { + SimpleMolecule result = new SimpleMolecule("id"); result.setHomodimer(12); - result.setElementId("id"); result.setName("id"); - result.setInitialAmount("12"); - result.setCharge("13"); - result.setInitialConcentration("14"); - result.setOnlySubstanceUnits("true"); + result.setInitialAmount(12); + result.setCharge(13); + result.setInitialConcentration(14); + result.setOnlySubstanceUnits(true); result.setPositionToCompartment(PositionToCompartment.TRANSMEMBRANE); result.setNotes("id"); MiriamData md = new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.PUBMED, "c"); @@ -211,9 +306,9 @@ public class ElementComparatorTest { @Test public void testDifferentNewReconFields() throws Exception { try { - CellDesignerSimpleMolecule element1 = createSimpleMolecule(); + SimpleMolecule element1 = createSimpleMolecule(); - CellDesignerSimpleMolecule element2 = createSimpleMolecule(); + SimpleMolecule element2 = createSimpleMolecule(); element2.setAbbreviation("ABRR"); assertTrue(comparator.compare(element1, element2) != 0); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/AliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/ElementTest.java similarity index 51% rename from model/src/test/java/lcsb/mapviewer/model/map/species/AliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/ElementTest.java index 02340a265c766da1af782aae62f01394b9db0919..32260105d054ee24a27d20f67ff39f52cc33e971 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/AliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/ElementTest.java @@ -9,14 +9,20 @@ import static org.junit.Assert.fail; import java.awt.geom.Point2D; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; +import lcsb.mapviewer.ModelTestFunctions; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.InvalidArgumentException; +import lcsb.mapviewer.model.map.MiriamData; +import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.SearchIndex; import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.layout.graphics.LayerText; @@ -24,11 +30,8 @@ import lcsb.mapviewer.model.map.model.AliasSubmodelConnection; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelData; import lcsb.mapviewer.model.map.model.ModelFullIndexed; -import lcsb.mapviewer.model.map.species.Element; -import lcsb.mapviewer.model.map.species.GenericProtein; -import lcsb.mapviewer.model.map.species.Species; -public class AliasTest { +public class ElementTest extends ModelTestFunctions { private static double EPSILON = Configuration.EPSILON; @@ -130,7 +133,7 @@ public class AliasTest { @Test public void testGetters() { try { - Species alias = new GenericProtein(); + Element element = new GenericProtein(); Double nullDouble = null; String xStr = "1.2"; Double x = 1.2; @@ -144,6 +147,7 @@ public class AliasTest { String heightStr = "4.0"; Double height = 4.0; ModelData modelData = new ModelData(); + Set<MiriamData> miriamData = new HashSet<>(); Compartment compartmentAlias = new Compartment("idd"); int id = 72; int transparencyLevel = 2; @@ -151,69 +155,88 @@ public class AliasTest { List<SearchIndex> indexes = new ArrayList<>(); indexes.add(new SearchIndex()); - alias.setX(xStr); - assertEquals(x, alias.getX(), Configuration.EPSILON); - alias.setX(nullDouble); - assertNull(alias.getX()); - alias.setX(x); - assertEquals(x, alias.getX(), Configuration.EPSILON); - - alias.setY(yStr); - assertEquals(y, alias.getY(), Configuration.EPSILON); - alias.setY(nullDouble); - assertNull(alias.getY()); - alias.setY(y); - assertEquals(y, alias.getY(), Configuration.EPSILON); - - alias.setFontSize(fontSizeStr); - assertEquals(fontSize, alias.getFontSize(), Configuration.EPSILON); - alias.setFontSize(nullDouble); - assertNull(alias.getFontSize()); - alias.setFontSize(fontSize); - assertEquals(fontSize, alias.getFontSize(), Configuration.EPSILON); - alias.setFontSize(nullDouble); - assertNull(alias.getFontSize()); - alias.setFontSize(fontSizeInt); - assertEquals(fontSize, alias.getFontSize(), Configuration.EPSILON); - - alias.setWidth(widthStr); - assertEquals(width, alias.getWidth(), Configuration.EPSILON); - alias.setWidth(nullDouble); - assertNull(alias.getWidth()); - alias.setWidth(width); - assertEquals(width, alias.getWidth(), Configuration.EPSILON); + element.setMiriamData(miriamData); + assertEquals(miriamData, element.getMiriamData()); + + element.setX(xStr); + assertEquals(x, element.getX(), Configuration.EPSILON); + element.setX(nullDouble); + assertNull(element.getX()); + element.setX(x); + assertEquals(x, element.getX(), Configuration.EPSILON); + + element.setY(yStr); + assertEquals(y, element.getY(), Configuration.EPSILON); + element.setY(nullDouble); + assertNull(element.getY()); + element.setY(y); + assertEquals(y, element.getY(), Configuration.EPSILON); + + element.setFontSize(fontSizeStr); + assertEquals(fontSize, element.getFontSize(), Configuration.EPSILON); + element.setFontSize(nullDouble); + assertNull(element.getFontSize()); + element.setFontSize(fontSize); + assertEquals(fontSize, element.getFontSize(), Configuration.EPSILON); + element.setFontSize(nullDouble); + assertNull(element.getFontSize()); + element.setFontSize(fontSizeInt); + assertEquals(fontSize, element.getFontSize(), Configuration.EPSILON); + + element.setWidth(widthStr); + assertEquals(width, element.getWidth(), Configuration.EPSILON); + element.setWidth(nullDouble); + assertNull(element.getWidth()); + element.setWidth(width); + assertEquals(width, element.getWidth(), Configuration.EPSILON); try { - alias.setWidth("as"); + element.setWidth("as"); fail("Exception expected"); } catch (InvalidArgumentException e) { } - alias.setHeight(heightStr); - assertEquals(height, alias.getHeight(), Configuration.EPSILON); - alias.setHeight(nullDouble); - assertNull(alias.getHeight()); - alias.setHeight(height); - assertEquals(height, alias.getHeight(), Configuration.EPSILON); + element.setHeight(heightStr); + assertEquals(height, element.getHeight(), Configuration.EPSILON); + element.setHeight(nullDouble); + assertNull(element.getHeight()); + element.setHeight(height); + assertEquals(height, element.getHeight(), Configuration.EPSILON); try { - alias.setHeight("as"); + element.setHeight("as"); fail("Exception expected"); } catch (InvalidArgumentException e) { } - alias.setCompartmentAlias(compartmentAlias); - assertEquals(compartmentAlias, alias.getCompartmentAlias()); - alias.setId(id); - assertEquals(id, alias.getId()); - alias.setTransparencyLevel(transparencyLevel); - assertEquals(transparencyLevel, alias.getTransparencyLevel()); - alias.setModel(model); - assertEquals(model, alias.getModel()); - alias.setModelData(modelData); - assertEquals(modelData, alias.getModelData()); - alias.setSearchIndexes(indexes); - assertEquals(indexes, alias.getSearchIndexes()); - - assertNotNull(alias.getBorder()); + element.setCompartmentAlias(compartmentAlias); + assertEquals(compartmentAlias, element.getCompartmentAlias()); + element.setId(id); + assertEquals(id, element.getId()); + element.setTransparencyLevel(transparencyLevel); + assertEquals(transparencyLevel, element.getTransparencyLevel()); + element.setModel(model); + assertEquals(model, element.getModel()); + element.setModelData(modelData); + assertEquals(modelData, element.getModelData()); + element.setSearchIndexes(indexes); + assertEquals(indexes, element.getSearchIndexes()); + + assertNotNull(element.getBorder()); + + element = Mockito.spy(Element.class); + List<String> synonyms = new ArrayList<>(); + List<String> formerSymbols = new ArrayList<>(); + String formula = "some_form"; + + element.setSynonyms(synonyms); + element.setFormerSymbols(formerSymbols); + element.setModel(model); + element.setFormula(formula); + + assertEquals(synonyms, element.getSynonyms()); + assertEquals(formerSymbols, element.getFormerSymbols()); + assertEquals(model.getModelData(), element.getModelData()); + assertEquals(formula, element.getFormula()); + } catch (Exception e) { e.printStackTrace(); throw e; @@ -303,4 +326,84 @@ public class AliasTest { } } + @Test + public void testAddMiriamCollection() { + try { + List<MiriamData> list = new ArrayList<>(); + list.add(new MiriamData(MiriamType.CAS, "1")); + list.add(new MiriamData(MiriamType.CAS, "1")); + Element element = Mockito.spy(Element.class); + element.addMiriamData(list); + assertEquals(1, element.getMiriamData().size()); + assertEquals(1, getWarnings().size()); + + element.addMiriamData(list); + assertEquals(3, getWarnings().size()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testSetNotes() { + try { + Element element = Mockito.spy(Element.class); + element.setNotes("</html>"); + fail("Exception epxected"); + } catch (InvalidArgumentException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testAddSynonym() { + try { + Element element = Mockito.spy(Element.class); + List<String> synonyms = new ArrayList<>(); + synonyms.add("syn"); + element.addSynonyms(synonyms); + element.addSynonym("syn2"); + assertEquals("syn", element.getSynonyms().get(0)); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 300; i++) { + sb.append("a"); + } + String syn = sb.toString(); + synonyms = new ArrayList<>(); + synonyms.add(syn); + element.addSynonyms(synonyms); + assertFalse(syn.equals(element.getSynonyms().get(1))); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testAddFormerSymbols() { + try { + Element element = Mockito.spy(Element.class); + List<String> formerSymbols = new ArrayList<>(); + formerSymbols.add("symbol"); + element.addFormerSymbols(formerSymbols); + element.addFormerSymbol("symbol2"); + assertEquals("symbol", element.getFormerSymbols().get(0)); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 300; i++) { + sb.append("a"); + } + String syn = sb.toString(); + formerSymbols = new ArrayList<>(); + formerSymbols.add(syn); + element.addFormerSymbols(formerSymbols); + assertFalse(syn.equals(element.getFormerSymbols().get(1))); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + } diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/GeneComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/GeneComparatorTest.java similarity index 71% rename from converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/GeneComparatorTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/GeneComparatorTest.java index b671da3858b5a2dfee5f43cf8e54e584203578f7..6f2653df93994750d3bc65b60a41f8f2a0648afd 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/GeneComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/GeneComparatorTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -9,12 +9,12 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; import lcsb.mapviewer.model.map.species.field.ModificationState; public class GeneComparatorTest { - CellDesignerGeneComparator comparator = new CellDesignerGeneComparator(); + GeneComparator comparator = new GeneComparator(); @Before public void setUp() throws Exception { @@ -27,8 +27,8 @@ public class GeneComparatorTest { @Test public void testEquals() { try { - CellDesignerGene gene1 = createGene(); - CellDesignerGene gene2 = createGene(); + Gene gene1 = createGene(); + Gene gene2 = createGene(); assertEquals(0, comparator.compare(gene1, gene1)); @@ -44,8 +44,8 @@ public class GeneComparatorTest { @Test public void testDifferent() { try { - CellDesignerGene gene1 = createGene(); - CellDesignerGene gene2 = createGene(); + Gene gene1 = createGene(); + Gene gene2 = createGene(); gene1.getModificationResidues().get(0).setName("bla"); assertTrue(comparator.compare(gene1, gene2) != 0); assertTrue(comparator.compare(gene2, gene1) != 0); @@ -62,11 +62,11 @@ public class GeneComparatorTest { assertTrue(comparator.compare(gene2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - CellDesignerGene gene = createGene(); + Gene gene = createGene(); gene.setName("n"); assertTrue(comparator.compare(gene, gene2) != 0); - assertTrue(comparator.compare(gene, new CellDesignerGene() { + assertTrue(comparator.compare(gene, new Gene() { private static final long serialVersionUID = 1L; }) != 0); @@ -76,25 +76,26 @@ public class GeneComparatorTest { } } - public CellDesignerGene createGene() { - CellDesignerGene result = new CellDesignerGene(); + public Gene createGene() { + Gene result = new Gene(); result.setHypothetical(true); - CellDesignerModificationResidue residue = new CellDesignerModificationResidue(); + ModificationResidue residue = new ModificationResidue(); result.addModificationResidue(residue); residue.setIdModificationResidue("a"); residue.setName("name"); - residue.setAngle("1"); - residue.setSize("2"); + residue.setAngle(1.0); + residue.setSize(2.0); residue.setSide("23"); residue.setState(ModificationState.ACETYLATED); return result; } + @Test public void testInvalid() { try { - class Tmp extends CellDesignerGene{ + class Tmp extends Gene { private static final long serialVersionUID = 1L; } Tmp object = new Tmp(); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/GeneTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/GeneTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d5fad50721dc213c2af535b3bb57bd3ddbe05d8e --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/GeneTest.java @@ -0,0 +1,94 @@ +package lcsb.mapviewer.model.map.species; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.SerializationUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; + +public class GeneTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new Gene()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testConstructor1() { + try { + Gene original = new Gene(); + original.addModificationResidue(new ModificationResidue()); + Gene gene = new Gene(original); + assertNotNull(gene); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testGetters() { + try { + List<ModificationResidue> modificationResidues = new ArrayList<>(); + Gene gene = new Gene("id"); + assertNotNull(gene.getStringType()); + gene.setModificationResidues(modificationResidues); + assertEquals(modificationResidues, gene.getModificationResidues()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testCopy() { + try { + Gene degraded = new Gene().copy(); + assertNotNull(degraded); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testInvalidCopy() { + try { + new Gene() { + + /** + * + */ + private static final long serialVersionUID = 1L; + }.copy(); + fail("Exception expected"); + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + +} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/GenericProteinTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/GenericProteinTest.java new file mode 100644 index 0000000000000000000000000000000000000000..53aa91c09504e06f17c4fa1c028d2be4a6d1ec5a --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/GenericProteinTest.java @@ -0,0 +1,72 @@ +package lcsb.mapviewer.model.map.species; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import org.apache.commons.lang3.SerializationUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import lcsb.mapviewer.common.exception.NotImplementedException; + +public class GenericProteinTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new GenericProtein()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testConstructor() { + try { + GenericProtein species = new GenericProtein(""); + assertNotNull(species); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testCopy1() { + try { + GenericProtein species = new GenericProtein(new GenericProtein()).copy(); + assertNotNull(species); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testCopy2() { + try { + new GenericProtein() { + + /** + * + */ + private static final long serialVersionUID = 1L; + }.copy(); + fail("Exception expected"); + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } +} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/IonChannelProteinTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/IonChannelProteinTest.java new file mode 100644 index 0000000000000000000000000000000000000000..abbd65bbb683061ac7a29a0f92b411be61c31470 --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/IonChannelProteinTest.java @@ -0,0 +1,69 @@ +package lcsb.mapviewer.model.map.species; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import org.apache.commons.lang3.SerializationUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; + +import lcsb.mapviewer.common.exception.NotImplementedException; + +public class IonChannelProteinTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new IonChannelProtein()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testConstructor() { + try { + IonChannelProtein species = new IonChannelProtein(new IonChannelProtein()); + assertNotNull(species); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testCopy1() { + try { + IonChannelProtein species = new IonChannelProtein("id").copy(); + assertNotNull(species); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testCopy2() { + try { + IonChannelProtein protein = Mockito.spy(IonChannelProtein.class); + protein.copy(); + fail("Exception expected"); + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + +} diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/IonComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/IonComparatorTest.java similarity index 66% rename from converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/IonComparatorTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/IonComparatorTest.java index d0c3eae081fe8f345cc4b70548b7cb60f2f38701..a9e5691708fcbf5427e7e5f68ffbfe1b9b899bad 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/IonComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/IonComparatorTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -9,12 +9,10 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerIon; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerIonComparator; public class IonComparatorTest { - CellDesignerIonComparator comparator = new CellDesignerIonComparator(); + IonComparator comparator = new IonComparator(); @Before public void setUp() throws Exception { @@ -27,8 +25,8 @@ public class IonComparatorTest { @Test public void testEquals() { try { - CellDesignerIon ion1 = createIon(); - CellDesignerIon ion2 = createIon(); + Ion ion1 = createIon(); + Ion ion2 = createIon(); assertEquals(0, comparator.compare(ion1, ion1)); @@ -44,16 +42,16 @@ public class IonComparatorTest { @Test public void testDifferent() { try { - CellDesignerIon ion2 = createIon(); + Ion ion2 = createIon(); assertTrue(comparator.compare(null, ion2) != 0); assertTrue(comparator.compare(ion2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - CellDesignerIon ion = createIon(); + Ion ion = createIon(); ion.setName("n"); assertTrue(comparator.compare(ion, ion2) != 0); - assertTrue(comparator.compare(ion, new CellDesignerIon() { + assertTrue(comparator.compare(ion, new Ion() { private static final long serialVersionUID = 1L; }) != 0); } catch (Exception e) { @@ -62,15 +60,15 @@ public class IonComparatorTest { } } - public CellDesignerIon createIon() { - CellDesignerIon result = new CellDesignerIon(); + public Ion createIon() { + Ion result = new Ion(); return result; } @Test public void testInvalid() { try { - class Tmp extends CellDesignerIon { + class Tmp extends Ion { private static final long serialVersionUID = 1L; } Tmp object = new Tmp(); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/IonTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/IonTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c1093393779db25925dd317e718eafbc23e49b3b --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/IonTest.java @@ -0,0 +1,84 @@ +package lcsb.mapviewer.model.map.species; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import org.apache.commons.lang3.SerializationUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import lcsb.mapviewer.common.exception.NotImplementedException; + +public class IonTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new Ion()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testConstructor1() { + try { + Ion degraded = new Ion(new Ion()); + assertNotNull(degraded); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testGetters() { + try { + Ion degraded = new Ion("id"); + assertNotNull(degraded.getStringType()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testCopy() { + try { + Ion degraded = new Ion().copy(); + assertNotNull(degraded); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testInvalidCopy() { + try { + new Ion() { + + /** + * + */ + private static final long serialVersionUID = 1L; + }.copy(); + fail("Exception expected"); + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + +} diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/PhenotypeComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/PhenotypeComparatorTest.java similarity index 70% rename from converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/PhenotypeComparatorTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/PhenotypeComparatorTest.java index f2af6d00a9c42b821265336929579ccfc4ce01fb..55b6357c7e117ee41526c398f34c6a48df968cf6 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/PhenotypeComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/PhenotypeComparatorTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -12,7 +12,7 @@ import lcsb.mapviewer.common.exception.NotImplementedException; public class PhenotypeComparatorTest { - CellDesignerPhenotypeComparator comparator = new CellDesignerPhenotypeComparator(); + PhenotypeComparator comparator = new PhenotypeComparator(); @Before public void setUp() throws Exception { @@ -25,8 +25,8 @@ public class PhenotypeComparatorTest { @Test public void testEquals() { try { - CellDesignerPhenotype phenotype1 = createPhenotype(); - CellDesignerPhenotype phenotype2 = createPhenotype(); + Phenotype phenotype1 = createPhenotype(); + Phenotype phenotype2 = createPhenotype(); assertEquals(0, comparator.compare(phenotype1, phenotype1)); @@ -42,7 +42,7 @@ public class PhenotypeComparatorTest { @Test public void testInvalid() { try { - class Tmp extends CellDesignerPhenotype { + class Tmp extends Phenotype { private static final long serialVersionUID = 1L; } Tmp phenotype1 = new Tmp(); @@ -62,16 +62,16 @@ public class PhenotypeComparatorTest { @Test public void testDifferent() { try { - CellDesignerPhenotype phenotype2 = createPhenotype(); + Phenotype phenotype2 = createPhenotype(); assertTrue(comparator.compare(null, phenotype2) != 0); assertTrue(comparator.compare(phenotype2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - assertTrue(comparator.compare(phenotype2, new CellDesignerPhenotype() { + assertTrue(comparator.compare(phenotype2, new Phenotype() { private static final long serialVersionUID = 1L; }) != 0); - CellDesignerPhenotype phenotype = createPhenotype(); + Phenotype phenotype = createPhenotype(); phenotype2 = createPhenotype(); phenotype.setName("n"); assertTrue(comparator.compare(phenotype, phenotype2) != 0); @@ -82,8 +82,8 @@ public class PhenotypeComparatorTest { } } - public CellDesignerPhenotype createPhenotype() { - CellDesignerPhenotype result = new CellDesignerPhenotype(); + public Phenotype createPhenotype() { + Phenotype result = new Phenotype(); return result; } diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/PhenotypeTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/PhenotypeTest.java new file mode 100644 index 0000000000000000000000000000000000000000..fd370eb7e4eddddb39fe9d4784911fa6954908c0 --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/PhenotypeTest.java @@ -0,0 +1,74 @@ +package lcsb.mapviewer.model.map.species; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import org.apache.commons.lang3.SerializationUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import lcsb.mapviewer.common.exception.NotImplementedException; + +public class PhenotypeTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new Phenotype()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testConstructor1() { + try { + Phenotype original = new Phenotype(); + Phenotype copy = new Phenotype(original); + assertNotNull(copy); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testCopy() { + try { + Phenotype degraded = new Phenotype().copy(); + assertNotNull(degraded); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testInvalidCopy() { + try { + new Phenotype() { + + /** + * + */ + private static final long serialVersionUID = 1L; + }.copy(); + fail("Exception expected"); + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + +} diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ProteinComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/ProteinComparatorTest.java similarity index 71% rename from converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ProteinComparatorTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/ProteinComparatorTest.java index 1fef8ac6709b0337d76cdd33731c6bdf65da2f31..a96555a5a4ee1743a49a2e0c4259577bc451b275 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ProteinComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/ProteinComparatorTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -8,12 +8,12 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; import lcsb.mapviewer.model.map.species.field.ModificationState; public class ProteinComparatorTest { - CellDesignerProteinComparator comparator = new CellDesignerProteinComparator(); + ProteinComparator comparator = new ProteinComparator(); @Before public void setUp() throws Exception { @@ -26,8 +26,8 @@ public class ProteinComparatorTest { @Test public void testEquals() { try { - CellDesignerGenericProtein aRna1 = createProtein(); - CellDesignerGenericProtein aRna2 = createProtein(); + GenericProtein aRna1 = createProtein(); + GenericProtein aRna2 = createProtein(); assertEquals(0, comparator.compare(aRna1, aRna1)); @@ -43,8 +43,8 @@ public class ProteinComparatorTest { @Test public void testDifferent() { try { - CellDesignerGenericProtein aRna1 = createProtein(); - CellDesignerGenericProtein aRna2 = createProtein(); + GenericProtein aRna1 = createProtein(); + GenericProtein aRna2 = createProtein(); aRna1.getModificationResidues().get(0).setName("bla"); assertTrue(comparator.compare(aRna1, aRna2) != 0); assertTrue(comparator.compare(aRna2, aRna1) != 0); @@ -61,7 +61,7 @@ public class ProteinComparatorTest { assertTrue(comparator.compare(aRna2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - assertTrue(comparator.compare(aRna2, new CellDesignerGenericProtein()) != 0); + assertTrue(comparator.compare(aRna2, new GenericProtein()) != 0); aRna1 = createProtein(); aRna2 = createProtein(); @@ -81,25 +81,25 @@ public class ProteinComparatorTest { assertTrue(comparator.compare(aRna1, aRna2) != 0); assertTrue(comparator.compare(aRna2, aRna1) != 0); -} catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); fail("Unknowne exception occurred"); } } - public CellDesignerGenericProtein createProtein() { - CellDesignerGenericProtein result = new CellDesignerGenericProtein(); + public GenericProtein createProtein() { + GenericProtein result = new GenericProtein(); result.setHomodimer(12); result.setStructuralState("id1"); result.setHypothetical(true); - CellDesignerModificationResidue residue = new CellDesignerModificationResidue(); + ModificationResidue residue = new ModificationResidue(); result.addModificationResidue(residue); residue.setIdModificationResidue("a"); residue.setName("name"); - residue.setAngle("1"); - residue.setSize("2"); + residue.setAngle(1.0); + residue.setSize(2.0); residue.setSide("23"); residue.setState(ModificationState.DONT_CARE); return result; diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/ProteinTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/ProteinTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0a3a22c3db5bead5e7b859bc3383ec3b2a0dfd2d --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/ProteinTest.java @@ -0,0 +1,105 @@ +package lcsb.mapviewer.model.map.species; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.SerializationUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; + +import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; + +public class ProteinTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new GenericProtein()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testConstructor1() { + try { + GenericProtein protein = new GenericProtein(); + protein.setStructuralState("srt"); + List<ModificationResidue> residues = new ArrayList<>(); + residues.add(new ModificationResidue()); + + protein.setModificationResidues(residues); + Protein protein2 = new GenericProtein(protein); + assertNotNull(protein2); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testSetStructuralState() { + try { + GenericProtein protein = new GenericProtein(); + protein.setStructuralState("str"); + protein.setStructuralState("str1"); + + assertEquals("str1", protein.getStructuralState()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testGetters() { + try { + GenericProtein protein = new GenericProtein("id"); + assertNotNull(protein.getStringType()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testCopy() { + try { + GenericProtein protein = new GenericProtein().copy(); + assertNotNull(protein); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testInvalidCopy() { + try { + GenericProtein mock = Mockito.spy(GenericProtein.class); + mock.copy(); + fail("Exception expected"); + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + +} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/ReceptorProteinTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/ReceptorProteinTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8d94528dbc598e43301b06b2d5a79188833062ed --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/ReceptorProteinTest.java @@ -0,0 +1,73 @@ +package lcsb.mapviewer.model.map.species; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import org.apache.commons.lang3.SerializationUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import lcsb.mapviewer.common.exception.NotImplementedException; + +public class ReceptorProteinTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new ReceptorProtein()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testConstructor() { + try { + ReceptorProtein species = new ReceptorProtein(new ReceptorProtein()); + assertNotNull(species); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testCopy1() { + try { + ReceptorProtein species = new ReceptorProtein("id").copy(); + assertNotNull(species); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testCopy2() { + try { + new ReceptorProtein() { + + /** + * + */ + private static final long serialVersionUID = 1L; + }.copy(); + fail("Exception expected"); + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + +} diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/RnaComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/RnaComparatorTest.java similarity index 76% rename from converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/RnaComparatorTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/RnaComparatorTest.java index 5fd31da29451a2323334f2efbb0c25781d381318..e86a6cf44cd5ec1fade2510187e45f441f6c43b8 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/RnaComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/RnaComparatorTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -10,10 +10,11 @@ import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.field.ModificationState; +import lcsb.mapviewer.model.map.species.field.RnaRegion; public class RnaComparatorTest { - CellDesignerRnaComparator comparator = new CellDesignerRnaComparator(); + RnaComparator comparator = new RnaComparator(); @Before public void setUp() throws Exception { @@ -26,8 +27,8 @@ public class RnaComparatorTest { @Test public void testEquals() { try { - CellDesignerRna aRna1 = createRna(); - CellDesignerRna aRna2 = createRna(); + Rna aRna1 = createRna(); + Rna aRna2 = createRna(); assertEquals(0, comparator.compare(aRna1, aRna1)); @@ -43,8 +44,8 @@ public class RnaComparatorTest { @Test public void testDifferent() { try { - CellDesignerRna aRna1 = createRna(); - CellDesignerRna aRna2 = createRna(); + Rna aRna1 = createRna(); + Rna aRna2 = createRna(); aRna1.getRegions().get(0).setState(ModificationState.ACETYLATED); assertTrue(comparator.compare(aRna1, aRna2) != 0); assertTrue(comparator.compare(aRna2, aRna1) != 0); @@ -61,11 +62,11 @@ public class RnaComparatorTest { assertTrue(comparator.compare(aRna2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - CellDesignerRna rna = createRna(); + Rna rna = createRna(); rna.setName("n"); assertTrue(comparator.compare(rna, aRna2) != 0); - assertTrue(comparator.compare(rna, new CellDesignerRna() { + assertTrue(comparator.compare(rna, new Rna() { private static final long serialVersionUID = 1L; }) != 0); @@ -75,11 +76,11 @@ public class RnaComparatorTest { } } - public CellDesignerRna createRna() { - CellDesignerRna result = new CellDesignerRna(); + public Rna createRna() { + Rna result = new Rna(); result.setHypothetical(true); - CellDesignerRnaRegion region1 = new CellDesignerRnaRegion(); + RnaRegion region1 = new RnaRegion(); result.addRegion(region1); region1.setIdRnaRegion("a"); region1.setState(ModificationState.DONT_CARE); @@ -92,7 +93,7 @@ public class RnaComparatorTest { @Test public void testInvalid() { try { - class Tmp extends CellDesignerRna { + class Tmp extends Rna { private static final long serialVersionUID = 1L; } Tmp object = new Tmp(); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/RnaTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/RnaTest.java new file mode 100644 index 0000000000000000000000000000000000000000..9bee28a121171fd069997e2149b71c37bb706c6f --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/RnaTest.java @@ -0,0 +1,109 @@ +package lcsb.mapviewer.model.map.species; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.SerializationUtils; +import org.apache.log4j.Logger; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.species.field.RnaRegion; + +public class RnaTest { + Logger logger = Logger.getLogger(RnaTest.class); + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new Rna()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testConstructor1() { + try { + Rna rna = new Rna("d"); + assertNotNull(rna); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testConstructor() { + try { + Rna rna = new Rna("d"); + rna.addRegion(new RnaRegion()); + Rna rna2 = new Rna(rna); + assertEquals(rna.getRegions().size(), rna2.getRegions().size()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testGetters() { + try { + Rna rna = new Rna(new Rna()); + assertNotNull(rna.getStringType()); + List<RnaRegion> regions = new ArrayList<>(); + + rna.setRegions(regions); + + assertEquals(regions, rna.getRegions()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testCopy() { + try { + Rna rna = new Rna().copy(); + assertNotNull(rna); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testInvalidCopy() { + try { + new Rna() { + + /** + * + */ + private static final long serialVersionUID = 1L; + }.copy(); + fail("Exception expected"); + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + +} diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SimpleMoleculeComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/SimpleMoleculeComparatorTest.java similarity index 71% rename from converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SimpleMoleculeComparatorTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/SimpleMoleculeComparatorTest.java index 65e44068bb5213f7e116af263363c2ed817716bc..fc05700b6319ca8fd2f05f92961b179ae1549561 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SimpleMoleculeComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/SimpleMoleculeComparatorTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -9,12 +9,10 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSimpleMolecule; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSimpleMoleculeComparator; public class SimpleMoleculeComparatorTest { - CellDesignerSimpleMoleculeComparator comparator = new CellDesignerSimpleMoleculeComparator(); + SimpleMoleculeComparator comparator = new SimpleMoleculeComparator(); @Before public void setUp() throws Exception { @@ -27,8 +25,8 @@ public class SimpleMoleculeComparatorTest { @Test public void testEquals() { try { - CellDesignerSimpleMolecule simpleMolecule1 = createSimpleMolecule(); - CellDesignerSimpleMolecule simpleMolecule2 = createSimpleMolecule(); + SimpleMolecule simpleMolecule1 = createSimpleMolecule(); + SimpleMolecule simpleMolecule2 = createSimpleMolecule(); assertEquals(0, comparator.compare(simpleMolecule1, simpleMolecule1)); @@ -44,8 +42,8 @@ public class SimpleMoleculeComparatorTest { @Test public void testDifferent() { try { - CellDesignerSimpleMolecule simpleMolecule1 = createSimpleMolecule(); - CellDesignerSimpleMolecule simpleMolecule2 = createSimpleMolecule(); + SimpleMolecule simpleMolecule1 = createSimpleMolecule(); + SimpleMolecule simpleMolecule2 = createSimpleMolecule(); simpleMolecule1.setHomodimer(3); assertTrue(comparator.compare(simpleMolecule1, simpleMolecule2) != 0); assertTrue(comparator.compare(simpleMolecule2, simpleMolecule1) != 0); @@ -68,7 +66,7 @@ public class SimpleMoleculeComparatorTest { assertTrue(comparator.compare(simpleMolecule2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - assertTrue(comparator.compare(simpleMolecule1, new CellDesignerSimpleMolecule() { + assertTrue(comparator.compare(simpleMolecule1, new SimpleMolecule() { private static final long serialVersionUID = 1L; }) != 0); @@ -81,7 +79,7 @@ public class SimpleMoleculeComparatorTest { @Test public void testInvalid() { try { - class Tmp extends CellDesignerSimpleMolecule { + class Tmp extends SimpleMolecule { private static final long serialVersionUID = 1L; } ; @@ -99,8 +97,8 @@ public class SimpleMoleculeComparatorTest { @Test public void testDifferentNewFields() throws Exception { try { - CellDesignerSimpleMolecule species1 = createSimpleMolecule(); - CellDesignerSimpleMolecule species2 = createSimpleMolecule(); + SimpleMolecule species1 = createSimpleMolecule(); + SimpleMolecule species2 = createSimpleMolecule(); species1.setSmiles("some symbol"); assertTrue(comparator.compare(species1, species2) != 0); @@ -119,8 +117,8 @@ public class SimpleMoleculeComparatorTest { } } - public CellDesignerSimpleMolecule createSimpleMolecule() { - CellDesignerSimpleMolecule result = new CellDesignerSimpleMolecule(); + public SimpleMolecule createSimpleMolecule() { + SimpleMolecule result = new SimpleMolecule(); result.setHomodimer(12); return result; diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/SimpleMoleculeTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/SimpleMoleculeTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a2e3158d89f90cf535309a43f86aa9fbe5988417 --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/SimpleMoleculeTest.java @@ -0,0 +1,84 @@ +package lcsb.mapviewer.model.map.species; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import org.apache.commons.lang3.SerializationUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import lcsb.mapviewer.common.exception.NotImplementedException; + +public class SimpleMoleculeTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new SimpleMolecule()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testConstructor1() { + try { + SimpleMolecule degraded = new SimpleMolecule("id"); + assertNotNull(degraded); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testGetters() { + try { + SimpleMolecule degraded = new SimpleMolecule(new SimpleMolecule()); + assertNotNull(degraded.getStringType()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testCopy() { + try { + SimpleMolecule degraded = new SimpleMolecule().copy(); + assertNotNull(degraded); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testInvalidCopy() { + try { + new SimpleMolecule() { + + /** + * + */ + private static final long serialVersionUID = 1L; + }.copy(); + fail("Exception expected"); + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + +} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesAliasComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesAliasComparatorTest.java deleted file mode 100644 index d0fe439e7ced32f2835ea13bb93c9c68e24d16e5..0000000000000000000000000000000000000000 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesAliasComparatorTest.java +++ /dev/null @@ -1,148 +0,0 @@ -package lcsb.mapviewer.model.map.species; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.awt.Color; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; - -import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.species.Complex; -import lcsb.mapviewer.model.map.species.GenericProtein; -import lcsb.mapviewer.model.map.species.Species; -import lcsb.mapviewer.model.map.species.SpeciesComparator; - -public class SpeciesAliasComparatorTest { - - SpeciesComparator comparator = new SpeciesComparator(); - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testEquals() { - try { - Species alias1 = createSpeciesAlias(); - Species alias2 = createSpeciesAlias(); - - assertEquals(0, comparator.compare(alias1, alias2)); - - assertEquals(0, comparator.compare(null, null)); - - assertEquals(0, comparator.compare(new Complex(), new Complex())); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testCompareInvalid() { - try { - - Species alias = Mockito.mock(Species.class); - comparator.compare(alias, alias); - fail("Exception expected"); - - } catch (NotImplementedException e) { - } catch (Exception e) { - e.printStackTrace(); - fail("Unkowne exception"); - } - } - - private Species createSpeciesAlias() { - GenericProtein result = new GenericProtein(); - result.setName("a"); - - result.setAliasId("asd"); - result.setX(12.0); - result.setY(123.0); - result.setWidth(4); - result.setHeight(5); - result.setFontSize(9.0); - result.setColor(Color.BLUE); - result.setVisibilityLevel(14); - result.setAliasStateLabel("123"); - result.setAliasStatePrefix("1234"); - - return result; - } - - @Test - public void testDifferent() throws Exception { - try { - Species alias1 = createSpeciesAlias(); - Species alias2 = createSpeciesAlias(); - - assertTrue(comparator.compare(alias1, null) != 0); - assertTrue(comparator.compare(null, alias1) != 0); - - assertTrue(comparator.compare(new Complex(), alias1) != 0); - - alias1 = createSpeciesAlias(); - alias2 = createSpeciesAlias(); - - alias1.setAliasId("tmp"); - - assertTrue(comparator.compare(alias1, alias2) != 0); - assertTrue(comparator.compare(alias2, alias1) != 0); - - alias1 = createSpeciesAlias(); - alias2 = createSpeciesAlias(); - - alias1.setAliasStateLabel("tmp"); - - assertTrue(comparator.compare(alias1, alias2) != 0); - assertTrue(comparator.compare(alias2, alias1) != 0); - - alias1 = createSpeciesAlias(); - alias2 = createSpeciesAlias(); - - alias1.setAliasStatePrefix("tmp"); - - assertTrue(comparator.compare(alias1, alias2) != 0); - assertTrue(comparator.compare(alias2, alias1) != 0); - - alias1 = createSpeciesAlias(); - alias2 = createSpeciesAlias(); - - alias1.setName("new namne"); - - assertTrue(comparator.compare(alias1, alias2) != 0); - assertTrue(comparator.compare(alias2, alias1) != 0); - - alias1 = createSpeciesAlias(); - alias2 = createSpeciesAlias(); - - alias1.setActivity(true); - - assertTrue(comparator.compare(alias1, alias2) != 0); - assertTrue(comparator.compare(alias2, alias1) != 0); - - alias1 = createSpeciesAlias(); - alias2 = createSpeciesAlias(); - - alias1.setLineWidth(453.75); - - assertTrue(comparator.compare(alias1, alias2) != 0); - assertTrue(comparator.compare(alias2, alias1) != 0); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - -} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesComparatorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..cc774a095d44264110cda6d3bf922f3fc441a618 --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesComparatorTest.java @@ -0,0 +1,291 @@ +package lcsb.mapviewer.model.map.species; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.awt.Color; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; + +import lcsb.mapviewer.common.exception.InvalidClassException; +import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.MiriamData; +import lcsb.mapviewer.model.map.MiriamRelationType; +import lcsb.mapviewer.model.map.MiriamType; +import lcsb.mapviewer.model.map.species.field.PositionToCompartment; + +public class SpeciesComparatorTest { + + + SpeciesComparator comparator = new SpeciesComparator(); + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testEquals() { + try { + Species alias1 = createSpeciesAlias(); + Species alias2 = createSpeciesAlias(); + + assertEquals(0, comparator.compare(alias1, alias2)); + + assertEquals(0, comparator.compare(null, null)); + + assertEquals(0, comparator.compare(new Complex(), new Complex())); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testCompareInvalid() { + try { + + Species alias = Mockito.mock(Species.class); + comparator.compare(alias, alias); + fail("Exception expected"); + + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + fail("Unkowne exception"); + } + } + + private Species createSpeciesAlias() { + GenericProtein result = new GenericProtein(); + result.setName("a"); + + result.setElementId("asd"); + result.setX(12.0); + result.setY(123.0); + result.setWidth(4); + result.setHeight(5); + result.setFontSize(9.0); + result.setColor(Color.BLUE); + result.setVisibilityLevel(14); + result.setAliasStateLabel("123"); + result.setAliasStatePrefix("1234"); + + return result; + } + + @Test + public void testDifferent() throws Exception { + try { + Species alias1 = createSpeciesAlias(); + Species alias2 = createSpeciesAlias(); + + assertTrue(comparator.compare(alias1, null) != 0); + assertTrue(comparator.compare(null, alias1) != 0); + + assertTrue(comparator.compare(new Complex(), alias1) != 0); + + alias1 = createSpeciesAlias(); + alias2 = createSpeciesAlias(); + + alias1.setElementId("tmp"); + + assertTrue(comparator.compare(alias1, alias2) != 0); + assertTrue(comparator.compare(alias2, alias1) != 0); + + alias1 = createSpeciesAlias(); + alias2 = createSpeciesAlias(); + + alias1.setAliasStateLabel("tmp"); + + assertTrue(comparator.compare(alias1, alias2) != 0); + assertTrue(comparator.compare(alias2, alias1) != 0); + + alias1 = createSpeciesAlias(); + alias2 = createSpeciesAlias(); + + alias1.setAliasStatePrefix("tmp"); + + assertTrue(comparator.compare(alias1, alias2) != 0); + assertTrue(comparator.compare(alias2, alias1) != 0); + + alias1 = createSpeciesAlias(); + alias2 = createSpeciesAlias(); + + alias1.setName("new namne"); + + assertTrue(comparator.compare(alias1, alias2) != 0); + assertTrue(comparator.compare(alias2, alias1) != 0); + + alias1 = createSpeciesAlias(); + alias2 = createSpeciesAlias(); + + alias1.setActivity(true); + + assertTrue(comparator.compare(alias1, alias2) != 0); + assertTrue(comparator.compare(alias2, alias1) != 0); + + alias1 = createSpeciesAlias(); + alias2 = createSpeciesAlias(); + + alias1.setLineWidth(453.75); + + assertTrue(comparator.compare(alias1, alias2) != 0); + assertTrue(comparator.compare(alias2, alias1) != 0); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + + @Test + public void testException() { + try { + Species mock = Mockito.mock(Species.class); + comparator.compare(mock, mock); + + fail("Exception expected"); + } catch (NotImplementedException e) { + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testEquals2() { + try { + SimpleMolecule species1 = createSimpleMolecule(); + SimpleMolecule species2 = createSimpleMolecule(); + assertEquals(0, comparator.compare(species1, species2)); + + assertEquals(0, comparator.compare(null, null)); + + assertEquals(0, comparator.compare(new AntisenseRna(), new AntisenseRna())); + assertEquals(0, comparator.compare(new Degraded(), new Degraded())); + assertEquals(0, comparator.compare(new Drug(), new Drug())); + assertEquals(0, comparator.compare(new Ion(), new Ion())); + assertEquals(0, comparator.compare(new Phenotype(), new Phenotype())); + assertEquals(0, comparator.compare(new Rna(), new Rna())); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testDifferent2() { + try { + SimpleMolecule species1 = createSimpleMolecule(); + SimpleMolecule species2 = createSimpleMolecule(); + + species1.setCharge(99); + assertTrue(comparator.compare(species1, species2) != 0); + assertTrue(comparator.compare(species2, species1) != 0); + assertTrue(comparator.compare(null, species1) != 0); + assertTrue(comparator.compare(species1, null) != 0); + + species1 = createSimpleMolecule(); + species2 = createSimpleMolecule(); + species1.setHomodimer(1233); + assertTrue(comparator.compare(species1, species2) != 0); + assertTrue(comparator.compare(species2, species1) != 0); + + species1 = createSimpleMolecule(); + species2 = createSimpleMolecule(); + species1.setElementId(""); + species1.setElementId("ASD"); + assertTrue(comparator.compare(species1, species2) != 0); + assertTrue(comparator.compare(species2, species1) != 0); + + species1 = createSimpleMolecule(); + species2 = createSimpleMolecule(); + species1.setNotes("ASD"); + assertTrue(comparator.compare(species1, species2) != 0); + assertTrue(comparator.compare(species2, species1) != 0); + + species1 = createSimpleMolecule(); + species2 = createSimpleMolecule(); + species1.setPositionToCompartment(PositionToCompartment.TRANSMEMBRANE); + assertTrue(comparator.compare(species1, species2) != 0); + assertTrue(comparator.compare(species2, species1) != 0); + + species1 = createSimpleMolecule(); + species2 = createSimpleMolecule(); + species1.getMiriamData().clear(); + assertTrue(comparator.compare(species1, species2) != 0); + assertTrue(comparator.compare(species2, species1) != 0); + + species1 = createSimpleMolecule(); + species2 = createSimpleMolecule(); + species1.setInitialAmount(4); + assertTrue(comparator.compare(species1, species2) != 0); + assertTrue(comparator.compare(species2, species1) != 0); + + species1 = createSimpleMolecule(); + species2 = createSimpleMolecule(); + species1.setInitialConcentration(4); + assertTrue(comparator.compare(species1, species2) != 0); + assertTrue(comparator.compare(species2, species1) != 0); + + species1 = createSimpleMolecule(); + species2 = createSimpleMolecule(); + species1.setOnlySubstanceUnits(false); + assertTrue(comparator.compare(species1, species2) != 0); + assertTrue(comparator.compare(species2, species1) != 0); + + species1 = createSimpleMolecule(); + species2 = createSimpleMolecule(); + species1.setHypothetical(true); + assertTrue(comparator.compare(species1, species2) != 0); + assertTrue(comparator.compare(species2, species1) != 0); + + species1 = createSimpleMolecule(); + species2 = createSimpleMolecule(); + species1.getMiriamData().iterator().next().setRelationType(MiriamRelationType.BQ_BIOL_IS); + assertTrue(comparator.compare(species1, species2) != 0); + assertTrue(comparator.compare(species2, species1) != 0); + + species1 = createSimpleMolecule(); + species2 = createSimpleMolecule(); + species1.addMiriamData(new MiriamData()); + assertTrue(comparator.compare(species1, species2) != 0); + assertTrue(comparator.compare(species2, species1) != 0); + + assertTrue(comparator.compare(new Rna(), new Drug()) != 0); + + } catch (Exception e) { + e.printStackTrace(); + fail("Unkowne exception"); + } + } + + public SimpleMolecule createSimpleMolecule() { + SimpleMolecule result = new SimpleMolecule(); + result.setHomodimer(12); + result.setElementId("id"); + result.setName("id"); + result.setInitialAmount(12); + result.setCharge(13); + result.setInitialConcentration(14); + result.setOnlySubstanceUnits(true); + result.setPositionToCompartment(PositionToCompartment.INSIDE); + result.setNotes("id"); + MiriamData md = new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.UNKNOWN, "c"); + result.addMiriamData(md); + return result; + } + +} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesAliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesTest.java similarity index 91% rename from model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesAliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesTest.java index 585a6b15d6cdc56345598b011eb89125de0955d9..a19acb8b2cddfd184d58c723d40baa9c122887e6 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesAliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesTest.java @@ -13,7 +13,7 @@ import lcsb.mapviewer.model.map.reaction.ReactionNode; import lcsb.mapviewer.model.map.species.GenericProtein; import lcsb.mapviewer.model.map.species.Species; -public class SpeciesAliasTest { +public class SpeciesTest { @Before public void setUp() throws Exception { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/TruncatedProteinTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/TruncatedProteinTest.java new file mode 100644 index 0000000000000000000000000000000000000000..3a00d4471fbcd94a0709030282efcf04b9b8b4f3 --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/TruncatedProteinTest.java @@ -0,0 +1,73 @@ +package lcsb.mapviewer.model.map.species; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import org.apache.commons.lang3.SerializationUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import lcsb.mapviewer.common.exception.NotImplementedException; + +public class TruncatedProteinTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new TruncatedProtein()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testConstructor() { + try { + TruncatedProtein species = new TruncatedProtein(new TruncatedProtein()); + assertNotNull(species); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testCopy1() { + try { + TruncatedProtein species = new TruncatedProtein("id").copy(); + assertNotNull(species); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testCopy2() { + try { + new TruncatedProtein() { + + /** + * + */ + private static final long serialVersionUID = 1L; + }.copy(); + fail("Exception expected"); + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + +} diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/UnknownComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/UnknownComparatorTest.java similarity index 65% rename from converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/UnknownComparatorTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/UnknownComparatorTest.java index 6eb492e92742ae61d16ec0fcc7d798e1a81b0698..a1e0a71553e93a4fb550345d74a12c7b9d9126a9 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/UnknownComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/UnknownComparatorTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -9,12 +9,10 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerUnknown; -import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerUnknownComparator; public class UnknownComparatorTest { - CellDesignerUnknownComparator comparator = new CellDesignerUnknownComparator(); + UnknownComparator comparator = new UnknownComparator(); @Before public void setUp() throws Exception { @@ -27,8 +25,8 @@ public class UnknownComparatorTest { @Test public void testEquals() { try { - CellDesignerUnknown aRna1 = createUnknown(); - CellDesignerUnknown aRna2 = createUnknown(); + Unknown aRna1 = createUnknown(); + Unknown aRna2 = createUnknown(); assertEquals(0, comparator.compare(aRna1, aRna1)); @@ -44,16 +42,16 @@ public class UnknownComparatorTest { @Test public void testDifferent() { try { - CellDesignerUnknown unknown2 = createUnknown(); + Unknown unknown2 = createUnknown(); assertTrue(comparator.compare(null, unknown2) != 0); assertTrue(comparator.compare(unknown2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - CellDesignerUnknown unknown = createUnknown(); + Unknown unknown = createUnknown(); unknown.setName("n"); assertTrue(comparator.compare(unknown, unknown2) != 0); - assertTrue(comparator.compare(unknown, new CellDesignerUnknown() { + assertTrue(comparator.compare(unknown, new Unknown() { private static final long serialVersionUID = 1L; }) != 0); @@ -63,15 +61,15 @@ public class UnknownComparatorTest { } } - public CellDesignerUnknown createUnknown() { - CellDesignerUnknown result = new CellDesignerUnknown(); + public Unknown createUnknown() { + Unknown result = new Unknown(); return result; } @Test public void testInvalid() { try { - class Tmp extends CellDesignerUnknown{ + class Tmp extends Unknown { private static final long serialVersionUID = 1L; } Tmp object = new Tmp(); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/UnknownTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/UnknownTest.java new file mode 100644 index 0000000000000000000000000000000000000000..ce6a2a0a88f7b0551ed01873cb21ca47e19aeaf4 --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/UnknownTest.java @@ -0,0 +1,84 @@ +package lcsb.mapviewer.model.map.species; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import org.apache.commons.lang3.SerializationUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import lcsb.mapviewer.common.exception.NotImplementedException; + +public class UnknownTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new Unknown()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testConstructor1() { + try { + Unknown degraded = new Unknown(new Unknown()); + assertNotNull(degraded); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testGetters() { + try { + Unknown degraded = new Unknown("id"); + assertNotNull(degraded.getStringType()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testCopy() { + try { + Unknown degraded = new Unknown().copy(); + assertNotNull(degraded); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testInvalidCopy() { + try { + new Unknown() { + + /** + * + */ + private static final long serialVersionUID = 1L; + }.copy(); + fail("Exception expected"); + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + +} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/field/AllFieldTests.java b/model/src/test/java/lcsb/mapviewer/model/map/species/field/AllFieldTests.java new file mode 100644 index 0000000000000000000000000000000000000000..3cc809ba3b47cb74f06e93a74f53eb8efc6e1f70 --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/field/AllFieldTests.java @@ -0,0 +1,17 @@ +package lcsb.mapviewer.model.map.species.field; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +@RunWith(Suite.class) +@SuiteClasses({ AntisenseRnaRegionTest.class, // + AntisenseRnaRegionTypeTest.class, // + ModificationStateTest.class, // + ModificationResidueTest.class, // + PositionToCompartmentTest.class, // + RnaRegionTest.class,// +}) +public class AllFieldTests { + +} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegionTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2821caabaf1b371a94d8804c4bcd47cb40167fa4 --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegionTest.java @@ -0,0 +1,173 @@ +package lcsb.mapviewer.model.map.species.field; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import org.apache.commons.lang3.SerializationUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import lcsb.mapviewer.common.Configuration; +import lcsb.mapviewer.common.exception.InvalidArgumentException; +import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.species.AntisenseRna; + +public class AntisenseRnaRegionTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new AntisenseRnaRegion()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testConstructor1() { + try { + AntisenseRnaRegion antisenseRna = new AntisenseRnaRegion(); + AntisenseRnaRegion antisenseRna2 = new AntisenseRnaRegion(antisenseRna); + assertNotNull(antisenseRna2); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testUpdate() { + try { + AntisenseRnaRegion antisenseRna = new AntisenseRnaRegion(); + antisenseRna.setState(ModificationState.EMPTY); + antisenseRna.setName("as"); + antisenseRna.setPos(3.0); + AntisenseRnaRegion antisenseRna2 = new AntisenseRnaRegion(); + antisenseRna2.update(antisenseRna); + assertEquals(antisenseRna.getState(), antisenseRna2.getState()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testInvalidUpdate() { + try { + AntisenseRnaRegion antisenseRna = new AntisenseRnaRegion(); + AntisenseRnaRegion antisenseRna2 = new AntisenseRnaRegion(); + antisenseRna.setIdAntisenseRnaRegion("@1"); + antisenseRna2.setIdAntisenseRnaRegion("@"); + antisenseRna2.update(antisenseRna); + fail("Exception expected"); + } catch (InvalidArgumentException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testGetters() { + try { + AntisenseRnaRegion region = new AntisenseRnaRegion(new AntisenseRnaRegion()); + int id = 91; + AntisenseRna species = new AntisenseRna("id"); + double pos = 4.6; + double size = 5.3; + AntisenseRnaRegionType type = AntisenseRnaRegionType.CODING_REGION; + String name = "nam"; + String idAntisenseRnaRegion = "iddd"; + + region.setId(id); + region.setSpecies(species); + region.setPos(pos); + region.setSize(size); + region.setType(type); + region.setName(name); + region.setIdAntisenseRnaRegion(idAntisenseRnaRegion); + region.setState(ModificationState.ACETYLATED); + + assertEquals(id, region.getId()); + assertEquals(species, region.getSpecies()); + assertEquals(pos, region.getPos(), Configuration.EPSILON); + assertEquals(size, region.getSize(), Configuration.EPSILON); + assertEquals(type, region.getType()); + assertEquals(name, region.getName()); + assertEquals(idAntisenseRnaRegion, region.getIdAntisenseRnaRegion()); + + assertEquals(ModificationState.ACETYLATED, region.getState()); + + try { + region.setSize("text"); + fail("Exception expected"); + } catch (InvalidArgumentException e) { + } + + try { + region.setPos("text"); + fail("Exception expected"); + } catch (InvalidArgumentException e) { + } + + region.setSize("1.0"); + region.setPos("1.0"); + assertEquals(1.0, region.getPos(), Configuration.EPSILON); + assertEquals(1.0, region.getSize(), Configuration.EPSILON); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testToString() { + try { + assertNotNull(new AntisenseRnaRegion().toString()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testCopy() { + try { + AntisenseRnaRegion degraded = new AntisenseRnaRegion().copy(); + assertNotNull(degraded); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testInvalidCopy() { + try { + new AntisenseRnaRegion() { + + /** + * + */ + private static final long serialVersionUID = 1L; + }.copy(); + fail("Exception expected"); + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + +} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegionTypeTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegionTypeTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c5a7537e0ebf47c63246848b760005b0bb93a7b0 --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegionTypeTest.java @@ -0,0 +1,53 @@ +package lcsb.mapviewer.model.map.species.field; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; + +public class AntisenseRnaRegionTypeTest { + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testEnum() { + try { + for (AntisenseRnaRegionType type : AntisenseRnaRegionType.values()) { + assertNotNull(type); + + // for coverage tests + AntisenseRnaRegionType.valueOf(type.name()); + assertNotNull(type.getName()); + + } + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testEnumGetTypeByString() { + try { + assertNotNull(AntisenseRnaRegionType.getTypeByString("proteinBindingDomain")); + assertNull(AntisenseRnaRegionType.getTypeByString("antisenseRnaDomainzz")); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + +} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/field/ModificationResidueTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/field/ModificationResidueTest.java new file mode 100644 index 0000000000000000000000000000000000000000..6b839c1379ca9b15929e1bf14355a74450f52961 --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/field/ModificationResidueTest.java @@ -0,0 +1,61 @@ +package lcsb.mapviewer.model.map.species.field; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; + +import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; + +public class ModificationResidueTest { + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testGetters() { + ModificationResidue mr = new ModificationResidue(); + Species species = new GenericProtein("id"); + int id = 94; + + mr.setSpecies(species); + mr.setId(id); + + assertEquals(species, mr.getSpecies()); + assertEquals(id, mr.getId()); + } + + @Test + public void testCopy() { + ModificationResidue mr = new ModificationResidue().copy(); + assertNotNull(mr); + } + + @Test + public void testInvalidCopy() { + ModificationResidue mr = Mockito.spy(ModificationResidue.class); + try { + mr.copy(); + fail("Exception expected"); + } catch (NotImplementedException e) { + + } + } + +} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/ModificationStateTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/field/ModificationStateTest.java similarity index 90% rename from model/src/test/java/lcsb/mapviewer/model/map/species/ModificationStateTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/field/ModificationStateTest.java index 1a1987dc8299eebaf30df1fa9fabdd137a1a4ca3..8867d157f8ff841b927969695534323a372fd116 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/ModificationStateTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/field/ModificationStateTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.species; +package lcsb.mapviewer.model.map.species.field; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/PositionToCompartmentTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/field/PositionToCompartmentTest.java similarity index 90% rename from model/src/test/java/lcsb/mapviewer/model/map/species/PositionToCompartmentTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/field/PositionToCompartmentTest.java index d8ca94fbd5e926fe48c4d2fadd7bf67a8d6948ae..5ddadcaac70fdec2e4fb748eef50231909884550 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/PositionToCompartmentTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/field/PositionToCompartmentTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.species; +package lcsb.mapviewer.model.map.species.field; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/field/RnaRegionTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/field/RnaRegionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..11e0edc346820fc24d8807caa425f8ed8d7e138e --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/field/RnaRegionTest.java @@ -0,0 +1,133 @@ +package lcsb.mapviewer.model.map.species.field; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import org.apache.commons.lang3.SerializationUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import lcsb.mapviewer.common.Configuration; +import lcsb.mapviewer.common.exception.InvalidArgumentException; +import lcsb.mapviewer.model.map.species.Rna; + +public class RnaRegionTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new RnaRegion()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testConstructor() { + try { + RnaRegion region = new RnaRegion(new RnaRegion()); + assertNotNull(region); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testSetSize() { + try { + RnaRegion region = new RnaRegion(); + try { + region.setSize("as"); + fail("Exception expected"); + } catch (InvalidArgumentException e) { + } + region.setSize("0.0"); + assertEquals(0.0, region.getSize(), Configuration.EPSILON); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testSetPos() { + try { + RnaRegion region = new RnaRegion(); + try { + region.setPos("as"); + fail("Exception expected"); + } catch (InvalidArgumentException e) { + } + region.setPos("1.0"); + assertEquals(1.0, region.getPos(), Configuration.EPSILON); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testUpdate() { + try { + RnaRegion region = new RnaRegion(); + RnaRegion region2 = new RnaRegion(); + region2.setState(ModificationState.ACETYLATED); + region2.setName("asd"); + region2.setPos(2.2); + region.update(region2); + assertEquals(region2.getName(), region.getName()); + assertEquals(region2.getPos(), region.getPos()); + assertEquals(region2.getState(), region.getState()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testUpdate2() { + try { + RnaRegion region = new RnaRegion(); + region.setIdRnaRegion("1"); + RnaRegion region2 = new RnaRegion(); + region2.setIdRnaRegion("2"); + region.update(region2); + fail("Exception expected"); + } catch (InvalidArgumentException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testGetters() { + try { + RnaRegion region = new RnaRegion(); + double size = 2.5; + int id = 58; + Rna species = new Rna("id"); + region.setSize(size); + region.setSpecies(species); + region.setId(id); + assertEquals(id, region.getId()); + assertEquals(size, region.getSize(), Configuration.EPSILON); + assertEquals(species, region.getSpecies()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } +} diff --git a/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/XML/ModelContructor.java b/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/XML/ModelContructor.java index 5403bf1b761b8107484dd9c405fb15d0475aed72..826bcee04c9ee412fcfeb9b9d09a51cfb9271d3d 100644 --- a/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/XML/ModelContructor.java +++ b/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/XML/ModelContructor.java @@ -977,7 +977,7 @@ public class ModelContructor { } } if (selectedAlias != null) { - selectedAlias.addAlias(alias); + selectedAlias.addElement(alias); } } } @@ -1103,7 +1103,7 @@ public class ModelContructor { List<Compartment> aliases = model.getCompartmentsAliases(); // clear all assignments for (Compartment compartmentAlias : aliases) { - compartmentAlias.getAliases().clear(); + compartmentAlias.getElements().clear(); } for (Element alias : model.getAliases()) { @@ -1128,7 +1128,7 @@ public class ModelContructor { } } if (parentAlias != null) { - parentAlias.addAlias(alias); + parentAlias.addElement(alias); alias.setParent(parentAlias); } } diff --git a/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/XML/ModelToGPML.java b/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/XML/ModelToGPML.java index cdfc86cc56717fe763f4d5770b2e5c953b53f65d..412b0124d6555711a89d11098d96256104c17e69 100644 --- a/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/XML/ModelToGPML.java +++ b/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/XML/ModelToGPML.java @@ -275,7 +275,7 @@ public class ModelToGPML { */ private String getAllNames(Compartment ca) { StringBuilder res = new StringBuilder(""); - for (Element a : ca.getAllSubAliases()) { + for (Element a : ca.getAllSubElements()) { if (a instanceof Species) { Species sp = (Species) a; res.append(sp.getName() + ";"); @@ -304,7 +304,7 @@ public class ModelToGPML { shape = "Rectangle"; } - comparments.append(" <Shape TextLabel=\"" + ca.getName() + "\" GraphId=\"" + ca.getAliasId() + "\">\n"); + comparments.append(" <Shape TextLabel=\"" + ca.getName() + "\" GraphId=\"" + ca.getElementId() + "\">\n"); comparments.append(" <Comment>" + getAllNames(ca) + "</Comment>\n"); comparments.append(" <Attribute Key=\"org.pathvisio.CellularComponentProperty\" Value=\"Cell\" />\n"); comparments.append(" <Attribute Key=\"org.pathvisio.DoubleLineProperty\" Value=\"Double\" />\n"); @@ -351,7 +351,7 @@ public class ModelToGPML { if (rn instanceof Reactant) { for (Point2D p2d : line.getPoints()) { if (p2d.equals(ps)) { - interaction.append(" <Point X=\"" + ps.getX() + "\" Y=\"" + ps.getY() + "\" GraphRef=\"" + rn.getAlias().getAliasId() + "\"/>\n"); + interaction.append(" <Point X=\"" + ps.getX() + "\" Y=\"" + ps.getY() + "\" GraphRef=\"" + rn.getAlias().getElementId() + "\"/>\n"); } else if (p2d.equals(pe)) { interaction.append(" <Point X=\"" + pe.getX() + "\" Y=\"" + pe.getY() + "\" GraphRef=\"" + anchId + "\"/>\n"); } else { @@ -364,7 +364,7 @@ public class ModelToGPML { interaction.append(" <Point X=\"" + ps.getX() + "\" Y=\"" + ps.getY() + "\" GraphRef=\"" + anchId + "\"/>\n"); } else if (p2d.equals(pe)) { interaction.append( - " <Point X=\"" + pe.getX() + "\" Y=\"" + pe.getY() + "\" GraphRef=\"" + rn.getAlias().getAliasId() + "\" ArrowHead=\"mim-conversion\"/>\n"); + " <Point X=\"" + pe.getX() + "\" Y=\"" + pe.getY() + "\" GraphRef=\"" + rn.getAlias().getElementId() + "\" ArrowHead=\"mim-conversion\"/>\n"); } else { interaction.append(" <Point X=\"" + p2d.getX() + "\" Y=\"" + p2d.getY() + "\"/>\n"); } @@ -372,7 +372,7 @@ public class ModelToGPML { } else if (rn instanceof Modifier) { for (Point2D p2d : line.getPoints()) { if (p2d.equals(ps)) { - interaction.append(" <Point X=\"" + ps.getX() + "\" Y=\"" + ps.getY() + "\" GraphRef=\"" + rn.getAlias().getAliasId() + "\"/>\n"); + interaction.append(" <Point X=\"" + ps.getX() + "\" Y=\"" + ps.getY() + "\" GraphRef=\"" + rn.getAlias().getElementId() + "\"/>\n"); } else if (p2d.equals(pe)) { interaction.append(" <Point X=\"" + pe.getX() + "\" Y=\"" + pe.getY() + "\" GraphRef=\"" + anchId + "\" ArrowHead=\"mim-catalysis\"/>\n"); } else { @@ -411,11 +411,11 @@ public class ModelToGPML { protected String getDataNodes(Model model) throws ConverterException { StringBuilder dataNodes = new StringBuilder(""); - for (Species sa : model.getNotComplexSpeciesAliases()) { + for (Species sa : model.getNotComplexSpeciesList()) { if (!(sa instanceof Complex)) { - dataNodes.append(" <DataNode TextLabel=\"" + sa.getName() + "\" GraphId=\"" + sa.getAliasId() + "\" Type=\"" + getType(sa) + "\""); + dataNodes.append(" <DataNode TextLabel=\"" + sa.getName() + "\" GraphId=\"" + sa.getElementId() + "\" Type=\"" + getType(sa) + "\""); if (sa.getComplexAlias() != null) { - dataNodes.append(" GroupRef=\"" + sa.getComplexAlias().getAliasId() + "\""); + dataNodes.append(" GroupRef=\"" + sa.getComplexAlias().getElementId() + "\""); } dataNodes.append(">\n"); @@ -447,11 +447,11 @@ public class ModelToGPML { } /** Special Case for empty Complexes **/ - for (Complex ca : model.getComplexAliases()) { + for (Complex ca : model.getComplexList()) { if (ca.getAliases().size() == 0) { - dataNodes.append(" <DataNode TextLabel=\"" + ca.getName() + "\" GraphId=\"" + ca.getAliasId() + "\" Type=\"Complex\""); + dataNodes.append(" <DataNode TextLabel=\"" + ca.getName() + "\" GraphId=\"" + ca.getElementId() + "\" Type=\"Complex\""); if (ca.getComplexAlias() != null) { - dataNodes.append(" GroupRef=\"" + ca.getComplexAlias().getAliasId() + "\""); + dataNodes.append(" GroupRef=\"" + ca.getComplexAlias().getElementId() + "\""); } dataNodes.append(">\n"); @@ -480,11 +480,11 @@ public class ModelToGPML { protected String getGroups(Model model) { StringBuilder groups = new StringBuilder(""); - for (Complex ca : model.getComplexAliases()) { + for (Complex ca : model.getComplexList()) { if (ca.getAliases().size() > 0) { - groups.append(" <Group GroupId=\"" + ca.getAliasId() + "\" GraphId=\"" + ca.getAliasId() + "\""); + groups.append(" <Group GroupId=\"" + ca.getElementId() + "\" GraphId=\"" + ca.getElementId() + "\""); if (ca.getComplexAlias() != null) { - groups.append(" GroupRef=\"" + ca.getComplexAlias().getAliasId() + "\""); + groups.append(" GroupRef=\"" + ca.getComplexAlias().getElementId() + "\""); } groups.append("/>\n"); } @@ -523,8 +523,8 @@ public class ModelToGPML { PolylineData line = getPolyline(start, end); Point2D ps = line.getBeginPoint(); Point2D pe = line.getEndPoint(); - String sid = start.getAlias().getAliasId(); - String eid = end.getAlias().getAliasId(); + String sid = start.getAlias().getElementId(); + String eid = end.getAlias().getElementId(); for (Point2D p2d : line.getPoints()) { if (p2d.equals(ps)) { diff --git a/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/ComplexReactionToModelTest.java b/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/ComplexReactionToModelTest.java index c2086f350b9284bd29e9d316624fde6c25088364..7b8690e29c538a6a83e900b3754e1b1e088d124f 100644 --- a/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/ComplexReactionToModelTest.java +++ b/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/ComplexReactionToModelTest.java @@ -176,8 +176,8 @@ public class ComplexReactionToModelTest { assertFalse(Color.BLACK.equals(reaction.getReactants().get(0).getLine().getColor())); - Element redAlias = model.getAliasByAliasId("d9620"); - Element blackAlias = model.getAliasByAliasId("d046f"); + Element redAlias = model.getElementByElementId("d9620"); + Element blackAlias = model.getElementByElementId("d046f"); assertFalse(Color.BLACK.equals(redAlias.getColor())); assertTrue(Color.WHITE.equals(blackAlias.getColor())); diff --git a/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/GPMLToModelTest.java b/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/GPMLToModelTest.java index 181a15f9ee8c7e1ab0e7983ea14cc26b8d178bea..5aaa91d06c5b1b298a289e94b33d2f572179d570 100644 --- a/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/GPMLToModelTest.java +++ b/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/GPMLToModelTest.java @@ -403,7 +403,7 @@ public class GPMLToModelTest { try { String fileName = "testFiles/complex/hypothetical_complex.gpml"; Model model = new GPMLToModel().getModel(fileName); - for (Complex species : model.getComplexAliases()) { + for (Complex species : model.getComplexList()) { assertTrue("Complex parsed from gpml should be hypothetical", species.isHypothetical()); } @@ -419,7 +419,7 @@ public class GPMLToModelTest { try { String fileName = "testFiles/complex/nonhypothetical_complex.gpml"; Model model = new GPMLToModel().getModel(fileName); - for (Complex species : model.getComplexAliases()) { + for (Complex species : model.getComplexList()) { assertFalse("Complex parsed from gpml should be hypothetical", species.isHypothetical()); } assertEquals(0, model.getCreationWarnings().size()); @@ -435,7 +435,7 @@ public class GPMLToModelTest { String fileName = "testFiles/complex/complex_with_name.gpml"; Model model = new GPMLToModel().getModel(fileName); boolean nameFound = false; - for (Complex species : model.getComplexAliases()) { + for (Complex species : model.getComplexList()) { if ("p70 S6 Kinases".equals(species.getName())) { nameFound = true; } @@ -580,7 +580,7 @@ public class GPMLToModelTest { Model model1 = new GPMLToModel().getModel(fileName); assertEquals(0, model1.getCreationWarnings().size()); - Gene protein = (Gene)model1.getAliasByAliasId("be3de"); + Gene protein = (Gene)model1.getElementByElementId("be3de"); assertNotNull(protein); assertEquals(2, protein.getModificationResidues().size()); @@ -605,7 +605,7 @@ public class GPMLToModelTest { Model model1 = new GPMLToModel().getModel(fileName); assertEquals(0, model1.getCreationWarnings().size()); - Gene protein = (Gene)model1.getAliasByAliasId("be3de"); + Gene protein = (Gene)model1.getElementByElementId("be3de"); assertNotNull(protein); assertEquals(2, protein.getModificationResidues().size()); @@ -695,7 +695,7 @@ public class GPMLToModelTest { String fileName = "testFiles/small/protein_with_state.gpml"; Model model1 = new GPMLToModel().getModel(fileName); - Protein protein = (Protein) model1.getAliasByName("Protein").get(0); + Protein protein = (Protein) model1.getElementsByName("Protein").get(0); assertEquals(0, protein.getModificationResidues().size()); assertEquals("GTP", protein.getStructuralState()); diff --git a/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/ModelToGPMLTest.java b/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/ModelToGPMLTest.java index f4696072ab00726c9aec9ab3629ee4f102d1df92..b69a4bb8b7594f0e8fe756295c6e6ea4d616260f 100644 --- a/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/ModelToGPMLTest.java +++ b/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/ModelToGPMLTest.java @@ -80,7 +80,7 @@ public class ModelToGPMLTest extends WikipathwaysTestFunctions { Model model2 = new GPMLToModel().getModel(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8))); - Element p = model2.getAliasByAliasId("sa"); + Element p = model2.getElementByElementId("sa"); assertEquals(alias.getMiriamData().size(), p.getMiriamData().size()); for (MiriamData md : p.getMiriamData()) { diff --git a/persist/src/db/10.0.3/fix_db_20161004.sql b/persist/src/db/10.0.3/fix_db_20161004.sql new file mode 100644 index 0000000000000000000000000000000000000000..fbb822d5011e5cb1496b2312e8567d5372437fbc --- /dev/null +++ b/persist/src/db/10.0.3/fix_db_20161004.sql @@ -0,0 +1,7 @@ +-- drop old species implementation + +alter table node_table drop column element_iddb; +alter table alias_table drop column idelementdb; +drop table species_table; + +alter table alias_table rename column aliasid to elementid; \ No newline at end of file diff --git a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/LayoutDaoTest.java b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/LayoutDaoTest.java index d1e9e9cf831225a4d014b6320ee244cb2f7899a0..f7527603437a2c2fd13e4a3de5bef674625881b9 100644 --- a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/LayoutDaoTest.java +++ b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/LayoutDaoTest.java @@ -210,7 +210,7 @@ public class LayoutDaoTest extends PersistTestFunctions { private Protein createSpeciesAlias(double x, double y, double width, double height, String aliasId) { GenericProtein alias = new GenericProtein("s" + identifierCounter++); - alias.setAliasId(aliasId); + alias.setElementId(aliasId); alias.setX(x); alias.setY(y); alias.setWidth(width); diff --git a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/ModelDaoTest.java b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/ModelDaoTest.java index ed8a97c14ccbe56206f6b0ebf3cae3bcc05fa447..a5126a28a621b63f841c90aadeb0fef6574ca6b5 100644 --- a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/ModelDaoTest.java +++ b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/ModelDaoTest.java @@ -107,7 +107,7 @@ public class ModelDaoTest extends PersistTestFunctions { boolean test = false; for (Element alias : model.getAliases()) { - assertNotNull(fullModel.getAliasByAliasId(alias.getAliasId())); + assertNotNull(fullModel.getElementByElementId(alias.getElementId())); test = true; } assertTrue(test); @@ -115,7 +115,7 @@ public class ModelDaoTest extends PersistTestFunctions { test = false; for (Element alias : model.getAliases()) { if (alias instanceof Compartment) { - assertNotNull(fullModel.getCompartmentAliasByCompartmentAliasId(alias.getAliasId())); + assertNotNull(fullModel.getCompartmentAliasByCompartmentAliasId(alias.getElementId())); test = true; } } @@ -216,8 +216,8 @@ public class ModelDaoTest extends PersistTestFunctions { projectDao.evict(project); Model model2 = new ModelFullIndexed(modelDao.getById(model.getId())); - Protein originalSpecies = (Protein) model.getAliasByAliasId("pr1"); - Protein fromDbSpecies = (Protein) model2.getAliasByAliasId("pr1"); + Protein originalSpecies = (Protein) model.getElementByElementId("pr1"); + Protein fromDbSpecies = (Protein) model2.getElementByElementId("pr1"); assertFalse(originalSpecies.equals(fromDbSpecies)); assertEquals(originalSpecies.getModificationResidues().size(), fromDbSpecies.getModificationResidues().size()); @@ -278,8 +278,8 @@ public class ModelDaoTest extends PersistTestFunctions { projectDao.evict(project); Model model2 = new ModelFullIndexed(modelDao.getById(model.getId())); - Protein originalSpecies = (Protein) model.getAliasByAliasId("pr1"); - Protein fromDbSpecies = (Protein) model2.getAliasByAliasId("pr1"); + Protein originalSpecies = (Protein) model.getElementByElementId("pr1"); + Protein fromDbSpecies = (Protein) model2.getElementByElementId("pr1"); assertFalse(originalSpecies.equals(fromDbSpecies)); assertEquals(originalSpecies.getMiriamData().size(), fromDbSpecies.getMiriamData().size()); @@ -393,7 +393,7 @@ public class ModelDaoTest extends PersistTestFunctions { alias.setName("SNCA"); alias.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "SNCA")); alias.addMiriamData(new MiriamData(MiriamType.HGNC, "11138")); - alias.setAliasId(aliasId); + alias.setElementId(aliasId); alias.setX(x); alias.setY(y); alias.setWidth(width); diff --git a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AliasDaoTest.java b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AliasDaoTest.java index 1e05e8b055cf9489befd7f580cfed2463296d3a5..c754a4adc71438325bbd6e1bfeb17f5fbd70875e 100644 --- a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AliasDaoTest.java +++ b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AliasDaoTest.java @@ -50,7 +50,7 @@ public class AliasDaoTest extends PersistTestFunctions { Model model = createModel(); project.addModel(model); - Species alias = (Species) model.getAliasByAliasId("sa2"); + Species alias = (Species) model.getElementByElementId("sa2"); alias.getSearchIndexes().add(new SearchIndex("blabla")); @@ -58,7 +58,7 @@ public class AliasDaoTest extends PersistTestFunctions { Model model2 = new ModelFullIndexed(modelDao.getById(model.getId())); - Species alias2 = (Species) aliasDao.getById(model2.getAliasByAliasId("sa2").getId()); + Species alias2 = (Species) aliasDao.getById(model2.getElementByElementId("sa2").getId()); assertEquals(1, alias2.getSearchIndexes().size()); @@ -127,7 +127,7 @@ public class AliasDaoTest extends PersistTestFunctions { long count = modelDao.getCount(); Model model = createModel(); Model model1 = createModel(); - Element alias = model.getAliasByAliasId("sa2"); + Element alias = model.getElementByElementId("sa2"); AliasSubmodelConnection submodel = new AliasSubmodelConnection(model1, SubmodelType.UNKNOWN); alias.setSubmodel(submodel); project.addModel(model); diff --git a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AliasDaoTest2.java b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AliasDaoTest2.java index a1a99c857e9d0b970c93beaa1f5d3d465688d771..76edf4dd1a2c12a640fcaaca78e43d3ddf8a4bfa 100644 --- a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AliasDaoTest2.java +++ b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AliasDaoTest2.java @@ -22,10 +22,10 @@ import lcsb.mapviewer.model.map.species.Protein; import lcsb.mapviewer.model.map.species.Rna; import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion; +import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegionType; import lcsb.mapviewer.model.map.species.field.ModificationResidue; import lcsb.mapviewer.model.map.species.field.ModificationState; import lcsb.mapviewer.model.map.species.field.RnaRegion; -import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion.AntisenseRnaRegionType; import lcsb.mapviewer.persist.PersistTestFunctions; public class AliasDaoTest2 extends PersistTestFunctions { @@ -70,7 +70,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { Species sp2 = (Species) aliasDao.getById(sp.getId()); assertNotNull(sp2); assertEquals(sp.getCharge(), sp2.getCharge()); - assertEquals(sp.getAliasId(), sp2.getAliasId()); + assertEquals(sp.getElementId(), sp2.getElementId()); assertEquals(sp.getInitialAmount(), sp2.getInitialAmount()); assertEquals(sp.getInitialConcentration(), sp2.getInitialConcentration()); assertEquals(sp.getName(), sp2.getName()); @@ -79,7 +79,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { Compartment parent2 = (Compartment) sp2.getParent(); assertNotNull(parent2); - assertEquals("comp id", parent2.getAliasId()); + assertEquals("comp id", parent2.getElementId()); assertNotNull(sp2.getMiriamData()); @@ -116,7 +116,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { Protein sp2 = (Protein) aliasDao.getById(protein.getId()); assertNotNull(sp2); - assertEquals(protein.getAliasId(), sp2.getAliasId()); + assertEquals(protein.getElementId(), sp2.getElementId()); assertNotNull(sp2.getModificationResidues()); assertEquals(1, sp2.getModificationResidues().size()); @@ -154,7 +154,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { Rna sp2 = (Rna) aliasDao.getById(sp.getId()); assertNotNull(sp2); - assertEquals(sp.getAliasId(), sp2.getAliasId()); + assertEquals(sp.getElementId(), sp2.getElementId()); assertNotNull(sp2.getRegions()); assertEquals(1, sp2.getRegions().size()); @@ -191,7 +191,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { AntisenseRna sp2 = (AntisenseRna) aliasDao.getById(sp.getId()); assertNotNull(sp2); - assertEquals(sp.getAliasId(), sp2.getAliasId()); + assertEquals(sp.getElementId(), sp2.getElementId()); assertNotNull(sp2.getRegions()); assertEquals(1, sp2.getRegions().size()); diff --git a/reactome/src/test/java/lcsb/mapviewer/reactome/utils/comparators/NodeComparatorTest.java b/reactome/src/test/java/lcsb/mapviewer/reactome/utils/comparators/NodeComparatorTest.java index ae7fe04c5c76d6c79b0b9108482dad2590471282..791b7bb32ab0452a8ce14b5c7fba4c9392476250 100644 --- a/reactome/src/test/java/lcsb/mapviewer/reactome/utils/comparators/NodeComparatorTest.java +++ b/reactome/src/test/java/lcsb/mapviewer/reactome/utils/comparators/NodeComparatorTest.java @@ -55,7 +55,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/reactome/cell_designer_references/reaction.xml", true); - Element speciesL_glu = model.getAliasByAliasId("sa6"); + Element speciesL_glu = model.getElementByElementId("sa6"); ReactomePhysicalEntity reactomeL_glu = seParser .parseObject(getXmlDocumentFromFile("testFiles/reactome/cell_designer_references/reactomeInput1.xml").getChildNodes().item(0)); @@ -76,7 +76,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/reactome/cell_designer_references/reaction.xml", true); - Element speciesNADP_PLUS = model.getAliasByAliasId("sa5"); + Element speciesNADP_PLUS = model.getElementByElementId("sa5"); ReactomeDefinedSet reactomeNAD_P_PLUS = dsParser .parseObject(getXmlDocumentFromFile("testFiles/reactome/cell_designer_references/reactomeInput2.xml").getChildNodes().item(0)); @@ -94,7 +94,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/reactome/cell_designer_references/reaction.xml", true); - Element h2o = model.getAliasByAliasId("sa7"); + Element h2o = model.getElementByElementId("sa7"); ReactomePhysicalEntity reactomeH2O = seParser .parseObject(getXmlDocumentFromFile("testFiles/reactome/cell_designer_references/reactomeInput3.xml").getChildNodes().item(0)); @@ -112,7 +112,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/reactome/cell_designer_references/reaction.xml", true); - Element oxoglutarate = model.getAliasByAliasId("sa1"); + Element oxoglutarate = model.getElementByElementId("sa1"); ReactomePhysicalEntity reactomeOxoglutaric = seParser .parseObject(getXmlDocumentFromFile("testFiles/reactome/cell_designer_references/reactomeOutput1.xml").getChildNodes().item(0)); @@ -130,7 +130,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/reactome/cell_designer_references/reaction.xml", true); - Element nadph = model.getAliasByAliasId("sa2"); + Element nadph = model.getElementByElementId("sa2"); ReactomeDefinedSet reactomeNadph = dsParser .parseObject(getXmlDocumentFromFile("testFiles/reactome/cell_designer_references/reactomeOutput3.xml").getChildNodes().item(0)); @@ -148,7 +148,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/reactome/cell_designer_references/reaction.xml", true); - Element hydron = model.getAliasByAliasId("sa3"); + Element hydron = model.getElementByElementId("sa3"); ReactomePhysicalEntity reactomeHydron = seParser .parseObject(getXmlDocumentFromFile("testFiles/reactome/cell_designer_references/reactomeOutput4.xml").getChildNodes().item(0)); @@ -166,7 +166,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/reactome/cell_designer_references/reaction.xml", true); - Element hydron = model.getAliasByAliasId("sa4"); + Element hydron = model.getElementByElementId("sa4"); ReactomeCatalystActivity reactomeHydron = caParser .parseObject(getXmlDocumentFromFile("testFiles/reactome/cell_designer_references/reactomeCatalyst1.xml").getChildNodes().item(0)); @@ -184,7 +184,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/small/tbid_bax_complex.xml", true); - Element species = model.getAliasByAliasId("csa1"); + Element species = model.getElementByElementId("csa1"); ReactomeDatabaseObject reactomeObject = rc.getFullObjectForDbId(168850); // these nodes match @@ -201,7 +201,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/small/bax.xml", true); - Element species = model.getAliasByAliasId("sa1"); + Element species = model.getElementByElementId("sa1"); ReactomeDatabaseObject reactomeObject = rc.getFullObjectForDbId(139907); // these nodes match @@ -218,7 +218,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/small/bid.xml", true); - Element species = model.getAliasByAliasId("sa1"); + Element species = model.getElementByElementId("sa1"); ReactomeDatabaseObject reactomeObject = rc.getFullObjectForDbId(139953); // these nodes match @@ -235,7 +235,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/small/fumarate_hydratase.xml", true); - Element species = model.getAliasByAliasId("csa1"); + Element species = model.getElementByElementId("csa1"); ReactomeDatabaseObject reactomeObject = rc.getFullObjectForDbId(70981); // these nodes match @@ -253,7 +253,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/small/acadl.xml", true); - Element species = model.getAliasByAliasId("sa1"); + Element species = model.getElementByElementId("sa1"); ReactomeDatabaseObject reactomeObject = rc.getFullObjectForDbId(77258); // these nodes match @@ -271,7 +271,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/small/phosphate_ion.xml", true); - Element species = model.getAliasByAliasId("sa1"); + Element species = model.getElementByElementId("sa1"); ReactomeDatabaseObject reactomeObject = rc.getFullObjectForDbId(113548); // these nodes match @@ -289,7 +289,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/small/dna.xml", true); - Element species = model.getAliasByAliasId("sa1"); + Element species = model.getElementByElementId("sa1"); ReactomeDatabaseObject reactomeObject = rc.getFullObjectForDbId(29428); // these nodes match @@ -307,7 +307,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/small/atp.xml", true); - Element species = model.getAliasByAliasId("sa1"); + Element species = model.getElementByElementId("sa1"); ReactomeDatabaseObject reactomeObject = rc.getFullObjectForDbId(416325); // these nodes match @@ -324,7 +324,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/small/bcl2l11_2.xml", true); - Element species = model.getAliasByAliasId("sa1"); + Element species = model.getElementByElementId("sa1"); ReactomeDatabaseObject reactomeObject = rc.getFullObjectForDbId(140526); // these nodes match @@ -341,7 +341,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/small/diablo_xiap_casp9.xml", true); - Element species = model.getAliasByAliasId("csa1"); + Element species = model.getElementByElementId("csa1"); ReactomeDatabaseObject reactomeObject = rc.getFullObjectForDbId(114318); // these nodes match @@ -358,7 +358,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/small/unknown.xml", true); - Element species = model.getAliasByAliasId("sa1"); + Element species = model.getElementByElementId("sa1"); ReactomeDatabaseObject reactomeObject = rc.getFullObjectForDbId(500676); // these nodes don't match after update of reactome @@ -375,7 +375,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/small/pcca_pccb_complex.xml", true); - Element species = model.getAliasByAliasId("csa1"); + Element species = model.getElementByElementId("csa1"); ReactomeDatabaseObject reactomeObject = rc.getFullObjectForDbId(71030); // these nodes match @@ -392,7 +392,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/small/dffb.xml", true); - Element species = model.getAliasByAliasId("sa1"); + Element species = model.getElementByElementId("sa1"); ReactomeDatabaseObject reactomeObject = rc.getFullObjectForDbId(211238); // these nodes match @@ -409,7 +409,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/small/caspase_7.xml", true); - Element species = model.getAliasByAliasId("csa1"); + Element species = model.getElementByElementId("csa1"); ReactomeDatabaseObject reactomeObject = rc.getFullObjectForDbId(202853); // these nodes match @@ -427,7 +427,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/small/coa.xml", true); - Element species = model.getAliasByAliasId("sa1"); + Element species = model.getElementByElementId("sa1"); ReactomeDatabaseObject reactomeObject = rc.getFullObjectForDbId(548839); // these nodes match @@ -444,7 +444,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/small/pdp1_complex.xml", true); - Element species = model.getAliasByAliasId("csa1"); + Element species = model.getElementByElementId("csa1"); ReactomeDatabaseObject reactomeObject = rc.getFullObjectForDbId(204160); // these nodes match @@ -461,7 +461,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/small/ca2.xml", true); - Element species = model.getAliasByAliasId("sa1"); + Element species = model.getElementByElementId("sa1"); ReactomeDatabaseObject reactomeObject = rc.getFullObjectForDbId(204160); // these nodes match @@ -478,7 +478,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/small/dna2.xml", true); - Element species = model.getAliasByAliasId("sa1"); + Element species = model.getElementByElementId("sa1"); ReactomeDatabaseObject reactomeObject = rc.getFullObjectForDbId(266214); // these nodes match @@ -495,7 +495,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/small/caspase_3.xml", true); - Element species = model.getAliasByAliasId("csa1"); + Element species = model.getElementByElementId("csa1"); ReactomeDatabaseObject reactomeObject = rc.getFullObjectForDbId(114327); // these nodes match @@ -512,7 +512,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/small/gpd1.xml", true); - Element species = model.getAliasByAliasId("sa1"); + Element species = model.getElementByElementId("sa1"); ReactomeDatabaseObject reactomeObject = rc.getFullObjectForDbId(1500607); // these nodes match @@ -529,7 +529,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/small/prkacb.xml", true); - Element species = model.getAliasByAliasId("sa1"); + Element species = model.getElementByElementId("sa1"); ReactomeDatabaseObject reactomeObject = rc.getFullObjectForDbId(443469); // these nodes match diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/CommentService.java b/service/src/main/java/lcsb/mapviewer/services/impl/CommentService.java index c2961ae1f7ab71f6c0682f71902e75c0011b2be8..eb6f7539a29ae437e0b7be5391dc58e91b7d37e1 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/CommentService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/CommentService.java @@ -296,7 +296,7 @@ public class CommentService implements ICommentService { } else { Element alias = model.getAliasByDbId(comment.getTableId()); if (alias != null) { - identifier = ((Species) alias).getAliasId(); + identifier = ((Species) alias).getElementId(); } else { logger.warn("Invalid alias dbID: " + comment.getTableId()); } @@ -369,7 +369,7 @@ public class CommentService implements ICommentService { result.setTableId(dbId); } } else if (id.startsWith("sa")) { - Integer dbId = model.getAliasByAliasId(id).getId(); + Integer dbId = model.getElementByElementId(id).getId(); result.setTableId(dbId); } String className = URLDecoder.decode(lines[COMMENT_SERIALIZATION_CLASS_TYPE_LINE], SERIALIZATION_ENCODING); diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/ExporterService.java b/service/src/main/java/lcsb/mapviewer/services/impl/ExporterService.java index ac91c3c6f93af92e62cfcc4c0206ac9f88b5354f..8de8004743d8cf177f21d14bc79bb84cf3a0a21d 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/ExporterService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/ExporterService.java @@ -283,7 +283,7 @@ public class ExporterService implements IExporterService { // in case the element is outside any component then we have to crate // artifical null component if (aliases.size() == 0) { - PathwayCompartment nullAlias = new PathwayCompartment(); + PathwayCompartment nullAlias = new PathwayCompartment("default"); nullAlias.setName("null"); aliases.add(nullAlias); } @@ -1049,7 +1049,7 @@ public class ExporterService implements IExporterService { * @return identifier that should be used for a given alias */ private String getId(Element alias) { - return alias.getAliasId(); + return alias.getElementId(); } @Override diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/SearchService.java b/service/src/main/java/lcsb/mapviewer/services/impl/SearchService.java index e9e5789c5ecbf31cc3d4a6e71eb7f069592d611a..0f555b798b48a2644fa303bc667c6e5fd7db4758 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/SearchService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/SearchService.java @@ -236,7 +236,7 @@ public class SearchService implements ISearchService { if (query.startsWith(REACTION_SEARCH_PREFIX)) { return getReactionById(model, query.replaceFirst(REACTION_SEARCH_PREFIX, "").toLowerCase()); } else if (query.startsWith(SPECIES_SEARCH_PREFIX)) { - result.add(fullAliasViewFactory.create(model.getAliasByAliasId(query.replaceFirst(SPECIES_SEARCH_PREFIX, "")))); + result.add(fullAliasViewFactory.create(model.getElementByElementId(query.replaceFirst(SPECIES_SEARCH_PREFIX, "")))); } else { Set<Element> aliases = model.getAliases(); diff --git a/service/src/main/java/lcsb/mapviewer/services/search/db/TargetViewFactory.java b/service/src/main/java/lcsb/mapviewer/services/search/db/TargetViewFactory.java index be65cf159edf151e729f7f374f90d84276feef21..fcc8cc04e4aeaf50c82daf4e6882dd1cf0c57cd3 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/db/TargetViewFactory.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/db/TargetViewFactory.java @@ -88,12 +88,12 @@ public class TargetViewFactory extends AbstractViewFactory<Target, TargetView> { geneRow.setAnnotation(annotationViewFactory.create(md)); if (model != null) { Set<AnnotatedObject> list = new HashSet<>(); - list.addAll(model.getAliasByName(md.getResource())); + list.addAll(model.getElementsByName(md.getResource())); list.addAll(model.getElementsByAnnotation(md)); int countInTopModel = list.size(); for (ModelSubmodelConnection submodel : model.getSubmodelConnections()) { - list.addAll(submodel.getSubmodel().getModel().getAliasByName(md.getResource())); + list.addAll(submodel.getSubmodel().getModel().getElementsByName(md.getResource())); list.addAll(submodel.getSubmodel().getModel().getElementsByAnnotation(md)); } int counter = list.size(); diff --git a/service/src/main/java/lcsb/mapviewer/services/search/db/drug/DrugViewFactory.java b/service/src/main/java/lcsb/mapviewer/services/search/db/drug/DrugViewFactory.java index 074d19044c3d5f1925ef7acf690ef0ccd51c9d94..8ed19f9a963c4182fb669e5aa43f270c2370c328 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/db/drug/DrugViewFactory.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/db/drug/DrugViewFactory.java @@ -147,7 +147,7 @@ public class DrugViewFactory extends SearchResultFactory<Drug, DrugView> { List<ElementIdentifier> result = new ArrayList<>(); for (Model m : models) { - List<Element> species = m.getAliasByName(annotation.getName()); + List<Element> species = m.getElementsByName(annotation.getName()); for (Element species2 : species) { result.add(new ElementIdentifier(species2, icon)); } diff --git a/service/src/main/java/lcsb/mapviewer/services/utils/SearchIndexer.java b/service/src/main/java/lcsb/mapviewer/services/utils/SearchIndexer.java index cb448f1dd0f9f3663a7172b7774a1f39c0ec8562..92ad037b37a01a431dc93add2e3280a0e243a9c1 100644 --- a/service/src/main/java/lcsb/mapviewer/services/utils/SearchIndexer.java +++ b/service/src/main/java/lcsb/mapviewer/services/utils/SearchIndexer.java @@ -75,7 +75,7 @@ public class SearchIndexer { */ public List<SearchIndex> createIndexForAlias(Element species) { List<SearchIndex> result = new ArrayList<>(); - String id1 = species.getAliasId(); + String id1 = species.getElementId(); result.add(new SearchIndex(getIndexStringForString(id1), SEARCH_SCORE_LEVEL_FOR_ALIAS_ID)); String id3 = species.getName(); diff --git a/service/src/main/java/lcsb/mapviewer/services/view/PubmedAnnotatedElementsView.java b/service/src/main/java/lcsb/mapviewer/services/view/PubmedAnnotatedElementsView.java index e8a9acaae8cedcfb96f2230dc2b0406a71c55e7e..4be94f326962a66a8fa68b3323854055c3abe7a8 100644 --- a/service/src/main/java/lcsb/mapviewer/services/view/PubmedAnnotatedElementsView.java +++ b/service/src/main/java/lcsb/mapviewer/services/view/PubmedAnnotatedElementsView.java @@ -94,7 +94,7 @@ public class PubmedAnnotatedElementsView extends AbstractView<MiriamData> { public void addElement(AnnotatedObject annotatedObject) { if (annotatedObject instanceof Element) { Element alias = (Element) annotatedObject; - elements.add(new Pair<String, String>(alias.getName(), SearchService.SPECIES_SEARCH_PREFIX + ":" + alias.getAliasId())); + elements.add(new Pair<String, String>(alias.getName(), SearchService.SPECIES_SEARCH_PREFIX + ":" + alias.getElementId())); } else if (annotatedObject instanceof Reaction) { Reaction reaction = (Reaction) annotatedObject; elements.add( diff --git a/service/src/test/java/lcsb/mapviewer/services/impl/CommentServiceTest.java b/service/src/test/java/lcsb/mapviewer/services/impl/CommentServiceTest.java index 6c5d5baafbfe2384b2d64007eca651e09f78d482..2d984725fa7ede16a23ba5092262e76f337d0162 100644 --- a/service/src/test/java/lcsb/mapviewer/services/impl/CommentServiceTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/impl/CommentServiceTest.java @@ -172,7 +172,7 @@ public class CommentServiceTest extends ServiceTestFunctions { @Test public void testAddCommentForAlias() throws Exception { try { - Element alias = model.getAliasByAliasId("sa1"); + Element alias = model.getElementByElementId("sa1"); long counter = commentService.getCommentCount(); Comment feedback = commentService.addComment("a", "b", "c", model, new Point2D.Double(0, 0), alias, false, model); long counter2 = commentService.getCommentCount(); diff --git a/service/src/test/java/lcsb/mapviewer/services/impl/ExporterServiceTest.java b/service/src/test/java/lcsb/mapviewer/services/impl/ExporterServiceTest.java index 893a4663a947bc11aa9391cf3db64f10f4d8dd5d..cc5c205c6dab74219e96b1e03397a954aede3f68 100644 --- a/service/src/test/java/lcsb/mapviewer/services/impl/ExporterServiceTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/impl/ExporterServiceTest.java @@ -123,7 +123,7 @@ public class ExporterServiceTest extends ServiceTestFunctions { try { Model model = getModelForFile("testFiles/export/hsp70.xml", true); - Species alias = (Species) model.getAliasByAliasId("csa1"); + Species alias = (Species) model.getElementByElementId("csa1"); ExportColumn columns[] = { ExportColumn.NAME }; ExporterParameters params = new IExporterService.ExporterParameters().model(model).// @@ -147,7 +147,7 @@ public class ExporterServiceTest extends ServiceTestFunctions { assertTrue(string.contains("BAG1")); // and now check complexes with mix of proteins and molecules - alias = (Species) model.getAliasByAliasId("csa3"); + alias = (Species) model.getElementByElementId("csa3"); elements = exporter.getExportStringForOneSpecies(alias, params); assertTrue(elements.size() > 0); @@ -246,7 +246,7 @@ public class ExporterServiceTest extends ServiceTestFunctions { model.getReactions().clear(); model.addReaction(reaction); Set<Compartment> aliases = new HashSet<Compartment>(); - aliases.add((Compartment) model.getAliasByAliasId("ca1")); + aliases.add((Compartment) model.getElementByElementId("ca1")); ExporterParameters params = new IExporterService.ExporterParameters() .model(model).fileType(ExportFileType.SIF).included("dopamine loaded synaptic vesicle"); assertEquals(0, exporter.getExportSingleInteractionString(reaction, params).size()); @@ -297,14 +297,14 @@ public class ExporterServiceTest extends ServiceTestFunctions { .model(model).fileType(ExportFileType.TAB_SEPARATED).column(ExportColumn.NAME).column(ExportColumn.COMPONENT_NAME) .column(ExportColumn.COMPARTMENT_NAME); - List<String> list = exporter.getExportStringForOneSpecies((Species) model.getAliasByAliasId("sa1"), params); + List<String> list = exporter.getExportStringForOneSpecies((Species) model.getElementByElementId("sa1"), params); String desc = list.get(0); String compartment = desc.split("\t")[2]; assertEquals("c1", compartment); String component = desc.split("\t")[1]; assertEquals("Test3", component); - list = exporter.getExportStringForOneSpecies((Species) model.getAliasByAliasId("sa2"), params); + list = exporter.getExportStringForOneSpecies((Species) model.getElementByElementId("sa2"), params); desc = null; for (String string : list) { if (string.contains("Test 1")) { @@ -336,7 +336,7 @@ public class ExporterServiceTest extends ServiceTestFunctions { component = desc.split("\t")[1]; assertEquals("Test3", component); - list = exporter.getExportStringForOneSpecies((Species) model.getAliasByAliasId("sa3"), params); + list = exporter.getExportStringForOneSpecies((Species) model.getElementByElementId("sa3"), params); boolean ok = false; for (String string : list) { if (string.split("\t")[2].equals("null") && string.split("\t")[1].equals("Test2")) { @@ -345,21 +345,21 @@ public class ExporterServiceTest extends ServiceTestFunctions { } assertTrue(ok); - list = exporter.getExportStringForOneSpecies((Species) model.getAliasByAliasId("sa4"), params); + list = exporter.getExportStringForOneSpecies((Species) model.getElementByElementId("sa4"), params); desc = list.get(0); compartment = desc.split("\t")[2]; assertEquals("null", compartment); component = desc.split("\t")[1]; assertEquals("Test3", component); - list = exporter.getExportStringForOneSpecies((Species) model.getAliasByAliasId("sa5"), params); + list = exporter.getExportStringForOneSpecies((Species) model.getElementByElementId("sa5"), params); desc = list.get(0); compartment = desc.split("\t")[2]; assertEquals("c3", compartment); component = desc.split("\t")[1]; assertEquals("null", component); - list = exporter.getExportStringForOneSpecies((Species) model.getAliasByAliasId("sa6"), params); + list = exporter.getExportStringForOneSpecies((Species) model.getElementByElementId("sa6"), params); desc = list.get(0); compartment = desc.split("\t")[2]; assertEquals("null", compartment); diff --git a/service/src/test/java/lcsb/mapviewer/services/impl/ProjectServiceTest.java b/service/src/test/java/lcsb/mapviewer/services/impl/ProjectServiceTest.java index 3858e05830b44c0c79d0692ca8e387b6c1c6a4e3..f79c6e0da847b76e9fe7362c887d29f81b1d44d1 100644 --- a/service/src/test/java/lcsb/mapviewer/services/impl/ProjectServiceTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/impl/ProjectServiceTest.java @@ -270,20 +270,20 @@ public class ProjectServiceTest extends ServiceTestFunctions { assertNotNull(s2Model); assertNotNull(s3Model); - Element al1 = model.getAliasByAliasId("sa1"); + Element al1 = model.getElementByElementId("sa1"); assertNotNull(al1.getSubmodel()); assertEquals(SubmodelType.DOWNSTREAM_TARGETS, al1.getSubmodel().getType()); assertEquals(s1Model, al1.getSubmodel().getSubmodel().getModel()); - Element al2 = model.getAliasByAliasId("sa2"); + Element al2 = model.getElementByElementId("sa2"); assertNull(al2.getSubmodel()); - Element al4 = model.getAliasByAliasId("sa4"); + Element al4 = model.getElementByElementId("sa4"); assertNotNull(al4.getSubmodel()); assertEquals(SubmodelType.PATHWAY, al4.getSubmodel().getType()); assertEquals(s2Model, al4.getSubmodel().getSubmodel().getModel()); - Element s1_al1 = s1Model.getAliasByAliasId("sa1"); + Element s1_al1 = s1Model.getElementByElementId("sa1"); assertNotNull(s1_al1.getSubmodel()); assertEquals(SubmodelType.DOWNSTREAM_TARGETS, s1_al1.getSubmodel().getType()); assertEquals(s3Model, s1_al1.getSubmodel().getSubmodel().getModel()); diff --git a/service/src/test/java/lcsb/mapviewer/services/search/data/FullAliasViewFactoryTest.java b/service/src/test/java/lcsb/mapviewer/services/search/data/FullAliasViewFactoryTest.java index 31df89988dd356c99b440b94d04251e54bdbcd1c..45445bb354ff8b10732e5793394b42dd531cc382 100644 --- a/service/src/test/java/lcsb/mapviewer/services/search/data/FullAliasViewFactoryTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/search/data/FullAliasViewFactoryTest.java @@ -168,7 +168,7 @@ public class FullAliasViewFactoryTest extends ServiceTestFunctions { try { Model model = getModelForFile("testFiles/protein_with_modification.xml", true); model.setTileSize(256); - Species alias = (Species) model.getAliasByAliasId("sa1"); + Species alias = (Species) model.getElementByElementId("sa1"); FullAliasView marker = fullAliasViewFactory.create(alias); List<?> list = (List<?>) marker.getOther("posttranslationalModifications"); assertNotNull(list); @@ -216,12 +216,12 @@ public class FullAliasViewFactoryTest extends ServiceTestFunctions { try { Model model = getModelForFile("testFiles/graph_path_example3.xml", false); model.setTileSize(256); - Species alias = (Species) model.getAliasByAliasId("sa4"); + Species alias = (Species) model.getElementByElementId("sa4"); assertNotNull(alias); FullAliasView result = fullAliasViewFactory.create(alias); assertNotNull(result.getOther("chebiTree")); - alias = (Species) model.getAliasByAliasId("sa3"); + alias = (Species) model.getElementByElementId("sa3"); result = fullAliasViewFactory.create(alias); assertNull(result.getOther("chebiTree")); diff --git a/service/src/test/java/lcsb/mapviewer/services/search/db/drug/DrugViewFactoryTest.java b/service/src/test/java/lcsb/mapviewer/services/search/db/drug/DrugViewFactoryTest.java index 981396c2664bd99edd624453f7d1ef372e5c1c65..3e3e73c0fd76d183b695862676feb3efcd59eb1d 100644 --- a/service/src/test/java/lcsb/mapviewer/services/search/db/drug/DrugViewFactoryTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/search/db/drug/DrugViewFactoryTest.java @@ -109,7 +109,7 @@ public class DrugViewFactoryTest extends ServiceTestFunctions { try { Drug drug = chemblParser.findDrug("AMANTADINE"); Model model = getModelForFile("testFiles/drug_target.xml", false); - Element alias = model.getAliasByAliasId("sa9"); + Element alias = model.getElementByElementId("sa9"); alias.setName("M"); alias.setId(12); model.removeAlias(alias); diff --git a/service/src/test/java/lcsb/mapviewer/services/utils/ColorSchemaReaderTest.java b/service/src/test/java/lcsb/mapviewer/services/utils/ColorSchemaReaderTest.java index 31d0c2284c0a49f3ebbd1eb04cbab47762ee1525..13ba77479e16faf515a042176fcf771fe7977103 100644 --- a/service/src/test/java/lcsb/mapviewer/services/utils/ColorSchemaReaderTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/utils/ColorSchemaReaderTest.java @@ -197,7 +197,7 @@ public class ColorSchemaReaderTest extends ServiceTestFunctions { ColorModelCommand factory = new ColorModelCommand(model, schemas); factory.execute(); - assertFalse(model.getAliasByAliasId("sa1").getColor().equals(Color.WHITE)); + assertFalse(model.getElementByElementId("sa1").getColor().equals(Color.WHITE)); } catch (Exception e) { e.printStackTrace(); diff --git a/web/src/test/java/lcsb/mapviewer/bean/DrugBeanTest.java b/web/src/test/java/lcsb/mapviewer/bean/DrugBeanTest.java index 6161edffeaec349cc95d32d21808cd3fa976c80a..21fbb10b623650d7cacc6e7394d19c2b69f2c5b3 100644 --- a/web/src/test/java/lcsb/mapviewer/bean/DrugBeanTest.java +++ b/web/src/test/java/lcsb/mapviewer/bean/DrugBeanTest.java @@ -86,7 +86,7 @@ public class DrugBeanTest extends WebTestFunctions { // set current map getMapBean().setCurrentMapId(project.getProjectId()); - List<Pair<String, ElementIdentifierDetails>> result = drugBean.getElementInformationForResult(new ElementIdentifier(model.getAliasByAliasId("sa2"), "")); + List<Pair<String, ElementIdentifierDetails>> result = drugBean.getElementInformationForResult(new ElementIdentifier(model.getElementByElementId("sa2"), "")); assertTrue(result.size() > 0);