From cd8d1eb1f631f59106d2bbdf27354a367d8ae4a4 Mon Sep 17 00:00:00 2001 From: "piotr.gawron" <piotr.gawron@uni-new> Date: Mon, 3 Oct 2016 17:38:01 +0200 Subject: [PATCH] base refactoring finsihed classes renamed to species (there are no aliases anymore) database data about annotators cleared --- .../annotation/services/ModelAnnotator.java | 16 +- .../annotators/BiocompendiumAnnotator.java | 4 +- .../services/annotators/ChebiAnnotator.java | 6 +- .../services/annotators/ElementAnnotator.java | 26 +- .../services/annotators/EnsemblAnnotator.java | 18 +- .../services/annotators/EntrezAnnotator.java | 18 +- .../services/annotators/GoAnnotator.java | 14 +- .../services/annotators/HgncAnnotator.java | 18 +- .../services/annotators/ReconAnnotator.java | 28 +- .../services/annotators/UniprotAnnotator.java | 8 +- .../services/ImproperAnnotationsTest.java | 6 +- .../services/MissingAnnotationTest.java | 4 +- .../MissingRequiredAnnotationsTest.java | 6 +- .../services/ModelAnnotatorTest.java | 30 +- .../annotators/ChebiAnnotatorTest.java | 12 +- .../annotators/ElementAnnotatorTest.java | 16 +- .../annotators/EnsemblAnnotatorTest.java | 14 +- .../annotators/EntrezAnnotatorTest.java | 12 +- .../services/annotators/GoAnnotatorTest.java | 4 +- .../annotators/HgncAnnotatorTest.java | 16 +- .../annotators/ReconAnnotatorTest.java | 8 +- .../annotators/UniprotAnnotatorTest.java | 12 +- .../java/lcsb/mapviewer/run/BellExport.java | 6 +- .../lcsb/mapviewer/run/ConsoleConverter.java | 32 +- .../mapviewer/run/ReactomeComparison.java | 4 +- .../lcsb/mapviewer/run/ReactomeExport.java | 56 +- .../java/lcsb/mapviewer/run/RunOptions.java | 14 +- .../java/lcsb/mapviewer/run/Statistics.java | 20 +- .../run/UnknownReactionInReactome.java | 4 +- .../lcsb/mapviewer/run/VibineSnippet.java | 4 +- .../CellDesignerElementCollection.java | 28 +- .../celldesigner/CellDesignerXmlParser.java | 102 +- .../model/celldesigner/CommonXmlParser.java | 212 ++-- .../model/celldesigner/LayerXmlParser.java | 12 +- .../alias/AbstractAliasXmlParser.java | 4 +- .../alias/AliasCollectionXmlParser.java | 42 +- .../alias/CompartmentAliasXmlParser.java | 58 +- .../alias/ComplexAliasXmlParser.java | 52 +- .../alias/SpeciesAliasXmlParser.java | 50 +- .../celldesigner/annotation/NoteField.java | 14 +- .../annotation/RestAnnotationParser.java | 24 +- .../CompartmentCollectionXmlParser.java | 21 +- .../compartment/CompartmentXmlParser.java | 18 +- .../AbstractCellDesignerAliasConverter.java | 4 +- ...ntisenseRnaCellDesignerAliasConverter.java | 218 ++-- .../geometry/CellDesignerAliasConverter.java | 74 +- .../ComplexCellDesignerAliasConverter.java | 120 +- .../DegradedCellDesignerAliasConverter.java | 18 +- .../DrugCellDesignerAliasConverter.java | 162 +-- .../GeneCellDesignerAliasConverter.java | 142 +-- .../geometry/ICellDesignerAliasConverter.java | 122 +- .../IonCellDesignerAliasConverter.java | 18 +- .../PhenotypeCellDesignerAliasConverter.java | 166 +-- .../ProteinCellDesignerAliasConverter.java | 44 +- .../RnaCellDesignerAliasConverter.java | 216 ++-- ...pleMoleculeCellDesignerAliasConverter.java | 10 +- .../UnknownCellDesignerAliasConverter.java | 12 +- .../geometry/helper/PolylineDataFactory.java | 122 +- .../reaction/ReactionCollectionXmlParser.java | 2 - .../reaction/ReactionFromXml.java | 30 +- .../celldesigner/reaction/ReactionToXml.java | 44 +- .../reaction/ReactionXmlParser.java | 3 - .../species/AbstractElementXmlParser.java | 6 +- .../species/AntisenseRnaXmlParser.java | 28 +- .../celldesigner/species/GeneXmlParser.java | 32 +- .../species/InternalModelSpeciesData.java | 108 +- .../celldesigner/species/ProteinMapping.java | 59 +- .../species/ProteinXmlParser.java | 34 +- .../celldesigner/species/RnaXmlParser.java | 24 +- .../species/SpeciesCollection.java | 8 +- .../species/SpeciesCollectionXmlParser.java | 128 +- .../celldesigner/species/SpeciesMapping.java | 98 +- .../species/SpeciesSbmlParser.java | 154 +-- .../celldesigner/species/package-info.java | 12 +- ...Rna.java => CellDesignerAntisenseRna.java} | 56 +- ...> CellDesignerAntisenseRnaComparator.java} | 18 +- ...va => CellDesignerAntisenseRnaRegion.java} | 34 +- ...hemical.java => CellDesignerChemical.java} | 12 +- ...ment.java => CellDesignerCompartment.java} | 36 +- ...=> CellDesignerCompartmentComparator.java} | 16 +- ...s.java => CellDesignerComplexSpecies.java} | 58 +- ...CellDesignerComplexSpeciesComparator.java} | 50 +- ...egraded.java => CellDesignerDegraded.java} | 18 +- .../CellDesignerDegradedComparator.java | 82 ++ .../{Drug.java => CellDesignerDrug.java} | 18 +- ...r.java => CellDesignerDrugComparator.java} | 16 +- ...{Element.java => CellDesignerElement.java} | 24 +- ...ava => CellDesignerElementComparator.java} | 24 +- .../{Gene.java => CellDesignerGene.java} | 47 +- ...r.java => CellDesignerGeneComparator.java} | 23 +- ...n.java => CellDesignerGenericProtein.java} | 20 +- .../{Ion.java => CellDesignerIon.java} | 18 +- ...ava => CellDesignerIonChannelProtein.java} | 18 +- ...or.java => CellDesignerIonComparator.java} | 31 +- ...notype.java => CellDesignerPhenotype.java} | 18 +- .../CellDesignerPhenotypeComparator.java | 91 ++ ...{Protein.java => CellDesignerProtein.java} | 45 +- ...ava => CellDesignerProteinComparator.java} | 27 +- ....java => CellDesignerReceptorProtein.java} | 18 +- .../{Rna.java => CellDesignerRna.java} | 58 +- ...or.java => CellDesignerRnaComparator.java} | 26 +- .../structure/CellDesignerRnaRegion.java | 86 +- ...e.java => CellDesignerSimpleMolecule.java} | 20 +- ...CellDesignerSimpleMoleculeComparator.java} | 22 +- ...{Species.java => CellDesignerSpecies.java} | 20 +- .../CellDesignerSpeciesComparator.java | 231 ++++ ...java => CellDesignerTruncatedProtein.java} | 18 +- ...{Unknown.java => CellDesignerUnknown.java} | 18 +- ...ava => CellDesignerUnknownComparator.java} | 22 +- .../structure/SpeciesComparator.java | 231 ---- .../CellDesignerModificationResidue.java | 102 +- .../structure/{ => fields}/ConnectScheme.java | 2 +- .../structure/{ => fields}/EditPoints.java | 2 +- .../{ => fields}/LineProperties.java | 2 +- .../structure/{ => fields}/SingleLine.java | 66 +- .../structure/{ => fields}/SpeciesState.java | 56 +- .../structure/{ => fields}/View.java | 2 +- .../celldesigner/types/ModifierTypeUtils.java | 6 +- .../CellDesignerXmlParserTest.java | 32 +- .../celldesigner/ComplexParserTests.java | 76 +- .../celldesigner/LayerXmlParserTest.java | 18 +- .../NestedComplexParsingTests.java | 52 +- .../ReconDataInCellDesignerXmlParserTest.java | 4 +- .../alias/AliasCollectionXmlParserTest.java | 128 +- .../alias/CompartmentAliasXmlParserTest.java | 44 +- .../alias/ComplexAliasXmlParserTest.java | 16 +- .../alias/SpeciesAliasXmlParserTest.java | 46 +- .../annotation/RestAnnotationParserTest.java | 26 +- .../CompartmentCollectionXmlParserTest.java | 18 +- .../compartment/CompartmentXmlParserTest.java | 22 +- ...bstractCellDesignerAliasConverterTest.java | 14 +- ...enseRnaCellDesignerAliasConverterTest.java | 8 +- .../CellDesignerAliasConverterTest.java | 4 +- ...egradedCellDesignerAliasConverterTest.java | 8 +- .../GeneCellDesignerAliasConverterTest.java | 10 +- .../IonCellDesignerAliasConverterTest.java | 8 +- ...ProteinCellDesignerAliasConverterTest.java | 4 +- .../geometry/ProteinConverterTest.java | 4 +- .../RnaCellDesignerAliasConverterTest.java | 8 +- ...oleculeCellDesignerAliasConverterTest.java | 10 +- ...UnknownCellDesignerAliasConverterTest.java | 6 +- .../ReactionCollectionXmlParserTest.java | 28 +- .../reaction/ReactionFromXmlTest.java | 22 +- .../reaction/ReactionParserTests.java | 68 +- .../reaction/ReactionToXmlTest.java | 14 +- .../species/AntisenseRnaXmlParserTest.java | 24 +- .../species/ComplexParserTest.java | 46 +- .../species/GeneXmlParserTest.java | 26 +- .../species/InternalModelSpeciesDataTest.java | 5 +- .../species/ProteinMappingTest.java | 7 +- .../species/ProteinXmlParserTest.java | 22 +- .../species/RnaXmlParserTest.java | 18 +- .../species/SpeciesCollectionTest.java | 35 +- .../SpeciesCollectionXmlParserTest.java | 114 +- .../species/SpeciesMappingTest.java | 9 +- .../species/SpeciesSbmlParserTest.java | 220 ++-- .../structure/AntisenseRnaComparatorTest.java | 34 +- .../structure/AntisenseRnaRegionTest.java | 28 +- .../structure/AntisenseRnaTest.java | 41 +- .../structure/CompartmentComparatorTest.java | 24 +- .../structure/CompartmentTest.java | 26 +- .../ComplexSpeciesComparatorTest.java | 94 +- .../structure/ComplexSpeciesTest.java | 41 +- .../structure/ConnectSchemeTest.java | 2 + .../structure/DegradedComparatorTest.java | 28 +- .../celldesigner/structure/DegradedTest.java | 15 +- .../structure/DrugComparatorTest.java | 26 +- .../celldesigner/structure/DrugTest.java | 15 +- .../structure/ElementComparatorTest.java | 30 +- .../celldesigner/structure/ElementTest.java | 14 +- .../structure/GeneComparatorTest.java | 29 +- .../celldesigner/structure/GeneTest.java | 35 +- .../structure/GenericProteinTest.java | 13 +- .../structure/IonChannelProteinTest.java | 13 +- .../structure/IonComparatorTest.java | 26 +- .../model/celldesigner/structure/IonTest.java | 15 +- .../structure/LinePropertiesTest.java | 2 + .../structure/ModificationResidueTest.java | 22 +- .../structure/PhenotypeComparatorTest.java | 22 +- .../celldesigner/structure/PhenotypeTest.java | 10 +- .../structure/ProteinComparatorTest.java | 25 +- .../celldesigner/structure/ProteinTest.java | 62 +- .../structure/ReceptorProteinTest.java | 13 +- .../structure/RnaComparatorTest.java | 28 +- .../celldesigner/structure/RnaRegionTest.java | 22 +- .../model/celldesigner/structure/RnaTest.java | 41 +- .../SimpleMoleculeComparatorTest.java | 30 +- .../structure/SimpleMoleculeTest.java | 13 +- .../structure/SpeciesComparatorTest.java | 54 +- .../structure/SpeciesStateTest.java | 24 +- .../celldesigner/structure/SpeciesTest.java | 45 +- .../structure/TruncatedProteinTest.java | 13 +- .../structure/UnknownComparatorTest.java | 26 +- .../celldesigner/structure/UnknownTest.java | 15 +- .../celldesigner/structure/ViewTest.java | 2 + .../types/ModifierTypeUtilsTest.java | 10 +- .../model/sbgnml/SbgnmlXmlExporter.java | 112 +- .../model/sbgnml/SbgnmlXmlParser.java | 116 +- .../graphics/AbstractImageGenerator.java | 60 +- .../converter/graphics/AliasConverter.java | 106 +- .../converter/graphics/IAliasConverter.java | 6 +- .../ArtifitialCompartmentConverter.java | 134 +- .../BottomSquareCompartmentConverter.java | 160 +-- .../compartment/CompartmentConverter.java | 4 +- .../LeftSquareCompartmentConverter.java | 160 +-- .../compartment/OvalCompartmentConverter.java | 182 +-- .../RightSquareCompartmentConverter.java | 172 +-- .../SquareCompartmentConverter.java | 196 +-- .../TopSquareCompartmentConverter.java | 152 +-- .../graphics/compartment/package-info.java | 12 +- .../graphics/placefinder/PlaceFinder.java | 932 +++++++------- .../species/AntisenseRnaConverter.java | 20 +- .../graphics/species/ComplexConverter.java | 16 +- .../graphics/species/DegradedConverter.java | 242 ++-- .../graphics/species/DrugConverter.java | 212 ++-- .../graphics/species/GeneConverter.java | 20 +- .../graphics/species/IonConverter.java | 18 +- .../graphics/species/PhenotypeConverter.java | 12 +- .../graphics/species/ProteinConverter.java | 77 +- .../graphics/species/RnaConverter.java | 25 +- .../SBGNNucleicAcidFeatureConverter.java | 12 +- .../species/SimpleMoleculeConverter.java | 15 +- .../graphics/species/SpeciesConverter.java | 28 +- .../graphics/species/UnknownConverter.java | 10 +- .../converter/graphics/ConverterTest.java | 73 +- .../graphics/NormalImageGeneratorTest.java | 24 +- .../graphics/PdfImageGeneratorTest.java | 4 +- .../placefinder/AllPlaceFinderTest.java | 22 +- .../species/SpeciesConverterTest.java | 24 +- .../converter/ComplexZipConverter.java | 36 +- .../converter/ComplexZipConverterTest.java | 48 +- .../lcsb/mapviewer/editor/SelectedPoint.java | 118 +- .../editor/gui/ElementModifiedEvent.java | 130 +- .../mapviewer/editor/gui/WindowContent.java | 272 ++-- .../gui/canvas/CanvasSelectMouseListener.java | 250 ++-- .../CreateChangeAbbreviationCommand.java | 66 +- .../detailstab/CreateChangeColorCommand.java | 64 +- .../CreateChangeFontSizeCommand.java | 82 +- .../CreateChangeFormerSymbolCommand.java | 12 +- .../CreateChangeFormulaCommand.java | 66 +- .../CreateChangeFullNameCommand.java | 66 +- .../CreateChangeMiriamDataCommand.java | 98 +- .../detailstab/CreateChangeNameCommand.java | 6 +- .../detailstab/CreateChangeNotesCommand.java | 64 +- .../detailstab/CreateChangeSymbolCommand.java | 66 +- .../CreateChangeSynonymCommand.java | 12 +- .../CreateListPropertyChangeCommand.java | 188 +-- .../CreatePropertyChangeCommand.java | 120 +- .../gui/detailstab/ElementDetailsPanel.java | 108 +- .../mapviewer/commands/ColorModelCommand.java | 28 +- .../lcsb/mapviewer/commands/CopyCommand.java | 60 +- .../commands/CreateHierarchyCommand.java | 172 +-- .../lcsb/mapviewer/commands/ModelCommand.java | 4 +- .../lcsb/mapviewer/commands/MoveCommand.java | 152 +-- .../commands/MoveElementsCommand.java | 362 +++--- .../mapviewer/commands/SubModelCommand.java | 34 +- .../AddElementFormerSymbolsCommand.java | 8 +- .../AddElementMiriamDataCommand.java | 6 +- .../AddElementPropertyListEntryCommand.java | 14 +- .../properties/AddElementSynonymsCommand.java | 8 +- .../ChangeElementAbbreviationCommand.java | 6 +- .../properties/ChangeElementColorCommand.java | 98 +- .../ChangeElementFontSizeCommand.java | 102 +- .../ChangeElementFormerSymbolCommand.java | 10 +- .../ChangeElementFormulaCommand.java | 8 +- .../ChangeElementFullNameCommand.java | 8 +- .../ChangeElementMiriamDataCommand.java | 6 +- .../properties/ChangeElementNameCommand.java | 6 +- .../properties/ChangeElementNotesCommand.java | 8 +- .../ChangeElementPropertyCommand.java | 240 ++-- ...ChangeElementPropertyListEntryCommand.java | 14 +- .../ChangeElementSymbolCommand.java | 8 +- .../ChangeElementSynonymCommand.java | 10 +- .../RemoveElementFormerSymbolsCommand.java | 8 +- .../RemoveElementMiriamDataCommand.java | 8 +- ...RemoveElementPropertyListEntryCommand.java | 14 +- .../RemoveElementSynonymsCommand.java | 8 +- .../commands/properties/package-info.java | 16 +- .../commands/ColorModelCommandTest.java | 8 +- .../commands/CommandTestFunctions.java | 8 +- .../mapviewer/commands/CopyCommandTest.java | 18 +- .../commands/CreateHierarchyCommandTest.java | 38 +- .../commands/MoveElementsCommandTest.java | 16 +- .../ChangeElementAbbreviationCommandTest.java | 6 +- .../ChangeElementColorCommandTest.java | 156 +-- .../ChangeElementFontSizeCommandTest.java | 150 +-- .../ChangeElementFormerSymbolCommandTest.java | 4 +- .../ChangeElementFormulaCommandTest.java | 6 +- .../ChangeElementFullNameCommandTest.java | 6 +- .../ChangeElementMiriamDataCommandTest.java | 8 +- .../ChangeElementNameCommandTest.java | 6 +- .../ChangeElementNotesCommandTest.java | 6 +- .../ChangeElementSymbolCommandTest.java | 6 +- .../ChangeElementSynonymCommandTest.java | 8 +- .../lcsb/mapviewer/model/map/MiriamType.java | 72 +- .../map/{layout/alias => }/SearchIndex.java | 11 +- .../BottomSquareCompartment.java} | 16 +- .../Compartment.java} | 55 +- .../CompartmentComparator.java} | 32 +- .../LeftSquareCompartment.java} | 16 +- .../OvalCompartment.java} | 14 +- .../PathwayCompartment.java} | 16 +- .../RightSquareCompartment.java} | 18 +- .../SquareCompartment.java} | 16 +- .../TopSquareCompartment.java} | 16 +- .../mapviewer/model/map/graph/DataMining.java | 8 +- .../map/layout/{alias => }/BlockDiagram.java | 38 +- .../model/map/layout/ColorSchema.java | 16 +- .../AliasGroup.java => ElementGroup.java} | 152 +-- .../layout/alias/DegradedAliasComparator.java | 83 -- .../map/layout/alias/IonAliasComparator.java | 83 -- .../map/model/AliasSubmodelConnection.java | 14 +- .../AliasSubmodelConnectionComparator.java | 224 ++-- .../lcsb/mapviewer/model/map/model/Model.java | 56 +- .../model/map/model/ModelComparator.java | 20 +- .../mapviewer/model/map/model/ModelData.java | 28 +- .../model/map/model/ModelFullIndexed.java | 151 +-- .../model/map/modifier/Catalysis.java | 4 +- .../model/map/modifier/Inhibition.java | 4 +- .../model/map/modifier/Modulation.java | 4 +- .../map/modifier/PhysicalStimulation.java | 4 +- .../mapviewer/model/map/modifier/Trigger.java | 4 +- .../model/map/modifier/UnknownCatalysis.java | 4 +- .../model/map/modifier/UnknownInhibition.java | 4 +- .../model/map/reaction/Modifier.java | 6 +- .../mapviewer/model/map/reaction/Product.java | 6 +- .../model/map/reaction/Reactant.java | 6 +- .../model/map/reaction/Reaction.java | 4 +- .../model/map/reaction/ReactionNode.java | 12 +- .../map/reaction/ReactionNodeComparator.java | 4 +- .../AntisenseRna.java} | 29 +- .../AntisenseRnaComparator.java} | 18 +- .../Chemical.java} | 8 +- .../ChemicalComparator.java} | 34 +- .../Complex.java} | 50 +- .../ComplexComparator.java} | 34 +- .../Degraded.java} | 16 +- .../map/species}/DegradedComparator.java | 29 +- .../DrugAlias.java => species/Drug.java} | 16 +- .../DrugComparator.java} | 18 +- .../alias/Alias.java => species/Element.java} | 34 +- .../ElementComparator.java} | 34 +- .../GeneAlias.java => species/Gene.java} | 29 +- .../GeneComparator.java} | 18 +- .../GenericProtein.java} | 16 +- .../GenericProteinComparator.java} | 22 +- .../alias/IonAlias.java => species/Ion.java} | 16 +- .../IonChannelProtein.java} | 16 +- .../IonChannelProteinComparator.java} | 18 +- .../model/map/species}/IonComparator.java | 30 +- .../Phenotype.java} | 16 +- .../PhenotypeComparator.java} | 18 +- .../Protein.java} | 24 +- .../ProteinComparator.java} | 50 +- .../ReceptorProtein.java} | 16 +- .../ReceptorProteinComparator.java} | 18 +- .../alias/RnaAlias.java => species/Rna.java} | 29 +- .../RnaComparator.java} | 18 +- .../SimpleMolecule.java} | 16 +- .../SimpleMoleculeComparator.java} | 18 +- .../Species.java} | 25 +- .../SpeciesComparator.java} | 104 +- .../TruncatedProtein.java} | 16 +- .../TruncatedProteinComparator.java} | 18 +- .../Unknown.java} | 16 +- .../UnknownComparator.java} | 18 +- .../field/AntisenseRnaRegion.java} | 32 +- .../species/field}/ModificationResidue.java | 68 +- .../field}/ModificationState.java | 2 +- .../field}/PositionToCompartment.java | 4 +- .../model/map/species/field}/RnaRegion.java | 70 +- .../alias => species}/package-info.java | 12 +- .../modelutils/map/ElementUtils.java | 32 +- .../modelutils/map/RequireAnnotationMap.java | 32 +- .../lcsb/mapviewer/model/map/AllMapTests.java | 4 +- .../map/compartment/AllCompartmentTests.java | 17 + .../BottomSquareCompartmentAliasTest.java | 14 +- .../CompartmentAliasComparatorTest.java | 55 +- .../CompartmentAliasTest.java | 94 +- .../LeftSquareCompartmentAliasTest.java | 14 +- .../RightSquareCompartmentAliasTest.java | 16 +- .../TopSquareCompartmentAliasTest.java | 14 +- .../model/map/graph/DataMiningTest.java | 6 +- .../model/map/layout/AllLayoutTests.java | 4 +- .../model/map/layout/ColorSchemaTest.java | 16 +- .../model/map/layout/alias/AllAliasTests.java | 28 - ...AliasSubmodelConnectionComparatorTest.java | 16 +- .../model/map/model/ModelComparatorTest.java | 28 +- .../model/map/model/ModelDataTest.java | 16 +- .../model/map/model/ModelFullIndexedTest.java | 92 +- ...ModelSubmodelConnectionComparatorTest.java | 10 +- .../mapviewer/model/map/model/ModelTest.java | 61 +- .../SubmodelConnectionComparatorTest.java | 10 +- .../model/map/modifier/CatalysisTest.java | 8 +- .../model/map/modifier/InhibitionTest.java | 8 +- .../model/map/modifier/ModulationTest.java | 8 +- .../map/modifier/PhysicalStimulationTest.java | 8 +- .../model/map/modifier/TriggerTest.java | 8 +- .../map/modifier/UnknownCatalysisTest.java | 8 +- .../map/modifier/UnknownInhibitionTest.java | 8 +- .../reaction/NodeOperatorComparatorTest.java | 14 +- .../map/reaction/ReactionComparatorTest.java | 16 +- .../reaction/ReactionNodeComparatorTest.java | 10 +- .../model/map/reaction/ReactionTest.java | 12 +- .../AliasComparatorTest.java | 63 +- .../alias => species}/AliasGroupTest.java | 16 +- .../{layout/alias => species}/AliasTest.java | 45 +- .../model/map/species/AllSpeciesTests.java | 27 + .../ArtifitialCompartmentAliasTest.java | 19 +- .../ComplexAliasComparatorTest.java | 54 +- .../alias => species}/ComplexAliasTest.java | 43 +- .../ModificationStateTest.java | 4 +- .../OvalCompartmentAliasTest.java | 15 +- .../PositionToCompartmentTest.java | 4 +- .../alias => species}/SearchIndexTest.java | 7 +- .../SpeciesAliasComparatorTest.java | 26 +- .../alias => species}/SpeciesAliasTest.java | 6 +- .../SquareCompartmentAliasTest.java | 15 +- .../modelutils/map/ElementUtilsTest.java | 18 +- .../wikipathway/XML/ModelContructor.java | 182 +-- .../wikipathway/XML/ModelToGPML.java | 82 +- .../model/GpmlModificationType.java | 2 +- .../mapviewer/wikipathway/model/State.java | 6 +- .../ComplexReactionToModelTest.java | 6 +- .../wikipathway/GPMLToModelTest.java | 22 +- .../mapviewer/wikipathway/XML/BugTest.java | 8 +- .../wikipathway/XML/ModelToGPMLTest.java | 8 +- .../wikipathway/XML/StateParserTest.java | 2 +- persist/src/db/10.0.3/fix_db_20161003.sql | 12 +- .../persist/dao/map/graph/DataMiningDao.java | 4 +- .../dao/map/layout/alias/AliasDao.java | 42 +- .../resources/applicationContext-persist.xml | 65 +- .../mapviewer/persist/dao/ProjectDaoTest.java | 26 +- .../persist/dao/map/CommentDaoTest.java | 32 +- .../persist/dao/map/LayoutDaoTest.java | 36 +- .../persist/dao/map/ModelDaoTest.java | 50 +- .../dao/map/graph/DataMiningDaoTest.java | 10 +- .../dao/map/layout/alias/AliasDaoTest.java | 36 +- .../dao/map/layout/alias/AliasDaoTest2.java | 80 +- .../map/layout/alias/AntisenseRnaTest.java | 18 +- .../persist/dao/map/layout/alias/RnaTest.java | 18 +- .../persist/dao/user/UserDaoTest.java | 6 +- .../reactome/utils/DataFormatter.java | 12 +- .../mapviewer/reactome/utils/ElementUtil.java | 6 +- .../reactome/utils/ReactionComparator.java | 24 +- .../reactome/utils/ReactomeQueryUtil.java | 50 +- .../utils/comparators/ANodeComparator.java | 10 +- .../ComplexAndCandidateSetComparator.java | 9 +- .../ComplexAndCatalystComparator.java | 10 +- .../ComplexAndComplexComparator.java | 11 +- .../ComplexAndDefinedSetComparator.java | 9 +- ...tityWithAccessionedSequenceComparator.java | 10 +- .../ComplexAndOtherEntityComparator.java | 9 +- .../ComplexAndSimpleEntityComparator.java | 10 +- ...tityWithAccessionedSequenceComparator.java | 8 +- .../DrugAndCatalystComparator.java | 10 +- .../GeneAndDefinedSetComparator.java | 10 +- .../GeneAndOtherEntityComparator.java | 10 +- .../comparators/IonAndCatalystComparator.java | 10 +- .../comparators/IonAndComplexComparator.java | 10 +- .../IonAndDefinedSetComparator.java | 10 +- ...tityWithAccessionedSequenceComparator.java | 10 +- .../IonAndSimpleEntityComparator.java | 10 +- .../utils/comparators/MatchResult.java | 26 +- .../MoleculeAndCatalystComparator.java | 10 +- .../MoleculeAndComplexComparator.java | 10 +- .../MoleculeAndDefinedSetComparator.java | 10 +- ...tityWithAccessionedSequenceComparator.java | 10 +- .../MoleculeAndSimpleEntityComparator.java | 10 +- .../utils/comparators/NodeComparator.java | 16 +- .../ProteinAndCandidateSetComparator.java | 10 +- .../ProteinAndCatalystComparator.java | 10 +- .../ProteinAndComplexComparator.java | 10 +- .../ProteinAndDefinedSetComparator.java | 10 +- ...tityWithAccessionedSequenceComparator.java | 10 +- .../ProteinAndGenomeEncodedEntity.java | 10 +- .../ProteinAndOtherEntityComparator.java | 10 +- .../ProteinAndPolymerComparator.java | 10 +- .../ProteinAndSimpleEntityComparator.java | 10 +- .../UnknownAndCatalystComparator.java | 10 +- ...knownAndGenomeEncodedEntityComparator.java | 10 +- .../reactome/utils/ReactomeQueryUtilTest.java | 10 +- .../utils/comparators/NodeComparatorTest.java | 58 +- .../services/impl/CommentService.java | 14 +- .../services/impl/DataMiningService.java | 34 +- .../services/impl/ExporterService.java | 232 ++-- .../services/impl/LayoutService.java | 16 +- .../mapviewer/services/impl/ModelService.java | 18 +- .../services/impl/ProjectService.java | 4 +- .../services/impl/SearchService.java | 114 +- .../interfaces/IDataMiningService.java | 10 +- .../services/interfaces/IExporterService.java | 24 +- .../services/interfaces/ILayoutService.java | 4 +- .../services/interfaces/IModelService.java | 290 ++--- .../services/search/SearchResultFactory.java | 30 +- .../comment/FullCommentViewFactory.java | 6 +- .../search/data/ElementIdentifier.java | 8 +- .../services/search/data/FullAliasView.java | 44 +- .../search/data/FullAliasViewFactory.java | 30 +- .../services/search/data/LightAliasView.java | 208 ++-- .../search/data/LightAliasViewFactory.java | 118 +- .../services/search/db/IDbSearchService.java | 4 +- .../search/db/chemical/ChemicalService.java | 14 +- .../db/chemical/ChemicalViewFactory.java | 4 +- .../services/search/db/drug/DrugService.java | 12 +- .../search/db/drug/DrugViewFactory.java | 8 +- .../search/db/mirna/MiRNAService.java | 14 +- .../search/db/mirna/MiRNAViewFactory.java | 4 +- .../search/layout/FullLayoutAliasView.java | 4 +- .../layout/FullLayoutAliasViewFactory.java | 6 +- .../search/layout/LightLayoutAliasView.java | 186 +-- .../layout/LightLayoutAliasViewFactory.java | 6 +- .../services/utils/SearchIndexer.java | 15 +- .../services/utils/data/ExportColumn.java | 16 +- .../services/view/CommentViewFactory.java | 4 +- .../view/PubmedAnnotatedElementsView.java | 6 +- .../services/impl/CommentServiceTest.java | 12 +- .../services/impl/DataMiningServiceTest.java | 20 +- .../services/impl/DataMiningServiceTest2.java | 32 +- .../services/impl/ExporterServiceTest.java | 60 +- .../services/impl/LayoutServiceTest2.java | 6 +- .../services/impl/LogServiceTest.java | 6 +- .../services/impl/ModelServiceTest.java | 6 +- .../services/impl/ProjectServiceTest.java | 18 +- .../services/impl/SearchServiceTest.java | 64 +- .../search/SearchResultFactoryTest.java | 6 +- .../search/data/FullAliasViewFactoryTest.java | 32 +- .../data/LightAliasViewFactoryTest.java | 6 +- .../db/chemical/ChemicalServiceTest.java | 8 +- .../search/db/drug/DrugServiceTest.java | 18 +- .../search/db/drug/DrugViewFactoryTest.java | 4 +- .../FullLayoutAliasViewFactoryTest.java | 8 +- .../LightLayoutAliasViewFactoryTest.java | 8 +- .../utils/graph/MissingConnectionDaoTest.java | 6 +- .../mapviewer/bean/AbstractManagedBean.java | 1094 ++++++++--------- .../lcsb/mapviewer/bean/ChemicalBean.java | 6 +- .../java/lcsb/mapviewer/bean/DrugBean.java | 6 +- .../java/lcsb/mapviewer/bean/ExportBean.java | 62 +- .../lcsb/mapviewer/bean/FeedbackBean.java | 6 +- .../java/lcsb/mapviewer/bean/MapBean.java | 4 +- .../java/lcsb/mapviewer/bean/MiRNABean.java | 6 +- 541 files changed, 11065 insertions(+), 11047 deletions(-) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{AntisenseRna.java => CellDesignerAntisenseRna.java} (54%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{AntisenseRnaComparator.java => CellDesignerAntisenseRnaComparator.java} (71%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{AntisenseRnaRegion.java => CellDesignerAntisenseRnaRegion.java} (80%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{Chemical.java => CellDesignerChemical.java} (80%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{Compartment.java => CellDesignerCompartment.java} (64%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{CompartmentComparator.java => CellDesignerCompartmentComparator.java} (71%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{ComplexSpecies.java => CellDesignerComplexSpecies.java} (59%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{ComplexSpeciesComparator.java => CellDesignerComplexSpeciesComparator.java} (69%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{Degraded.java => CellDesignerDegraded.java} (60%) create mode 100644 converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDegradedComparator.java rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{Drug.java => CellDesignerDrug.java} (62%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{DrugComparator.java => CellDesignerDrugComparator.java} (72%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{Element.java => CellDesignerElement.java} (91%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{ElementComparator.java => CellDesignerElementComparator.java} (82%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{Gene.java => CellDesignerGene.java} (51%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{GeneComparator.java => CellDesignerGeneComparator.java} (67%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{GenericProtein.java => CellDesignerGenericProtein.java} (51%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{Ion.java => CellDesignerIon.java} (63%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{IonChannelProtein.java => CellDesignerIonChannelProtein.java} (51%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{PhenotypeComparator.java => CellDesignerIonComparator.java} (62%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{Phenotype.java => CellDesignerPhenotype.java} (60%) create mode 100644 converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerPhenotypeComparator.java rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{Protein.java => CellDesignerProtein.java} (61%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{ProteinComparator.java => CellDesignerProteinComparator.java} (70%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{ReceptorProtein.java => CellDesignerReceptorProtein.java} (52%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{Rna.java => CellDesignerRna.java} (53%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{RnaComparator.java => CellDesignerRnaComparator.java} (68%) rename model/src/main/java/lcsb/mapviewer/model/map/layout/alias/RnaRegionAlias.java => converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRnaRegion.java (69%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{SimpleMolecule.java => CellDesignerSimpleMolecule.java} (56%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{SimpleMoleculeComparator.java => CellDesignerSimpleMoleculeComparator.java} (72%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{Species.java => CellDesignerSpecies.java} (91%) create mode 100644 converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSpeciesComparator.java rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{TruncatedProtein.java => CellDesignerTruncatedProtein.java} (52%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{Unknown.java => CellDesignerUnknown.java} (61%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{UnknownComparator.java => CellDesignerUnknownComparator.java} (64%) delete mode 100644 converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/SpeciesComparator.java rename model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ModificationResidueAlias.java => converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerModificationResidue.java (67%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{ => fields}/ConnectScheme.java (91%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{ => fields}/EditPoints.java (93%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{ => fields}/LineProperties.java (88%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{ => fields}/SingleLine.java (80%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{ => fields}/SpeciesState.java (60%) rename converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/{ => fields}/View.java (89%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias => }/SearchIndex.java (88%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/BottomSquareCompartmentAlias.java => compartment/BottomSquareCompartment.java} (70%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/CompartmentAlias.java => compartment/Compartment.java} (83%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/CompartmentAliasComparator.java => compartment/CompartmentComparator.java} (78%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/LeftSquareCompartmentAlias.java => compartment/LeftSquareCompartment.java} (70%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/OvalCompartmentAlias.java => compartment/OvalCompartment.java} (67%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/ArtifitialCompartmentAlias.java => compartment/PathwayCompartment.java} (61%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/RightSquareCompartmentAlias.java => compartment/RightSquareCompartment.java} (75%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/SquareCompartmentAlias.java => compartment/SquareCompartment.java} (64%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/TopSquareCompartmentAlias.java => compartment/TopSquareCompartment.java} (71%) rename model/src/main/java/lcsb/mapviewer/model/map/layout/{alias => }/BlockDiagram.java (82%) rename model/src/main/java/lcsb/mapviewer/model/map/layout/{alias/AliasGroup.java => ElementGroup.java} (70%) delete mode 100644 model/src/main/java/lcsb/mapviewer/model/map/layout/alias/DegradedAliasComparator.java delete mode 100644 model/src/main/java/lcsb/mapviewer/model/map/layout/alias/IonAliasComparator.java rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/AntisenseRnaAlias.java => species/AntisenseRna.java} (59%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/AntisenseRnaAliasComparator.java => species/AntisenseRnaComparator.java} (68%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/ChemicalAlias.java => species/Chemical.java} (86%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/ChemicalAliasComparator.java => species/ChemicalComparator.java} (59%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/ComplexAlias.java => species/Complex.java} (70%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/ComplexAliasComparator.java => species/ComplexComparator.java} (71%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/DegradedAlias.java => species/Degraded.java} (59%) rename {converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure => model/src/main/java/lcsb/mapviewer/model/map/species}/DegradedComparator.java (71%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/DrugAlias.java => species/Drug.java} (60%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/DrugAliasComparator.java => species/DrugComparator.java} (70%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/Alias.java => species/Element.java} (96%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/AliasComparator.java => species/ElementComparator.java} (86%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/GeneAlias.java => species/Gene.java} (62%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/GeneAliasComparator.java => species/GeneComparator.java} (70%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/GenericProteinAlias.java => species/GenericProtein.java} (52%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/GenericProteinAliasComparator.java => species/GenericProteinComparator.java} (64%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/IonAlias.java => species/Ion.java} (61%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/IonChannelProteinAlias.java => species/IonChannelProtein.java} (51%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/IonChannelProteinAliasComparator.java => species/IonChannelProteinComparator.java} (69%) rename {converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure => model/src/main/java/lcsb/mapviewer/model/map/species}/IonComparator.java (70%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/PhenotypeAlias.java => species/Phenotype.java} (58%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/PhenotypeAliasComparator.java => species/PhenotypeComparator.java} (69%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/ProteinAlias.java => species/Protein.java} (69%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/ProteinAliasComparator.java => species/ProteinComparator.java} (51%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/ReceptorProteinAlias.java => species/ReceptorProtein.java} (52%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/ReceptorProteinAliasComparator.java => species/ReceptorProteinComparator.java} (70%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/RnaAlias.java => species/Rna.java} (64%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/RnaAliasComparator.java => species/RnaComparator.java} (71%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/SimpleMoleculeAlias.java => species/SimpleMolecule.java} (56%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/SimpleMoleculeAliasComparator.java => species/SimpleMoleculeComparator.java} (67%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/SpeciesAlias.java => species/Species.java} (89%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/SpeciesAliasComparator.java => species/SpeciesComparator.java} (59%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/TruncatedProteinAlias.java => species/TruncatedProtein.java} (51%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/TruncatedProteinAliasComparator.java => species/TruncatedProteinComparator.java} (70%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/UnknownAlias.java => species/Unknown.java} (59%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/UnknownAliasComparator.java => species/UnknownComparator.java} (69%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias/AntisenseRnaRegionAlias.java => species/field/AntisenseRnaRegion.java} (86%) rename {converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure => model/src/main/java/lcsb/mapviewer/model/map/species/field}/ModificationResidue.java (79%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias => species/field}/ModificationState.java (93%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias => species/field}/PositionToCompartment.java (86%) rename {converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure => model/src/main/java/lcsb/mapviewer/model/map/species/field}/RnaRegion.java (75%) rename model/src/main/java/lcsb/mapviewer/model/map/{layout/alias => species}/package-info.java (70%) create mode 100644 model/src/test/java/lcsb/mapviewer/model/map/compartment/AllCompartmentTests.java rename model/src/test/java/lcsb/mapviewer/model/map/{layout/alias => compartment}/BottomSquareCompartmentAliasTest.java (70%) rename model/src/test/java/lcsb/mapviewer/model/map/{layout/alias => compartment}/CompartmentAliasComparatorTest.java (68%) rename model/src/test/java/lcsb/mapviewer/model/map/{layout/alias => compartment}/CompartmentAliasTest.java (68%) rename model/src/test/java/lcsb/mapviewer/model/map/{layout/alias => compartment}/LeftSquareCompartmentAliasTest.java (70%) rename model/src/test/java/lcsb/mapviewer/model/map/{layout/alias => compartment}/RightSquareCompartmentAliasTest.java (70%) rename model/src/test/java/lcsb/mapviewer/model/map/{layout/alias => compartment}/TopSquareCompartmentAliasTest.java (71%) delete mode 100644 model/src/test/java/lcsb/mapviewer/model/map/layout/alias/AllAliasTests.java rename model/src/test/java/lcsb/mapviewer/model/map/{layout/alias => species}/AliasComparatorTest.java (59%) rename model/src/test/java/lcsb/mapviewer/model/map/{layout/alias => species}/AliasGroupTest.java (65%) rename model/src/test/java/lcsb/mapviewer/model/map/{layout/alias => species}/AliasTest.java (85%) create mode 100644 model/src/test/java/lcsb/mapviewer/model/map/species/AllSpeciesTests.java rename model/src/test/java/lcsb/mapviewer/model/map/{layout/alias => species}/ArtifitialCompartmentAliasTest.java (67%) rename model/src/test/java/lcsb/mapviewer/model/map/{layout/alias => species}/ComplexAliasComparatorTest.java (68%) rename model/src/test/java/lcsb/mapviewer/model/map/{layout/alias => species}/ComplexAliasTest.java (65%) rename model/src/test/java/lcsb/mapviewer/model/map/{layout/alias => species}/ModificationStateTest.java (83%) rename model/src/test/java/lcsb/mapviewer/model/map/{layout/alias => species}/OvalCompartmentAliasTest.java (70%) rename model/src/test/java/lcsb/mapviewer/model/map/{layout/alias => species}/PositionToCompartmentTest.java (83%) rename model/src/test/java/lcsb/mapviewer/model/map/{layout/alias => species}/SearchIndexTest.java (87%) rename model/src/test/java/lcsb/mapviewer/model/map/{layout/alias => species}/SpeciesAliasComparatorTest.java (75%) rename model/src/test/java/lcsb/mapviewer/model/map/{layout/alias => species}/SpeciesAliasTest.java (74%) rename model/src/test/java/lcsb/mapviewer/model/map/{layout/alias => species}/SquareCompartmentAliasTest.java (69%) 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 580bfcdccb..bb3bede1cb 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/ModelAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/ModelAnnotator.java @@ -31,10 +31,10 @@ import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.modelutils.map.ClassTreeNode; import lcsb.mapviewer.modelutils.map.ElementUtils; @@ -241,10 +241,10 @@ public class ModelAnnotator { protected void copyAnnotationFromOtherSpecies(Model model, IProgressUpdater progressUpdater) { double counter = 0; double amount = model.getAliases().size(); - for (SpeciesAlias element : model.getSpeciesAliases()) { + for (Species element : model.getSpeciesAliases()) { if (element.getMiriamData().size() == 0) { - List<Alias> speciesList = model.getAliasByName(element.getName()); - for (Alias species2 : speciesList) { + List<Element> speciesList = model.getAliasByName(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()) { element.addMiriamData(new MiriamData(md)); @@ -278,7 +278,7 @@ public class ModelAnnotator { double amount = model.getAliases().size() + model.getReactions().size(); // annotate all elements - for (Alias element : model.getAliases()) { + for (Element element : model.getAliases()) { List<ElementAnnotator> list = null; if (annotators != null) { list = annotators.get(element.getClass()); @@ -363,7 +363,7 @@ public class ModelAnnotator { double ratio = modelCounter / modelSize; double size = model.getAliases().size() + model.getReactions().size(); double counter = 0; - for (Alias element : model.getAliases()) { + for (Element element : model.getAliases()) { result.addAll(findImproperAnnotations(element, validAnnotations.get(element.getClass()))); counter++; updater.setProgress(ratio * IProgressUpdater.MAX_PROGRESS + (counter / size * IProgressUpdater.MAX_PROGRESS) / modelSize); @@ -427,7 +427,7 @@ public class ModelAnnotator { models.add(m); models.addAll(m.getSubmodels()); for (Model model : models) { - for (Alias alias : model.getAliases()) { + for (Element alias : model.getAliases()) { result.addAll(findMissing(alias, requestedAnnotations.get(alias.getClass()))); } for (Reaction reaction : model.getReactions()) { diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/BiocompendiumAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/BiocompendiumAnnotator.java index 833d1dd0d0..be9a83cdc8 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/BiocompendiumAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/BiocompendiumAnnotator.java @@ -35,7 +35,7 @@ import lcsb.mapviewer.converter.model.celldesigner.annotation.RestAnnotationPars import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; +import lcsb.mapviewer.model.map.species.Protein; /** * This class is responsible for connection to Vencata annotation service. The @@ -75,7 +75,7 @@ public class BiocompendiumAnnotator extends ElementAnnotator implements IExterna * Default constructor. */ public BiocompendiumAnnotator() { - super(BiocompendiumAnnotator.class, new Class[] { ProteinAlias.class, ProteinAlias.class, ProteinAlias.class }, true); + super(BiocompendiumAnnotator.class, new Class[] { Protein.class, Protein.class, Protein.class }, true); } @Override diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ChebiAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ChebiAnnotator.java index b2790e358d..bc37df5ec1 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ChebiAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ChebiAnnotator.java @@ -24,7 +24,7 @@ import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamRelationType; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.ChemicalAlias; +import lcsb.mapviewer.model.map.species.Chemical; import lcsb.mapviewer.modelutils.map.ElementUtils; import uk.ac.ebi.chebi.webapps.chebiWS.client.ChebiWebServiceClient; import uk.ac.ebi.chebi.webapps.chebiWS.model.ChebiWebServiceFault_Exception; @@ -132,7 +132,7 @@ public class ChebiAnnotator extends ElementAnnotator implements IExternalService * {@link Chebi} from/to xml. */ public ChebiAnnotator() { - super(ChebiAnnotator.class, new Class[] { ChemicalAlias.class }, true); + super(ChebiAnnotator.class, new Class[] { Chemical.class }, true); chebiSerializer = new XmlSerializer<>(Chebi.class); } @@ -457,7 +457,7 @@ public class ChebiAnnotator extends ElementAnnotator implements IExternalService chebi = getChebiElementForChebiId(md); } } - ChemicalAlias species = (ChemicalAlias) element; + Chemical species = (Chemical) element; if (chebi != null) { super.setFullName(species, chebi.getName(), warnPrefix); diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java index ff1e497ac7..c0f499bbb9 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java @@ -7,14 +7,14 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.annotation.cache.CachableInterface; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.converter.model.celldesigner.structure.Chemical; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerChemical; import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ChemicalAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Chemical; +import lcsb.mapviewer.model.map.species.Species; /** * Interface that allows to annotate {@link AnnotatedObject elements} in the @@ -186,7 +186,7 @@ public abstract class ElementAnnotator extends CachableInterface { * @param prefix * prefix used in warnings */ - protected void setFullName(Alias element, String name, String prefix) { + protected void setFullName(Element element, String name, String prefix) { if (element.getFullName() == null || element.getFullName().equals("") || element.getFullName().equals(name)) { element.setFullName(name); } else { @@ -223,7 +223,7 @@ public abstract class ElementAnnotator extends CachableInterface { } /** - * Sets {@link Chemical#inChI}. + * Sets {@link CellDesignerChemical#inChI}. * * @param element * element where annotation should be added @@ -232,7 +232,7 @@ public abstract class ElementAnnotator extends CachableInterface { * @param value * value to set */ - protected void setInchi(ChemicalAlias element, String value, String prefix) { + protected void setInchi(Chemical element, String value, String prefix) { if (element.getInChI() == null || element.getInChI().isEmpty() || element.getInChI().equals(value)) { element.setInChI(value); } else { @@ -242,7 +242,7 @@ public abstract class ElementAnnotator extends CachableInterface { } /** - * Sets {@link Chemical#inChIKey}. + * Sets {@link CellDesignerChemical#inChIKey}. * * @param element * element where annotation should be added @@ -251,7 +251,7 @@ public abstract class ElementAnnotator extends CachableInterface { * @param value * value to set */ - protected void setInchiKey(ChemicalAlias element, String value, String prefix) { + protected void setInchiKey(Chemical element, String value, String prefix) { if (element.getInChIKey() == null || element.getInChIKey().equals("")) { element.setInChIKey(value); } else if (!element.getInChIKey().equalsIgnoreCase(value)) { @@ -261,7 +261,7 @@ public abstract class ElementAnnotator extends CachableInterface { } /** - * Sets {@link Chemical#smiles}. + * Sets {@link CellDesignerChemical#smiles}. * * @param element * element where annotation should be added @@ -270,7 +270,7 @@ public abstract class ElementAnnotator extends CachableInterface { * @param value * value to set */ - protected void setSmile(ChemicalAlias element, String value, String prefix) { + protected void setSmile(Chemical element, String value, String prefix) { if (element.getSmiles() == null || element.getSmiles().isEmpty() || element.getSmiles().equals(value)) { element.setSmiles(value); } else { @@ -295,7 +295,7 @@ public abstract class ElementAnnotator extends CachableInterface { } /** - * Sets {@link SpeciesAlias#charge}. + * Sets {@link Species#charge}. * * @param element * element where annotation should be added @@ -304,7 +304,7 @@ public abstract class ElementAnnotator extends CachableInterface { * @param prefix * prefix used in warnings */ - protected void setCharge(SpeciesAlias element, String value, String prefix) { + protected void setCharge(Species element, String value, String prefix) { Integer charge = Integer.parseInt(value); if (element.getCharge() == null || element.getCharge() == 0 || element.getCharge().equals(charge)) { element.setCharge(Integer.valueOf(charge)); diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotator.java index defee8a8f7..378054263a 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotator.java @@ -23,11 +23,11 @@ import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Rna; import lcsb.mapviewer.modelutils.map.ElementUtils; /** @@ -66,7 +66,7 @@ public class EnsemblAnnotator extends ElementAnnotator implements IExternalServi * Default constructor. */ public EnsemblAnnotator() { - super(EnsemblAnnotator.class, new Class[] { ProteinAlias.class, RnaAlias.class, GeneAlias.class }, false); + super(EnsemblAnnotator.class, new Class[] { Protein.class, Rna.class, Gene.class }, false); } @Override @@ -112,7 +112,7 @@ public class EnsemblAnnotator extends ElementAnnotator implements IExternalServi try { - GenericProteinAlias proteinAlias = new GenericProteinAlias("mock_id"); + GenericProtein proteinAlias = new GenericProtein("mock_id"); proteinAlias.addMiriamData(new MiriamData(MiriamType.ENSEMBL, "ENSG00000157764")); annotateElement(proteinAlias); @@ -219,7 +219,7 @@ public class EnsemblAnnotator extends ElementAnnotator implements IExternalServi } String fullName = super.getNodeAttr("description", node); if (symbol != null) { - setFullName((Alias) annotatedObject, fullName, prefix); + setFullName((Element) annotatedObject, fullName, prefix); } NodeList synonymNodeList = node.getChildNodes(); @@ -280,7 +280,7 @@ public class EnsemblAnnotator extends ElementAnnotator implements IExternalServi if (!MiriamType.ENSEMBL.equals(miriamData.getDataType())) { throw new InvalidArgumentException("Only " + MiriamType.ENSEMBL + " identifier is accepted as an input"); } - GenericProteinAlias proteinAlias = new GenericProteinAlias("id"); + GenericProtein proteinAlias = new GenericProtein("id"); annotateElement(proteinAlias, miriamData, ""); for (MiriamData md : proteinAlias.getMiriamData()) { if (MiriamType.ENTREZ.equals(md.getDataType())) { diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EntrezAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EntrezAnnotator.java index 00985d9a87..72ab25bc9d 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EntrezAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EntrezAnnotator.java @@ -27,11 +27,11 @@ import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamRelationType; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Rna; import lcsb.mapviewer.modelutils.map.ElementUtils; /** @@ -72,7 +72,7 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic * Default constructor. */ public EntrezAnnotator() { - super(EntrezAnnotator.class, new Class[] { ProteinAlias.class, RnaAlias.class, GeneAlias.class }, false); + super(EntrezAnnotator.class, new Class[] { Protein.class, Rna.class, Gene.class }, false); entrezSerializer = new XmlSerializer<>(EntrezData.class); } @@ -130,7 +130,7 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic this.setCache(null); try { - GenericProteinAlias proteinAlias = new GenericProteinAlias("id"); + GenericProtein proteinAlias = new GenericProtein("id"); proteinAlias.addMiriamData(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.ENTREZ, "9999")); annotateElement(proteinAlias); @@ -186,7 +186,7 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic if (data != null) { setSymbol(element, data.getSymbol(), prefix); - setFullName((Alias) element, data.getFullName(), prefix); + setFullName((Element) element, data.getFullName(), prefix); element.addMiriamData(data.getMiriamData()); element.setSynonyms(data.getSynonyms()); @@ -343,7 +343,7 @@ public class EntrezAnnotator extends ElementAnnotator implements IExternalServic String key = CACHE_HGNC_ID_PREFIX + miriamData.getResource(); String value = getCacheValue(key); if (value == null) { - GenericProteinAlias proteinAlias = new GenericProteinAlias("some_id"); + GenericProtein proteinAlias = new GenericProtein("some_id"); annotateElement(proteinAlias, miriamData, ""); for (MiriamData md : proteinAlias.getMiriamData()) { if (MiriamType.HGNC.equals(md.getDataType())) { diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/GoAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/GoAnnotator.java index c85d695aa6..a6ac2d4c67 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/GoAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/GoAnnotator.java @@ -25,10 +25,10 @@ import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamRelationType; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Phenotype; import lcsb.mapviewer.modelutils.map.ElementUtils; /** @@ -90,7 +90,7 @@ public class GoAnnotator extends ElementAnnotator implements IExternalService { * {@link Go} from/to xml. */ public GoAnnotator() { - super(GoAnnotator.class, new Class[] { PhenotypeAlias.class, CompartmentAlias.class, ComplexAlias.class }, true); + super(GoAnnotator.class, new Class[] { Phenotype.class, Compartment.class, Complex.class }, true); goSerializer = new XmlSerializer<>(Go.class); } @@ -112,7 +112,7 @@ public class GoAnnotator extends ElementAnnotator implements IExternalService { String commonName = go.getCommonName(); - setFullName((Alias) object, commonName, new ElementUtils().getElementTag(object, this)); + setFullName((Element) object, commonName, new ElementUtils().getElementTag(object, this)); String description = go.getDescription(); setDescription(object, description); } catch (GoSearchException e) { @@ -173,7 +173,7 @@ public class GoAnnotator extends ElementAnnotator implements IExternalService { this.setCache(null); try { - CompartmentAlias compartmentAlias = new CompartmentAlias("some_id"); + Compartment compartmentAlias = new Compartment("some_id"); compartmentAlias.addMiriamData(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.GO, "GO:0046902")); annotateElement(compartmentAlias); diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/HgncAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/HgncAnnotator.java index e5a17cfc26..0388009aee 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/HgncAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/HgncAnnotator.java @@ -19,11 +19,11 @@ import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamRelationType; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Rna; import lcsb.mapviewer.modelutils.map.ElementUtils; /** @@ -45,7 +45,7 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService * Default constructor. */ public HgncAnnotator() { - super(HgncAnnotator.class, new Class[] { ProteinAlias.class, RnaAlias.class, GeneAlias.class }, true); + super(HgncAnnotator.class, new Class[] { Protein.class, Rna.class, Gene.class }, true); } @Override @@ -90,7 +90,7 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService this.setCache(null); try { - GenericProteinAlias proteinAlias = new GenericProteinAlias("id"); + GenericProtein proteinAlias = new GenericProtein("id"); proteinAlias.addMiriamData(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.HGNC_SYMBOL, "SNCA")); annotateElement(proteinAlias); @@ -184,7 +184,7 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService } setSymbol(element, getNodeValue(node), prefix); } else if (type.equals("name")) { - setFullName((Alias) element, getNodeValue(node), prefix); + setFullName((Element) element, getNodeValue(node), prefix); } } else if (node.getNodeName().equals("arr")) { String type = getNodeAttr("name", node); @@ -205,7 +205,7 @@ public class HgncAnnotator extends ElementAnnotator implements IExternalService strings.add(getNodeValue(subnode)); } } - ((Alias) element).setFormerSymbols(strings); + ((Element) element).setFormerSymbols(strings); } else if (type.equals("alias_symbol")) { List<String> strings = new ArrayList<String>(); NodeList sublist = node.getChildNodes(); diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ReconAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ReconAnnotator.java index 09a0fb2c3c..b5a4a5b8a7 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ReconAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ReconAnnotator.java @@ -17,13 +17,13 @@ import lcsb.mapviewer.annotation.services.ExternalServiceStatusType; import lcsb.mapviewer.annotation.services.IExternalService; import lcsb.mapviewer.common.EventStorageLoggerAppender; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.converter.model.celldesigner.structure.Chemical; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerChemical; import lcsb.mapviewer.model.map.AnnotatedObject; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ChemicalAlias; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Chemical; +import lcsb.mapviewer.model.map.species.SimpleMolecule; +import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.modelutils.map.ElementUtils; /** @@ -79,7 +79,7 @@ public class ReconAnnotator extends ElementAnnotator implements IExternalService * Default constructor. */ public ReconAnnotator() { - super(ReconAnnotator.class, new Class[] { ChemicalAlias.class, Reaction.class }, false); + super(ReconAnnotator.class, new Class[] { Chemical.class, Reaction.class }, false); } @Override @@ -91,7 +91,7 @@ public class ReconAnnotator extends ElementAnnotator implements IExternalService EventStorageLoggerAppender appender = new EventStorageLoggerAppender(); Logger.getRootLogger().addAppender(appender); try { - SimpleMoleculeAlias smallMoleculeAlias = new SimpleMoleculeAlias("some_id"); + SimpleMolecule smallMoleculeAlias = new SimpleMolecule("some_id"); smallMoleculeAlias.setName("h2o"); annotateElement(smallMoleculeAlias); status.setStatus(ExternalServiceStatusType.OK); @@ -124,7 +124,7 @@ public class ReconAnnotator extends ElementAnnotator implements IExternalService id = tmp[tmp.length - 1]; } String url = null; - if (annotatedObject instanceof Alias) { + if (annotatedObject instanceof Element) { url = ELEMENT_ANNOTATION_URL_PREFIX + id; } else if (annotatedObject instanceof Reaction) { url = REACTION_ANNOTATION_URL_PREFIX + id; @@ -194,20 +194,20 @@ public class ReconAnnotator extends ElementAnnotator implements IExternalService } else if (key.equals("chargedFormula")) { setFormula(annotatedObject, value, prefix); } else if (key.equals("charge")) { - if (annotatedObject instanceof SpeciesAlias) { - setCharge((SpeciesAlias) annotatedObject, value, prefix); + if (annotatedObject instanceof Species) { + setCharge((Species) annotatedObject, value, prefix); } else { unknown = true; } } else if (key.equals("inchiString")) { - if (annotatedObject instanceof ChemicalAlias) { - setInchi((ChemicalAlias) annotatedObject, value, prefix); + if (annotatedObject instanceof Chemical) { + setInchi((Chemical) annotatedObject, value, prefix); } else { unknown = true; } } else if (key.equals("smile")) { - if (annotatedObject instanceof Chemical) { - setSmile((ChemicalAlias) annotatedObject, value, prefix); + if (annotatedObject instanceof CellDesignerChemical) { + setSmile((Chemical) annotatedObject, value, prefix); } else { unknown = true; } diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/UniprotAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/UniprotAnnotator.java index 17f559a9f7..705d8e1586 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/UniprotAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/UniprotAnnotator.java @@ -20,9 +20,9 @@ import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Rna; import lcsb.mapviewer.modelutils.map.ElementUtils; /** @@ -57,7 +57,7 @@ public class UniprotAnnotator extends ElementAnnotator implements IExternalServi * Default constructor. */ public UniprotAnnotator() { - super(UniprotAnnotator.class, new Class[] { ProteinAlias.class, GeneAlias.class, RnaAlias.class }, false); + super(UniprotAnnotator.class, new Class[] { Protein.class, Gene.class, Rna.class }, false); } @Override diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/ImproperAnnotationsTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/ImproperAnnotationsTest.java index 611cb1163b..2af983bf77 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/ImproperAnnotationsTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/ImproperAnnotationsTest.java @@ -15,7 +15,7 @@ import org.junit.Test; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; +import lcsb.mapviewer.model.map.species.GenericProtein; public class ImproperAnnotationsTest { @@ -36,7 +36,7 @@ public class ImproperAnnotationsTest { try { List<MiriamData> list = new ArrayList<>(); list.add(new MiriamData(MiriamType.CAS, "a")); - ImproperAnnotations ie = new ImproperAnnotations(new GenericProteinAlias("id"), list); + ImproperAnnotations ie = new ImproperAnnotations(new GenericProtein("id"), list); assertNotNull(ie.toString()); } catch (InvalidArgumentException e) { assertTrue(e.getMessage().contains("Only miriam data from elements are accepted")); @@ -46,7 +46,7 @@ public class ImproperAnnotationsTest { @Test public void testConstructor4() { try { - new ImproperAnnotations(new GenericProteinAlias("id"), new ArrayList<>()); + new ImproperAnnotations(new GenericProtein("id"), new ArrayList<>()); fail("Exception expected"); } catch (InvalidArgumentException e) { assertTrue(e.getMessage().contains("List of improper annotations cannot be null")); diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/MissingAnnotationTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/MissingAnnotationTest.java index 2cb12ed5e6..84490b1219 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/MissingAnnotationTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/MissingAnnotationTest.java @@ -7,7 +7,7 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; +import lcsb.mapviewer.model.map.species.GenericProtein; public class MissingAnnotationTest { @@ -25,7 +25,7 @@ public class MissingAnnotationTest { @Test public void test() { - MissingAnnotation annotation = new MissingAnnotation(new GenericProteinAlias("id")); + MissingAnnotation annotation = new MissingAnnotation(new GenericProtein("id")); assertTrue(annotation.toString().contains("misses annotations")); } diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/MissingRequiredAnnotationsTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/MissingRequiredAnnotationsTest.java index e68b7cdd69..9b901b6e7b 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/MissingRequiredAnnotationsTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/MissingRequiredAnnotationsTest.java @@ -12,7 +12,7 @@ import org.junit.Test; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; +import lcsb.mapviewer.model.map.species.GenericProtein; public class MissingRequiredAnnotationsTest { @@ -31,7 +31,7 @@ public class MissingRequiredAnnotationsTest { @Test public void testConstructorWithInvalidParams() { try { - new MissingRequiredAnnotations(new GenericProteinAlias("id"), new ArrayList<>()); + new MissingRequiredAnnotations(new GenericProtein("id"), new ArrayList<>()); } catch (InvalidArgumentException e) { assertTrue(e.getMessage().contains("List of improper annotations cannot be null")); } @@ -42,7 +42,7 @@ public class MissingRequiredAnnotationsTest { try { List<MiriamType> list = new ArrayList<>(); list.add(MiriamType.CAS); - MissingRequiredAnnotations mre = new MissingRequiredAnnotations(new GenericProteinAlias("id"), list); + MissingRequiredAnnotations mre = new MissingRequiredAnnotations(new GenericProtein("id"), list); assertTrue(mre.toString().contains("misses one of the following annotations")); } catch (InvalidArgumentException e) { assertTrue(e.getMessage().contains("List of improper annotations cannot be null")); 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 bba1c52d6f..e2ad6b257a 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/ModelAnnotatorTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/ModelAnnotatorTest.java @@ -33,15 +33,15 @@ import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamRelationType; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; import lcsb.mapviewer.model.map.model.ModelSubmodelConnection; 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.GenericProtein; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.persist.dao.map.ModelDao; public class ModelAnnotatorTest extends AnnotationTestFunctions { @@ -73,10 +73,10 @@ public class ModelAnnotatorTest extends AnnotationTestFunctions { model.addReaction(new Reaction()); - SpeciesAlias proteinAlias1 = new GenericProteinAlias("a1"); + Species proteinAlias1 = new GenericProtein("a1"); proteinAlias1.setName("SNCA"); - SpeciesAlias proteinAlias2 = new GenericProteinAlias("a2"); + Species proteinAlias2 = new GenericProtein("a2"); proteinAlias2.setName("PDK1"); proteinAlias2.addMiriamData(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CAS, "c")); @@ -98,11 +98,11 @@ public class ModelAnnotatorTest extends AnnotationTestFunctions { public void testAnnotateModelWithGivenAnnotators() { try { Model model = new ModelFullIndexed(null); - GenericProteinAlias species = new GenericProteinAlias("id1"); + GenericProtein species = new GenericProtein("id1"); species.setName("SNCA"); model.addAlias(species); - GenericProteinAlias species2 = new GenericProteinAlias("id2"); + GenericProtein species2 = new GenericProtein("id2"); species2.setName("PDK1"); species2.addMiriamData(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CAS, "c")); model.addAlias(species2); @@ -112,7 +112,7 @@ public class ModelAnnotatorTest extends AnnotationTestFunctions { List<ElementAnnotator> annotatorList = new ArrayList<>(); annotatorList.addAll(modelAnnotator.getDefaultAnnotators()); annotators.put(Reaction.class, annotatorList); - annotators.put(GenericProteinAlias.class, new ArrayList<>()); + annotators.put(GenericProtein.class, new ArrayList<>()); ReconAnnotator reconMock = Mockito.mock(ReconAnnotator.class); Mockito.doThrow(new AnnotatorException("")).when(reconMock).annotateElement(any()); @@ -135,7 +135,7 @@ public class ModelAnnotatorTest extends AnnotationTestFunctions { modelAnnotator.copyAnnotationFromOtherSpecies(model, updater); - for (SpeciesAlias element : model.getSpeciesAliases()) { + for (Species element : model.getSpeciesAliases()) { if (element.getName().equals("s4")) assertEquals(0, element.getMiriamData().size()); else if (element.getName().equals("hello")) @@ -192,8 +192,8 @@ public class ModelAnnotatorTest extends AnnotationTestFunctions { public void testGetAnnotationsForSYN() throws Exception { try { Model model = getModelForFile("testFiles/annotation/emptyAnnotationsSyn1.xml", true); - Alias sa1 = model.getAliasByAliasId("sa1"); - Alias sa2 = model.getAliasByAliasId("sa2"); + Element sa1 = model.getAliasByAliasId("sa1"); + Element sa2 = model.getAliasByAliasId("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 (SpeciesAlias el : model.getSpeciesAliases()) { + for (Species el : model.getSpeciesAliases()) { if (el.getNotes() != null) { assertFalse("Invalid notes: " + el.getNotes(), el.getNotes().contains("Symbol")); assertFalse("Invalid notes: " + el.getNotes(), el.getNotes().contains("HGNC")); @@ -300,7 +300,7 @@ public class ModelAnnotatorTest extends AnnotationTestFunctions { Model submodel = new ModelFullIndexed(null); Model submodel2 = new ModelFullIndexed(null); - GenericProteinAlias protein = new GenericProteinAlias("el"); + GenericProtein protein = new GenericProtein("el"); model.addSubmodelConnection(new ModelSubmodelConnection(submodel, SubmodelType.UNKNOWN)); model.addSubmodelConnection(new ModelSubmodelConnection(submodel2, SubmodelType.UNKNOWN)); @@ -328,7 +328,7 @@ public class ModelAnnotatorTest extends AnnotationTestFunctions { @Test public void testGetAvailableAnnotators() { try { - List<ElementAnnotator> list = modelAnnotator.getAvailableAnnotators(ProteinAlias.class); + List<ElementAnnotator> list = modelAnnotator.getAvailableAnnotators(Protein.class); assertTrue(list.size() > 0); } catch (Exception e) { e.printStackTrace(); diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ChebiAnnotatorTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ChebiAnnotatorTest.java index dfed5a1f58..8ca9b43561 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ChebiAnnotatorTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ChebiAnnotatorTest.java @@ -28,7 +28,7 @@ import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamRelationType; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; +import lcsb.mapviewer.model.map.species.SimpleMolecule; import uk.ac.ebi.chebi.webapps.chebiWS.client.ChebiWebServiceClient; import uk.ac.ebi.chebi.webapps.chebiWS.model.ChebiWebServiceFault_Exception; import uk.ac.ebi.chebi.webapps.chebiWS.model.DataItem; @@ -316,7 +316,7 @@ public class ChebiAnnotatorTest extends AnnotationTestFunctions { @Test public void testAnnotateChemical() throws Exception { try { - SimpleMoleculeAlias simpleMolecule = new SimpleMoleculeAlias("id"); + SimpleMolecule simpleMolecule = new SimpleMolecule("id"); simpleMolecule.setName("water"); backend.annotateElement(simpleMolecule); @@ -336,7 +336,7 @@ public class ChebiAnnotatorTest extends AnnotationTestFunctions { @Test public void testAnnotateWhenConnectionFails() throws Exception { try { - SimpleMoleculeAlias simpleMolecule = new SimpleMoleculeAlias("id"); + SimpleMolecule simpleMolecule = new SimpleMolecule("id"); simpleMolecule.setName("water"); ChebiWebServiceClient chebiWebServiceClient = Mockito.mock(ChebiWebServiceClient.class); @@ -372,7 +372,7 @@ public class ChebiAnnotatorTest extends AnnotationTestFunctions { @Test public void testAnnotateChemicalWithInvalidName() throws Exception { try { - SimpleMoleculeAlias simpleMolecule = new SimpleMoleculeAlias("id"); + SimpleMolecule simpleMolecule = new SimpleMolecule("id"); simpleMolecule.setName("blasdh"); backend.annotateElement(simpleMolecule); @@ -388,7 +388,7 @@ public class ChebiAnnotatorTest extends AnnotationTestFunctions { @Test public void testUpdateChemicalFromDb() throws Exception { try { - SimpleMoleculeAlias simpleMolecule = new SimpleMoleculeAlias("id"); + SimpleMolecule simpleMolecule = new SimpleMolecule("id"); simpleMolecule.addMiriamData(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CHEBI, "CHEBI:15377")); backend.annotateElement(simpleMolecule); @@ -408,7 +408,7 @@ public class ChebiAnnotatorTest extends AnnotationTestFunctions { @Test public void testUpdateChemicalFromDbWithDifferentData() throws Exception { try { - SimpleMoleculeAlias simpleMolecule = new SimpleMoleculeAlias("id"); + SimpleMolecule simpleMolecule = new SimpleMolecule("id"); simpleMolecule.setName("water"); simpleMolecule.setFullName("xxx"); simpleMolecule.setInChI("x"); diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotatorTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotatorTest.java index 4324fef802..bb65b83da6 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotatorTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotatorTest.java @@ -12,9 +12,9 @@ import lcsb.mapviewer.annotation.AnnotationTestFunctions; import lcsb.mapviewer.annotation.cache.CachableInterface; import lcsb.mapviewer.annotation.cache.SourceNotAvailable; import lcsb.mapviewer.model.map.AnnotatedObject; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.IonAlias; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Ion; public class ElementAnnotatorTest extends AnnotationTestFunctions { @@ -60,7 +60,7 @@ public class ElementAnnotatorTest extends AnnotationTestFunctions { @Test public void testSetNotMatchingSymbol() { - GenericProteinAlias species = new GenericProteinAlias("id"); + GenericProtein species = new GenericProtein("id"); species.setSymbol("X"); annotator.setSymbol(species, "Y", null); @@ -69,7 +69,7 @@ public class ElementAnnotatorTest extends AnnotationTestFunctions { @Test public void testSetNotMatchingFullname() { - GenericProteinAlias species = new GenericProteinAlias("id"); + GenericProtein species = new GenericProtein("id"); species.setFullName("X"); annotator.setFullName(species, "Y", null); @@ -78,7 +78,7 @@ public class ElementAnnotatorTest extends AnnotationTestFunctions { @Test public void testSetNotMatchingNotes() { - GenericProteinAlias species = new GenericProteinAlias("id"); + GenericProtein species = new GenericProtein("id"); species.setNotes("X"); annotator.setDescription(species, "Y"); @@ -87,7 +87,7 @@ public class ElementAnnotatorTest extends AnnotationTestFunctions { @Test public void testSetNotMatchingIchi() { - IonAlias species = new IonAlias("id"); + Ion species = new Ion("id"); species.setInChI("X"); annotator.setInchi(species, "Y", null); @@ -96,7 +96,7 @@ public class ElementAnnotatorTest extends AnnotationTestFunctions { @Test public void testSetNotMatchingSmile() { - IonAlias species = new IonAlias("id"); + Ion species = new Ion("id"); annotator.setSmile(species, "X", null); annotator.setSmile(species, "Y", null); @@ -105,7 +105,7 @@ public class ElementAnnotatorTest extends AnnotationTestFunctions { @Test public void testSetNotMatchingCharge() { - IonAlias species = new IonAlias("id"); + Ion species = new Ion("id"); species.setCharge(2); annotator.setCharge(species, "3", null); diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotatorTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotatorTest.java index d72467f1d5..89e2b2707a 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotatorTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotatorTest.java @@ -26,8 +26,8 @@ import lcsb.mapviewer.annotation.services.WrongResponseCodeIOException; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class EnsemblAnnotatorTest extends AnnotationTestFunctions { @@ -46,7 +46,7 @@ public class EnsemblAnnotatorTest extends AnnotationTestFunctions { public void testGetAnnotationsForEnsemblId() throws Exception { try { MiriamData nsmf = new MiriamData(MiriamType.ENSEMBL, "ENSG00000157764"); - GenericProteinAlias proteinAlias = new GenericProteinAlias("id"); + GenericProtein proteinAlias = new GenericProtein("id"); proteinAlias.addMiriamData(nsmf); ensemblAnnotator.annotateElement(proteinAlias); assertNotNull(proteinAlias.getSymbol()); @@ -88,7 +88,7 @@ public class EnsemblAnnotatorTest extends AnnotationTestFunctions { try { MiriamData nsmf = new MiriamData(MiriamType.ENSEMBL, "ENSG00000157764"); MiriamData nsmf1 = new MiriamData(MiriamType.ENSEMBL, "ENSG00000157765"); - GenericProteinAlias proteinAlias = new GenericProteinAlias("id"); + GenericProtein proteinAlias = new GenericProtein("id"); proteinAlias.addMiriamData(nsmf); proteinAlias.addMiriamData(nsmf1); ensemblAnnotator.annotateElement(proteinAlias); @@ -104,7 +104,7 @@ public class EnsemblAnnotatorTest extends AnnotationTestFunctions { @Test public void testGetAnnotationsWhenNoIdFound() throws Exception { try { - GenericProteinAlias proteinAlias = new GenericProteinAlias("id"); + GenericProtein proteinAlias = new GenericProtein("id"); ensemblAnnotator.annotateElement(proteinAlias); assertEquals(1, getWarnings().size()); @@ -119,7 +119,7 @@ public class EnsemblAnnotatorTest extends AnnotationTestFunctions { public void testGetAnnotationsForInvalid() throws Exception { try { MiriamData nsmf = new MiriamData(MiriamType.ENSEMBL, "blabla"); - GenericProteinAlias proteinAlias = new GenericProteinAlias("id"); + GenericProtein proteinAlias = new GenericProtein("id"); proteinAlias.addMiriamData(nsmf); ensemblAnnotator.annotateElement(proteinAlias); @@ -281,7 +281,7 @@ public class EnsemblAnnotatorTest extends AnnotationTestFunctions { WebPageDownloader mockDownloader = Mockito.mock(WebPageDownloader.class); when(mockDownloader.getFromNetwork(anyString())).thenThrow(new WrongResponseCodeIOException(null, 0)); ensemblAnnotator.setWebPageDownloader(mockDownloader); - SpeciesAlias proteinAlias = new GenericProteinAlias("id"); + Species proteinAlias = new GenericProtein("id"); proteinAlias.addMiriamData(new MiriamData(MiriamType.ENSEMBL, "1234")); ensemblAnnotator.annotateElement(proteinAlias); fail("Exception expected"); diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/EntrezAnnotatorTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/EntrezAnnotatorTest.java index 4498de25fb..40b24bc0e2 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/EntrezAnnotatorTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/EntrezAnnotatorTest.java @@ -30,8 +30,8 @@ import lcsb.mapviewer.annotation.services.WrongResponseCodeIOException; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class EntrezAnnotatorTest extends AnnotationTestFunctions { @@ -50,7 +50,7 @@ public class EntrezAnnotatorTest extends AnnotationTestFunctions { public void testGetAnnotationsForEntrezId() throws Exception { try { MiriamData nsmf = new MiriamData(MiriamType.ENTREZ, "84532"); - GenericProteinAlias proteinAlias = new GenericProteinAlias("id"); + GenericProtein proteinAlias = new GenericProtein("id"); proteinAlias.addMiriamData(nsmf); entrezAnnotator.annotateElement(proteinAlias); assertNotNull(proteinAlias.getSymbol()); @@ -87,7 +87,7 @@ public class EntrezAnnotatorTest extends AnnotationTestFunctions { public void testGetAnnotationsForInvalid() throws Exception { try { MiriamData nsmf = new MiriamData(MiriamType.ENTREZ, "blabla"); - GenericProteinAlias proteinAlias = new GenericProteinAlias("id"); + GenericProtein proteinAlias = new GenericProtein("id"); proteinAlias.addMiriamData(nsmf); entrezAnnotator.annotateElement(proteinAlias); @@ -310,7 +310,7 @@ public class EntrezAnnotatorTest extends AnnotationTestFunctions { @Test public void testAnnotateElementWithoutId() throws Exception { try { - GenericProteinAlias proteinAlias = new GenericProteinAlias("id"); + GenericProtein proteinAlias = new GenericProtein("id"); entrezAnnotator.annotateElement(proteinAlias); assertEquals(1, getWarnings().size()); @@ -324,7 +324,7 @@ public class EntrezAnnotatorTest extends AnnotationTestFunctions { @Test public void testAnnotateElementWithTwoEntrez() throws Exception { try { - SpeciesAlias proteinAlias = new GenericProteinAlias("id"); + Species proteinAlias = new GenericProtein("id"); proteinAlias.addMiriamData(new MiriamData(MiriamType.ENTREZ, "6647")); proteinAlias.addMiriamData(new MiriamData(MiriamType.ENTREZ, "6648")); entrezAnnotator.annotateElement(proteinAlias); diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/GoAnnotatorTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/GoAnnotatorTest.java index 709270c056..ce4045811d 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/GoAnnotatorTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/GoAnnotatorTest.java @@ -28,7 +28,7 @@ import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamRelationType; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; public class GoAnnotatorTest extends AnnotationTestFunctions { Logger logger = Logger.getLogger(GoAnnotatorTest.class); @@ -50,7 +50,7 @@ public class GoAnnotatorTest extends AnnotationTestFunctions { @Test public void testContent() throws Exception { try { - CompartmentAlias compartmentAlias = new CompartmentAlias("id"); + Compartment compartmentAlias = new Compartment("id"); compartmentAlias.addMiriamData(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.GO, "GO:0046902")); goAnnotator.annotateElement(compartmentAlias); assertFalse(compartmentAlias.getFullName().equals("")); diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/HgncAnnotatorTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/HgncAnnotatorTest.java index 0ff8111c11..56a549a5e9 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/HgncAnnotatorTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/HgncAnnotatorTest.java @@ -18,8 +18,8 @@ import lcsb.mapviewer.annotation.AnnotationTestFunctions; import lcsb.mapviewer.annotation.services.ExternalServiceStatusType; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class HgncAnnotatorTest extends AnnotationTestFunctions { @@ -40,7 +40,7 @@ public class HgncAnnotatorTest extends AnnotationTestFunctions { public void testGetAnnotationsForSNCA() throws Exception { try { MiriamData snca = new MiriamData(MiriamType.HGNC_SYMBOL, "SNCA"); - GenericProteinAlias proteinAlias = new GenericProteinAlias("id"); + GenericProtein proteinAlias = new GenericProtein("id"); proteinAlias.addMiriamData(snca); hgncAnnotator.annotateElement(proteinAlias); assertNotNull(proteinAlias.getSymbol()); @@ -89,7 +89,7 @@ public class HgncAnnotatorTest extends AnnotationTestFunctions { public void testGetAnnotationsForHGNC_ID() throws Exception { try { MiriamData nsmf = new MiriamData(MiriamType.HGNC, "11138"); - GenericProteinAlias proteinAlias = new GenericProteinAlias("id"); + GenericProtein proteinAlias = new GenericProtein("id"); proteinAlias.addMiriamData(nsmf); hgncAnnotator.annotateElement(proteinAlias); assertNotNull(proteinAlias.getSymbol()); @@ -132,7 +132,7 @@ public class HgncAnnotatorTest extends AnnotationTestFunctions { @Test public void testGetAnnotationsForSNCA2() throws Exception { try { - GenericProteinAlias proteinAlias = new GenericProteinAlias("id"); + GenericProtein proteinAlias = new GenericProtein("id"); proteinAlias.setName("SNCA"); hgncAnnotator.annotateElement(proteinAlias); assertNotNull(proteinAlias.getSymbol()); @@ -176,7 +176,7 @@ public class HgncAnnotatorTest extends AnnotationTestFunctions { @Test public void testGetAnnotationsForInvalid() throws Exception { try { - SpeciesAlias proteinAlias = new GenericProteinAlias("id"); + Species proteinAlias = new GenericProtein("id"); proteinAlias.setName("UNKNNOWNASD asd"); hgncAnnotator.annotateElement(proteinAlias); @@ -191,7 +191,7 @@ public class HgncAnnotatorTest extends AnnotationTestFunctions { @Test public void testGetAnnotationsForInvalid2() throws Exception { try { - SpeciesAlias proteinAlias = new GenericProteinAlias("id"); + Species proteinAlias = new GenericProtein("id"); proteinAlias.setName("cAMP/cGMP-dependent protein kinase"); hgncAnnotator.annotateElement(proteinAlias); @@ -245,7 +245,7 @@ public class HgncAnnotatorTest extends AnnotationTestFunctions { try { MiriamData md1 = new MiriamData(MiriamType.HGNC, "11138"); MiriamData md2 = new MiriamData(MiriamType.HGNC, "111382"); - SpeciesAlias proteinAlias = new GenericProteinAlias("id"); + Species proteinAlias = new GenericProtein("id"); proteinAlias.addMiriamData(md1); proteinAlias.addMiriamData(md2); hgncAnnotator.annotateElement(proteinAlias); diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ReconAnnotatorTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ReconAnnotatorTest.java index 0382edadfe..bb8137e1ac 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ReconAnnotatorTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ReconAnnotatorTest.java @@ -21,9 +21,9 @@ import lcsb.mapviewer.annotation.AnnotationTestFunctions; import lcsb.mapviewer.annotation.cache.WebPageDownloader; import lcsb.mapviewer.annotation.services.ExternalServiceStatusType; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.SimpleMolecule; +import lcsb.mapviewer.model.map.species.Species; public class ReconAnnotatorTest extends AnnotationTestFunctions { Logger logger = Logger.getLogger(ReconAnnotatorTest.class); @@ -55,7 +55,7 @@ public class ReconAnnotatorTest extends AnnotationTestFunctions { @Test public void testAnnotateElement() throws Exception { try { - SimpleMoleculeAlias smallMolecule = new SimpleMoleculeAlias("id"); + SimpleMolecule smallMolecule = new SimpleMolecule("id"); smallMolecule.setAbbreviation("h2o"); reconAnnotator.annotateElement(smallMolecule); assertTrue("No new annotations from recon db imported", smallMolecule.getMiriamData().size() > 0); @@ -69,7 +69,7 @@ public class ReconAnnotatorTest extends AnnotationTestFunctions { @Test public void testAnnotateElement2() throws Exception { try { - SpeciesAlias smallMolecule = new SimpleMoleculeAlias("id"); + Species smallMolecule = new SimpleMolecule("id"); smallMolecule.setAbbreviation("P5CRm"); reconAnnotator.annotateElement(smallMolecule); assertEquals(0, smallMolecule.getMiriamData().size()); diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/UniprotAnnotatorTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/UniprotAnnotatorTest.java index 1dd9020950..89f1c18669 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/UniprotAnnotatorTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/UniprotAnnotatorTest.java @@ -21,8 +21,8 @@ import lcsb.mapviewer.annotation.services.ExternalServiceStatusType; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class UniprotAnnotatorTest extends AnnotationTestFunctions { @@ -41,7 +41,7 @@ public class UniprotAnnotatorTest extends AnnotationTestFunctions { public void testAnnotate1() throws Exception { try { - SpeciesAlias protein = new GenericProteinAlias("id"); + Species protein = new GenericProtein("id"); protein.setName("P01308"); uniprotAnnotator.annotateElement(protein); @@ -74,7 +74,7 @@ public class UniprotAnnotatorTest extends AnnotationTestFunctions { @Test public void testAnnotate2() throws Exception { try { - SpeciesAlias protein = new GenericProteinAlias("id"); + Species protein = new GenericProtein("id"); protein.setName("bla"); protein.addMiriamData(new MiriamData(MiriamType.UNIPROT, "P01308")); uniprotAnnotator.annotateElement(protein); @@ -108,7 +108,7 @@ public class UniprotAnnotatorTest extends AnnotationTestFunctions { @Test public void testAnnotateInvalidUniprot() throws Exception { try { - SpeciesAlias protein = new GenericProteinAlias("id"); + Species protein = new GenericProtein("id"); protein.setName("bla"); protein.addMiriamData(new MiriamData(MiriamType.UNIPROT, "bla")); uniprotAnnotator.annotateElement(protein); @@ -127,7 +127,7 @@ public class UniprotAnnotatorTest extends AnnotationTestFunctions { @Test public void testAnnotateInvalid() throws Exception { try { - SpeciesAlias protein = new GenericProteinAlias("id"); + Species protein = new GenericProtein("id"); protein.setName("bla"); uniprotAnnotator.annotateElement(protein); diff --git a/console/src/main/java/lcsb/mapviewer/run/BellExport.java b/console/src/main/java/lcsb/mapviewer/run/BellExport.java index 04c2a09111..fb59ddcb95 100644 --- a/console/src/main/java/lcsb/mapviewer/run/BellExport.java +++ b/console/src/main/java/lcsb/mapviewer/run/BellExport.java @@ -7,8 +7,8 @@ import lcsb.mapviewer.annotation.services.ModelAnnotator; import lcsb.mapviewer.common.IProgressUpdater; import lcsb.mapviewer.converter.ConverterParams; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.persist.ApplicationContextLoader; import lcsb.mapviewer.persist.DbUtils; import lcsb.mapviewer.services.interfaces.IExporterService; @@ -94,7 +94,7 @@ public class BellExport { ExporterParameters params = new IExporterService.ExporterParameters().model(model).// fileName("out/bell/" + version + "-reactions.txt").// fileType(ExportFileType.TAB_SEPARATED).// - type(SpeciesAlias.class).// + type(Species.class).// moleculeEdges(false); exporter.exportReactions(params); @@ -102,7 +102,7 @@ public class BellExport { params = new IExporterService.ExporterParameters().model(model).// fileName("out/bell/" + version + "-species.txt").// fileType(ExportFileType.TAB_SEPARATED).// - type(SpeciesAlias.class).// + type(Species.class).// // column(ExportColumn.FULL).// moleculeEdges(false); exporter.exportSpecies(params); diff --git a/console/src/main/java/lcsb/mapviewer/run/ConsoleConverter.java b/console/src/main/java/lcsb/mapviewer/run/ConsoleConverter.java index 5aa503bf51..13f7337c2e 100644 --- a/console/src/main/java/lcsb/mapviewer/run/ConsoleConverter.java +++ b/console/src/main/java/lcsb/mapviewer/run/ConsoleConverter.java @@ -24,8 +24,6 @@ import lcsb.mapviewer.model.graphics.PolylineData; import lcsb.mapviewer.model.map.InconsistentModelException; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; import lcsb.mapviewer.model.map.modifier.Catalysis; @@ -33,6 +31,8 @@ import lcsb.mapviewer.model.map.reaction.Modifier; import lcsb.mapviewer.model.map.reaction.Product; import lcsb.mapviewer.model.map.reaction.Reactant; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.modelutils.map.ElementUtils; /** @@ -60,7 +60,7 @@ public class ConsoleConverter { private MiriamConnector mc = new MiriamConnector(); /** - * Util class used to access some information about {@link Alias}. + * Util class used to access some information about {@link Element}. */ private ElementUtils elementUtils = new ElementUtils(); @@ -111,7 +111,7 @@ public class ConsoleConverter { model.setWidth(inputOptions.getModelSize()); model.setHeight(inputOptions.getModelSize()); - Set<Alias> elements = null; + Set<Element> elements = null; try { elements = getNodes(nodesFilename); } catch (IOException e) { @@ -124,7 +124,7 @@ public class ConsoleConverter { double size = elements.size(); double x = 0; - for (Alias alias : model.getAliases()) { + for (Element alias : model.getAliases()) { alias.setWidth(inputOptions.getAliasWidth()); alias.setHeight(inputOptions.getAliasHeight()); double angle = x / size * 2 * Math.PI; @@ -240,7 +240,7 @@ public class ConsoleConverter { String productString = cols[productsColumn]; for (String string : productString.split(",")) { if (!string.isEmpty()) { - SpeciesAlias alias = model.getAliasByAliasId(string.trim()); + Species alias = model.getAliasByAliasId(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()) { - SpeciesAlias element = model.getAliasByAliasId(string.trim()); + Species element = model.getAliasByAliasId(string.trim()); Reactant product = new Reactant(element); reactants.add(product); } @@ -266,13 +266,13 @@ public class ConsoleConverter { String modifierString = cols[modifiersColumn]; for (String string : modifierString.split(",")) { if (!string.isEmpty()) { - SpeciesAlias element = model.getAliasByAliasId(string.trim()); + Species element = model.getAliasByAliasId(string.trim()); Modifier modifier = new Catalysis(element); modifiers.add(modifier); } } - Alias alias1 = products.get(0).getAlias(); - Alias alias2 = reactants.get(0).getAlias(); + Element alias1 = products.get(0).getAlias(); + Element alias2 = reactants.get(0).getAlias(); Point2D middle = new Point2D.Double((alias1.getCenterX() + alias2.getCenterX()) / 2, (alias1.getCenterY() + alias2.getCenterY()) / 2); @@ -324,21 +324,21 @@ public class ConsoleConverter { } /** - * This method parses the data from input file into set of {@link Alias + * This method parses the data from input file into set of {@link Element * elements}. * * @param filename * nam of input file - * @return set of {@link Alias elements} + * @return set of {@link Element elements} * @throws InvalidInputDataExecption * thrown when the input data is invalid * @throws IOException * thrown when there is a problem with input file */ - private Set<Alias> getNodes(String filename) throws InvalidInputDataExecption, IOException { + private Set<Element> getNodes(String filename) throws InvalidInputDataExecption, IOException { ElementUtils elementUtils = new ElementUtils(); - Set<Alias> result = new HashSet<>(); + Set<Element> result = new HashSet<>(); Set<String> ids = new HashSet<>(); Integer identifierColumn = null; @@ -412,10 +412,10 @@ public class ConsoleConverter { } try { - if (!Alias.class.isAssignableFrom(clazz)) { + if (!Element.class.isAssignableFrom(clazz)) { throw new InvalidInputDataExecption("Invliad element type: " + className, filename); } - Alias element = (Alias) clazz.getConstructor(String.class).newInstance(id); + Element element = (Element) clazz.getConstructor(String.class).newInstance(id); element.setName(name); element.addMiriamData(annotations); result.add(element); diff --git a/console/src/main/java/lcsb/mapviewer/run/ReactomeComparison.java b/console/src/main/java/lcsb/mapviewer/run/ReactomeComparison.java index 8f27f97d6c..7b5f0f24a6 100644 --- a/console/src/main/java/lcsb/mapviewer/run/ReactomeComparison.java +++ b/console/src/main/java/lcsb/mapviewer/run/ReactomeComparison.java @@ -21,9 +21,9 @@ import lcsb.mapviewer.annotation.services.annotators.AnnotatorException; import lcsb.mapviewer.common.IProgressUpdater; import lcsb.mapviewer.converter.ConverterParams; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.persist.ApplicationContextLoader; import lcsb.mapviewer.reactome.model.ReactomeDatabaseObject; import lcsb.mapviewer.reactome.model.ReactomeReactionlikeEvent; @@ -112,7 +112,7 @@ public class ReactomeComparison { Set<String> list = new HashSet<String>(); - for (SpeciesAlias element : model.getSpeciesAliases()) { + for (Species element : model.getSpeciesAliases()) { 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 f6fde1ee7c..2af675a904 100644 --- a/console/src/main/java/lcsb/mapviewer/run/ReactomeExport.java +++ b/console/src/main/java/lcsb/mapviewer/run/ReactomeExport.java @@ -18,13 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired; import lcsb.mapviewer.converter.ConverterParams; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.IonAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.reaction.AbstractNode; import lcsb.mapviewer.model.map.reaction.Modifier; @@ -33,6 +27,12 @@ import lcsb.mapviewer.model.map.reaction.Product; import lcsb.mapviewer.model.map.reaction.Reactant; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.ReactionNode; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Ion; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.SimpleMolecule; +import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.persist.ApplicationContextLoader; import lcsb.mapviewer.reactome.model.ReactomeDatabaseObject; import lcsb.mapviewer.reactome.utils.DataSourceUpdater; @@ -109,7 +109,7 @@ public class ReactomeExport { * Map between aliases in our model and identifiers that will be used in the * reactome vizualization model. */ - private Map<Alias, Integer> tempIds = new HashMap<Alias, Integer>(); + private Map<Element, Integer> tempIds = new HashMap<Element, Integer>(); /** * Creates reactome identifier for alias. @@ -118,7 +118,7 @@ public class ReactomeExport { * object for which identifier is created * @return identifier of the alias */ - public int addElement(Alias alias) { + public int addElement(Element alias) { int result = -1; if (tempIds.containsKey(alias)) { result = tempIds.get(alias); @@ -126,12 +126,12 @@ public class ReactomeExport { tempIds.put(alias, ++id); result = id; - if (alias instanceof ComplexAlias) { - for (Alias a : ((ComplexAlias) alias).getAliases()) { + if (alias instanceof Complex) { + for (Element a : ((Complex) alias).getAliases()) { addElement(a); } - } else if (alias instanceof CompartmentAlias) { - for (Alias a : ((CompartmentAlias) alias).getAliases()) { + } else if (alias instanceof Compartment) { + for (Element a : ((Compartment) alias).getAliases()) { addElement(a); } } @@ -177,10 +177,10 @@ public class ReactomeExport { */ private void printAliases(Model model) throws IOException { print("<Nodes>\n"); - List<Alias> aliases = new ArrayList<Alias>(); + List<Element> aliases = new ArrayList<Element>(); aliases.addAll(model.getAliases()); - Collections.sort(aliases, Alias.SIZE_COMPARATOR); - for (Alias alias : aliases) { + Collections.sort(aliases, Element.SIZE_COMPARATOR); + for (Element alias : aliases) { if (!aliasFeasible(alias)) { continue; } @@ -197,7 +197,7 @@ public class ReactomeExport { Set<Integer> components = new HashSet<Integer>(); String type = ""; - if (alias instanceof SpeciesAlias) { + if (alias instanceof Species) { String stableIdentifier = rcu.getReactomeIdentifierForSpecies(alias); if (stableIdentifier != null) { ReactomeDatabaseObject obj = rc.getFullObjectForStableIdentifier(stableIdentifier); @@ -206,32 +206,32 @@ public class ReactomeExport { } } parameters.put("displayName", alias.getName()); - if (alias instanceof ComplexAlias) { - for (Alias a : ((ComplexAlias) alias).getAliases()) { + if (alias instanceof Complex) { + for (Element a : ((Complex) alias).getAliases()) { components.add(addElement(a)); } } } - if (alias instanceof CompartmentAlias) { + if (alias instanceof Compartment) { parameters.put("displayName", alias.getName()); - for (Alias a : ((CompartmentAlias) alias).getAliases()) { + for (Element a : ((Compartment) alias).getAliases()) { components.add(addElement(a)); } } - if (alias instanceof ComplexAlias) { + if (alias instanceof Complex) { type = "org.gk.render.RenderableComplex"; attributes.put("hideComponents", "true"); attributes.put("textPosition", (int) alias.getCenterX() + " " + (int) (alias.getY() + alias.getHeight())); - } else if (alias instanceof SimpleMoleculeAlias) { + } else if (alias instanceof SimpleMolecule) { type = "org.gk.render.RenderableChemical"; - } else if (alias instanceof IonAlias) { + } else if (alias instanceof Ion) { type = "org.gk.render.RenderableChemical"; - } else if (alias instanceof ProteinAlias) { + } else if (alias instanceof Protein) { type = "org.gk.render.RenderableProtein"; - } else if (alias instanceof SpeciesAlias) { + } else if (alias instanceof Species) { type = "org.gk.render.RenderableEntity"; - } else if (alias instanceof CompartmentAlias) { + } else if (alias instanceof Compartment) { type = "org.gk.render.RenderableCompartment"; } else { logger.debug("Ignoring: " + parameters.get("displayName") + "(" + alias.getClass() + ")"); @@ -563,7 +563,7 @@ public class ReactomeExport { * @return <code>true</code> if alias can be put into reactome vizualization, * <code>false</code> otherwise */ - public boolean aliasFeasible(Alias alias) { + public boolean aliasFeasible(Element alias) { Point2D point = new Point2D.Double(alias.getX(), alias.getY()); Point2D point2 = new Point2D.Double(alias.getX() + alias.getWidth(), alias.getY() + alias.getHeight()); if (bound.contains(point) && bound.contains(point2)) { diff --git a/console/src/main/java/lcsb/mapviewer/run/RunOptions.java b/console/src/main/java/lcsb/mapviewer/run/RunOptions.java index d6e0c47361..c8a80569ab 100644 --- a/console/src/main/java/lcsb/mapviewer/run/RunOptions.java +++ b/console/src/main/java/lcsb/mapviewer/run/RunOptions.java @@ -12,8 +12,8 @@ import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.log4j.Logger; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.modelutils.map.ElementUtils; /** @@ -304,9 +304,9 @@ public class RunOptions { public void printFormat() { String desc = NODES_DESCRIPTION; ElementUtils eu = new ElementUtils(); - List<Class<? extends Alias>> classes = eu.getAvailableElementSubclasses(); + List<Class<? extends Element>> classes = eu.getAvailableElementSubclasses(); String classString = ""; - for (Class<? extends Alias> class1 : classes) { + for (Class<? extends Element> class1 : classes) { classString += class1.getSimpleName() + ", "; } desc = desc.replaceAll("\\$TYPES", classString); @@ -380,10 +380,10 @@ public class RunOptions { /** * Returns width of created - * {@link lcsb.mapviewer.model.map.layout.alias.Alias}. + * {@link lcsb.mapviewer.model.map.species.Element}. * * @return width of created - * {@link lcsb.mapviewer.model.map.layout.alias.Alias} + * {@link lcsb.mapviewer.model.map.species.Element} */ public int getAliasWidth() { return RunOptions.ALIAS_WIDTH; @@ -391,10 +391,10 @@ public class RunOptions { /** * Returns height of created - * {@link lcsb.mapviewer.model.map.layout.alias.Alias}. + * {@link lcsb.mapviewer.model.map.species.Element}. * * @return height of created - * {@link lcsb.mapviewer.model.map.layout.alias.Alias} + * {@link lcsb.mapviewer.model.map.species.Element} */ public int getAliasHeight() { return RunOptions.ALIAS_HEIGHT; diff --git a/console/src/main/java/lcsb/mapviewer/run/Statistics.java b/console/src/main/java/lcsb/mapviewer/run/Statistics.java index 8754380e03..90e6e1f4af 100644 --- a/console/src/main/java/lcsb/mapviewer/run/Statistics.java +++ b/console/src/main/java/lcsb/mapviewer/run/Statistics.java @@ -22,12 +22,12 @@ import lcsb.mapviewer.converter.ConverterParams; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.model.Model; 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.Species; import lcsb.mapviewer.persist.ApplicationContextLoader; import lcsb.mapviewer.persist.DbUtils; @@ -188,8 +188,8 @@ public class Statistics { Map<String, Set<String>> typeNames = new HashMap<>(); for (Model model : models) { - for (Alias element : model.getAliases()) { - if (element instanceof SpeciesAlias) { + for (Element element : model.getAliases()) { + if (element instanceof Species) { names.add(element.getName()); Set<String> tmp = typeNames.get(element.getClass().getName()); if (tmp == null) { @@ -223,7 +223,7 @@ public class Statistics { Set<String> set = new HashSet<String>(); for (Model model : models) { - for (CompartmentAlias comp : model.getCompartmentsAliases()) { + for (Compartment comp : model.getCompartmentsAliases()) { set.add(comp.getName()); } } @@ -255,8 +255,8 @@ public class Statistics { } print("-----------------------------"); print("Complex annotations:"); - for (Alias element : model.getAliases()) { - if (element instanceof ComplexAlias && element.getMiriamData().size() > 0) { + 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()); } } @@ -316,7 +316,7 @@ public class Statistics { */ protected String createPubmedExportString(Model model) throws Exception { Map<String, List<String>> links = new HashMap<String, List<String>>(); - for (Alias element : model.getAliases()) { + for (Element element : model.getAliases()) { for (MiriamData md : element.getMiriamData()) { if (MiriamType.PUBMED.equals(md.getDataType())) { List<String> list = links.get(md.getResource()); diff --git a/console/src/main/java/lcsb/mapviewer/run/UnknownReactionInReactome.java b/console/src/main/java/lcsb/mapviewer/run/UnknownReactionInReactome.java index 3c104e7aa7..f9153e1376 100644 --- a/console/src/main/java/lcsb/mapviewer/run/UnknownReactionInReactome.java +++ b/console/src/main/java/lcsb/mapviewer/run/UnknownReactionInReactome.java @@ -21,7 +21,7 @@ import lcsb.mapviewer.converter.graphics.MapGenerator; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.ReactionNode; @@ -208,7 +208,7 @@ public class UnknownReactionInReactome { Set<String> ontologies = new HashSet<String>(); - for (CompartmentAlias alias : model.getCompartmentsAliases()) { + for (Compartment alias : model.getCompartmentsAliases()) { for (ReactionNode node : result.getLocalReaction().getReactionNodes()) { if (alias.contains(node.getAlias())) { ontologies.add(alias.getName()); diff --git a/console/src/main/java/lcsb/mapviewer/run/VibineSnippet.java b/console/src/main/java/lcsb/mapviewer/run/VibineSnippet.java index f40554f26b..a5c577a07e 100644 --- a/console/src/main/java/lcsb/mapviewer/run/VibineSnippet.java +++ b/console/src/main/java/lcsb/mapviewer/run/VibineSnippet.java @@ -7,10 +7,10 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.converter.ConverterParams; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.ReactionNode; +import lcsb.mapviewer.model.map.species.Species; /** * This class is a snippet for Vibine collaboration project. It shows how to @@ -84,7 +84,7 @@ public class VibineSnippet { String speciesId = "sa7208"; String reactionId = "re332"; - SpeciesAlias species = model.getAliasByAliasId(speciesId); + Species species = model.getAliasByAliasId(speciesId); logger.debug("Element with id: " + speciesId); logger.debug("Element type: " + species.getClass()); 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 757a4ae6b1..008e12601d 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 @@ -5,41 +5,41 @@ import java.util.List; import java.util.Map; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.converter.model.celldesigner.structure.Compartment; -import lcsb.mapviewer.converter.model.celldesigner.structure.Element; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerCompartment; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerElement; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; public class CellDesignerElementCollection { - private Map<String, Element<?>> elementById = new HashMap<>(); + private Map<String, CellDesignerElement<?>> elementById = new HashMap<>(); @SuppressWarnings("unchecked") - public <T extends Element<?>> T getSpeciesBySpeciesId(String speciesId) { + public <T extends CellDesignerElement<?>> T getSpeciesBySpeciesId(String speciesId) { return (T) elementById.get(speciesId); } - public Compartment getCompartmentByCompartmentId(String compartmentId) { - return (Compartment) elementById.get(compartmentId); + public CellDesignerCompartment getCompartmentByCompartmentId(String compartmentId) { + return (CellDesignerCompartment) elementById.get(compartmentId); } - public String getElementId(Alias alias) { + 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(); } - public void addElements(List<? extends Element<?>> elements) { - for (Element<?> element : elements) { + public void addElements(List<? extends CellDesignerElement<?>> elements) { + for (CellDesignerElement<?> element : elements) { addElement(element); } } - public void addElement(Element<?> element) { + public void addElement(CellDesignerElement<?> element) { addElement(element, element.getElementId()); } - private void addElement(Element<?> element, String id) { + private void addElement(CellDesignerElement<?> element, String id) { if (elementById.get(id) != null) { throw new InvalidArgumentException( "[" + element.getClass().getSimpleName() + " " + element.getElementId() + "]\t" + "Element with given id alread exists. ID: " + id); @@ -47,7 +47,7 @@ public class CellDesignerElementCollection { elementById.put(id, element); } - public void addAlias(SpeciesAlias alias, Element<?> element) { + public void addAlias(Species alias, CellDesignerElement<?> element) { addElement(element, getElementId(alias)); if (getSpeciesBySpeciesId(element.getElementId()) == null) { addElement(element); 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 42b24a9e7f..2c990f4f37 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 @@ -33,18 +33,11 @@ import lcsb.mapviewer.converter.model.celldesigner.reaction.ReactionCollectionXm import lcsb.mapviewer.converter.model.celldesigner.reaction.UnknownReactionClassException; import lcsb.mapviewer.converter.model.celldesigner.species.InternalModelSpeciesData; import lcsb.mapviewer.converter.model.celldesigner.species.SpeciesCollectionXmlParser; -import lcsb.mapviewer.converter.model.celldesigner.structure.Compartment; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerCompartment; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; import lcsb.mapviewer.model.graphics.PolylineData; import lcsb.mapviewer.model.map.InconsistentModelException; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaAlias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.layout.graphics.LayerOval; import lcsb.mapviewer.model.map.layout.graphics.LayerRect; @@ -52,6 +45,13 @@ import lcsb.mapviewer.model.map.layout.graphics.LayerText; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.AntisenseRna; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Rna; +import lcsb.mapviewer.model.map.species.Species; /** * This class is a parser for CellDesigner files. There are two typical use @@ -99,7 +99,7 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { */ private AliasCollectionXmlParser aliasCollectionParser; - private RestAnnotationParser rap = new RestAnnotationParser(); + private RestAnnotationParser rap = new RestAnnotationParser(); @Override public Model createModel(ConverterParams params) throws InvalidInputDataExecption { @@ -115,7 +115,7 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { if (params.getFilename() != null) { model.setName(FilenameUtils.getBaseName(params.getFilename())); } - speciesSbmlParser = new SpeciesCollectionXmlParser(model, elements); + speciesSbmlParser = new SpeciesCollectionXmlParser(elements); aliasCollectionParser = new AliasCollectionXmlParser(elements, model); compartmentCollectionXmlParser = new CompartmentCollectionXmlParser(elements); @@ -147,7 +147,7 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { Node compartmentNode = getNode("listOfCompartments", modelNode.getChildNodes()); if (compartmentNode != null) { - List<Compartment> compartments = compartmentCollectionXmlParser.parseXmlCompartmentCollection(compartmentNode); + List<CellDesignerCompartment> compartments = compartmentCollectionXmlParser.parseXmlCompartmentCollection(compartmentNode); elements.addElements(compartments); } @@ -155,7 +155,7 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { Node speciesNode = getNode("listOfSpecies", modelNode.getChildNodes()); if (speciesNode != null) { - List<Pair<String, ? extends Species<?>>> species = speciesSbmlParser.parseSbmlSpeciesCollection(speciesNode); + List<Pair<String, ? extends CellDesignerSpecies<?>>> species = speciesSbmlParser.parseSbmlSpeciesCollection(speciesNode); modelData.updateSpecies(species); } Node reactionsNode = null; @@ -195,7 +195,7 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { parseAnnotation(model, annotationNode, modelData, elements); if (speciesNode != null) { - List<Pair<String, ? extends Species<?>>> species = speciesSbmlParser.parseSbmlSpeciesCollection(speciesNode); + List<Pair<String, ? extends CellDesignerSpecies<?>>> species = speciesSbmlParser.parseSbmlSpeciesCollection(speciesNode); modelData.updateSpecies(species); } @@ -264,7 +264,7 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { double maxY = 0; double minX = model.getWidth(); double minY = model.getHeight(); - for (Alias alias : model.getAliases()) { + for (Element alias : model.getAliases()) { maxX = Math.max(maxX, alias.getWidth() + alias.getX()); maxY = Math.max(maxY, alias.getHeight() + alias.getY()); @@ -355,7 +355,7 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { */ private void parseAnnotation(Model model, Node annotationNode, InternalModelSpeciesData modelData, CellDesignerElementCollection elements) throws InvalidXmlSchemaException { - SpeciesCollectionXmlParser parser = new SpeciesCollectionXmlParser(model, elements); + SpeciesCollectionXmlParser parser = new SpeciesCollectionXmlParser(elements); Node extensionNode = getNode("celldesigner:extension", annotationNode.getChildNodes()); if (extensionNode == null) { @@ -411,36 +411,36 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { } if (listOfComparmentAlias != null) { - List<CompartmentAlias> aliases = aliasCollectionParser.parseXmlCompartmentAliasCollection(listOfComparmentAlias); - for (Alias alias : aliases) { + List<Compartment> aliases = aliasCollectionParser.parseXmlCompartmentAliasCollection(listOfComparmentAlias); + for (Element alias : aliases) { rap.processNotes(alias); model.addAlias(alias); } } if (includedSpecies != null) { - List<Pair<String, ? extends Species<?>>> species = parser.parseIncludedSpeciesCollection(includedSpecies); + List<Pair<String, ? extends CellDesignerSpecies<?>>> species = parser.parseIncludedSpeciesCollection(includedSpecies); modelData.updateSpecies(species); } if (listOfProteins != null) { - List<Pair<String, ? extends Species<?>>> species = parser.parseXmlProteinCollection(listOfProteins); + List<Pair<String, ? extends CellDesignerSpecies<?>>> species = parser.parseXmlProteinCollection(listOfProteins); modelData.updateSpecies(species); } if (listOfGenes != null) { - List<Pair<String, ? extends Species<?>>> species = parser.parseXmlGeneCollection(listOfGenes); + List<Pair<String, ? extends CellDesignerSpecies<?>>> species = parser.parseXmlGeneCollection(listOfGenes); modelData.updateSpecies(species); } if (listOfRnas != null) { - List<Pair<String, ? extends Species<?>>> species = parser.parseXmlRnaCollection(listOfRnas); + List<Pair<String, ? extends CellDesignerSpecies<?>>> species = parser.parseXmlRnaCollection(listOfRnas); modelData.updateSpecies(species); } if (listOfAntisenseRnas != null) { - List<Pair<String, ? extends Species<?>>> species = parser.parseXmlAntisenseRnaCollection(listOfAntisenseRnas); + List<Pair<String, ? extends CellDesignerSpecies<?>>> species = parser.parseXmlAntisenseRnaCollection(listOfAntisenseRnas); modelData.updateSpecies(species); } - for (Species species : modelData.getAll()) { + for (CellDesignerSpecies<?> species : modelData.getAll()) { if (!species.getElementId().equals("")) { elements.addElement(species); } else { @@ -451,16 +451,16 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { } if (listOfComplexSpeciesAlias != null) { - List<ComplexAlias> aliases = aliasCollectionParser.parseXmlComplexAliasCollection(listOfComplexSpeciesAlias); - for (Alias alias : aliases) { + List<Complex> aliases = aliasCollectionParser.parseXmlComplexAliasCollection(listOfComplexSpeciesAlias); + for (Element alias : aliases) { rap.processNotes(alias); model.addAlias(alias); } } if (listofSpeciesAlias != null) { - List<SpeciesAlias> aliases = aliasCollectionParser.parseXmlSpeciesAliasCollection(listofSpeciesAlias); - for (Alias alias : aliases) { + List<Species> aliases = aliasCollectionParser.parseXmlSpeciesAliasCollection(listofSpeciesAlias); + for (Element alias : aliases) { rap.processNotes(alias); model.addAlias(alias); } @@ -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); - ComplexAlias alias = (ComplexAlias) model.getAliasByAliasId(aliasId); + Complex alias = (Complex) model.getAliasByAliasId(aliasId); if (alias == null) { throw new InvalidXmlSchemaException("Alias does not exist " + aliasId); } - ComplexAlias complex = (ComplexAlias) model.getAliasByAliasId(complexId); + Complex complex = (Complex) model.getAliasByAliasId(complexId); if (complex != null) { complex.addAlias(alias); alias.setParent(complex); @@ -534,14 +534,14 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { if (node.getNodeName().equalsIgnoreCase("celldesigner:speciesAlias")) { String aliasId = getNodeAttr("id", node); String complexId = getNodeAttr("complexSpeciesAlias", node); - Alias alias = model.getAliasByAliasId(aliasId); + Element alias = model.getAliasByAliasId(aliasId); if (alias == null) { throw new InvalidXmlSchemaException("Alias does not exist " + aliasId); - } else if (alias instanceof SpeciesAlias) { - ComplexAlias complex = (ComplexAlias) model.getAliasByAliasId(complexId); + } else if (alias instanceof Species) { + Complex complex = (Complex) model.getAliasByAliasId(complexId); if (complex != null) { alias.setParent(complex); - complex.addAlias((SpeciesAlias) alias); + complex.addAlias((Species) alias); } } } else { @@ -563,7 +563,7 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { public String toXml(Model model) throws InconsistentModelException { CellDesignerElementCollection elements = new CellDesignerElementCollection(); - SpeciesCollectionXmlParser speciesCollectionXmlParser = new SpeciesCollectionXmlParser(model, elements); + SpeciesCollectionXmlParser speciesCollectionXmlParser = new SpeciesCollectionXmlParser(elements); ReactionCollectionXmlParser reactionCollectionXmlParser = new ReactionCollectionXmlParser(model, elements); aliasCollectionParser = new AliasCollectionXmlParser(elements, model); @@ -585,7 +585,7 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { result.append(annotationToXml(model, elements)); compartmentCollectionXmlParser = new CompartmentCollectionXmlParser(elements); - + result.append(compartmentCollectionXmlParser.toXml(model.getCompartmentsAliases())); result.append(speciesCollectionXmlParser.speciesCollectionToSbmlString(model.getSpeciesAliases())); @@ -605,7 +605,7 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { * @return annotation xml string for the model */ private String annotationToXml(Model model, CellDesignerElementCollection elements) { - SpeciesCollectionXmlParser speciesCollectionXmlParser = new SpeciesCollectionXmlParser(model, elements); + SpeciesCollectionXmlParser speciesCollectionXmlParser = new SpeciesCollectionXmlParser(elements); StringBuilder result = new StringBuilder(); result.append("<annotation>\n"); @@ -619,19 +619,19 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { result.append(aliasCollectionParser.complexAliasCollectionToXmlString(model.getComplexAliases())); result.append(aliasCollectionParser.speciesAliasCollectionToXmlString(model.getNotComplexSpeciesAliases())); - List<ProteinAlias> proteins = new ArrayList<>(); - List<GeneAlias> genes = new ArrayList<>(); - List<RnaAlias> rnas = new ArrayList<>(); - List<AntisenseRnaAlias> antisenseRnas = new ArrayList<>(); - for (Alias element : model.getAliases()) { - if (element instanceof ProteinAlias) { - proteins.add((ProteinAlias) element); - } else if (element instanceof GeneAlias) { - genes.add((GeneAlias) element); - } else if (element instanceof AntisenseRnaAlias) { - antisenseRnas.add((AntisenseRnaAlias) element); - } else if (element instanceof RnaAlias) { - rnas.add((RnaAlias) element); + List<Protein> proteins = new ArrayList<>(); + List<Gene> genes = new ArrayList<>(); + List<Rna> rnas = new ArrayList<>(); + List<AntisenseRna> antisenseRnas = new ArrayList<>(); + for (Element element : model.getAliases()) { + if (element instanceof Protein) { + proteins.add((Protein) element); + } else if (element instanceof Gene) { + genes.add((Gene) element); + } else if (element instanceof AntisenseRna) { + antisenseRnas.add((AntisenseRna) element); + } else if (element instanceof Rna) { + rnas.add((Rna) element); } } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CommonXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CommonXmlParser.java index 98aff110e0..a334aac73e 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CommonXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CommonXmlParser.java @@ -1,106 +1,106 @@ -package lcsb.mapviewer.converter.model.celldesigner; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.geom.Point2D; - -import lcsb.mapviewer.common.XmlParser; -import lcsb.mapviewer.converter.model.celldesigner.structure.SingleLine; -import lcsb.mapviewer.converter.model.celldesigner.structure.View; - -import org.w3c.dom.Node; - -/** - * Class with parsers for common CellDesigner objects. - * - * @author Piotr Gawron - * - */ -public class CommonXmlParser extends XmlParser { - /** - * Parse xml representation of position into Poin2D object. - * - * @param node - * xml node to parse - * @return Point2D object - */ - public Point2D getPosition(Node node) { - double x = Double.parseDouble(getNodeAttr("x", node)); - double y = Double.parseDouble(getNodeAttr("y", node)); - return new Point2D.Double(x, y); - - } - - /** - * Parse xml representation of dimension. - * - * @param node - * xml node to parse - * @return dimension (with width and height fields) - */ - public Dimension getDimension(Node node) { - double width = Double.parseDouble(getNodeAttr("width", node)); - double height = Double.parseDouble(getNodeAttr("height", node)); - Dimension result = new Dimension(); - result.setSize(width, height); - return result; - } - - /** - * Parse xml representation of CellDesigner SingleLine. - * - * @param node - * xml node to parse - * @return sinle line object (with width field) - */ - public SingleLine getSingleLine(Node node) { - SingleLine result = new SingleLine(); - result.setWidth(Double.parseDouble(getNodeAttr("width", node))); - return result; - } - - /** - * Parse xml representation of CellDesigner color. - * - * @param node - * xml node to parse - * @return Color value stored in xml - */ - public Color getColor(Node node) { - String color = getNodeAttr("color", node); - return stringToColor(color); - } - - /** - * Parse xml representation of CellDesigner view. - * - * @param node - * xml node to parse - * @return view parsed from xml - * @see View - */ - public View getView(Node node) { - View result = new View(); - Node tmpNode = getNode("celldesigner:innerPosition", node.getChildNodes()); - if (tmpNode != null) { - result.setInnerPosition(getPosition(tmpNode)); - } - - tmpNode = getNode("celldesigner:boxSize", node.getChildNodes()); - if (tmpNode != null) { - result.setBoxSize(getDimension(tmpNode)); - } - - tmpNode = getNode("celldesigner:singleLine", node.getChildNodes()); - if (tmpNode != null) { - result.setSingleLine(getSingleLine(tmpNode)); - } - - tmpNode = getNode("celldesigner:paint", node.getChildNodes()); - if (tmpNode != null) { - result.setColor(getColor(tmpNode)); - } - return result; - } - -} +package lcsb.mapviewer.converter.model.celldesigner; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.geom.Point2D; + +import lcsb.mapviewer.common.XmlParser; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.SingleLine; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.View; + +import org.w3c.dom.Node; + +/** + * Class with parsers for common CellDesigner objects. + * + * @author Piotr Gawron + * + */ +public class CommonXmlParser extends XmlParser { + /** + * Parse xml representation of position into Poin2D object. + * + * @param node + * xml node to parse + * @return Point2D object + */ + public Point2D getPosition(Node node) { + double x = Double.parseDouble(getNodeAttr("x", node)); + double y = Double.parseDouble(getNodeAttr("y", node)); + return new Point2D.Double(x, y); + + } + + /** + * Parse xml representation of dimension. + * + * @param node + * xml node to parse + * @return dimension (with width and height fields) + */ + public Dimension getDimension(Node node) { + double width = Double.parseDouble(getNodeAttr("width", node)); + double height = Double.parseDouble(getNodeAttr("height", node)); + Dimension result = new Dimension(); + result.setSize(width, height); + return result; + } + + /** + * Parse xml representation of CellDesigner SingleLine. + * + * @param node + * xml node to parse + * @return sinle line object (with width field) + */ + public SingleLine getSingleLine(Node node) { + SingleLine result = new SingleLine(); + result.setWidth(Double.parseDouble(getNodeAttr("width", node))); + return result; + } + + /** + * Parse xml representation of CellDesigner color. + * + * @param node + * xml node to parse + * @return Color value stored in xml + */ + public Color getColor(Node node) { + String color = getNodeAttr("color", node); + return stringToColor(color); + } + + /** + * Parse xml representation of CellDesigner view. + * + * @param node + * xml node to parse + * @return view parsed from xml + * @see View + */ + public View getView(Node node) { + View result = new View(); + Node tmpNode = getNode("celldesigner:innerPosition", node.getChildNodes()); + if (tmpNode != null) { + result.setInnerPosition(getPosition(tmpNode)); + } + + tmpNode = getNode("celldesigner:boxSize", node.getChildNodes()); + if (tmpNode != null) { + result.setBoxSize(getDimension(tmpNode)); + } + + tmpNode = getNode("celldesigner:singleLine", node.getChildNodes()); + if (tmpNode != null) { + result.setSingleLine(getSingleLine(tmpNode)); + } + + tmpNode = getNode("celldesigner:paint", node.getChildNodes()); + if (tmpNode != null) { + result.setColor(getColor(tmpNode)); + } + return result; + } + +} 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 f232c0aad7..c7566f716d 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 @@ -14,14 +14,14 @@ import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; import lcsb.mapviewer.model.graphics.ArrowType; import lcsb.mapviewer.model.graphics.LineType; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.AliasGroup; -import lcsb.mapviewer.model.map.layout.alias.BlockDiagram; +import lcsb.mapviewer.model.map.layout.BlockDiagram; +import lcsb.mapviewer.model.map.layout.ElementGroup; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.layout.graphics.LayerOval; import lcsb.mapviewer.model.map.layout.graphics.LayerRect; import lcsb.mapviewer.model.map.layout.graphics.LayerText; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; /** * Parser used for parsing CellDesigner xml to get {@link Layer} object. @@ -164,15 +164,15 @@ public class LayerXmlParser extends XmlParser { * thrown when xml node contains data that is not supported by xml * schema */ - AliasGroup getAliasGroup(Node groupNode, Model model) throws InvalidXmlSchemaException { - AliasGroup result = new AliasGroup(); + ElementGroup getAliasGroup(Node groupNode, Model model) throws InvalidXmlSchemaException { + ElementGroup result = new ElementGroup(); String id = getNodeAttr("id", groupNode); result.setIdGroup(id); String members = getNodeAttr("members", groupNode); String[] list = members.split(","); for (String string : list) { - Alias alias = model.getAliasByAliasId(string); + Element alias = model.getAliasByAliasId(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/AbstractAliasXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/AbstractAliasXmlParser.java index fa7a8f4414..a4a9319242 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/AbstractAliasXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/AbstractAliasXmlParser.java @@ -8,7 +8,7 @@ import org.w3c.dom.NodeList; import lcsb.mapviewer.common.XmlParser; import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; import lcsb.mapviewer.converter.model.celldesigner.CommonXmlParser; -import lcsb.mapviewer.model.map.layout.alias.Alias; +import lcsb.mapviewer.model.map.species.Element; /** * Generic abstract interface for parsing CellDesigner xml nodes with species @@ -19,7 +19,7 @@ import lcsb.mapviewer.model.map.layout.alias.Alias; * @param <T> * type of the object to parse */ -public abstract class AbstractAliasXmlParser<T extends Alias> extends XmlParser { +public abstract class AbstractAliasXmlParser<T extends Element> extends XmlParser { /** * Default class logger. diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/AliasCollectionXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/AliasCollectionXmlParser.java index f2bb7f53f8..f1ffccc93d 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/AliasCollectionXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/AliasCollectionXmlParser.java @@ -12,11 +12,11 @@ import lcsb.mapviewer.common.XmlParser; import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection; import lcsb.mapviewer.converter.model.celldesigner.annotation.RestAnnotationParser; -import lcsb.mapviewer.model.map.layout.alias.ArtifitialCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.compartment.PathwayCompartment; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Species; /** * This class contains function to parse CellDesigner xml nodes containing @@ -76,14 +76,14 @@ public class AliasCollectionXmlParser extends XmlParser { * @throws InvalidXmlSchemaException * thrown when there is a problem with xml */ - public List<SpeciesAlias> parseXmlSpeciesAliasCollection(Node aliasListNode) throws InvalidXmlSchemaException { - List<SpeciesAlias> result = new ArrayList<SpeciesAlias>(); + public List<Species> parseXmlSpeciesAliasCollection(Node aliasListNode) throws InvalidXmlSchemaException { + List<Species> result = new ArrayList<Species>(); NodeList nodes = aliasListNode.getChildNodes(); for (int x = 0; x < nodes.getLength(); x++) { Node node = nodes.item(x); if (node.getNodeType() == Node.ELEMENT_NODE) { if (node.getNodeName().equalsIgnoreCase("celldesigner:speciesAlias")) { - SpeciesAlias alias = speciesAliasParser.parseXmlAlias(node); + Species alias = speciesAliasParser.parseXmlAlias(node); rap.processNotes(alias); result.add(alias); } else { @@ -101,9 +101,9 @@ public class AliasCollectionXmlParser extends XmlParser { * collection of SpeciesAlias * @return xml string representing collection of SpeciesAlias */ - public String speciesAliasCollectionToXmlString(Collection<SpeciesAlias> collection) { + public String speciesAliasCollectionToXmlString(Collection<Species> collection) { StringBuilder sb = new StringBuilder("<celldesigner:listOfSpeciesAliases>\n"); - for (SpeciesAlias alias : collection) { + for (Species alias : collection) { sb.append(speciesAliasParser.toXml(alias)); } sb.append("</celldesigner:listOfSpeciesAliases>\n"); @@ -120,21 +120,21 @@ public class AliasCollectionXmlParser extends XmlParser { * @throws InvalidXmlSchemaException * thrown when xmlString is invalid */ - public List<ComplexAlias> parseXmlComplexAliasCollection(Node aliasListNode) throws InvalidXmlSchemaException { - List<ComplexAlias> result = new ArrayList<ComplexAlias>(); + public List<Complex> parseXmlComplexAliasCollection(Node aliasListNode) throws InvalidXmlSchemaException { + List<Complex> result = new ArrayList<Complex>(); NodeList nodes = aliasListNode.getChildNodes(); for (int x = 0; x < nodes.getLength(); x++) { Node node = nodes.item(x); if (node.getNodeType() == Node.ELEMENT_NODE) { if (node.getNodeName().equalsIgnoreCase("celldesigner:complexSpeciesAlias")) { - ComplexAlias alias = complexAliasParser.parseXmlAlias(node); + Complex alias = complexAliasParser.parseXmlAlias(node); result.add(alias); } else { throw new InvalidXmlSchemaException("Unknown element of celldesigner:listOfComplexSpeciesAliases: " + node.getNodeName()); } } } - for (ComplexAlias complexAlias : result) { + for (Complex complexAlias : result) { complexAliasParser.addReference(complexAlias); } return result; @@ -147,9 +147,9 @@ public class AliasCollectionXmlParser extends XmlParser { * collection of ComplexAlias * @return xml string representing collection of ComplexAlias */ - public String complexAliasCollectionToXmlString(Collection<ComplexAlias> collection) { + public String complexAliasCollectionToXmlString(Collection<Complex> collection) { StringBuilder sb = new StringBuilder("<celldesigner:listOfComplexSpeciesAliases>\n"); - for (ComplexAlias alias : collection) { + for (Complex alias : collection) { sb.append(complexAliasParser.toXml(alias)); } sb.append("</celldesigner:listOfComplexSpeciesAliases>\n"); @@ -166,14 +166,14 @@ public class AliasCollectionXmlParser extends XmlParser { * @throws InvalidXmlSchemaException * thrown when xmlString is invalid */ - public List<CompartmentAlias> parseXmlCompartmentAliasCollection(Node aliasListNode) throws InvalidXmlSchemaException { - List<CompartmentAlias> result = new ArrayList<CompartmentAlias>(); + public List<Compartment> parseXmlCompartmentAliasCollection(Node aliasListNode) throws InvalidXmlSchemaException { + List<Compartment> result = new ArrayList<Compartment>(); NodeList nodes = aliasListNode.getChildNodes(); for (int x = 0; x < nodes.getLength(); x++) { Node node = nodes.item(x); if (node.getNodeType() == Node.ELEMENT_NODE) { if (node.getNodeName().equalsIgnoreCase("celldesigner:compartmentAlias")) { - CompartmentAlias alias = compartmentAliasParser.parseXmlAlias(node); + Compartment alias = compartmentAliasParser.parseXmlAlias(node); result.add(alias); } else { @@ -191,11 +191,11 @@ public class AliasCollectionXmlParser extends XmlParser { * collection of CompartmentAlias * @return xml string representing collection of CompartmentAlias */ - public String compartmentAliasCollectionToXmlString(Collection<CompartmentAlias> collection) { + public String compartmentAliasCollectionToXmlString(Collection<Compartment> collection) { StringBuilder sb = new StringBuilder("<celldesigner:listOfCompartmentAliases>\n"); - for (CompartmentAlias alias : collection) { + for (Compartment alias : collection) { // artifitial compartment aliases cannot be exported - if (!(alias instanceof ArtifitialCompartmentAlias)) { + if (!(alias instanceof PathwayCompartment)) { sb.append(compartmentAliasParser.toXml(alias)); } } 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 b3a9c6865b..47d06cb3a5 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 @@ -7,14 +7,14 @@ import org.w3c.dom.NodeList; import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection; -import lcsb.mapviewer.converter.model.celldesigner.structure.Compartment; -import lcsb.mapviewer.model.map.layout.alias.BottomSquareCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.LeftSquareCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.OvalCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.RightSquareCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.SquareCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.TopSquareCompartmentAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerCompartment; +import lcsb.mapviewer.model.map.compartment.BottomSquareCompartment; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.compartment.LeftSquareCompartment; +import lcsb.mapviewer.model.map.compartment.OvalCompartment; +import lcsb.mapviewer.model.map.compartment.RightSquareCompartment; +import lcsb.mapviewer.model.map.compartment.SquareCompartment; +import lcsb.mapviewer.model.map.compartment.TopSquareCompartment; import lcsb.mapviewer.model.map.model.Model; /** @@ -23,7 +23,7 @@ import lcsb.mapviewer.model.map.model.Model; * @author Piotr Gawron * */ -public class CompartmentAliasXmlParser extends AbstractAliasXmlParser<CompartmentAlias> { +public class CompartmentAliasXmlParser extends AbstractAliasXmlParser<Compartment> { /** * Default class logger. @@ -50,15 +50,15 @@ public class CompartmentAliasXmlParser extends AbstractAliasXmlParser<Compartmen } @Override - CompartmentAlias parseXmlAlias(Node aliasNode) throws InvalidXmlSchemaException { + Compartment parseXmlAlias(Node aliasNode) throws InvalidXmlSchemaException { String compartmentId = getNodeAttr("compartment", aliasNode); - Compartment compartment = elements.getCompartmentByCompartmentId(compartmentId); + CellDesignerCompartment compartment = elements.getCompartmentByCompartmentId(compartmentId); if (compartment == null) { throw new InvalidXmlSchemaException("Compartment does not exist in a model: " + compartmentId); } String aliasId = getNodeAttr("id", aliasNode); - CompartmentAlias result = compartment.createAlias(aliasId); + Compartment result = compartment.createAlias(aliasId); NodeList nodes = aliasNode.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { @@ -67,17 +67,17 @@ public class CompartmentAliasXmlParser extends AbstractAliasXmlParser<Compartmen if (node.getNodeName().equalsIgnoreCase("celldesigner:class")) { String type = getNodeValue(node); if (type.equalsIgnoreCase("SQUARE")) { - result = new SquareCompartmentAlias(result); + result = new SquareCompartment(result); } else if (type.equalsIgnoreCase("SQUARE_CLOSEUP_NORTH")) { - result = new BottomSquareCompartmentAlias(result, model); + result = new BottomSquareCompartment(result, model); } else if (type.equalsIgnoreCase("SQUARE_CLOSEUP_SOUTH")) { - result = new TopSquareCompartmentAlias(result, model); + result = new TopSquareCompartment(result, model); } else if (type.equalsIgnoreCase("SQUARE_CLOSEUP_WEST")) { - result = new RightSquareCompartmentAlias(result, model); + result = new RightSquareCompartment(result, model); } else if (type.equalsIgnoreCase("SQUARE_CLOSEUP_EAST")) { - result = new LeftSquareCompartmentAlias(result, model); + result = new LeftSquareCompartment(result, model); } else if (type.equalsIgnoreCase("OVAL")) { - result = new OvalCompartmentAlias(result); + result = new OvalCompartment(result); } else { throw new InvalidXmlSchemaException("Unknown compartment type: " + type); } @@ -96,14 +96,14 @@ public class CompartmentAliasXmlParser extends AbstractAliasXmlParser<Compartmen // not handled continue; } else if (node.getNodeName().equalsIgnoreCase("celldesigner:point")) { - if (result instanceof BottomSquareCompartmentAlias) { + if (result instanceof BottomSquareCompartment) { result.setY(getNodeAttr("y", node)); - } else if (result instanceof LeftSquareCompartmentAlias) { + } else if (result instanceof LeftSquareCompartment) { result.setX(getNodeAttr("x", node)); - } else if (result instanceof RightSquareCompartmentAlias) { + } else if (result instanceof RightSquareCompartment) { result.setX(getNodeAttr("x", node)); result.setWidth(result.getWidth() - result.getX()); - } else if (result instanceof TopSquareCompartmentAlias) { + } else if (result instanceof TopSquareCompartment) { result.setY(getNodeAttr("y", node)); } else { throw new InvalidXmlSchemaException("Don't know what to do with celldesigner:point for class: " + result.getClass()); @@ -119,7 +119,7 @@ public class CompartmentAliasXmlParser extends AbstractAliasXmlParser<Compartmen } @Override - public String toXml(CompartmentAlias alias) { + public String toXml(Compartment alias) { StringBuilder sb = new StringBuilder(""); sb.append("<celldesigner:compartmentAlias "); @@ -128,23 +128,23 @@ public class CompartmentAliasXmlParser extends AbstractAliasXmlParser<Compartmen boolean bounds = true; - if (alias.getClass().getName().equals(SquareCompartmentAlias.class.getName())) { + if (alias.getClass().getName().equals(SquareCompartment.class.getName())) { sb.append("<celldesigner:class>SQUARE</celldesigner:class>\n"); - } else if (alias.getClass().getName().equals(OvalCompartmentAlias.class.getName())) { + } else if (alias.getClass().getName().equals(OvalCompartment.class.getName())) { sb.append("<celldesigner:class>OVAL</celldesigner:class>\n"); - } else if (alias.getClass().getName().equals(BottomSquareCompartmentAlias.class.getName())) { + } else if (alias.getClass().getName().equals(BottomSquareCompartment.class.getName())) { sb.append("<celldesigner:class>SQUARE_CLOSEUP_NORTH</celldesigner:class>\n"); bounds = false; sb.append("<celldesigner:point x=\"10\" y=\"" + alias.getY() + "\"/>"); - } else if (alias.getClass().getName().equals(TopSquareCompartmentAlias.class.getName())) { + } else if (alias.getClass().getName().equals(TopSquareCompartment.class.getName())) { sb.append("<celldesigner:class>SQUARE_CLOSEUP_SOUTH</celldesigner:class>\n"); bounds = false; sb.append("<celldesigner:point x=\"10\" y=\"" + alias.getY() + "\"/>"); - } else if (alias.getClass().getName().equals(LeftSquareCompartmentAlias.class.getName())) { + } else if (alias.getClass().getName().equals(LeftSquareCompartment.class.getName())) { sb.append("<celldesigner:class>SQUARE_CLOSEUP_EAST</celldesigner:class>\n"); bounds = false; sb.append("<celldesigner:point x=\"" + alias.getWidth() + "\" y=\"10\"/>"); - } else if (alias.getClass().getName().equals(RightSquareCompartmentAlias.class.getName())) { + } else if (alias.getClass().getName().equals(RightSquareCompartment.class.getName())) { sb.append("<celldesigner:class>SQUARE_CLOSEUP_WEST</celldesigner:class>\n"); bounds = false; sb.append("<celldesigner:point x=\"" + alias.getX() + "\" y=\"10\"/>"); 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 20d178c1f9..ae29b5a2fa 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 @@ -11,14 +11,14 @@ import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection; -import lcsb.mapviewer.converter.model.celldesigner.structure.ComplexSpecies; -import lcsb.mapviewer.converter.model.celldesigner.structure.View; -import lcsb.mapviewer.model.map.layout.alias.ArtifitialCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerComplexSpecies; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.View; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.compartment.PathwayCompartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelData; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Species; /** * Parser of CellDesigner xml used for parsing complex aliases. Important: Only @@ -26,9 +26,9 @@ import lcsb.mapviewer.model.map.model.ModelData; * * @author Piotr Gawron * - * @see ComplexAlias + * @see Complex */ -public class ComplexAliasXmlParser extends AbstractAliasXmlParser<ComplexAlias> { +public class ComplexAliasXmlParser extends AbstractAliasXmlParser<Complex> { /** * Default class logger. @@ -41,7 +41,7 @@ public class ComplexAliasXmlParser extends AbstractAliasXmlParser<ComplexAlias> * all processed Complexes. This infomrmation later on is used for connecting * complexes in hierarchical view. */ - private Map<String, ComplexAlias> complexAliasesMapById = new HashMap<String, ComplexAlias>(); + private Map<String, Complex> complexAliasesMapById = new HashMap<String, Complex>(); /** * Because of the CellDesigner xml model we have to store information about @@ -70,16 +70,16 @@ public class ComplexAliasXmlParser extends AbstractAliasXmlParser<ComplexAlias> } @Override - ComplexAlias parseXmlAlias(Node aliasNode) throws InvalidXmlSchemaException { + Complex parseXmlAlias(Node aliasNode) throws InvalidXmlSchemaException { String aliasId = getNodeAttr("id", aliasNode); String speciesId = getNodeAttr("species", aliasNode); - ComplexSpecies species = (ComplexSpecies) elements.getSpeciesBySpeciesId(speciesId); + CellDesignerComplexSpecies species = (CellDesignerComplexSpecies) elements.getSpeciesBySpeciesId(speciesId); if (species == null) { throw new InvalidXmlSchemaException("No species with id=\"" + speciesId + "\" for complex alias \"" + aliasId + "\""); } - ComplexAlias result = species.createAlias(aliasId); + Complex result = species.createAlias(aliasId); String state = "usual"; NodeList nodes = aliasNode.getChildNodes(); @@ -140,7 +140,7 @@ public class ComplexAliasXmlParser extends AbstractAliasXmlParser<ComplexAlias> result.setState(state); String compartmentAliasId = getNodeAttr("compartmentAlias", aliasNode); if (!compartmentAliasId.isEmpty()) { - CompartmentAlias ca = model.getCompartmentAliasByCompartmentAliasId(compartmentAliasId); + Compartment ca = model.getCompartmentAliasByCompartmentAliasId(compartmentAliasId); if (ca == null) { throw new InvalidXmlSchemaException("CompartmentAlias does not exist: " + compartmentAliasId); } else { @@ -164,7 +164,7 @@ public class ComplexAliasXmlParser extends AbstractAliasXmlParser<ComplexAlias> * @param alias * alias object to be modified if necessary */ - private void processAliasState(Node node, SpeciesAlias alias) { + private void processAliasState(Node node, Species alias) { String state = getNodeAttr("state", node); if ("open".equalsIgnoreCase(state)) { String prefix = getNodeAttr("prefix", node); @@ -187,10 +187,10 @@ public class ComplexAliasXmlParser extends AbstractAliasXmlParser<ComplexAlias> * @param alias * alias for which we want to add parent information */ - public void addReference(ComplexAlias alias) { + public void addReference(Complex alias) { String parentId = parents.get(alias.getAliasId()); if (parentId != null) { - ComplexAlias ca = complexAliasesMapById.get(parentId); + Complex ca = complexAliasesMapById.get(parentId); if (ca == null) { throw new InvalidArgumentException("Parent complex alias does not exist: " + parentId + " for alias: " + alias.getAliasId()); } else { @@ -201,19 +201,19 @@ public class ComplexAliasXmlParser extends AbstractAliasXmlParser<ComplexAlias> } @Override - public String toXml(ComplexAlias alias) { - CompartmentAlias ca = null; + public String toXml(Complex alias) { + Compartment ca = null; // we have to exclude artifitial compartment aliases, becuase they aren't // exported to CellDesigner file - if (alias.getParent() instanceof CompartmentAlias && !(alias.getParent() instanceof ArtifitialCompartmentAlias)) { - ca = (CompartmentAlias) alias.getParent(); - } else if (alias.getCompartmentAlias() != null && !(alias.getCompartmentAlias() instanceof ArtifitialCompartmentAlias)) { + if (alias.getParent() instanceof Compartment && !(alias.getParent() instanceof PathwayCompartment)) { + ca = (Compartment) alias.getParent(); + } else if (alias.getCompartmentAlias() != null && !(alias.getCompartmentAlias() instanceof PathwayCompartment)) { ca = alias.getCompartmentAlias(); } else if (alias.getComplexAlias() == null) { ModelData modelData = alias.getModelData(); if (modelData != null) { - for (CompartmentAlias cAlias : modelData.getModel().getCompartmentsAliases()) { - if (!(cAlias instanceof ArtifitialCompartmentAlias) && cAlias.cross(alias)) { + for (Compartment cAlias : modelData.getModel().getCompartmentsAliases()) { + if (!(cAlias instanceof PathwayCompartment) && cAlias.cross(alias)) { if (ca == null) { ca = cAlias; } else if (ca.getSize() > cAlias.getSize()) { @@ -224,9 +224,9 @@ public class ComplexAliasXmlParser extends AbstractAliasXmlParser<ComplexAlias> } } - ComplexAlias complexAlias = null; - if (alias.getParent() instanceof ComplexAlias) { - complexAlias = (ComplexAlias) alias.getParent(); + Complex complexAlias = null; + if (alias.getParent() instanceof Complex) { + complexAlias = (Complex) alias.getParent(); } String compartmentAliasId = null; 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 4fb76150be..f72a2f4d4d 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 @@ -7,24 +7,24 @@ import org.w3c.dom.NodeList; import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection; -import lcsb.mapviewer.converter.model.celldesigner.structure.ComplexSpecies; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; -import lcsb.mapviewer.converter.model.celldesigner.structure.View; -import lcsb.mapviewer.model.map.layout.alias.ArtifitialCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerComplexSpecies; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.View; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.compartment.PathwayCompartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelData; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Species; /** * Parser of CellDesigner xml used for parsing SpeciesAlias. * * @author Piotr Gawron * - * @see ComplexAlias + * @see Complex */ -public class SpeciesAliasXmlParser extends AbstractAliasXmlParser<SpeciesAlias> { +public class SpeciesAliasXmlParser extends AbstractAliasXmlParser<Species> { /** * Default class logger. */ @@ -46,19 +46,19 @@ public class SpeciesAliasXmlParser extends AbstractAliasXmlParser<SpeciesAlias> } @Override - SpeciesAlias parseXmlAlias(Node aliasNode) throws InvalidXmlSchemaException { + Species parseXmlAlias(Node aliasNode) throws InvalidXmlSchemaException { String speciesId = getNodeAttr("species", aliasNode); String aliasId = getNodeAttr("id", aliasNode); - Species species = elements.getSpeciesBySpeciesId(speciesId); + CellDesignerSpecies<?> species = elements.getSpeciesBySpeciesId(speciesId); if (species == null) { throw new InvalidXmlSchemaException("Unknown species for alias (speciesId: " + speciesId + ")"); } - if (species instanceof ComplexSpecies) { + if (species instanceof CellDesignerComplexSpecies) { logger.warn("[" + speciesId + "," + aliasId + "]\tSpecies is defined as a complex, but alias is not a complex. Changing alias to complex."); } - SpeciesAlias result = species.createAlias(aliasId); + Species result = species.createAlias(aliasId); String state = "usual"; NodeList nodes = aliasNode.getChildNodes(); @@ -111,7 +111,7 @@ public class SpeciesAliasXmlParser extends AbstractAliasXmlParser<SpeciesAlias> result.setState(state); String compartmentAliasId = getNodeAttr("compartmentAlias", aliasNode); if (!compartmentAliasId.isEmpty()) { - CompartmentAlias ca = model.getCompartmentAliasByCompartmentAliasId(compartmentAliasId); + Compartment ca = model.getCompartmentAliasByCompartmentAliasId(compartmentAliasId); if (ca == null) { throw new InvalidXmlSchemaException("CompartmentAlias does not exist: " + compartmentAliasId); } else { @@ -121,7 +121,7 @@ public class SpeciesAliasXmlParser extends AbstractAliasXmlParser<SpeciesAlias> } String complexAliasId = getNodeAttr("complexSpeciesAlias", aliasNode); if (!complexAliasId.isEmpty()) { - ComplexAlias alias = (ComplexAlias) model.getAliasByAliasId(complexAliasId); + Complex alias = (Complex) model.getAliasByAliasId(complexAliasId); if (alias == null) { throw new InvalidXmlSchemaException("ComplexAlias does not exist: " + complexAliasId + ", current: " + result.getAliasId()); } else { @@ -140,7 +140,7 @@ public class SpeciesAliasXmlParser extends AbstractAliasXmlParser<SpeciesAlias> * @param alias * alias object to be modified if necessary */ - private void processAliasState(Node node, SpeciesAlias alias) { + private void processAliasState(Node node, Species alias) { String state = getNodeAttr("state", node); if ("open".equalsIgnoreCase(state)) { String prefix = getNodeAttr("prefix", node); @@ -158,16 +158,16 @@ public class SpeciesAliasXmlParser extends AbstractAliasXmlParser<SpeciesAlias> } @Override - public String toXml(SpeciesAlias alias) { - CompartmentAlias ca = null; + public String toXml(Species alias) { + Compartment ca = null; // artifitial compartment aliases should be excluded - if (alias.getParent() instanceof CompartmentAlias && !(alias.getParent() instanceof ArtifitialCompartmentAlias)) { - ca = (CompartmentAlias) alias.getParent(); + if (alias.getParent() instanceof Compartment && !(alias.getParent() instanceof PathwayCompartment)) { + ca = (Compartment) alias.getParent(); } else if (alias.getComplexAlias() == null) { ModelData model = alias.getModelData(); if (model != null) { - for (CompartmentAlias cAlias : model.getModel().getCompartmentsAliases()) { - if (!(cAlias instanceof ArtifitialCompartmentAlias) && cAlias.cross(alias)) { + for (Compartment cAlias : model.getModel().getCompartmentsAliases()) { + if (!(cAlias instanceof PathwayCompartment) && cAlias.cross(alias)) { if (ca == null) { ca = cAlias; } else if (ca.getSize() > cAlias.getSize()) { @@ -178,9 +178,9 @@ public class SpeciesAliasXmlParser extends AbstractAliasXmlParser<SpeciesAlias> } } - ComplexAlias complexAlias = null; - if (alias.getParent() instanceof ComplexAlias) { - complexAlias = (ComplexAlias) alias.getParent(); + Complex complexAlias = null; + if (alias.getParent() instanceof Complex) { + complexAlias = (Complex) alias.getParent(); } String compartmentAliasId = null; diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/annotation/NoteField.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/annotation/NoteField.java index f64ef822ac..db00f59da0 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/annotation/NoteField.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/annotation/NoteField.java @@ -1,7 +1,7 @@ package lcsb.mapviewer.converter.model.celldesigner.annotation; -import lcsb.mapviewer.converter.model.celldesigner.structure.Element; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerElement; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.reaction.Reaction; @@ -51,12 +51,12 @@ public enum NoteField { /** * {@link Element#symbol}. */ - SYMBOL("Symbol", Element.class, null), // + SYMBOL("Symbol", CellDesignerElement.class, null), // /** * {@link Element#fullName}. */ - NAME("Name", Element.class, null), // + NAME("Name", CellDesignerElement.class, null), // /** * {@link Element#notes} or {@link Reaction#notes} . @@ -66,7 +66,7 @@ public enum NoteField { /** * {@link Element#formerSymbols}. */ - PREVIOUS_SYMBOLS("Previous Symbols", Element.class, null), // + PREVIOUS_SYMBOLS("Previous Symbols", CellDesignerElement.class, null), // /** * {@link Element#synonyms} or {@link Reaction#synonyms}. @@ -111,12 +111,12 @@ public enum NoteField { /** * {@link Element#formula}. */ - CHARGED_FORMULA("ChargedFormula", Element.class, null), // + CHARGED_FORMULA("ChargedFormula", CellDesignerElement.class, null), // /** * {@link Species#charge}. */ - CHARGE("Charge", Species.class, null); // + CHARGE("Charge", CellDesignerSpecies.class, null); // /** * Name used in the notes to distinguish fields. diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/annotation/RestAnnotationParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/annotation/RestAnnotationParser.java index 40d0164073..b938e0ed8d 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/annotation/RestAnnotationParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/annotation/RestAnnotationParser.java @@ -25,9 +25,9 @@ import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamRelationType; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.modelutils.map.ElementUtils; /** @@ -99,7 +99,7 @@ public class RestAnnotationParser extends XmlParser { * element for which notes are created * @return note string with structural information about element */ - public String createAnnotationString(Alias element) { + public String createAnnotationString(Element element) { String symbol = element.getSymbol(); if (symbol == null) { symbol = ""; @@ -319,7 +319,7 @@ public class RestAnnotationParser extends XmlParser { * @param annotationString * notes string */ - private void setFormerSymbolsToSpecies(Alias element, String annotationString) { + private void setFormerSymbolsToSpecies(Element element, String annotationString) { List<String> formerSymbols = getFormerSymbols(annotationString); if (formerSymbols.size() == 0) { return; @@ -344,7 +344,7 @@ public class RestAnnotationParser extends XmlParser { * @param annotationString * notes string */ - private void setFullNameToSpecies(Alias element, String annotationString) { + private void setFullNameToSpecies(Element element, String annotationString) { StringComparator stringComparator = new StringComparator(); String fullName = getParamByPrefix(annotationString, NoteField.NAME.getCommonName() + ":"); if (fullName == null) { @@ -480,7 +480,7 @@ public class RestAnnotationParser extends XmlParser { * @param annotationString * notes string */ - private void setCharge(SpeciesAlias element, String annotationString) { + private void setCharge(Species element, String annotationString) { IntegerComparator integerComparator = new IntegerComparator(); String value = getParamByPrefix(annotationString, NoteField.CHARGE.getCommonName() + ":"); if (value == null || value.trim().equals("") || value.trim().equals("-")) { @@ -634,11 +634,11 @@ public class RestAnnotationParser extends XmlParser { setUpperBoundToReaction(reaction, ann); setSubsystemToReaction(reaction, ann); setGeneProteinReactionToReaction(reaction, ann); - } else if (object instanceof Alias) { - setFullNameToSpecies((Alias) object, ann); - setFormerSymbolsToSpecies((Alias) object, ann); - if (object instanceof SpeciesAlias) { - setCharge((SpeciesAlias) object, ann); + } else if (object instanceof Element) { + setFullNameToSpecies((Element) object, ann); + setFormerSymbolsToSpecies((Element) object, ann); + if (object instanceof Species) { + setCharge((Species) object, ann); } } else { throw new NotImplementedException("Don't know how to process class: " + object.getClass()); @@ -674,7 +674,7 @@ public class RestAnnotationParser extends XmlParser { } } - public void processNotes(Alias alias) { + public void processNotes(Element alias) { processNotes(alias.getNotes(), alias); } } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/compartment/CompartmentCollectionXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/compartment/CompartmentCollectionXmlParser.java index 8cf2978af5..fd8b7d2abf 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/compartment/CompartmentCollectionXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/compartment/CompartmentCollectionXmlParser.java @@ -12,8 +12,8 @@ import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.common.XmlParser; import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection; -import lcsb.mapviewer.converter.model.celldesigner.structure.Compartment; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerCompartment; +import lcsb.mapviewer.model.map.compartment.Compartment; /** * CellDEsigner xml parser for collection of compartments. @@ -27,20 +27,17 @@ public class CompartmentCollectionXmlParser extends XmlParser { * Default class logger. */ @SuppressWarnings("unused") - private Logger logger = Logger.getLogger(CompartmentCollectionXmlParser.class.getName()); + private Logger logger = Logger.getLogger(CompartmentCollectionXmlParser.class.getName()); /** * CellDesigner xml parser for single compartment. */ - private CompartmentXmlParser compartmentParser; - - private CellDesignerElementCollection elements; + private CompartmentXmlParser compartmentParser; /** * Default constructor. */ public CompartmentCollectionXmlParser(CellDesignerElementCollection elements) { - this.elements = elements; compartmentParser = new CompartmentXmlParser(elements); } @@ -53,14 +50,14 @@ public class CompartmentCollectionXmlParser extends XmlParser { * @throws InvalidXmlSchemaException * thrown when there is a problem with xml */ - public List<Compartment> parseXmlCompartmentCollection(Node compartmentsNode) throws InvalidXmlSchemaException { - List<Compartment> result = new ArrayList<Compartment>(); + public List<CellDesignerCompartment> parseXmlCompartmentCollection(Node compartmentsNode) throws InvalidXmlSchemaException { + List<CellDesignerCompartment> result = new ArrayList<CellDesignerCompartment>(); NodeList nodes = compartmentsNode.getChildNodes(); for (int x = 0; x < nodes.getLength(); x++) { Node node = nodes.item(x); if (node.getNodeType() == Node.ELEMENT_NODE) { if (node.getNodeName().equalsIgnoreCase("compartment")) { - Pair<String, Compartment> compartmentPair = compartmentParser.parseXmlElement(node); + Pair<String, CellDesignerCompartment> compartmentPair = compartmentParser.parseXmlElement(node); result.add(compartmentPair.getRight()); } else { throw new InvalidXmlSchemaException("Unknown element of model/listOfCompartments: " + node.getNodeName()); @@ -77,10 +74,10 @@ public class CompartmentCollectionXmlParser extends XmlParser { * collection of compartments to be transformed into xml * @return xml representation of the compartments */ - public String toXml(Collection<CompartmentAlias> collection) { + public String toXml(Collection<Compartment> collection) { String result = ""; result += "<listOfCompartments>\n"; - for (CompartmentAlias compartment : collection) { + for (Compartment compartment : collection) { result += compartmentParser.toXml(compartment); } result += "</listOfCompartments>\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 ca0cbbbe61..c1ba9e05a9 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 @@ -9,8 +9,8 @@ import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection; import lcsb.mapviewer.converter.model.celldesigner.annotation.XmlAnnotationParser; import lcsb.mapviewer.converter.model.celldesigner.species.AbstractElementXmlParser; -import lcsb.mapviewer.converter.model.celldesigner.structure.Compartment; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerCompartment; +import lcsb.mapviewer.model.map.compartment.Compartment; /** * Parser of CellDesginer xml nodes for compartment elements. @@ -18,7 +18,7 @@ import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; * @author Piotr Gawron * */ -public class CompartmentXmlParser extends AbstractElementXmlParser<Compartment, CompartmentAlias> { +public class CompartmentXmlParser extends AbstractElementXmlParser<CellDesignerCompartment, Compartment> { /** * Default class logger. @@ -38,8 +38,8 @@ public class CompartmentXmlParser extends AbstractElementXmlParser<Compartment, } @Override - public Pair<String, Compartment> parseXmlElement(Node compartmentNode) throws InvalidXmlSchemaException { - Compartment compartment = new Compartment(); + public Pair<String, CellDesignerCompartment> parseXmlElement(Node compartmentNode) throws InvalidXmlSchemaException { + CellDesignerCompartment compartment = new CellDesignerCompartment(); // we ignore metaid - it's useless and obstruct data model // compartment.setMetaId(getNodeAttr("metaid", compartmentNode)); compartment.setElementId(getNodeAttr("id", compartmentNode)); @@ -55,7 +55,7 @@ public class CompartmentXmlParser extends AbstractElementXmlParser<Compartment, } } } - return new Pair<String, Compartment>(compartment.getElementId(), compartment); + return new Pair<String, CellDesignerCompartment>(compartment.getElementId(), compartment); } /** @@ -68,7 +68,7 @@ public class CompartmentXmlParser extends AbstractElementXmlParser<Compartment, * @throws InvalidXmlSchemaException * thrown when there is a problem with xml */ - private void parseAnnotationNode(Compartment compartment, Node xmlNode) throws InvalidXmlSchemaException { + private void parseAnnotationNode(CellDesignerCompartment compartment, Node xmlNode) throws InvalidXmlSchemaException { NodeList annotationNodes = xmlNode.getChildNodes(); for (int y = 0; y < annotationNodes.getLength(); y++) { Node annotationNode = annotationNodes.item(y); @@ -94,7 +94,7 @@ public class CompartmentXmlParser extends AbstractElementXmlParser<Compartment, * @throws InvalidXmlSchemaException * thrown when xmlNode is invalid */ - private void parseExtensionNode(Compartment compartment, Node xmlNode) throws InvalidXmlSchemaException { + private void parseExtensionNode(CellDesignerCompartment compartment, Node xmlNode) throws InvalidXmlSchemaException { NodeList annotationNodes = xmlNode.getChildNodes(); for (int y = 0; y < annotationNodes.getLength(); y++) { Node annotationNode = annotationNodes.item(y); @@ -110,7 +110,7 @@ public class CompartmentXmlParser extends AbstractElementXmlParser<Compartment, } @Override - public String toXml(CompartmentAlias compartment) { + public String toXml(Compartment compartment) { StringBuilder sb = new StringBuilder(""); sb.append("<compartment "); sb.append("metaid=\"" + elements.getElementId(compartment) + "\" "); diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AbstractCellDesignerAliasConverter.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AbstractCellDesignerAliasConverter.java index 6ef03b86f2..0c70c484da 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AbstractCellDesignerAliasConverter.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AbstractCellDesignerAliasConverter.java @@ -12,7 +12,7 @@ import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerE import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerPolygonTransformation; import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerRectangleTransformation; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.Alias; +import lcsb.mapviewer.model.map.species.Element; /** * This abstract class is an interface for setting up graphical data for alias @@ -22,7 +22,7 @@ import lcsb.mapviewer.model.map.layout.alias.Alias; * * @param <T> */ -public abstract class AbstractCellDesignerAliasConverter<T extends Alias> implements ICellDesignerAliasConverter<T> { +public abstract class AbstractCellDesignerAliasConverter<T extends Element> implements ICellDesignerAliasConverter<T> { /** * Default class logger. diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AntisenseRnaCellDesignerAliasConverter.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AntisenseRnaCellDesignerAliasConverter.java index bd881768e3..946fc4ab37 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AntisenseRnaCellDesignerAliasConverter.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AntisenseRnaCellDesignerAliasConverter.java @@ -1,109 +1,109 @@ -package lcsb.mapviewer.converter.model.celldesigner.geometry; - -import java.awt.geom.AffineTransform; -import java.awt.geom.GeneralPath; -import java.awt.geom.PathIterator; -import java.awt.geom.Point2D; -import java.util.ArrayList; - -import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; - -/** - * Class that provides CellDesigner specific graphical information for - * AntisenseRna. It's used for conversion from xml to normal x,y coordinates. - * - * @author Piotr Gawron - * - */ -public class AntisenseRnaCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<SpeciesAlias> { - - /** - * How big should be the arc in rectangle for nucleic acid feature representation. - */ - private static final int RECTANGLE_CORNER_ARC_SIZE = 5; - - @Override - public Point2D getPointCoordinates(SpeciesAlias alias, CellDesignerAnchor anchor) { - if (invalidAnchorPosition(alias, anchor)) { - return alias.getCenter(); - } - if (alias.getModel().isSbgnFormat()) { - return getRectangleTransformation().getPointOnRectangleByAnchor(alias.getX(), alias.getY(), - alias.getWidth(), alias.getHeight(), anchor); - } - ArrayList<Point2D> points = getPoints(alias); - return getPolygonTransformation().getPointOnPolygonByAnchor(points, anchor); - } - - @Override - protected PathIterator getBoundPathIterator(SpeciesAlias alias) { - return getAntisebseRnaPath(alias).getPathIterator(new AffineTransform()); - } - - /** - * Returns shape of the AntisenseRna as a list of points. - * - * @param alias - * alias for which we are looking for a border - * @return list of points defining border of the given alias - */ - private ArrayList<Point2D> getPoints(Alias alias) { - double x = alias.getX(); - double y = alias.getY(); - double width = alias.getWidth(); - double height = alias.getHeight(); - ArrayList<Point2D> points = new ArrayList<Point2D>(); - - // CHECKSTYLE:OFF - points.add(new Point2D.Double(x + width / 8, y + height / 2)); - points.add(new Point2D.Double(x, y)); - points.add(new Point2D.Double(x + width * 3 / 8, y)); - points.add(new Point2D.Double(x + width * 3 / 4, y)); - points.add(new Point2D.Double(x + width * 7 / 8, y + height / 2)); - points.add(new Point2D.Double(x + width, y + height)); - points.add(new Point2D.Double(x + width * 5 / 8, y + height)); - points.add(new Point2D.Double(x + width / 4, y + height)); - // CHECKSTYLE:ON - return points; - } - - /** - * Returns shape of the AntisenseRna as a GeneralPath object. - * - * @param alias - * alias for which we are looking for a border - * @return GeneralPath object defining border of the given alias - */ - private GeneralPath getAntisebseRnaPath(Alias alias) { - // CHECKSTYLE:OFF - GeneralPath path; - if (!alias.getModel().isSbgnFormat()) { - path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 4); - path.moveTo(alias.getX(), alias.getY()); - path.lineTo(alias.getX() + alias.getWidth() * 3 / 4, alias.getY()); - path.lineTo(alias.getX() + alias.getWidth(), alias.getY() + alias.getHeight()); - path.lineTo(alias.getX() + alias.getWidth() / 4, alias.getY() + alias.getHeight()); - path.closePath(); - } else { - path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 6); - double x = alias.getX(), y = alias.getY(), width = alias.getWidth(), height = alias.getHeight(); - - path.moveTo(x, y); - path.lineTo(x, y + height - RECTANGLE_CORNER_ARC_SIZE); - path.curveTo(x, y + height, - x + RECTANGLE_CORNER_ARC_SIZE, y + height, - x + RECTANGLE_CORNER_ARC_SIZE, y + height); - path.lineTo(x + width - RECTANGLE_CORNER_ARC_SIZE, y + height); - path.curveTo(x + width, y + height, - x + width, y + height - RECTANGLE_CORNER_ARC_SIZE, - x + width, y + height - RECTANGLE_CORNER_ARC_SIZE); - path.lineTo(x + width, y); - path.closePath(); - } - // CHECKSTYLE:ON - return path; - } - -} +package lcsb.mapviewer.converter.model.celldesigner.geometry; + +import java.awt.geom.AffineTransform; +import java.awt.geom.GeneralPath; +import java.awt.geom.PathIterator; +import java.awt.geom.Point2D; +import java.util.ArrayList; + +import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; + +/** + * Class that provides CellDesigner specific graphical information for + * AntisenseRna. It's used for conversion from xml to normal x,y coordinates. + * + * @author Piotr Gawron + * + */ +public class AntisenseRnaCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<Species> { + + /** + * How big should be the arc in rectangle for nucleic acid feature representation. + */ + private static final int RECTANGLE_CORNER_ARC_SIZE = 5; + + @Override + public Point2D getPointCoordinates(Species alias, CellDesignerAnchor anchor) { + if (invalidAnchorPosition(alias, anchor)) { + return alias.getCenter(); + } + if (alias.getModel().isSbgnFormat()) { + return getRectangleTransformation().getPointOnRectangleByAnchor(alias.getX(), alias.getY(), + alias.getWidth(), alias.getHeight(), anchor); + } + ArrayList<Point2D> points = getPoints(alias); + return getPolygonTransformation().getPointOnPolygonByAnchor(points, anchor); + } + + @Override + protected PathIterator getBoundPathIterator(Species alias) { + return getAntisebseRnaPath(alias).getPathIterator(new AffineTransform()); + } + + /** + * Returns shape of the AntisenseRna as a list of points. + * + * @param alias + * alias for which we are looking for a border + * @return list of points defining border of the given alias + */ + private ArrayList<Point2D> getPoints(Element alias) { + double x = alias.getX(); + double y = alias.getY(); + double width = alias.getWidth(); + double height = alias.getHeight(); + ArrayList<Point2D> points = new ArrayList<Point2D>(); + + // CHECKSTYLE:OFF + points.add(new Point2D.Double(x + width / 8, y + height / 2)); + points.add(new Point2D.Double(x, y)); + points.add(new Point2D.Double(x + width * 3 / 8, y)); + points.add(new Point2D.Double(x + width * 3 / 4, y)); + points.add(new Point2D.Double(x + width * 7 / 8, y + height / 2)); + points.add(new Point2D.Double(x + width, y + height)); + points.add(new Point2D.Double(x + width * 5 / 8, y + height)); + points.add(new Point2D.Double(x + width / 4, y + height)); + // CHECKSTYLE:ON + return points; + } + + /** + * Returns shape of the AntisenseRna as a GeneralPath object. + * + * @param alias + * alias for which we are looking for a border + * @return GeneralPath object defining border of the given alias + */ + private GeneralPath getAntisebseRnaPath(Element alias) { + // CHECKSTYLE:OFF + GeneralPath path; + if (!alias.getModel().isSbgnFormat()) { + path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 4); + path.moveTo(alias.getX(), alias.getY()); + path.lineTo(alias.getX() + alias.getWidth() * 3 / 4, alias.getY()); + path.lineTo(alias.getX() + alias.getWidth(), alias.getY() + alias.getHeight()); + path.lineTo(alias.getX() + alias.getWidth() / 4, alias.getY() + alias.getHeight()); + path.closePath(); + } else { + path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 6); + double x = alias.getX(), y = alias.getY(), width = alias.getWidth(), height = alias.getHeight(); + + path.moveTo(x, y); + path.lineTo(x, y + height - RECTANGLE_CORNER_ARC_SIZE); + path.curveTo(x, y + height, + x + RECTANGLE_CORNER_ARC_SIZE, y + height, + x + RECTANGLE_CORNER_ARC_SIZE, y + height); + path.lineTo(x + width - RECTANGLE_CORNER_ARC_SIZE, y + height); + path.curveTo(x + width, y + height, + x + width, y + height - RECTANGLE_CORNER_ARC_SIZE, + x + width, y + height - RECTANGLE_CORNER_ARC_SIZE); + path.lineTo(x + width, y); + path.closePath(); + } + // CHECKSTYLE:ON + return path; + } + +} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/CellDesignerAliasConverter.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/CellDesignerAliasConverter.java index 4328d77ca5..fe8993bbdd 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/CellDesignerAliasConverter.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/CellDesignerAliasConverter.java @@ -7,21 +7,21 @@ import java.util.Map; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.DegradedAlias; -import lcsb.mapviewer.model.map.layout.alias.DrugAlias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.IonAlias; -import lcsb.mapviewer.model.map.layout.alias.IonChannelProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias; -import lcsb.mapviewer.model.map.layout.alias.ReceptorProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; -import lcsb.mapviewer.model.map.layout.alias.TruncatedProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.UnknownAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.AntisenseRna; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Degraded; +import lcsb.mapviewer.model.map.species.Drug; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Ion; +import lcsb.mapviewer.model.map.species.IonChannelProtein; +import lcsb.mapviewer.model.map.species.Phenotype; +import lcsb.mapviewer.model.map.species.ReceptorProtein; +import lcsb.mapviewer.model.map.species.Rna; +import lcsb.mapviewer.model.map.species.SimpleMolecule; +import lcsb.mapviewer.model.map.species.TruncatedProtein; +import lcsb.mapviewer.model.map.species.Unknown; import lcsb.mapviewer.modelutils.map.ElementUtils; /** @@ -33,7 +33,7 @@ import lcsb.mapviewer.modelutils.map.ElementUtils; * */ -public class CellDesignerAliasConverter implements ICellDesignerAliasConverter<Alias> { +public class CellDesignerAliasConverter implements ICellDesignerAliasConverter<Element> { // ***************************************************************** // @@ -47,7 +47,7 @@ public class CellDesignerAliasConverter implements ICellDesignerAliasConverter<A * a converter that can process the alias with the specific element type * reference. */ - private static Map<Class<? extends Alias>, ICellDesignerAliasConverter<?>> elementConverters; + private static Map<Class<? extends Element>, ICellDesignerAliasConverter<?>> elementConverters; private static ElementUtils eu = new ElementUtils(); @@ -57,20 +57,20 @@ public class CellDesignerAliasConverter implements ICellDesignerAliasConverter<A // at the beginning lets add all implemented aliases // for alias reference - addElementConverter(GenericProteinAlias.class, new ProteinCellDesignerAliasConverter()); - addElementConverter(TruncatedProteinAlias.class, new ProteinCellDesignerAliasConverter()); - addElementConverter(ReceptorProteinAlias.class, new ProteinCellDesignerAliasConverter()); - addElementConverter(IonChannelProteinAlias.class, new ProteinCellDesignerAliasConverter()); - addElementConverter(DegradedAlias.class, new DegradedCellDesignerAliasConverter()); - addElementConverter(ComplexAlias.class, new ComplexCellDesignerAliasConverter()); - addElementConverter(SimpleMoleculeAlias.class, new SimpleMoleculeCellDesignerAliasConverter()); - addElementConverter(DrugAlias.class, new DrugCellDesignerAliasConverter()); - addElementConverter(IonAlias.class, new IonCellDesignerAliasConverter()); - addElementConverter(PhenotypeAlias.class, new PhenotypeCellDesignerAliasConverter()); - addElementConverter(RnaAlias.class, new RnaCellDesignerAliasConverter()); - addElementConverter(AntisenseRnaAlias.class, new AntisenseRnaCellDesignerAliasConverter()); - addElementConverter(GeneAlias.class, new GeneCellDesignerAliasConverter()); - addElementConverter(UnknownAlias.class, new UnknownCellDesignerAliasConverter()); + addElementConverter(GenericProtein.class, new ProteinCellDesignerAliasConverter()); + addElementConverter(TruncatedProtein.class, new ProteinCellDesignerAliasConverter()); + addElementConverter(ReceptorProtein.class, new ProteinCellDesignerAliasConverter()); + addElementConverter(IonChannelProtein.class, new ProteinCellDesignerAliasConverter()); + addElementConverter(Degraded.class, new DegradedCellDesignerAliasConverter()); + addElementConverter(Complex.class, new ComplexCellDesignerAliasConverter()); + addElementConverter(SimpleMolecule.class, new SimpleMoleculeCellDesignerAliasConverter()); + addElementConverter(Drug.class, new DrugCellDesignerAliasConverter()); + addElementConverter(Ion.class, new IonCellDesignerAliasConverter()); + addElementConverter(Phenotype.class, new PhenotypeCellDesignerAliasConverter()); + addElementConverter(Rna.class, new RnaCellDesignerAliasConverter()); + addElementConverter(AntisenseRna.class, new AntisenseRnaCellDesignerAliasConverter()); + addElementConverter(Gene.class, new GeneCellDesignerAliasConverter()); + addElementConverter(Unknown.class, new UnknownCellDesignerAliasConverter()); } @@ -82,7 +82,7 @@ public class CellDesignerAliasConverter implements ICellDesignerAliasConverter<A * @param converter * converter that should be used for conversion of this alias */ - protected static void addElementConverter(Class<? extends Alias> clazz, ICellDesignerAliasConverter<?> converter) { + protected static void addElementConverter(Class<? extends Element> clazz, ICellDesignerAliasConverter<?> converter) { elementConverters.put(clazz, converter); } @@ -95,7 +95,7 @@ public class CellDesignerAliasConverter implements ICellDesignerAliasConverter<A * @return converter that can be applied for the given alias; null if such * converter doesn't exist */ - private static ICellDesignerAliasConverter<? extends Alias> getConverterForAlias(Alias alias) { + private static ICellDesignerAliasConverter<? extends Element> getConverterForAlias(Element alias) { if (alias == null) { throw new InvalidArgumentException("alias cannot be null"); } @@ -122,7 +122,7 @@ public class CellDesignerAliasConverter implements ICellDesignerAliasConverter<A * @param alias * alias for which this converter will be used */ - public CellDesignerAliasConverter(Alias alias) { + public CellDesignerAliasConverter(Element alias) { converter = getConverterForAlias(alias); // if we don't know which converter to use then throw an exception if (converter == null) { @@ -132,19 +132,19 @@ public class CellDesignerAliasConverter implements ICellDesignerAliasConverter<A @SuppressWarnings("unchecked") @Override - public CellDesignerAnchor getAnchorForCoordinates(Alias alias, Point2D point) { + public CellDesignerAnchor getAnchorForCoordinates(Element alias, Point2D point) { return converter.getAnchorForCoordinates(alias, point); } @SuppressWarnings("unchecked") @Override - public Point2D getPointCoordinates(Alias alias, CellDesignerAnchor anchor) { + public Point2D getPointCoordinates(Element alias, CellDesignerAnchor anchor) { return converter.getPointCoordinates(alias, anchor); } @SuppressWarnings("unchecked") @Override - public Point2D getAnchorPointCoordinates(Alias alias, CellDesignerAnchor anchor, PolylineData line) { + public Point2D getAnchorPointCoordinates(Element alias, CellDesignerAnchor anchor, PolylineData line) { return converter.getAnchorPointCoordinates(alias, anchor, line); } } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/ComplexCellDesignerAliasConverter.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/ComplexCellDesignerAliasConverter.java index 4fd078e5a0..6e7e3b279c 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/ComplexCellDesignerAliasConverter.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/ComplexCellDesignerAliasConverter.java @@ -1,60 +1,60 @@ -package lcsb.mapviewer.converter.model.celldesigner.geometry; - -import java.awt.geom.AffineTransform; -import java.awt.geom.GeneralPath; -import java.awt.geom.PathIterator; -import java.awt.geom.Point2D; - -import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; - -/** - * Class that provides CellDesigner specific graphical information for - * ComplexAlias. It's used for conversion from xml to normal x,y coordinates. - * - * @author Piotr Gawron - * - */ -public class ComplexCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<ComplexAlias> { - - /** - * How big is the triangle trimmed part of the complex. - */ - private static final int TRIMMED_CORNER_SIZE = 5; - - @Override - public Point2D getPointCoordinates(ComplexAlias alias, CellDesignerAnchor anchor) { - if (invalidAnchorPosition(alias, anchor)) { - return alias.getCenter(); - } - return getRectangleTransformation().getPointOnRectangleByAnchor(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight(), anchor); - } - - @Override - public PathIterator getBoundPathIterator(ComplexAlias alias) { - return getAliasPath(alias).getPathIterator(new AffineTransform()); - } - - /** - * Returns the border of complex alias. - * - * @param alias - * exact object for which we want to get a border - * @return border of the alias - */ - private GeneralPath getAliasPath(Alias alias) { - GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD); - path.moveTo(alias.getX() + TRIMMED_CORNER_SIZE, alias.getY()); - path.lineTo(alias.getX() + alias.getWidth() - TRIMMED_CORNER_SIZE, alias.getY()); - path.lineTo(alias.getX() + alias.getWidth(), alias.getY() + TRIMMED_CORNER_SIZE); - path.lineTo(alias.getX() + alias.getWidth(), alias.getY() + alias.getHeight() - TRIMMED_CORNER_SIZE); - path.lineTo(alias.getX() + alias.getWidth() - TRIMMED_CORNER_SIZE, alias.getY() + alias.getHeight()); - path.lineTo(alias.getX() + TRIMMED_CORNER_SIZE, alias.getY() + alias.getHeight()); - path.lineTo(alias.getX(), alias.getY() + alias.getHeight() - TRIMMED_CORNER_SIZE); - path.lineTo(alias.getX(), alias.getY() + TRIMMED_CORNER_SIZE); - path.closePath(); - return path; - } - -} +package lcsb.mapviewer.converter.model.celldesigner.geometry; + +import java.awt.geom.AffineTransform; +import java.awt.geom.GeneralPath; +import java.awt.geom.PathIterator; +import java.awt.geom.Point2D; + +import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Complex; + +/** + * Class that provides CellDesigner specific graphical information for + * ComplexAlias. It's used for conversion from xml to normal x,y coordinates. + * + * @author Piotr Gawron + * + */ +public class ComplexCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<Complex> { + + /** + * How big is the triangle trimmed part of the complex. + */ + private static final int TRIMMED_CORNER_SIZE = 5; + + @Override + public Point2D getPointCoordinates(Complex alias, CellDesignerAnchor anchor) { + if (invalidAnchorPosition(alias, anchor)) { + return alias.getCenter(); + } + return getRectangleTransformation().getPointOnRectangleByAnchor(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight(), anchor); + } + + @Override + public PathIterator getBoundPathIterator(Complex alias) { + return getAliasPath(alias).getPathIterator(new AffineTransform()); + } + + /** + * Returns the border of complex alias. + * + * @param alias + * exact object for which we want to get a border + * @return border of the alias + */ + private GeneralPath getAliasPath(Element alias) { + GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD); + path.moveTo(alias.getX() + TRIMMED_CORNER_SIZE, alias.getY()); + path.lineTo(alias.getX() + alias.getWidth() - TRIMMED_CORNER_SIZE, alias.getY()); + path.lineTo(alias.getX() + alias.getWidth(), alias.getY() + TRIMMED_CORNER_SIZE); + path.lineTo(alias.getX() + alias.getWidth(), alias.getY() + alias.getHeight() - TRIMMED_CORNER_SIZE); + path.lineTo(alias.getX() + alias.getWidth() - TRIMMED_CORNER_SIZE, alias.getY() + alias.getHeight()); + path.lineTo(alias.getX() + TRIMMED_CORNER_SIZE, alias.getY() + alias.getHeight()); + path.lineTo(alias.getX(), alias.getY() + alias.getHeight() - TRIMMED_CORNER_SIZE); + path.lineTo(alias.getX(), alias.getY() + TRIMMED_CORNER_SIZE); + path.closePath(); + return path; + } + +} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/DegradedCellDesignerAliasConverter.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/DegradedCellDesignerAliasConverter.java index 34c657eed6..cdd6afa00f 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/DegradedCellDesignerAliasConverter.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/DegradedCellDesignerAliasConverter.java @@ -5,8 +5,8 @@ import java.awt.geom.Point2D; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; /** * Class that provides CellDesigner specific graphical information for Degraded @@ -15,7 +15,7 @@ import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; * @author Piotr Gawron * */ -public class DegradedCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<SpeciesAlias> { +public class DegradedCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<Species> { /** * Part of height of the line used to cross degraded circle that goes behind @@ -24,7 +24,7 @@ public class DegradedCellDesignerAliasConverter extends AbstractCellDesignerAlia private static final int DEGRADED_MARGIN = 7; @Override - public Point2D getPointCoordinates(SpeciesAlias alias, CellDesignerAnchor anchor) { + public Point2D getPointCoordinates(Species alias, CellDesignerAnchor anchor) { double diameter = getDiameter(alias); double x = getXCoord(alias, diameter); double y = getYCoord(alias); @@ -42,7 +42,7 @@ public class DegradedCellDesignerAliasConverter extends AbstractCellDesignerAlia * object alias to to which we are looking for y coordinate * @return y coordinate of the alias */ - private double getYCoord(Alias alias) { + private double getYCoord(Element alias) { double y = alias.getY() + DEGRADED_MARGIN; return y; } @@ -56,7 +56,7 @@ public class DegradedCellDesignerAliasConverter extends AbstractCellDesignerAlia * diameter of cross line used in this alias * @return x coordinate of the alias */ - private double getXCoord(Alias alias, double diameter) { + private double getXCoord(Element alias, double diameter) { double x = alias.getX() + (alias.getWidth() - diameter) / 2; return x; } @@ -68,7 +68,7 @@ public class DegradedCellDesignerAliasConverter extends AbstractCellDesignerAlia * object alias to to which we are looking for diameter. * @return diameter of the cross line */ - private double getDiameter(Alias alias) { + private double getDiameter(Element alias) { double diameter = Math.min(alias.getWidth(), alias.getHeight()) - 2 * DEGRADED_MARGIN; if (diameter < 0) { diameter = 0; @@ -77,7 +77,7 @@ public class DegradedCellDesignerAliasConverter extends AbstractCellDesignerAlia } @Override - public Point2D getAnchorPointCoordinates(SpeciesAlias alias, double angle) { + public Point2D getAnchorPointCoordinates(Species alias, double angle) { if (alias.getWidth() == 0 && alias.getHeight() == 0) { return alias.getCenter(); } @@ -90,7 +90,7 @@ public class DegradedCellDesignerAliasConverter extends AbstractCellDesignerAlia } @Override - public PathIterator getBoundPathIterator(SpeciesAlias alias) { + public PathIterator getBoundPathIterator(Species alias) { throw new NotImplementedException("This class doesn't have bound"); } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/DrugCellDesignerAliasConverter.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/DrugCellDesignerAliasConverter.java index c5c1ddfcbd..f7eb9b728a 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/DrugCellDesignerAliasConverter.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/DrugCellDesignerAliasConverter.java @@ -1,81 +1,81 @@ -package lcsb.mapviewer.converter.model.celldesigner.geometry; - -import java.awt.Shape; -import java.awt.geom.AffineTransform; -import java.awt.geom.PathIterator; -import java.awt.geom.Point2D; -import java.awt.geom.RoundRectangle2D; -import java.util.ArrayList; - -import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; - -/** - * Class that provides CellDesigner specific graphical information for Drug. - * It's used for conversion from xml to normal x,y coordinates. - * - * @author Piotr Gawron - * - */ -public class DrugCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<SpeciesAlias> { - /** - * How big should be the arc in rectangle for drug representation. - */ - private static final int RECTANGLE_CORNER_ARC_SIZE = 40; - - @Override - public Point2D getPointCoordinates(SpeciesAlias alias, CellDesignerAnchor anchor) { - if (invalidAnchorPosition(alias, anchor)) { - return alias.getCenter(); - } - ArrayList<Point2D> list = getDrugPoints(alias); - - return getPolygonTransformation().getPointOnPolygonByAnchor(list, anchor); - } - - @Override - protected PathIterator getBoundPathIterator(SpeciesAlias alias) { - return getDrugShape(alias).getPathIterator(new AffineTransform()); - } - - /** - * Returns shape of the Drug as a list of points. - * - * @param alias - * alias for which we are looking for a border - * @return list of points defining border of the given alias - */ - protected ArrayList<Point2D> getDrugPoints(SpeciesAlias alias) { - ArrayList<Point2D> list = new ArrayList<Point2D>(); - - double x = alias.getX(); - double y = alias.getY(); - double width = alias.getWidth(); - double height = alias.getHeight(); - - // CHECKSTYLE:OFF - list.add(new Point2D.Double(x, y + height / 2)); - list.add(new Point2D.Double(x + width / 12, y)); - list.add(new Point2D.Double(x + width / 2, y)); - list.add(new Point2D.Double(x + width * 11 / 12, y)); - list.add(new Point2D.Double(x + width, y + height / 2)); - list.add(new Point2D.Double(x + width * 11 / 12, y + height)); - list.add(new Point2D.Double(x + width / 2, y + height)); - list.add(new Point2D.Double(x + width / 12, y + height)); - // CHECKSTYLE:ON - return list; - } - - /** - * Returns shape of the Drug. - * - * @param alias - * alias for which we are looking for a border - * @return Shape object defining given alias - */ - private Shape getDrugShape(Alias alias) { - return new RoundRectangle2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight(), RECTANGLE_CORNER_ARC_SIZE, RECTANGLE_CORNER_ARC_SIZE); - } - -} +package lcsb.mapviewer.converter.model.celldesigner.geometry; + +import java.awt.Shape; +import java.awt.geom.AffineTransform; +import java.awt.geom.PathIterator; +import java.awt.geom.Point2D; +import java.awt.geom.RoundRectangle2D; +import java.util.ArrayList; + +import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; + +/** + * Class that provides CellDesigner specific graphical information for Drug. + * It's used for conversion from xml to normal x,y coordinates. + * + * @author Piotr Gawron + * + */ +public class DrugCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<Species> { + /** + * How big should be the arc in rectangle for drug representation. + */ + private static final int RECTANGLE_CORNER_ARC_SIZE = 40; + + @Override + public Point2D getPointCoordinates(Species alias, CellDesignerAnchor anchor) { + if (invalidAnchorPosition(alias, anchor)) { + return alias.getCenter(); + } + ArrayList<Point2D> list = getDrugPoints(alias); + + return getPolygonTransformation().getPointOnPolygonByAnchor(list, anchor); + } + + @Override + protected PathIterator getBoundPathIterator(Species alias) { + return getDrugShape(alias).getPathIterator(new AffineTransform()); + } + + /** + * Returns shape of the Drug as a list of points. + * + * @param alias + * alias for which we are looking for a border + * @return list of points defining border of the given alias + */ + protected ArrayList<Point2D> getDrugPoints(Species alias) { + ArrayList<Point2D> list = new ArrayList<Point2D>(); + + double x = alias.getX(); + double y = alias.getY(); + double width = alias.getWidth(); + double height = alias.getHeight(); + + // CHECKSTYLE:OFF + list.add(new Point2D.Double(x, y + height / 2)); + list.add(new Point2D.Double(x + width / 12, y)); + list.add(new Point2D.Double(x + width / 2, y)); + list.add(new Point2D.Double(x + width * 11 / 12, y)); + list.add(new Point2D.Double(x + width, y + height / 2)); + list.add(new Point2D.Double(x + width * 11 / 12, y + height)); + list.add(new Point2D.Double(x + width / 2, y + height)); + list.add(new Point2D.Double(x + width / 12, y + height)); + // CHECKSTYLE:ON + return list; + } + + /** + * Returns shape of the Drug. + * + * @param alias + * alias for which we are looking for a border + * @return Shape object defining given alias + */ + private Shape getDrugShape(Element alias) { + return new RoundRectangle2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight(), RECTANGLE_CORNER_ARC_SIZE, RECTANGLE_CORNER_ARC_SIZE); + } + +} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/GeneCellDesignerAliasConverter.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/GeneCellDesignerAliasConverter.java index 476f1e4242..f7e9a9c9e2 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/GeneCellDesignerAliasConverter.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/GeneCellDesignerAliasConverter.java @@ -1,71 +1,71 @@ -package lcsb.mapviewer.converter.model.celldesigner.geometry; - -import java.awt.Rectangle; -import java.awt.Shape; -import java.awt.geom.AffineTransform; -import java.awt.geom.GeneralPath; -import java.awt.geom.PathIterator; -import java.awt.geom.Point2D; - -import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; - -/** - * Class that provides CellDesigner specific graphical information for Gene. - * It's used for conversion from xml to normal x,y coordinates. - * - * @author Piotr Gawron - * - */ -public class GeneCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<SpeciesAlias> { - - /** - * How big should be the arc in rectangle for nucleic acid feature representation. - */ - private static final int RECTANGLE_CORNER_ARC_SIZE = 5; - - @Override - public Point2D getPointCoordinates(SpeciesAlias alias, CellDesignerAnchor anchor) { - if (invalidAnchorPosition(alias, anchor)) { - return alias.getCenter(); - } - return getRectangleTransformation().getPointOnRectangleByAnchor(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight(), anchor); - } - - /** - * Shape representation of the gene alias. - * - * @param alias - * alias for which we are looking for a Shape - * @return Shape object that represents alias - */ - private Shape getGeneShape(Alias alias) { - if (!alias.getModel().isSbgnFormat()) { - Shape shape; - shape = new Rectangle(alias.getX().intValue(), alias.getY().intValue(), alias.getWidth().intValue(), alias.getHeight().intValue()); - return shape; - } else { - GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD); - double x = alias.getX(), y = alias.getY(), width = alias.getWidth(), height = alias.getHeight(); - - path.moveTo(x, y); - path.lineTo(x, y + height - RECTANGLE_CORNER_ARC_SIZE); - path.curveTo(x, y + height, - x + RECTANGLE_CORNER_ARC_SIZE, y + height, - x + RECTANGLE_CORNER_ARC_SIZE, y + height); - path.lineTo(x + width - RECTANGLE_CORNER_ARC_SIZE, y + height); - path.curveTo(x + width, y + height, - x + width, y + height - RECTANGLE_CORNER_ARC_SIZE, - x + width, y + height - RECTANGLE_CORNER_ARC_SIZE); - path.lineTo(x + width, y); - path.closePath(); - return path; - } - } - - @Override - public PathIterator getBoundPathIterator(SpeciesAlias alias) { - return getGeneShape(alias).getPathIterator(new AffineTransform()); - } -} +package lcsb.mapviewer.converter.model.celldesigner.geometry; + +import java.awt.Rectangle; +import java.awt.Shape; +import java.awt.geom.AffineTransform; +import java.awt.geom.GeneralPath; +import java.awt.geom.PathIterator; +import java.awt.geom.Point2D; + +import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; + +/** + * Class that provides CellDesigner specific graphical information for Gene. + * It's used for conversion from xml to normal x,y coordinates. + * + * @author Piotr Gawron + * + */ +public class GeneCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<Species> { + + /** + * How big should be the arc in rectangle for nucleic acid feature representation. + */ + private static final int RECTANGLE_CORNER_ARC_SIZE = 5; + + @Override + public Point2D getPointCoordinates(Species alias, CellDesignerAnchor anchor) { + if (invalidAnchorPosition(alias, anchor)) { + return alias.getCenter(); + } + return getRectangleTransformation().getPointOnRectangleByAnchor(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight(), anchor); + } + + /** + * Shape representation of the gene alias. + * + * @param alias + * alias for which we are looking for a Shape + * @return Shape object that represents alias + */ + private Shape getGeneShape(Element alias) { + if (!alias.getModel().isSbgnFormat()) { + Shape shape; + shape = new Rectangle(alias.getX().intValue(), alias.getY().intValue(), alias.getWidth().intValue(), alias.getHeight().intValue()); + return shape; + } else { + GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD); + double x = alias.getX(), y = alias.getY(), width = alias.getWidth(), height = alias.getHeight(); + + path.moveTo(x, y); + path.lineTo(x, y + height - RECTANGLE_CORNER_ARC_SIZE); + path.curveTo(x, y + height, + x + RECTANGLE_CORNER_ARC_SIZE, y + height, + x + RECTANGLE_CORNER_ARC_SIZE, y + height); + path.lineTo(x + width - RECTANGLE_CORNER_ARC_SIZE, y + height); + path.curveTo(x + width, y + height, + x + width, y + height - RECTANGLE_CORNER_ARC_SIZE, + x + width, y + height - RECTANGLE_CORNER_ARC_SIZE); + path.lineTo(x + width, y); + path.closePath(); + return path; + } + } + + @Override + public PathIterator getBoundPathIterator(Species alias) { + return getGeneShape(alias).getPathIterator(new AffineTransform()); + } +} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/ICellDesignerAliasConverter.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/ICellDesignerAliasConverter.java index eb32400a8a..a42fa6d4b6 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/ICellDesignerAliasConverter.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/ICellDesignerAliasConverter.java @@ -1,61 +1,61 @@ -package lcsb.mapviewer.converter.model.celldesigner.geometry; - -import java.awt.geom.Point2D; - -import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; -import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.Alias; - -/** - * Interface that defines functions usefull in transforming graphical - * information from objects retrieved from CellDesigner xml into abslote values. - * - * @author Piotr Gawron - * - * @param <T> - */ -public interface ICellDesignerAliasConverter<T extends Alias> { - /** - * This method computes which anchor is the most probable for describing the - * point on the border of alias. There are 16 possible anchors on the border - * of every alias and one undefined point that will be used if no point can be - * found (see {@link CellDesignerAnchor} to find information about anchors). - * - * @param alias - * object for which we try to find anchor - * @param point - * point on the border of alias for which we try to find anchor - * @return CellDesigner anchor point that describe the best point on the - * border - */ - CellDesignerAnchor getAnchorForCoordinates(T alias, Point2D point); - - /** - * This method transform CellDesigner anchor point on the alias into x,y - * coordinates. - * - * @param alias - * we want to find coordinates on this alias border - * @param anchor - * CelDesigner anchor that defines point on the border - * @return point on the border that is defined by the anchor point - */ - Point2D getPointCoordinates(T alias, CellDesignerAnchor anchor); - - /** - * This method transform CellDesigner anchor point on the alias into x,y - * coordinates. If the anchor point doesn't define point then the line - * parameter is used to find the right angle on the alias border and point on - * the border with this angle is used as a result. - * - * @param alias - * we want to find coordinates on this alias border - * @param anchor - * CelDesigner anchor that defines point on the border - * @param line - * line that starts in the alias - * @return point on the border that is defined by the anchor point - */ - Point2D getAnchorPointCoordinates(T alias, CellDesignerAnchor anchor, PolylineData line); - -} +package lcsb.mapviewer.converter.model.celldesigner.geometry; + +import java.awt.geom.Point2D; + +import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; +import lcsb.mapviewer.model.graphics.PolylineData; +import lcsb.mapviewer.model.map.species.Element; + +/** + * Interface that defines functions usefull in transforming graphical + * information from objects retrieved from CellDesigner xml into abslote values. + * + * @author Piotr Gawron + * + * @param <T> + */ +public interface ICellDesignerAliasConverter<T extends Element> { + /** + * This method computes which anchor is the most probable for describing the + * point on the border of alias. There are 16 possible anchors on the border + * of every alias and one undefined point that will be used if no point can be + * found (see {@link CellDesignerAnchor} to find information about anchors). + * + * @param alias + * object for which we try to find anchor + * @param point + * point on the border of alias for which we try to find anchor + * @return CellDesigner anchor point that describe the best point on the + * border + */ + CellDesignerAnchor getAnchorForCoordinates(T alias, Point2D point); + + /** + * This method transform CellDesigner anchor point on the alias into x,y + * coordinates. + * + * @param alias + * we want to find coordinates on this alias border + * @param anchor + * CelDesigner anchor that defines point on the border + * @return point on the border that is defined by the anchor point + */ + Point2D getPointCoordinates(T alias, CellDesignerAnchor anchor); + + /** + * This method transform CellDesigner anchor point on the alias into x,y + * coordinates. If the anchor point doesn't define point then the line + * parameter is used to find the right angle on the alias border and point on + * the border with this angle is used as a result. + * + * @param alias + * we want to find coordinates on this alias border + * @param anchor + * CelDesigner anchor that defines point on the border + * @param line + * line that starts in the alias + * @return point on the border that is defined by the anchor point + */ + Point2D getAnchorPointCoordinates(T alias, CellDesignerAnchor anchor, PolylineData line); + +} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/IonCellDesignerAliasConverter.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/IonCellDesignerAliasConverter.java index b7d0c6c83b..80b206935d 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/IonCellDesignerAliasConverter.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/IonCellDesignerAliasConverter.java @@ -5,8 +5,8 @@ import java.awt.geom.Point2D; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; /** * Class that provides CellDesigner specific graphical information for Ion. It's @@ -15,10 +15,10 @@ import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; * @author Piotr Gawron * */ -public class IonCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<SpeciesAlias> { +public class IonCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<Species> { @Override - public Point2D getPointCoordinates(SpeciesAlias alias, CellDesignerAnchor anchor) { + public Point2D getPointCoordinates(Species alias, CellDesignerAnchor anchor) { double diameter = getDiameter(alias); double x = getXCoord(alias, diameter); double y = getYCoord(alias); @@ -36,7 +36,7 @@ public class IonCellDesignerAliasConverter extends AbstractCellDesignerAliasConv * object alias to to which we are looking for y coordinate * @return y coordinate of the alias */ - private double getYCoord(Alias alias) { + private double getYCoord(Element alias) { double y = alias.getY(); return y; } @@ -50,7 +50,7 @@ public class IonCellDesignerAliasConverter extends AbstractCellDesignerAliasConv * diameter of the circle representing alias * @return x coordinate of the alias */ - private double getXCoord(Alias alias, double diameter) { + private double getXCoord(Element alias, double diameter) { double x = alias.getX() + (alias.getWidth() - diameter) / 2; return x; } @@ -62,7 +62,7 @@ public class IonCellDesignerAliasConverter extends AbstractCellDesignerAliasConv * object alias to to which we are looking for diameter. * @return diameter of the alias */ - private double getDiameter(Alias alias) { + private double getDiameter(Element alias) { double diameter = Math.min(alias.getWidth(), alias.getHeight()); if (diameter < 0) { diameter = 0; @@ -71,7 +71,7 @@ public class IonCellDesignerAliasConverter extends AbstractCellDesignerAliasConv } @Override - public Point2D getAnchorPointCoordinates(SpeciesAlias alias, double angle) { + public Point2D getAnchorPointCoordinates(Species alias, double angle) { if (alias.getWidth() == 0 && alias.getHeight() == 0) { return alias.getCenter(); } @@ -84,7 +84,7 @@ public class IonCellDesignerAliasConverter extends AbstractCellDesignerAliasConv } @Override - protected PathIterator getBoundPathIterator(SpeciesAlias alias) { + protected PathIterator getBoundPathIterator(Species alias) { throw new NotImplementedException("This class doesn't have bound"); } } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/PhenotypeCellDesignerAliasConverter.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/PhenotypeCellDesignerAliasConverter.java index 7d46c15936..25e9b8e934 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/PhenotypeCellDesignerAliasConverter.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/PhenotypeCellDesignerAliasConverter.java @@ -1,83 +1,83 @@ -package lcsb.mapviewer.converter.model.celldesigner.geometry; - -import java.awt.geom.AffineTransform; -import java.awt.geom.GeneralPath; -import java.awt.geom.PathIterator; -import java.awt.geom.Point2D; -import java.util.ArrayList; - -import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; - -/** - * Class that provides CellDesigner specific graphical information for Phenotype. - * It's used for conversion from xml to normal x,y coordinates. - * - * @author Piotr Gawron - * - */ -public class PhenotypeCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<SpeciesAlias> { - @Override - public Point2D getPointCoordinates(SpeciesAlias alias, CellDesignerAnchor anchor) { - if (invalidAnchorPosition(alias, anchor)) { - return alias.getCenter(); - } - return getPolygonTransformation().getPointOnPolygonByAnchor(getPointsForAlias(alias), anchor); - } - - /** - * Returns shape of the Phenotype as a list of points. - * - * @param alias - * alias for which we are looking for a border - * @return list of points defining border of the given alias - */ - private ArrayList<Point2D> getPointsForAlias(Alias alias) { - ArrayList<Point2D> list = new ArrayList<Point2D>(); - - double x = alias.getX(); - double y = alias.getY(); - double width = alias.getWidth(); - double height = alias.getHeight(); - - // CHECKSTYLE:OFF - list.add(new Point2D.Double(x, y + height / 2)); - list.add(new Point2D.Double(x + width / 6, y)); - list.add(new Point2D.Double(x + width / 2, y)); - list.add(new Point2D.Double(x + width * 5 / 6, y)); - list.add(new Point2D.Double(x + width, y + height / 2)); - list.add(new Point2D.Double(x + width * 5 / 6, y + height)); - list.add(new Point2D.Double(x + width / 2, y + height)); - list.add(new Point2D.Double(x + width / 6, y + height)); - // CHECKSTYLE:ON - return list; - } - - @Override - public PathIterator getBoundPathIterator(SpeciesAlias alias) { - return getPhenotypePath(alias).getPathIterator(new AffineTransform()); - } - - /** - * Returns shape of the Phenotype as a GeneralPath object. - * - * @param alias - * alias for which we are looking for a border - * @return GeneralPath object defining border of the given alias - */ - private GeneralPath getPhenotypePath(Alias alias) { - // CHECKSTYLE:OFF - GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 6); - path.moveTo(alias.getX() + alias.getWidth() / 6, alias.getY()); - path.lineTo(alias.getX() + alias.getWidth() * 5 / 6, alias.getY()); - path.lineTo(alias.getX() + alias.getWidth(), alias.getY() + alias.getHeight() / 2); - path.lineTo(alias.getX() + alias.getWidth() * 5 / 6, alias.getY() + alias.getHeight()); - path.lineTo(alias.getX() + alias.getWidth() / 6, alias.getY() + alias.getHeight()); - path.lineTo(alias.getX(), alias.getY() + alias.getHeight() / 2); - // CHECKSTYLE:ON - path.closePath(); - return path; - } - -} +package lcsb.mapviewer.converter.model.celldesigner.geometry; + +import java.awt.geom.AffineTransform; +import java.awt.geom.GeneralPath; +import java.awt.geom.PathIterator; +import java.awt.geom.Point2D; +import java.util.ArrayList; + +import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; + +/** + * Class that provides CellDesigner specific graphical information for Phenotype. + * It's used for conversion from xml to normal x,y coordinates. + * + * @author Piotr Gawron + * + */ +public class PhenotypeCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<Species> { + @Override + public Point2D getPointCoordinates(Species alias, CellDesignerAnchor anchor) { + if (invalidAnchorPosition(alias, anchor)) { + return alias.getCenter(); + } + return getPolygonTransformation().getPointOnPolygonByAnchor(getPointsForAlias(alias), anchor); + } + + /** + * Returns shape of the Phenotype as a list of points. + * + * @param alias + * alias for which we are looking for a border + * @return list of points defining border of the given alias + */ + private ArrayList<Point2D> getPointsForAlias(Element alias) { + ArrayList<Point2D> list = new ArrayList<Point2D>(); + + double x = alias.getX(); + double y = alias.getY(); + double width = alias.getWidth(); + double height = alias.getHeight(); + + // CHECKSTYLE:OFF + list.add(new Point2D.Double(x, y + height / 2)); + list.add(new Point2D.Double(x + width / 6, y)); + list.add(new Point2D.Double(x + width / 2, y)); + list.add(new Point2D.Double(x + width * 5 / 6, y)); + list.add(new Point2D.Double(x + width, y + height / 2)); + list.add(new Point2D.Double(x + width * 5 / 6, y + height)); + list.add(new Point2D.Double(x + width / 2, y + height)); + list.add(new Point2D.Double(x + width / 6, y + height)); + // CHECKSTYLE:ON + return list; + } + + @Override + public PathIterator getBoundPathIterator(Species alias) { + return getPhenotypePath(alias).getPathIterator(new AffineTransform()); + } + + /** + * Returns shape of the Phenotype as a GeneralPath object. + * + * @param alias + * alias for which we are looking for a border + * @return GeneralPath object defining border of the given alias + */ + private GeneralPath getPhenotypePath(Element alias) { + // CHECKSTYLE:OFF + GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 6); + path.moveTo(alias.getX() + alias.getWidth() / 6, alias.getY()); + path.lineTo(alias.getX() + alias.getWidth() * 5 / 6, alias.getY()); + path.lineTo(alias.getX() + alias.getWidth(), alias.getY() + alias.getHeight() / 2); + path.lineTo(alias.getX() + alias.getWidth() * 5 / 6, alias.getY() + alias.getHeight()); + path.lineTo(alias.getX() + alias.getWidth() / 6, alias.getY() + alias.getHeight()); + path.lineTo(alias.getX(), alias.getY() + alias.getHeight() / 2); + // CHECKSTYLE:ON + path.closePath(); + return path; + } + +} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/ProteinCellDesignerAliasConverter.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/ProteinCellDesignerAliasConverter.java index 12da63203e..9a9b3794a0 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/ProteinCellDesignerAliasConverter.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/ProteinCellDesignerAliasConverter.java @@ -13,12 +13,12 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.IonChannelProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ReceptorProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.TruncatedProteinAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.IonChannelProtein; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.ReceptorProtein; +import lcsb.mapviewer.model.map.species.TruncatedProtein; import lcsb.mapviewer.modelutils.map.ElementUtils; /** @@ -28,7 +28,7 @@ import lcsb.mapviewer.modelutils.map.ElementUtils; * @author Piotr Gawron * */ -public class ProteinCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<ProteinAlias> { +public class ProteinCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<Protein> { /** * Default class logger. */ @@ -43,7 +43,7 @@ public class ProteinCellDesignerAliasConverter extends AbstractCellDesignerAlias private ElementUtils eu = new ElementUtils(); @Override - public Point2D getPointCoordinates(ProteinAlias alias, CellDesignerAnchor anchor) { + public Point2D getPointCoordinates(Protein alias, CellDesignerAnchor anchor) { Point2D result = null; if (invalidAnchorPosition(alias, anchor)) { result = alias.getCenter(); @@ -53,14 +53,14 @@ public class ProteinCellDesignerAliasConverter extends AbstractCellDesignerAlias alias.setWidth(alias.getWidth() - AbstractCellDesignerAliasConverter.HOMODIMER_OFFSET * (homodir - 1)); alias.setHeight(alias.getHeight() - AbstractCellDesignerAliasConverter.HOMODIMER_OFFSET * (homodir - 1)); - if (alias instanceof GenericProteinAlias) { + if (alias instanceof GenericProtein) { result = getRectangleTransformation().getPointOnRectangleByAnchor(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight(), anchor); - } else if (alias instanceof ReceptorProteinAlias) { + } else if (alias instanceof ReceptorProtein) { ArrayList<Point2D> points = getReceptorPoints(alias); result = getPolygonTransformation().getPointOnPolygonByAnchor(points, anchor); - } else if (alias instanceof IonChannelProteinAlias) { + } else if (alias instanceof IonChannelProtein) { result = getRectangleTransformation().getPointOnRectangleByAnchor(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight(), anchor); - } else if (alias instanceof TruncatedProteinAlias) { + } else if (alias instanceof TruncatedProtein) { ArrayList<Point2D> points = getTruncatedPoints(alias); result = getPolygonTransformation().getPointOnPolygonByAnchor(points, anchor); } else { @@ -74,14 +74,14 @@ public class ProteinCellDesignerAliasConverter extends AbstractCellDesignerAlias } @Override - public PathIterator getBoundPathIterator(ProteinAlias alias) { - if (alias instanceof GenericProteinAlias) { + public PathIterator getBoundPathIterator(Protein alias) { + if (alias instanceof GenericProtein) { return getGenericShape(alias).getPathIterator(new AffineTransform()); - } else if (alias instanceof ReceptorProteinAlias) { + } else if (alias instanceof ReceptorProtein) { return getReceptorShape(alias).getPathIterator(new AffineTransform()); - } else if (alias instanceof IonChannelProteinAlias) { + } else if (alias instanceof IonChannelProtein) { return getGenericShape(alias).getPathIterator(new AffineTransform()); - } else if (alias instanceof TruncatedProteinAlias) { + } else if (alias instanceof TruncatedProtein) { return getTruncatedShape(alias).getPathIterator(new AffineTransform()); } else { throw new NotImplementedException(eu.getElementTag(alias) + "Not implemented protein converter for type: " + alias.getClass()); @@ -95,7 +95,7 @@ public class ProteinCellDesignerAliasConverter extends AbstractCellDesignerAlias * alias for which we are looking for a border * @return Shape object defining given alias */ - private Shape getGenericShape(Alias alias) { + private Shape getGenericShape(Element alias) { return new RoundRectangle2D.Double( alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight(), GENERIC_PROTEIN_RECTANGLE_CORNER_ARC_SIZE, GENERIC_PROTEIN_RECTANGLE_CORNER_ARC_SIZE); } @@ -107,7 +107,7 @@ public class ProteinCellDesignerAliasConverter extends AbstractCellDesignerAlias * alias for which we are looking for a border * @return list of points defining border of the given alias */ - private ArrayList<Point2D> getTruncatedPoints(Alias alias) { + private ArrayList<Point2D> getTruncatedPoints(Element alias) { double x = alias.getX(); double y = alias.getY(); double width = alias.getWidth(); @@ -143,7 +143,7 @@ public class ProteinCellDesignerAliasConverter extends AbstractCellDesignerAlias * alias for which we are looking for a border * @return Shape object defining given alias */ - protected Shape getReceptorShape(Alias alias) { + protected Shape getReceptorShape(Element alias) { Shape shape; GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD); ArrayList<Point2D> points = getReceptorPoints(alias); @@ -163,7 +163,7 @@ public class ProteinCellDesignerAliasConverter extends AbstractCellDesignerAlias * alias for which we are looking for a border * @return Shape object defining given alias */ - protected Shape getTruncatedShape(Alias alias) { + protected Shape getTruncatedShape(Element alias) { Shape shape; GeneralPath path = new GeneralPath(); @@ -194,7 +194,7 @@ public class ProteinCellDesignerAliasConverter extends AbstractCellDesignerAlias * alias for which we are looking for a border * @return list of points defining border of the given alias */ - private ArrayList<Point2D> getReceptorPoints(Alias alias) { + private ArrayList<Point2D> getReceptorPoints(Element alias) { double x = alias.getX(); double y = alias.getY(); double width = alias.getWidth(); diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/RnaCellDesignerAliasConverter.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/RnaCellDesignerAliasConverter.java index 413837fcf3..71567f6ca9 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/RnaCellDesignerAliasConverter.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/RnaCellDesignerAliasConverter.java @@ -1,108 +1,108 @@ -package lcsb.mapviewer.converter.model.celldesigner.geometry; - -import java.awt.geom.AffineTransform; -import java.awt.geom.GeneralPath; -import java.awt.geom.PathIterator; -import java.awt.geom.Point2D; -import java.util.ArrayList; - -import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; - -/** - * Class that provides CellDesigner specific graphical information for Rna. - * It's used for conversion from xml to normal x,y coordinates. - * - * @author Piotr Gawron - * - */ -public class RnaCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<SpeciesAlias> { - - /** - * How big should be the arc in rectangle for nucleic acid feature representation. - */ - private static final int RECTANGLE_CORNER_ARC_SIZE = 5; - - @Override - public Point2D getPointCoordinates(SpeciesAlias alias, CellDesignerAnchor anchor) { - if (invalidAnchorPosition(alias, anchor)) { - return alias.getCenter(); - } - if (alias.getModel().isSbgnFormat()) { - return getRectangleTransformation().getPointOnRectangleByAnchor(alias.getX(), alias.getY(), - alias.getWidth(), alias.getHeight(), anchor); - } - ArrayList<Point2D> points = getPoints(alias); - return getPolygonTransformation().getPointOnPolygonByAnchor(points, anchor); - } - - @Override - public PathIterator getBoundPathIterator(SpeciesAlias alias) { - return getRnaPath(alias).getPathIterator(new AffineTransform()); - } - - /** - * Returns shape of the Rna as a list of points. - * - * @param alias - * alias for which we are looking for a border - * @return list of points defining border of the given alias - */ - private ArrayList<Point2D> getPoints(Alias alias) { - double x = alias.getX(); - double y = alias.getY(); - double width = alias.getWidth(); - double height = alias.getHeight(); - ArrayList<Point2D> points = new ArrayList<Point2D>(); - // CHECKSTYLE:OFF - points.add(new Point2D.Double(x + width / 8, y + height / 2)); - points.add(new Point2D.Double(x + width / 4, y)); - points.add(new Point2D.Double(x + width * 5 / 8, y)); - points.add(new Point2D.Double(x + width, y)); - points.add(new Point2D.Double(x + width * 7 / 8, y + height / 2)); - points.add(new Point2D.Double(x + width * 3 / 4, y + height)); - points.add(new Point2D.Double(x + width * 3 / 8, y + height)); - // CHECKSTYLE:ON - points.add(new Point2D.Double(x, y + height)); - return points; - } - - /** - * Returns shape of the Rna as a GeneralPath object. - * - * @param alias - * alias for which we are looking for a border - * @return GeneralPath object defining border of the given alias - */ - private GeneralPath getRnaPath(Alias alias) { - // CHECKSTYLE:OFF - GeneralPath path; - if (!alias.getModel().isSbgnFormat()) { - path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 4); - path.moveTo(alias.getX() + alias.getWidth() / 4, alias.getY()); - path.lineTo(alias.getX() + alias.getWidth(), alias.getY()); - path.lineTo(alias.getX() + alias.getWidth() * 3 / 4, alias.getY() + alias.getHeight()); - path.lineTo(alias.getX(), alias.getY() + alias.getHeight()); - path.closePath(); - } else { - path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 6); - double x = alias.getX(), y = alias.getY(), width = alias.getWidth(), height = alias.getHeight(); - - path.moveTo(x, y); - path.lineTo(x, y + height - RECTANGLE_CORNER_ARC_SIZE); - path.curveTo(x, y + height, - x + RECTANGLE_CORNER_ARC_SIZE, y + height, - x + RECTANGLE_CORNER_ARC_SIZE, y + height); - path.lineTo(x + width - RECTANGLE_CORNER_ARC_SIZE, y + height); - path.curveTo(x + width, y + height, - x + width, y + height - RECTANGLE_CORNER_ARC_SIZE, - x + width, y + height - RECTANGLE_CORNER_ARC_SIZE); - path.lineTo(x + width, y); - path.closePath(); - } - // CHECKSTYLE:ON - return path; - } - -} +package lcsb.mapviewer.converter.model.celldesigner.geometry; + +import java.awt.geom.AffineTransform; +import java.awt.geom.GeneralPath; +import java.awt.geom.PathIterator; +import java.awt.geom.Point2D; +import java.util.ArrayList; + +import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; + +/** + * Class that provides CellDesigner specific graphical information for Rna. + * It's used for conversion from xml to normal x,y coordinates. + * + * @author Piotr Gawron + * + */ +public class RnaCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<Species> { + + /** + * How big should be the arc in rectangle for nucleic acid feature representation. + */ + private static final int RECTANGLE_CORNER_ARC_SIZE = 5; + + @Override + public Point2D getPointCoordinates(Species alias, CellDesignerAnchor anchor) { + if (invalidAnchorPosition(alias, anchor)) { + return alias.getCenter(); + } + if (alias.getModel().isSbgnFormat()) { + return getRectangleTransformation().getPointOnRectangleByAnchor(alias.getX(), alias.getY(), + alias.getWidth(), alias.getHeight(), anchor); + } + ArrayList<Point2D> points = getPoints(alias); + return getPolygonTransformation().getPointOnPolygonByAnchor(points, anchor); + } + + @Override + public PathIterator getBoundPathIterator(Species alias) { + return getRnaPath(alias).getPathIterator(new AffineTransform()); + } + + /** + * Returns shape of the Rna as a list of points. + * + * @param alias + * alias for which we are looking for a border + * @return list of points defining border of the given alias + */ + private ArrayList<Point2D> getPoints(Element alias) { + double x = alias.getX(); + double y = alias.getY(); + double width = alias.getWidth(); + double height = alias.getHeight(); + ArrayList<Point2D> points = new ArrayList<Point2D>(); + // CHECKSTYLE:OFF + points.add(new Point2D.Double(x + width / 8, y + height / 2)); + points.add(new Point2D.Double(x + width / 4, y)); + points.add(new Point2D.Double(x + width * 5 / 8, y)); + points.add(new Point2D.Double(x + width, y)); + points.add(new Point2D.Double(x + width * 7 / 8, y + height / 2)); + points.add(new Point2D.Double(x + width * 3 / 4, y + height)); + points.add(new Point2D.Double(x + width * 3 / 8, y + height)); + // CHECKSTYLE:ON + points.add(new Point2D.Double(x, y + height)); + return points; + } + + /** + * Returns shape of the Rna as a GeneralPath object. + * + * @param alias + * alias for which we are looking for a border + * @return GeneralPath object defining border of the given alias + */ + private GeneralPath getRnaPath(Element alias) { + // CHECKSTYLE:OFF + GeneralPath path; + if (!alias.getModel().isSbgnFormat()) { + path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 4); + path.moveTo(alias.getX() + alias.getWidth() / 4, alias.getY()); + path.lineTo(alias.getX() + alias.getWidth(), alias.getY()); + path.lineTo(alias.getX() + alias.getWidth() * 3 / 4, alias.getY() + alias.getHeight()); + path.lineTo(alias.getX(), alias.getY() + alias.getHeight()); + path.closePath(); + } else { + path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 6); + double x = alias.getX(), y = alias.getY(), width = alias.getWidth(), height = alias.getHeight(); + + path.moveTo(x, y); + path.lineTo(x, y + height - RECTANGLE_CORNER_ARC_SIZE); + path.curveTo(x, y + height, + x + RECTANGLE_CORNER_ARC_SIZE, y + height, + x + RECTANGLE_CORNER_ARC_SIZE, y + height); + path.lineTo(x + width - RECTANGLE_CORNER_ARC_SIZE, y + height); + path.curveTo(x + width, y + height, + x + width, y + height - RECTANGLE_CORNER_ARC_SIZE, + x + width, y + height - RECTANGLE_CORNER_ARC_SIZE); + path.lineTo(x + width, y); + path.closePath(); + } + // CHECKSTYLE:ON + return path; + } + +} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/SimpleMoleculeCellDesignerAliasConverter.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/SimpleMoleculeCellDesignerAliasConverter.java index 1c558af529..1023676545 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/SimpleMoleculeCellDesignerAliasConverter.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/SimpleMoleculeCellDesignerAliasConverter.java @@ -5,7 +5,7 @@ import java.awt.geom.Point2D; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Species; /** * Class that provides CellDesigner specific graphical information for @@ -14,10 +14,10 @@ import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; * @author Piotr Gawron * */ -public class SimpleMoleculeCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<SpeciesAlias> { +public class SimpleMoleculeCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<Species> { @Override - public Point2D getPointCoordinates(SpeciesAlias alias, CellDesignerAnchor anchor) { + public Point2D getPointCoordinates(Species alias, CellDesignerAnchor anchor) { double x = alias.getX(); double y = alias.getY(); double width = Math.max(alias.getWidth(), 1); @@ -32,7 +32,7 @@ public class SimpleMoleculeCellDesignerAliasConverter extends AbstractCellDesign } @Override - public Point2D getAnchorPointCoordinates(SpeciesAlias alias, double angle) { + public Point2D getAnchorPointCoordinates(Species alias, double angle) { if (alias.getWidth().equals(0.0) && alias.getHeight().equals(0.0)) { return alias.getCenter(); } @@ -48,7 +48,7 @@ public class SimpleMoleculeCellDesignerAliasConverter extends AbstractCellDesign } @Override - public PathIterator getBoundPathIterator(SpeciesAlias alias) { + public PathIterator getBoundPathIterator(Species alias) { throw new NotImplementedException("This class doesn't provide boundPath"); } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/UnknownCellDesignerAliasConverter.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/UnknownCellDesignerAliasConverter.java index 719c38f3b8..3be9ff8abc 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/UnknownCellDesignerAliasConverter.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/UnknownCellDesignerAliasConverter.java @@ -5,19 +5,19 @@ import java.awt.geom.Point2D; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Species; /** * Class that provides CellDesigner specific graphical information for - * {@link lcsb.mapviewer.converter.model.celldesigner.structure.db.model.map.species.Unknown Unknown}. It's used for + * {@link lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerUnknown.model.map.species.Unknown Unknown}. It's used for * conversion from xml to normal x,y coordinates. * * @author Piotr Gawron * */ -public class UnknownCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<SpeciesAlias> { +public class UnknownCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<Species> { @Override - public Point2D getPointCoordinates(SpeciesAlias alias, CellDesignerAnchor anchor) { + public Point2D getPointCoordinates(Species alias, CellDesignerAnchor anchor) { if (invalidAnchorPosition(alias, anchor)) { return alias.getCenter(); } @@ -25,12 +25,12 @@ public class UnknownCellDesignerAliasConverter extends AbstractCellDesignerAlias } @Override - public PathIterator getBoundPathIterator(SpeciesAlias alias) { + public PathIterator getBoundPathIterator(Species alias) { throw new NotImplementedException("This class doesn't provide boundPath"); } @Override - public Point2D getAnchorPointCoordinates(SpeciesAlias alias, double angle) { + public Point2D getAnchorPointCoordinates(Species alias, double angle) { if (alias.getWidth() == 0 && alias.getHeight() == 0) { return alias.getCenter(); } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/helper/PolylineDataFactory.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/helper/PolylineDataFactory.java index df3e1dabb9..64483cb31c 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/helper/PolylineDataFactory.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/helper/PolylineDataFactory.java @@ -1,61 +1,61 @@ -package lcsb.mapviewer.converter.model.celldesigner.geometry.helper; - -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.List; - -import lcsb.mapviewer.converter.model.celldesigner.structure.EditPoints; -import lcsb.mapviewer.model.graphics.PolylineData; - -/** - * Facory util that creates {@link PolylineData} objects from CellDesigner - * structure. - * - * @author Piotr Gawron - * - */ -public final class PolylineDataFactory { - - /** - * Default constructore that prevent instantiation. - */ - private PolylineDataFactory() { - } - - /** - * Creates {@link PolylineData} object from two CellDesigner base points and - * list of points (in CellDesigner formet). - * - * @param baseA - * first base point - * @param baseB - * second base point - * @param points - * intermediate points in CellDesigner format - * @return {@link PolylineData} object representing input data - */ - public static PolylineData createPolylineDataFromEditPoints(Point2D baseA, Point2D baseB, List<Point2D> points) { - List<Point2D> pointsList = new CellDesignerLineTransformation().getLinePointsFromPoints(baseA, baseB, points); - return new PolylineData(pointsList); - } - - /** - * Creates {@link PolylineData} object from two CellDesigner base points and - * list of points (in CellDesigner formet). - * - * @param baseA - * first base point - * @param baseB - * second base point - * @param points - * structure with intermediate points in CellDesigner format - * @return {@link PolylineData} object representing input data - */ - public static PolylineData createPolylineDataFromEditPoints(Point2D baseA, Point2D baseB, EditPoints points) { - if (points != null) { - return createPolylineDataFromEditPoints(baseA, baseB, points.getPoints()); - } else { - return createPolylineDataFromEditPoints(baseA, baseB, new ArrayList<Point2D>()); - } - } -} +package lcsb.mapviewer.converter.model.celldesigner.geometry.helper; + +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.List; + +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.EditPoints; +import lcsb.mapviewer.model.graphics.PolylineData; + +/** + * Facory util that creates {@link PolylineData} objects from CellDesigner + * structure. + * + * @author Piotr Gawron + * + */ +public final class PolylineDataFactory { + + /** + * Default constructore that prevent instantiation. + */ + private PolylineDataFactory() { + } + + /** + * Creates {@link PolylineData} object from two CellDesigner base points and + * list of points (in CellDesigner formet). + * + * @param baseA + * first base point + * @param baseB + * second base point + * @param points + * intermediate points in CellDesigner format + * @return {@link PolylineData} object representing input data + */ + public static PolylineData createPolylineDataFromEditPoints(Point2D baseA, Point2D baseB, List<Point2D> points) { + List<Point2D> pointsList = new CellDesignerLineTransformation().getLinePointsFromPoints(baseA, baseB, points); + return new PolylineData(pointsList); + } + + /** + * Creates {@link PolylineData} object from two CellDesigner base points and + * list of points (in CellDesigner formet). + * + * @param baseA + * first base point + * @param baseB + * second base point + * @param points + * structure with intermediate points in CellDesigner format + * @return {@link PolylineData} object representing input data + */ + public static PolylineData createPolylineDataFromEditPoints(Point2D baseA, Point2D baseB, EditPoints points) { + if (points != null) { + return createPolylineDataFromEditPoints(baseA, baseB, points.getPoints()); + } else { + return createPolylineDataFromEditPoints(baseA, baseB, new ArrayList<Point2D>()); + } + } +} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionCollectionXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionCollectionXmlParser.java index 94c27b11d3..0bcaec942f 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionCollectionXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionCollectionXmlParser.java @@ -38,7 +38,6 @@ public class ReactionCollectionXmlParser extends XmlParser { * Object used for parsing single reaction. */ private ReactionXmlParser xmlStructureFactory; - private CellDesignerElementCollection elements; /** * Default constructor. Model is required because some nodes require access to @@ -49,7 +48,6 @@ public class ReactionCollectionXmlParser extends XmlParser { */ public ReactionCollectionXmlParser(Model model, CellDesignerElementCollection elements) { this.model = model; - this.elements = elements; xmlStructureFactory = new ReactionXmlParser(elements); } 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 dcaec51edc..3bf8dc5200 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 @@ -25,9 +25,9 @@ import lcsb.mapviewer.converter.model.celldesigner.geometry.ReactionCellDesigner import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerPointTransformation; import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.PolylineDataFactory; -import lcsb.mapviewer.converter.model.celldesigner.structure.ConnectScheme; -import lcsb.mapviewer.converter.model.celldesigner.structure.EditPoints; -import lcsb.mapviewer.converter.model.celldesigner.structure.LineProperties; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.ConnectScheme; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.EditPoints; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.LineProperties; import lcsb.mapviewer.converter.model.celldesigner.types.ModifierType; import lcsb.mapviewer.converter.model.celldesigner.types.ModifierTypeUtils; import lcsb.mapviewer.converter.model.celldesigner.types.OperatorType; @@ -36,8 +36,6 @@ import lcsb.mapviewer.model.graphics.ArrowType; import lcsb.mapviewer.model.graphics.ArrowTypeData; import lcsb.mapviewer.model.graphics.LineType; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.reaction.AbstractNode; import lcsb.mapviewer.model.map.reaction.AndOperator; @@ -61,6 +59,8 @@ import lcsb.mapviewer.model.map.reaction.type.SimpleReactionInterface; import lcsb.mapviewer.model.map.reaction.type.TruncationReaction; import lcsb.mapviewer.model.map.reaction.type.TwoProductReactionInterface; import lcsb.mapviewer.model.map.reaction.type.TwoReactantReactionInterface; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; /** * This is a part of {@link ReactionXmlParser} class functionality that allows @@ -481,7 +481,7 @@ public class ReactionFromXml extends XmlParser { * modifier to update */ private void createLineForModifier(Reaction reaction, Modifier modifier) { - Alias alias = modifier.getAlias(); + Element alias = modifier.getAlias(); CellDesignerAliasConverter converter = new CellDesignerAliasConverter(alias); Point2D startPoint = converter.getPointCoordinates(alias, anchorsByNodes.get(modifier)); ModifierTypeUtils modifierTypeUtils = new ModifierTypeUtils(); @@ -891,9 +891,9 @@ public class ReactionFromXml extends XmlParser { Point2D p2 = reactantConverter2.getPointCoordinates(reactant2.getAlias(), anchorsByNodes.get(reactant2)); Point2D p3 = productConverter.getPointCoordinates(product.getAlias(), anchorsByNodes.get(product)); - Alias alias1 = reactant1.getAlias(); - Alias alias2 = reactant2.getAlias(); - Alias alias3 = product.getAlias(); + Element alias1 = reactant1.getAlias(); + Element alias2 = reactant2.getAlias(); + Element alias3 = product.getAlias(); Point2D pointA = alias2.getCenter(); Point2D pointC = alias1.getCenter(); @@ -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); - SpeciesAlias al = (SpeciesAlias) model.getAliasByAliasId(aliasId); + Species al = (Species) model.getAliasByAliasId(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); - SpeciesAlias al = (SpeciesAlias) model.getAliasByAliasId(aliasId); + Species al = (Species) model.getAliasByAliasId(aliasId); if (al == null) { throw new ReactionParserException("Alias doesn't exist (id: " + aliasId + ")", reaction); } @@ -1367,11 +1367,11 @@ public class ReactionFromXml extends XmlParser { String lineConnectionType = getNodeAttr("targetLineIndex", rootNode); String points = getNodeAttr("editPoints", rootNode); - List<SpeciesAlias> aliasList = new ArrayList<SpeciesAlias>(); + List<Species> aliasList = new ArrayList<Species>(); String[] list = aliasId.split(","); for (String string : list) { - SpeciesAlias al = (SpeciesAlias) model.getAliasByAliasId(string); + Species al = (Species) model.getAliasByAliasId(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); - SpeciesAlias alias = (SpeciesAlias) model.getAliasByAliasId(aliasId); + Species alias = (Species) model.getAliasByAliasId(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); - SpeciesAlias alias = (SpeciesAlias) model.getAliasByAliasId(aliasId); + Species alias = (Species) model.getAliasByAliasId(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 65d6cd0a9d..75e72f5e0b 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 @@ -26,9 +26,6 @@ import lcsb.mapviewer.converter.model.celldesigner.types.ModifierTypeUtils; import lcsb.mapviewer.converter.model.celldesigner.types.OperatorType; import lcsb.mapviewer.converter.model.celldesigner.types.OperatorTypeUtils; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.reaction.AbstractNode; import lcsb.mapviewer.model.map.reaction.Modifier; import lcsb.mapviewer.model.map.reaction.NodeOperator; @@ -38,6 +35,9 @@ import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.type.SimpleReactionInterface; import lcsb.mapviewer.model.map.reaction.type.TwoProductReactionInterface; import lcsb.mapviewer.model.map.reaction.type.TwoReactantReactionInterface; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.modelutils.map.ElementUtils; /** @@ -179,7 +179,7 @@ public class ReactionToXml extends XmlParser { * @return modifierSpeciesReference sbml node for given modifer */ private String getModifierReferenceXmlString(Modifier modifier) { - Alias alias = modifier.getAlias(); + Element alias = modifier.getAlias(); StringBuilder sb = new StringBuilder(); sb.append("<modifierSpeciesReference "); sb.append("metaid=\"" + elements.getElementId(alias) + "\" "); @@ -348,7 +348,7 @@ public class ReactionToXml extends XmlParser { for (Product product : reaction.getProducts()) { // metaid is missing, maybe it will work ;) - Alias alias = product.getAlias(); + Element alias = product.getAlias(); sb.append("<speciesReference species=\"" + elements.getElementId(alias) + "\">\n"); @@ -375,9 +375,9 @@ public class ReactionToXml extends XmlParser { sb.append("<listOfReactants>\n"); for (Reactant reactant : reaction.getReactants()) { // metaid is missing, maybe it will work ;) - SpeciesAlias species = (SpeciesAlias) reactant.getAlias(); + Species species = (Species) reactant.getAlias(); - Set<Alias> parents = new HashSet<>(); + Set<Element> parents = new HashSet<>(); // we need top parent species while (species.getComplexAlias() != null) { @@ -388,8 +388,8 @@ public class ReactionToXml extends XmlParser { parents.add(species); } // and top parent alias (for sbml compliant view of celldesigner file) - Alias alias = reactant.getAlias(); - while (alias.getParent() instanceof ComplexAlias) { + Element alias = reactant.getAlias(); + while (alias.getParent() instanceof Complex) { alias = alias.getParent(); } sb.append("<speciesReference species=\"" + elements.getElementId(species) + "\">\n"); @@ -466,8 +466,8 @@ public class ReactionToXml extends XmlParser { result.append("<celldesigner:listOfGateMember>\n"); ReactionLineData lineData = ReactionLineData .getByLineType(reaction.getProducts().get(0).getLine().getType(), reaction.getProducts().get(0).getLine().getEndAtd().getArrowType()); - Alias alias1 = reactant1.getAlias(); - Alias alias2 = reactant2.getAlias(); + Element alias1 = reactant1.getAlias(); + Element alias2 = reactant2.getAlias(); // product line result.append("<celldesigner:GateMember type=\"" + type.getStringName() + "\""); @@ -596,7 +596,7 @@ public class ReactionToXml extends XmlParser { * @return xml node describing reactantLink */ private String getReactantLinkXmlString(Reactant reactant) { - Alias alias = reactant.getAlias(); + Element alias = reactant.getAlias(); StringBuilder sb = new StringBuilder(); sb.append("<celldesigner:reactantLink "); sb.append("reactant=\"" + elements.getElementId(alias) + "\" "); @@ -633,7 +633,7 @@ public class ReactionToXml extends XmlParser { * @return xml node describing productLink */ private String getProductLinkXmlString(Product product) { - Alias alias = product.getAlias(); + Element alias = product.getAlias(); PolylineData[] lines = new PolylineData[] { product.getLine() }; StringBuilder sb = new StringBuilder(); @@ -695,12 +695,12 @@ public class ReactionToXml extends XmlParser { /** * Creates - * {@link lcsb.mapviewer.converter.model.celldesigner.structure.EditPoints} + * {@link lcsb.mapviewer.converter.model.celldesigner.structure.fields.EditPoints} * structure representing lines in CellDesigner. * * @param lines * lines to be transformed into single - * {@link lcsb.mapviewer.converter.model.celldesigner.structure.EditPoints} + * {@link lcsb.mapviewer.converter.model.celldesigner.structure.fields.EditPoints} * structure * @param centerIndex * where the central line is positioned @@ -712,12 +712,12 @@ public class ReactionToXml extends XmlParser { /** * Creates - * {@link lcsb.mapviewer.converter.model.celldesigner.structure.EditPoints} + * {@link lcsb.mapviewer.converter.model.celldesigner.structure.fields.EditPoints} * structure representing lines in CellDesigner. * * @param lines * lines to be transformed into single - * {@link lcsb.mapviewer.converter.model.celldesigner.structure.EditPoints} + * {@link lcsb.mapviewer.converter.model.celldesigner.structure.fields.EditPoints} * structure * @param centerPoint * central point whene list of lines is greater than 1 @@ -767,13 +767,13 @@ public class ReactionToXml extends XmlParser { /** * Returns xml node representing - * {@link lcsb.mapviewer.converter.model.celldesigner.structure.EditPoints} + * {@link lcsb.mapviewer.converter.model.celldesigner.structure.fields.EditPoints} * structure. * * @param reaction * reaction for which xml node is generated * @return xml node representing - * {@link lcsb.mapviewer.converter.model.celldesigner.structure.EditPoints} + * {@link lcsb.mapviewer.converter.model.celldesigner.structure.fields.EditPoints} * structure */ String getEditPointsXmlStringForReaction(Reaction reaction) { @@ -972,7 +972,7 @@ public class ReactionToXml extends XmlParser { StringBuilder sb = new StringBuilder(); sb.append("<celldesigner:baseProducts>\n"); for (Product product : products) { - Alias alias = product.getAlias(); + Element alias = product.getAlias(); sb.append("<celldesigner:baseProduct "); sb.append("species=\"" + elements.getElementId(product.getAlias()) + "\" "); sb.append("alias=\"" + product.getAlias().getAliasId() + "\" "); @@ -1002,7 +1002,7 @@ public class ReactionToXml extends XmlParser { StringBuilder sb = new StringBuilder(); sb.append("<celldesigner:baseReactants>\n"); for (Reactant reactant : reactants) { - Alias alias = reactant.getAlias(); + Element alias = reactant.getAlias(); sb.append("<celldesigner:baseReactant "); sb.append("species=\"" + elements.getElementId(reactant.getAlias()) + "\" "); sb.append("alias=\"" + reactant.getAlias().getAliasId() + "\" "); @@ -1025,7 +1025,7 @@ public class ReactionToXml extends XmlParser { * point * @return xml node with anchor point */ - private String getAnchorXml(Alias alias, Point2D point) { + private String getAnchorXml(Element alias, Point2D point) { CellDesignerAliasConverter converter = new CellDesignerAliasConverter(alias); CellDesignerAnchor anchor = converter.getAnchorForCoordinates(alias, point); if (anchor != null) { diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionXmlParser.java index a51a7f7392..92ca7c65bc 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionXmlParser.java @@ -27,10 +27,7 @@ public class ReactionXmlParser extends XmlParser { */ private ReactionFromXml reactionFromXml; - private CellDesignerElementCollection elements; - public ReactionXmlParser(CellDesignerElementCollection elements) { - this.elements = elements; reactionToXml = new ReactionToXml(elements); reactionFromXml = new ReactionFromXml(elements); } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/AbstractElementXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/AbstractElementXmlParser.java index 5dc3dea215..5d6268512a 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/AbstractElementXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/AbstractElementXmlParser.java @@ -7,9 +7,9 @@ import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.common.XmlParser; import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; import lcsb.mapviewer.converter.model.celldesigner.annotation.RestAnnotationParser; -import lcsb.mapviewer.converter.model.celldesigner.structure.Element; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerElement; import lcsb.mapviewer.model.map.InconsistentModelException; -import lcsb.mapviewer.model.map.layout.alias.Alias; +import lcsb.mapviewer.model.map.species.Element; import org.apache.log4j.Logger; import org.w3c.dom.Document; @@ -24,7 +24,7 @@ import org.w3c.dom.NodeList; * @param <T> * type of the object to parse */ -public abstract class AbstractElementXmlParser<T extends Element<?>, S extends Alias> extends XmlParser { +public abstract class AbstractElementXmlParser<T extends CellDesignerElement<?>, S extends Element> extends XmlParser { /** * Default class logger. 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 02a2833012..0535c416c8 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 @@ -8,11 +8,11 @@ import lcsb.mapviewer.common.Pair; 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.AntisenseRna; -import lcsb.mapviewer.converter.model.celldesigner.structure.AntisenseRnaRegion; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaAlias; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaRegionAlias; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaRegionAlias.AntisenseRnaRegionType; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerAntisenseRna; +import lcsb.mapviewer.converter.model.celldesigner.structure.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; /** * Class that performs parsing of the CellDesigner xml for AntisenseRna object. @@ -20,7 +20,7 @@ import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaRegionAlias.AntisenseRn * @author Piotr Gawron * */ -public class AntisenseRnaXmlParser extends AbstractElementXmlParser<AntisenseRna, AntisenseRnaAlias> { +public class AntisenseRnaXmlParser extends AbstractElementXmlParser<CellDesignerAntisenseRna, AntisenseRna> { /** * Default class logger. @@ -35,8 +35,8 @@ public class AntisenseRnaXmlParser extends AbstractElementXmlParser<AntisenseRna } @Override - public Pair<String, AntisenseRna> parseXmlElement(Node antisenseRnaNode) throws InvalidXmlSchemaException { - AntisenseRna antisenseRna = new AntisenseRna(); + public Pair<String, CellDesignerAntisenseRna> parseXmlElement(Node antisenseRnaNode) throws InvalidXmlSchemaException { + CellDesignerAntisenseRna antisenseRna = new CellDesignerAntisenseRna(); String identifier = getNodeAttr("id", antisenseRnaNode); antisenseRna.setName(decodeName(getNodeAttr("name", antisenseRnaNode))); NodeList list = antisenseRnaNode.getChildNodes(); @@ -62,12 +62,12 @@ public class AntisenseRnaXmlParser extends AbstractElementXmlParser<AntisenseRna } } } - Pair<String, AntisenseRna> result = new Pair<String, AntisenseRna>(identifier, antisenseRna); + Pair<String, CellDesignerAntisenseRna> result = new Pair<String, CellDesignerAntisenseRna>(identifier, antisenseRna); return result; } @Override - public String toXml(AntisenseRnaAlias antisenseRna) { + public String toXml(AntisenseRna antisenseRna) { String attributes = ""; String result = ""; attributes += " id=\"ar_" + elements.getElementId(antisenseRna) + "\""; @@ -85,7 +85,7 @@ public class AntisenseRnaXmlParser extends AbstractElementXmlParser<AntisenseRna result += "</celldesigner:notes>"; if (antisenseRna.getRegions().size() > 0) { result += "<celldesigner:listOfRegions>"; - for (AntisenseRnaRegionAlias region : antisenseRna.getRegions()) { + for (AntisenseRnaRegion region : antisenseRna.getRegions()) { result += toXml(region); } result += "</celldesigner:listOfRegions>"; @@ -101,7 +101,7 @@ public class AntisenseRnaXmlParser extends AbstractElementXmlParser<AntisenseRna * object to be transformed * @return xml representation of the given region */ - private String toXml(AntisenseRnaRegionAlias region) { + private String toXml(AntisenseRnaRegion region) { String result = ""; String attributes = ""; if (!region.getIdAntisenseRnaRegion().equals("")) { @@ -134,8 +134,8 @@ public class AntisenseRnaXmlParser extends AbstractElementXmlParser<AntisenseRna * @throws InvalidXmlSchemaException * thrown when input xml node doesn't follow defined schema */ - private AntisenseRnaRegion getAntisenseRnaRegion(Node regionNode) throws InvalidXmlSchemaException { - AntisenseRnaRegion residue = new AntisenseRnaRegion(); + private CellDesignerAntisenseRnaRegion getAntisenseRnaRegion(Node regionNode) throws InvalidXmlSchemaException { + CellDesignerAntisenseRnaRegion residue = new CellDesignerAntisenseRnaRegion(); residue.setIdAntisenseRnaRegion(getNodeAttr("id", regionNode)); residue.setName(getNodeAttr("name", regionNode)); residue.setSize(getNodeAttr("size", regionNode)); diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/GeneXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/GeneXmlParser.java index a113aff089..273be9a258 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/GeneXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/GeneXmlParser.java @@ -8,18 +8,18 @@ import lcsb.mapviewer.common.Pair; 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.Gene; -import lcsb.mapviewer.converter.model.celldesigner.structure.ModificationResidue; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationResidueAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerGene; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; /** - * Class that performs parsing of the CellDesigner xml for {@link Gene} object. + * Class that performs parsing of the CellDesigner xml for {@link CellDesignerGene} object. * * @author Piotr Gawron * */ -public class GeneXmlParser extends AbstractElementXmlParser<Gene, GeneAlias> { +public class GeneXmlParser extends AbstractElementXmlParser<CellDesignerGene, Gene> { /** * Default class logger. @@ -34,8 +34,8 @@ public class GeneXmlParser extends AbstractElementXmlParser<Gene, GeneAlias> { } @Override - public Pair<String, Gene> parseXmlElement(Node geneNode) throws InvalidXmlSchemaException { - Gene gene = new Gene(); + public Pair<String, CellDesignerGene> parseXmlElement(Node geneNode) throws InvalidXmlSchemaException { + CellDesignerGene gene = new CellDesignerGene(); String identifier = getNodeAttr("id", geneNode); gene.setName(decodeName(getNodeAttr("name", geneNode))); NodeList list = geneNode.getChildNodes(); @@ -61,7 +61,7 @@ public class GeneXmlParser extends AbstractElementXmlParser<Gene, GeneAlias> { } } } - return new Pair<String, Gene>(identifier, gene); + return new Pair<String, CellDesignerGene>(identifier, gene); } /** @@ -73,8 +73,8 @@ public class GeneXmlParser extends AbstractElementXmlParser<Gene, GeneAlias> { * @throws InvalidXmlSchemaException * thrown when input xml node doesn't follow defined schema */ - ModificationResidue getModificationResidue(Node residueNode) throws InvalidXmlSchemaException { - ModificationResidue residue = new ModificationResidue(); + CellDesignerModificationResidue getModificationResidue(Node residueNode) throws InvalidXmlSchemaException { + CellDesignerModificationResidue residue = new CellDesignerModificationResidue(); residue.setIdModificationResidue(getNodeAttr("id", residueNode)); residue.setName(getNodeAttr("name", residueNode)); residue.setSide(getNodeAttr("side", residueNode)); @@ -90,7 +90,7 @@ public class GeneXmlParser extends AbstractElementXmlParser<Gene, GeneAlias> { } @Override - public String toXml(GeneAlias gene) { + public String toXml(Gene gene) { String attributes = ""; String result = ""; attributes += " id=\"g_" + elements.getElementId(gene) + "\""; @@ -108,7 +108,7 @@ public class GeneXmlParser extends AbstractElementXmlParser<Gene, GeneAlias> { if (gene.getModificationResidues().size() > 0) { result += "<celldesigner:listOfRegions>\n"; - for (ModificationResidueAlias mr : gene.getModificationResidues()) { + for (ModificationResidue mr : gene.getModificationResidues()) { result += toXml(mr); } result += "</celldesigner:listOfRegions>\n"; @@ -119,13 +119,13 @@ public class GeneXmlParser extends AbstractElementXmlParser<Gene, GeneAlias> { } /** - * Generates CellDesigner xml for {@link ModificationResidue}. + * Generates CellDesigner xml for {@link CellDesignerModificationResidue}. * * @param mr * object to transform into xml - * @return CellDesigner xml for {@link ModificationResidue} + * @return CellDesigner xml for {@link CellDesignerModificationResidue} */ - String toXml(ModificationResidueAlias mr) { + String toXml(ModificationResidue mr) { String result = ""; String attributes = ""; if (!mr.getIdModificationResidue().equals("")) { diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/InternalModelSpeciesData.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/InternalModelSpeciesData.java index 79b6301913..fe20ad5b43 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/InternalModelSpeciesData.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/InternalModelSpeciesData.java @@ -8,18 +8,18 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.converter.model.celldesigner.structure.AntisenseRna; -import lcsb.mapviewer.converter.model.celldesigner.structure.ComplexSpecies; -import lcsb.mapviewer.converter.model.celldesigner.structure.Degraded; -import lcsb.mapviewer.converter.model.celldesigner.structure.Drug; -import lcsb.mapviewer.converter.model.celldesigner.structure.Gene; -import lcsb.mapviewer.converter.model.celldesigner.structure.Ion; -import lcsb.mapviewer.converter.model.celldesigner.structure.Phenotype; -import lcsb.mapviewer.converter.model.celldesigner.structure.Protein; -import lcsb.mapviewer.converter.model.celldesigner.structure.Rna; -import lcsb.mapviewer.converter.model.celldesigner.structure.SimpleMolecule; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; -import lcsb.mapviewer.converter.model.celldesigner.structure.Unknown; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerAntisenseRna; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerComplexSpecies; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerDegraded; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerDrug; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerGene; +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.CellDesignerSimpleMolecule; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerUnknown; /** * This class contains information about all species in model that are relevant @@ -39,57 +39,57 @@ public class InternalModelSpeciesData { /** * Collection of proteins. Used only by the CellDesigner parser. */ - private SpeciesCollection<Protein<?>> proteins; + private SpeciesCollection<CellDesignerProtein<?>> proteins; /** * Collection of genes. Used only by the CellDesigner parser. */ - private SpeciesCollection<Gene> genes; + private SpeciesCollection<CellDesignerGene> genes; /** * Collection of genes. Used only by the CellDesigner parser. */ - private SpeciesCollection<Rna> rnas; + private SpeciesCollection<CellDesignerRna> rnas; /** * Collection of antisense rnas. Used only by the CellDesigner parser. */ - private SpeciesCollection<AntisenseRna> antisenseRnas; + private SpeciesCollection<CellDesignerAntisenseRna> antisenseRnas; /** * Collection of phenotypes. Used only by the CellDesigner parser. */ - private SpeciesCollection<Phenotype> phenotypes; + private SpeciesCollection<CellDesignerPhenotype> phenotypes; /** * Collection of ions. Used only by the CellDesigner parser. */ - private SpeciesCollection<Ion> ions; + private SpeciesCollection<CellDesignerIon> ions; /** * Collection of simple molecules. Used only by the CellDesigner parser. */ - private SpeciesCollection<SimpleMolecule> simpleMolecules; + private SpeciesCollection<CellDesignerSimpleMolecule> simpleMolecules; /** * Collection of drugs. Used only by the CellDesigner parser. */ - private SpeciesCollection<Drug> drugs; + private SpeciesCollection<CellDesignerDrug> drugs; /** * Collection of unknowns. Used only by the CellDesigner parser. */ - private SpeciesCollection<Unknown> unknowns; + private SpeciesCollection<CellDesignerUnknown> unknowns; /** * Collection of degraded elements. Used only by the CellDesigner parser. */ - private SpeciesCollection<Degraded> degradeds; + private SpeciesCollection<CellDesignerDegraded> degradeds; /** * Collection of complexes. */ - private List<ComplexSpecies> complexes = new ArrayList<>(); + private List<CellDesignerComplexSpecies> complexes = new ArrayList<>(); /** * Default constructor. @@ -111,7 +111,7 @@ public class InternalModelSpeciesData { * * @return {@link #proteins} */ - public Collection<Protein<?>> getProteins() { + public Collection<CellDesignerProtein<?>> getProteins() { return proteins.getAll(); } @@ -119,7 +119,7 @@ public class InternalModelSpeciesData { * * @return {@link #genes} */ - public Collection<Gene> getGenes() { + public Collection<CellDesignerGene> getGenes() { return genes.getAll(); } @@ -127,7 +127,7 @@ public class InternalModelSpeciesData { * * @return {@link #rnas} */ - public Collection<Rna> getRnas() { + public Collection<CellDesignerRna> getRnas() { return rnas.getAll(); } @@ -135,7 +135,7 @@ public class InternalModelSpeciesData { * * @return {@link #antisenseRnas} */ - public Collection<AntisenseRna> getAntisenseRnas() { + public Collection<CellDesignerAntisenseRna> getAntisenseRnas() { return antisenseRnas.getAll(); } @@ -146,8 +146,8 @@ public class InternalModelSpeciesData { * set of species to be updated, first element in pair defines * celldesigner identifier, second is the species */ - public void updateSpecies(Collection<Pair<String, ? extends Species<?>>> collection) { - for (Pair<String, ? extends Species<?>> species : collection) { + public void updateSpecies(Collection<Pair<String, ? extends CellDesignerSpecies<?>>> collection) { + for (Pair<String, ? extends CellDesignerSpecies<?>> species : collection) { updateSpecies(species.getRight(), species.getLeft()); } } @@ -161,29 +161,29 @@ public class InternalModelSpeciesData { * @param identifier * celldesigner identifier */ - public void updateSpecies(Species<?> sp, String identifier) { - if (sp instanceof Gene) { - genes.updateSpeciesByLocalId((Gene) sp, identifier); - } else if (sp instanceof Protein) { - proteins.updateSpeciesByLocalId((Protein<?>) sp, identifier); - } else if (sp instanceof Rna) { - rnas.updateSpeciesByLocalId((Rna) sp, identifier); - } else if (sp instanceof AntisenseRna) { - antisenseRnas.updateSpeciesByLocalId((AntisenseRna) sp, identifier); - } else if (sp instanceof Degraded) { - degradeds.updateSpeciesByLocalId((Degraded) sp, identifier); - } else if (sp instanceof Unknown) { - unknowns.updateSpeciesByLocalId((Unknown) sp, identifier); - } else if (sp instanceof Drug) { - drugs.updateSpeciesByLocalId((Drug) sp, identifier); - } else if (sp instanceof SimpleMolecule) { - simpleMolecules.updateSpeciesByLocalId((SimpleMolecule) sp, identifier); - } else if (sp instanceof Ion) { - ions.updateSpeciesByLocalId((Ion) sp, identifier); - } else if (sp instanceof Phenotype) { - phenotypes.updateSpeciesByLocalId((Phenotype) sp, identifier); - } else if (sp instanceof ComplexSpecies) { - complexes.add((ComplexSpecies) sp); + public void updateSpecies(CellDesignerSpecies<?> sp, String identifier) { + if (sp instanceof CellDesignerGene) { + genes.updateSpeciesByLocalId((CellDesignerGene) sp, identifier); + } else if (sp instanceof CellDesignerProtein) { + proteins.updateSpeciesByLocalId((CellDesignerProtein<?>) sp, identifier); + } else if (sp instanceof CellDesignerRna) { + rnas.updateSpeciesByLocalId((CellDesignerRna) sp, identifier); + } else if (sp instanceof CellDesignerAntisenseRna) { + antisenseRnas.updateSpeciesByLocalId((CellDesignerAntisenseRna) sp, identifier); + } else if (sp instanceof CellDesignerDegraded) { + degradeds.updateSpeciesByLocalId((CellDesignerDegraded) sp, identifier); + } else if (sp instanceof CellDesignerUnknown) { + unknowns.updateSpeciesByLocalId((CellDesignerUnknown) sp, identifier); + } else if (sp instanceof CellDesignerDrug) { + drugs.updateSpeciesByLocalId((CellDesignerDrug) sp, identifier); + } else if (sp instanceof CellDesignerSimpleMolecule) { + simpleMolecules.updateSpeciesByLocalId((CellDesignerSimpleMolecule) sp, identifier); + } else if (sp instanceof CellDesignerIon) { + ions.updateSpeciesByLocalId((CellDesignerIon) sp, identifier); + } else if (sp instanceof CellDesignerPhenotype) { + phenotypes.updateSpeciesByLocalId((CellDesignerPhenotype) sp, identifier); + } else if (sp instanceof CellDesignerComplexSpecies) { + complexes.add((CellDesignerComplexSpecies) sp); } else { throw new InvalidArgumentException("Unknown species type: " + sp.getClass().getName()); } @@ -194,8 +194,8 @@ public class InternalModelSpeciesData { * * @return list of all species in dataset */ - public Collection<Species<?>> getAll() { - List<Species<?>> result = new ArrayList<>(); + public Collection<CellDesignerSpecies<?>> getAll() { + List<CellDesignerSpecies<?>> result = new ArrayList<>(); result.addAll(genes.getAll()); result.addAll(rnas.getAll()); diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/ProteinMapping.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/ProteinMapping.java index 1c2c682218..64ff8471cb 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/ProteinMapping.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/ProteinMapping.java @@ -3,20 +3,20 @@ package lcsb.mapviewer.converter.model.celldesigner.species; import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.InvalidStateException; -import lcsb.mapviewer.converter.model.celldesigner.structure.GenericProtein; -import lcsb.mapviewer.converter.model.celldesigner.structure.IonChannelProtein; -import lcsb.mapviewer.converter.model.celldesigner.structure.Protein; -import lcsb.mapviewer.converter.model.celldesigner.structure.ReceptorProtein; -import lcsb.mapviewer.converter.model.celldesigner.structure.TruncatedProtein; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.IonChannelProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ReceptorProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.TruncatedProteinAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerGenericProtein; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerIonChannelProtein; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerProtein; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerReceptorProtein; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerTruncatedProtein; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.IonChannelProtein; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.ReceptorProtein; +import lcsb.mapviewer.model.map.species.TruncatedProtein; /** * This enum contains information about mapping between CellDesigner xml nodes - * and classes that extend {@link Protein}. + * and classes that extend {@link CellDesignerProtein}. * * @author Piotr Gawron * @@ -26,22 +26,22 @@ public enum ProteinMapping { /** * {@link GenericProtein}. */ - GENERIC_PROTEIN(GenericProteinAlias.class, GenericProtein.class, "GENERIC"), + GENERIC_PROTEIN(GenericProtein.class, CellDesignerGenericProtein.class, "GENERIC"), /** * {@link IonChannelProtein}. */ - ION_CHANNEL_PROTEIN(IonChannelProteinAlias.class, IonChannelProtein.class, "ION_CHANNEL"), + ION_CHANNEL_PROTEIN(IonChannelProtein.class, CellDesignerIonChannelProtein.class, "ION_CHANNEL"), /** * {@link ReceptorProtein}. */ - RECEPTOR_PROTEIN(ReceptorProteinAlias.class, ReceptorProtein.class, "RECEPTOR"), + RECEPTOR_PROTEIN(ReceptorProtein.class, CellDesignerReceptorProtein.class, "RECEPTOR"), /** * {@link TruncatedProtein}. */ - TRUNCATED_PROTEIN(TruncatedProteinAlias.class, TruncatedProtein.class, "TRUNCATED"); + TRUNCATED_PROTEIN(TruncatedProtein.class, CellDesignerTruncatedProtein.class, "TRUNCATED"); /** * CellDesigner xml node type. @@ -51,11 +51,12 @@ public enum ProteinMapping { /** * Class that should be used to represent cell designer node. */ - private Class<? extends ProteinAlias> clazz; + private Class<? extends Protein> clazz; - private static Logger logger = Logger.getLogger(ProteinMapping.class); + @SuppressWarnings("unused") + private static Logger logger = Logger.getLogger(ProteinMapping.class); - private Class<? extends Protein> cellDesignerClazz; + private Class<? extends CellDesignerProtein<?>> cellDesignerClazz; /** * Default constructor. @@ -65,7 +66,7 @@ public enum ProteinMapping { * @param cellDesignerString * {@link #cellDesignerString} */ - ProteinMapping(Class<? extends ProteinAlias> modelClazz, Class<? extends Protein> cellDesignerClazz, String cellDesignerString) { + ProteinMapping(Class<? extends Protein> modelClazz, Class<? extends CellDesignerProtein<?>> cellDesignerClazz, String cellDesignerString) { this.cellDesignerString = cellDesignerString; this.clazz = modelClazz; this.cellDesignerClazz = cellDesignerClazz; @@ -83,11 +84,11 @@ public enum ProteinMapping { * @return the clazz * @see #clazz */ - public Class<? extends ProteinAlias> getClazz() { + public Class<? extends Protein> getClazz() { return clazz; } - public Class<? extends Protein> getCellDesignerClazz() { + public Class<? extends CellDesignerProtein<?>> getCellDesignerClazz() { return cellDesignerClazz; } @@ -108,13 +109,13 @@ public enum ProteinMapping { } /** - * Returns {@link ProteinMapping} for given {@link Protein} class. + * Returns {@link ProteinMapping} for given {@link CellDesignerProtein} class. * * @param searchClazz - * {@link Protein} class - * @return {@link ProteinMapping} for given {@link Protein} class + * {@link CellDesignerProtein} class + * @return {@link ProteinMapping} for given {@link CellDesignerProtein} class */ - public static ProteinMapping getMappingByClass(Class<? extends ProteinAlias> searchClazz) { + public static ProteinMapping getMappingByClass(Class<? extends Protein> searchClazz) { for (ProteinMapping mapping : ProteinMapping.values()) { if (mapping.getClazz().isAssignableFrom(searchClazz)) { return mapping; @@ -124,13 +125,13 @@ public enum ProteinMapping { } /** - * Creates instance of {@link Protein} specific for this + * Creates instance of {@link CellDesignerProtein} specific for this * {@link ProteinMapping}. * - * @return new instance of {@link Protein} specific for this + * @return new instance of {@link CellDesignerProtein} specific for this * {@link ProteinMapping}. */ - public Protein createProtein() { + public CellDesignerProtein<?> createProtein() { try { return cellDesignerClazz.getConstructor().newInstance(); } catch (Exception e) { @@ -138,7 +139,7 @@ public enum ProteinMapping { } } - public ProteinAlias createProteinAlias() { + public Protein createProteinAlias() { try { return clazz.getConstructor().newInstance(); } catch (Exception e) { diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/ProteinXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/ProteinXmlParser.java index 90a9750784..7d41df9d79 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/ProteinXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/ProteinXmlParser.java @@ -8,20 +8,20 @@ import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection; -import lcsb.mapviewer.converter.model.celldesigner.structure.ModificationResidue; -import lcsb.mapviewer.converter.model.celldesigner.structure.Protein; -import lcsb.mapviewer.model.map.layout.alias.ModificationResidueAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerProtein; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; /** - * Class that performs parsing of the CellDesigner xml for {@link Protein} + * Class that performs parsing of the CellDesigner xml for {@link CellDesignerProtein} * object. * * @author Piotr Gawron * */ -public class ProteinXmlParser extends AbstractElementXmlParser<Protein<?>, ProteinAlias> { +public class ProteinXmlParser extends AbstractElementXmlParser<CellDesignerProtein<?>, Protein> { /** * Default class logger. @@ -36,8 +36,8 @@ public class ProteinXmlParser extends AbstractElementXmlParser<Protein<?>, Prote } @Override - public Pair<String, Protein<?>> parseXmlElement(Node proteinNode) throws InvalidXmlSchemaException { - Protein<?> protein = null; + public Pair<String, CellDesignerProtein<?>> parseXmlElement(Node proteinNode) throws InvalidXmlSchemaException { + CellDesignerProtein<?> protein = null; String value = getNodeAttr("type", proteinNode); ProteinMapping mapping = ProteinMapping.getMappingByString(value); if (mapping != null) { @@ -72,11 +72,11 @@ public class ProteinXmlParser extends AbstractElementXmlParser<Protein<?>, Prote } } - return new Pair<String, Protein<?>>(identifier, protein); + return new Pair<String, CellDesignerProtein<?>>(identifier, protein); } @Override - public String toXml(ProteinAlias protein) { + public String toXml(Protein protein) { String attributes = ""; String result = ""; attributes += " id=\"p_" + elements.getElementId(protein) + "\""; @@ -94,7 +94,7 @@ public class ProteinXmlParser extends AbstractElementXmlParser<Protein<?>, Prote result += "<celldesigner:protein" + attributes + ">\n"; if (protein.getModificationResidues().size() > 0) { result += "<celldesigner:listOfModificationResidues>"; - for (ModificationResidueAlias mr : protein.getModificationResidues()) { + for (ModificationResidue mr : protein.getModificationResidues()) { result += toXml(mr); } result += "</celldesigner:listOfModificationResidues>\n"; @@ -107,13 +107,13 @@ public class ProteinXmlParser extends AbstractElementXmlParser<Protein<?>, Prote } /** - * Generates CellDesigner xml for {@link ModificationResidue}. + * Generates CellDesigner xml for {@link CellDesignerModificationResidue}. * * @param mr * object to transform into xml - * @return CellDesigner xml for {@link ModificationResidue} + * @return CellDesigner xml for {@link CellDesignerModificationResidue} */ - private String toXml(ModificationResidueAlias mr) { + private String toXml(ModificationResidue mr) { String result = ""; String attributes = ""; if (!mr.getIdModificationResidue().equals("")) { @@ -139,12 +139,12 @@ public class ProteinXmlParser extends AbstractElementXmlParser<Protein<?>, Prote * * @param residueNode * xml node to parse - * @return {@link ModificationResidue} object created from the node + * @return {@link CellDesignerModificationResidue} object created from the node * @throws InvalidXmlSchemaException * thrown when input xml node doesn't follow defined schema */ - private ModificationResidue getModificationResidue(Node residueNode) throws InvalidXmlSchemaException { - ModificationResidue residue = new ModificationResidue(); + private CellDesignerModificationResidue getModificationResidue(Node residueNode) throws InvalidXmlSchemaException { + CellDesignerModificationResidue residue = new CellDesignerModificationResidue(); residue.setIdModificationResidue(getNodeAttr("id", residueNode)); residue.setName(getNodeAttr("name", residueNode)); residue.setSide(getNodeAttr("side", residueNode)); 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 816c08eefe..025e5e3d12 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 @@ -8,18 +8,18 @@ import lcsb.mapviewer.common.Pair; 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.Rna; -import lcsb.mapviewer.converter.model.celldesigner.structure.RnaRegion; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerRna; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerRnaRegion; +import lcsb.mapviewer.model.map.species.Rna; /** - * Class that performs parsing of the CellDesigner xml for {@link Rna} object. + * Class that performs parsing of the CellDesigner xml for {@link CellDesignerRna} object. * * @author Piotr Gawron * */ -public class RnaXmlParser extends AbstractElementXmlParser<Rna, RnaAlias> { +public class RnaXmlParser extends AbstractElementXmlParser<CellDesignerRna, Rna> { /** * Default class logger. @@ -34,8 +34,8 @@ public class RnaXmlParser extends AbstractElementXmlParser<Rna, RnaAlias> { } @Override - public Pair<String, Rna> parseXmlElement(Node rnaNode) throws InvalidXmlSchemaException { - Rna rna = new Rna(); + public Pair<String, CellDesignerRna> parseXmlElement(Node rnaNode) throws InvalidXmlSchemaException { + CellDesignerRna rna = new CellDesignerRna(); String identifier = getNodeAttr("id", rnaNode); rna.setName(decodeName(getNodeAttr("name", rnaNode))); NodeList list = rnaNode.getChildNodes(); @@ -61,7 +61,7 @@ public class RnaXmlParser extends AbstractElementXmlParser<Rna, RnaAlias> { } } } - return new Pair<String, Rna>(identifier, rna); + return new Pair<String, CellDesignerRna>(identifier, rna); } /** @@ -69,12 +69,12 @@ public class RnaXmlParser extends AbstractElementXmlParser<Rna, RnaAlias> { * * @param residueNode * xml node to parse - * @return {@link RnaRegion} object created from the node + * @return {@link CellDesignerRnaRegion} object created from the node * @throws InvalidXmlSchemaException * thrown when input xml node doesn't follow defined schema */ - private RnaRegion getRnaRegion(Node residueNode) throws InvalidXmlSchemaException { - RnaRegion residue = new RnaRegion(); + private CellDesignerRnaRegion getRnaRegion(Node residueNode) throws InvalidXmlSchemaException { + CellDesignerRnaRegion residue = new CellDesignerRnaRegion(); residue.setIdRnaRegion(getNodeAttr("id", residueNode)); residue.setSize(getNodeAttr("size", residueNode)); residue.setPos(getNodeAttr("pos", residueNode)); @@ -90,7 +90,7 @@ public class RnaXmlParser extends AbstractElementXmlParser<Rna, RnaAlias> { } @Override - public String toXml(RnaAlias rna) { + public String toXml(Rna rna) { String attributes = ""; String result = ""; attributes += " id=\"r_" + elements.getElementId(rna) + "\""; diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesCollection.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesCollection.java index 7594604db1..8741c3038d 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesCollection.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesCollection.java @@ -8,7 +8,7 @@ import java.util.Map; import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.InvalidStateException; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; /** * This collection performs some magic, so please try no to understand it :). It @@ -23,7 +23,7 @@ import lcsb.mapviewer.converter.model.celldesigner.structure.Species; * @param <C> * class of the species */ -public class SpeciesCollection<C extends Species> { +public class SpeciesCollection<C extends CellDesignerSpecies<?>> { /** * Default class logger. @@ -38,7 +38,7 @@ public class SpeciesCollection<C extends Species> { /** * Map of species identified by specific identifier of the species (like - * {@link lcsb.mapviewer.db.model.map.species.Protein#proteinId + * {@link lcsb.mapviewer.db.model.map.species.CellDesignerProtein#proteinId * Protein#proteinId}. */ private Map<String, ArrayList<C>> speciesListByLocalId; @@ -155,7 +155,7 @@ public class SpeciesCollection<C extends Species> { @SuppressWarnings({ "rawtypes", "unchecked" }) protected C createNewInstance(Class clazz, C c) { try { - return (C) clazz.getConstructor(Species.class).newInstance(c); + return (C) clazz.getConstructor(CellDesignerSpecies.class).newInstance(c); } catch (Exception e) { throw new InvalidStateException("Problem with creating object", e); } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesCollectionXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesCollectionXmlParser.java index 0abe096913..131b7beea9 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesCollectionXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesCollectionXmlParser.java @@ -16,25 +16,24 @@ import lcsb.mapviewer.common.exception.NotImplementedException; 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.AntisenseRna; -import lcsb.mapviewer.converter.model.celldesigner.structure.Element; -import lcsb.mapviewer.converter.model.celldesigner.structure.Gene; -import lcsb.mapviewer.converter.model.celldesigner.structure.Protein; -import lcsb.mapviewer.converter.model.celldesigner.structure.Rna; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerAntisenseRna; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerElement; +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.CellDesignerSpecies; import lcsb.mapviewer.model.map.InconsistentModelException; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; -import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.AntisenseRna; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Rna; +import lcsb.mapviewer.model.map.species.Species; /** * Class used to parse CellDesigner xml nodes containing collections of - * {@link Species}. + * {@link CellDesignerSpecies}. * * @author Piotr Gawron * @@ -48,27 +47,22 @@ public class SpeciesCollectionXmlParser extends XmlParser { private Logger logger = Logger.getLogger(SpeciesCollectionXmlParser.class.getName()); /** - * Model for which parsing (or transformation to xml) is being done. - */ - private Model model; - - /** - * Parser used for {@link Rna} objects. + * Parser used for {@link CellDesignerRna} objects. */ private RnaXmlParser rnaParser; /** - * Parser used for {@link Gene} objects. + * Parser used for {@link CellDesignerGene} objects. */ private GeneXmlParser geneParser; /** - * Parser used for {@link Protein} objects. + * Parser used for {@link CellDesignerProtein} objects. */ private ProteinXmlParser proteinParser; /** - * Parser used for {@link AntisenseRna} objects. + * Parser used for {@link CellDesignerAntisenseRna} objects. */ private AntisenseRnaXmlParser antisenseRnaParser; @@ -90,19 +84,19 @@ public class SpeciesCollectionXmlParser extends XmlParser { /** * Helper class used to decode/encode CellDesigner strings. */ - private AbstractElementXmlParser<Element<?>, Alias> helpParser = new AbstractElementXmlParser<Element<?>, Alias>() { + private AbstractElementXmlParser<CellDesignerElement<?>, Element> helpParser = new AbstractElementXmlParser<CellDesignerElement<?>, Element>() { @Override public String encodeName(String name) { return super.encodeName(name); } @Override - public String toXml(Alias element) throws InconsistentModelException { + public String toXml(Element element) throws InconsistentModelException { throw new NotImplementedException(); } @Override - public Pair<String, Element<?>> parseXmlElement(Node node) + public Pair<String, CellDesignerElement<?>> parseXmlElement(Node node) throws InvalidXmlSchemaException { throw new NotImplementedException(); } @@ -113,12 +107,8 @@ public class SpeciesCollectionXmlParser extends XmlParser { /** * Default constructor. Model is required because some CellDesigner nodes * require access to other parts of the model. - * - * @param model - * model that is parsed/transformed into xml */ - public SpeciesCollectionXmlParser(Model model, CellDesignerElementCollection elements) { - this.model = model; + public SpeciesCollectionXmlParser(CellDesignerElementCollection elements) { sbmlSpeciesParser = new SpeciesSbmlParser(elements); this.elements = elements; rnaParser = new RnaXmlParser(elements); @@ -137,14 +127,14 @@ public class SpeciesCollectionXmlParser extends XmlParser { * @throws InvalidXmlSchemaException * thrown when node contains problematic data */ - public List<Pair<String, ? extends Species<?>>> parseXmlRnaCollection(Node rnaNode) throws InvalidXmlSchemaException { - List<Pair<String, ? extends Species<?>>> result = new ArrayList<>(); + public List<Pair<String, ? extends CellDesignerSpecies<?>>> parseXmlRnaCollection(Node rnaNode) throws InvalidXmlSchemaException { + List<Pair<String, ? extends CellDesignerSpecies<?>>> result = new ArrayList<>(); NodeList nodes = rnaNode.getChildNodes(); for (int x = 0; x < nodes.getLength(); x++) { Node node = nodes.item(x); if (node.getNodeType() == Node.ELEMENT_NODE) { if (node.getNodeName().equalsIgnoreCase("celldesigner:RNA")) { - Pair<String, Rna> rna = rnaParser.parseXmlElement(node); + Pair<String, CellDesignerRna> rna = rnaParser.parseXmlElement(node); result.add(rna); } else { throw new InvalidXmlSchemaException("Unknown element of celldesigner:listOfRNAs: " + node.getNodeName()); @@ -161,10 +151,10 @@ public class SpeciesCollectionXmlParser extends XmlParser { * set of rnas * @return CellDesigner xml node corrseponding to the input */ - public String rnaCollectionToXmlString(Collection<RnaAlias> collection) { + public String rnaCollectionToXmlString(Collection<Rna> collection) { StringBuilder result = new StringBuilder(); result.append("<celldesigner:listOfRNAs>"); - for (RnaAlias species : collection) { + for (Rna species : collection) { result.append(rnaParser.toXml(species)); } result.append("</celldesigner:listOfRNAs>\n"); @@ -180,14 +170,14 @@ public class SpeciesCollectionXmlParser extends XmlParser { * @throws InvalidXmlSchemaException * thrown when there is a problem with xml */ - public List<Pair<String, ? extends Species<?>>> parseXmlGeneCollection(Node geneNode) throws InvalidXmlSchemaException { - List<Pair<String, ? extends Species<?>>> result = new ArrayList<>(); + public List<Pair<String, ? extends CellDesignerSpecies<?>>> parseXmlGeneCollection(Node geneNode) throws InvalidXmlSchemaException { + List<Pair<String, ? extends CellDesignerSpecies<?>>> result = new ArrayList<>(); NodeList nodes = geneNode.getChildNodes(); for (int x = 0; x < nodes.getLength(); x++) { Node node = nodes.item(x); if (node.getNodeType() == Node.ELEMENT_NODE) { if (node.getNodeName().equalsIgnoreCase("celldesigner:gene")) { - Pair<String, Gene> gene = geneParser.parseXmlElement(node); + Pair<String, CellDesignerGene> gene = geneParser.parseXmlElement(node); result.add(gene); } else { throw new InvalidXmlSchemaException("Unknown element of celldesigner:listOfGenes: " + node.getNodeName()); @@ -204,10 +194,10 @@ public class SpeciesCollectionXmlParser extends XmlParser { * set of genes * @return CellDesigner xml node corrseponding to the input */ - public String geneCollectionToXmlString(Collection<GeneAlias> collection) { + public String geneCollectionToXmlString(Collection<Gene> collection) { StringBuilder result = new StringBuilder(); result.append("<celldesigner:listOfGenes>"); - for (GeneAlias species : collection) { + for (Gene species : collection) { result.append(geneParser.toXml(species)); } result.append("</celldesigner:listOfGenes>\n"); @@ -223,14 +213,14 @@ public class SpeciesCollectionXmlParser extends XmlParser { * @throws InvalidXmlSchemaException * thrown when there is a problem with xml */ - public List<Pair<String, ? extends Species<?>>> parseXmlProteinCollection(Node proteinNode) throws InvalidXmlSchemaException { - List<Pair<String, ? extends Species<?>>> result = new ArrayList<>(); + public List<Pair<String, ? extends CellDesignerSpecies<?>>> parseXmlProteinCollection(Node proteinNode) throws InvalidXmlSchemaException { + List<Pair<String, ? extends CellDesignerSpecies<?>>> result = new ArrayList<>(); NodeList nodes = proteinNode.getChildNodes(); for (int x = 0; x < nodes.getLength(); x++) { Node node = nodes.item(x); if (node.getNodeType() == Node.ELEMENT_NODE) { if (node.getNodeName().equalsIgnoreCase("celldesigner:protein")) { - Pair<String, Protein<?>> protein = proteinParser.parseXmlElement(node); + Pair<String, CellDesignerProtein<?>> protein = proteinParser.parseXmlElement(node); result.add(protein); } else { throw new InvalidXmlSchemaException("Unknown element of celldesigner:listOfProteins: " + node.getNodeName()); @@ -247,10 +237,10 @@ public class SpeciesCollectionXmlParser extends XmlParser { * set of proteins * @return CellDesigner xml node corrseponding to the input */ - public String proteinCollectionToXmlString(Collection<ProteinAlias> collection) { + public String proteinCollectionToXmlString(Collection<Protein> collection) { StringBuilder result = new StringBuilder(); result.append("<celldesigner:listOfProteins>"); - for (ProteinAlias species : collection) { + for (Protein species : collection) { result.append(proteinParser.toXml(species)); } result.append("</celldesigner:listOfProteins>\n"); @@ -267,14 +257,14 @@ public class SpeciesCollectionXmlParser extends XmlParser { * @throws InvalidXmlSchemaException * thrown when there is a problem with xml */ - public List<Pair<String, ? extends Species<?>>> parseXmlAntisenseRnaCollection(Node rnaNode) throws InvalidXmlSchemaException { - List<Pair<String, ? extends Species<?>>> result = new ArrayList<>(); + public List<Pair<String, ? extends CellDesignerSpecies<?>>> parseXmlAntisenseRnaCollection(Node rnaNode) throws InvalidXmlSchemaException { + List<Pair<String, ? extends CellDesignerSpecies<?>>> result = new ArrayList<>(); NodeList nodes = rnaNode.getChildNodes(); for (int x = 0; x < nodes.getLength(); x++) { Node node = nodes.item(x); if (node.getNodeType() == Node.ELEMENT_NODE) { if (node.getNodeName().equalsIgnoreCase("celldesigner:AntisenseRNA")) { - Pair<String, AntisenseRna> antisenseRna = antisenseRnaParser.parseXmlElement(node); + Pair<String, CellDesignerAntisenseRna> antisenseRna = antisenseRnaParser.parseXmlElement(node); result.add(antisenseRna); } else { throw new InvalidXmlSchemaException("Unknown element of celldesigner:listOfAntisenseRNAs: " + node.getNodeName()); @@ -291,10 +281,10 @@ public class SpeciesCollectionXmlParser extends XmlParser { * set of antisense rnas * @return CellDesigner xml node corrseponding to the input */ - public String antisenseRnaCollectionToXmlString(Collection<AntisenseRnaAlias> collection) { + public String antisenseRnaCollectionToXmlString(Collection<AntisenseRna> collection) { StringBuilder result = new StringBuilder(); result.append("<celldesigner:listOfAntisenseRNAs>"); - for (AntisenseRnaAlias species : collection) { + for (AntisenseRna species : collection) { result.append(antisenseRnaParser.toXml(species)); } result.append("</celldesigner:listOfAntisenseRNAs>\n"); @@ -310,14 +300,14 @@ public class SpeciesCollectionXmlParser extends XmlParser { * @throws InvalidXmlSchemaException * thrown when there is a problem with xml */ - public List<Pair<String, ? extends Species<?>>> parseSbmlSpeciesCollection(Node spieciesNode) throws InvalidXmlSchemaException { - List<Pair<String, ? extends Species<?>>> result = new ArrayList<>(); + public List<Pair<String, ? extends CellDesignerSpecies<?>>> parseSbmlSpeciesCollection(Node spieciesNode) throws InvalidXmlSchemaException { + List<Pair<String, ? extends CellDesignerSpecies<?>>> result = new ArrayList<>(); NodeList nodes = spieciesNode.getChildNodes(); for (int x = 0; x < nodes.getLength(); x++) { Node node = nodes.item(x); if (node.getNodeType() == Node.ELEMENT_NODE) { if (node.getNodeName().equalsIgnoreCase("species") || node.getNodeName().equalsIgnoreCase("celldesigner:species")) { - Pair<String, Species<?>> sp = sbmlSpeciesParser.parseXmlElement(node); + Pair<String, CellDesignerSpecies<?>> sp = sbmlSpeciesParser.parseXmlElement(node); result.add(sp); } else { throw new InvalidXmlSchemaException("Unknown element of listOfSpecies: " + node.getNodeName()); @@ -328,7 +318,7 @@ public class SpeciesCollectionXmlParser extends XmlParser { } /** - * Transforms set of {@link Species} into SBML node. + * Transforms set of {@link CellDesignerSpecies} into SBML node. * * @param collection * set of species to transform @@ -337,14 +327,14 @@ public class SpeciesCollectionXmlParser extends XmlParser { * thrown when xml cannot be generated because structure of objects * is invalid */ - public String speciesCollectionToSbmlString(Collection<SpeciesAlias> collection) throws InconsistentModelException { + public String speciesCollectionToSbmlString(Collection<Species> collection) throws InconsistentModelException { StringBuilder result = new StringBuilder(); result.append("<listOfSpecies>"); - for (SpeciesAlias species : collection) { + for (Species species : collection) { // not all elements should be added to the result string: elements that // are in complexes should be excluded boolean add = false; - if (!(species.getParent() instanceof ComplexAlias)) { + if (!(species.getParent() instanceof Complex)) { add = true; } if (add) { @@ -367,8 +357,8 @@ public class SpeciesCollectionXmlParser extends XmlParser { * @throws InvalidXmlSchemaException * thrown when there is a problem with xml */ - public List<Pair<String, ? extends Species<?>>> parseIncludedSpeciesCollection(Node spieciesNode) throws InvalidXmlSchemaException { - List<Pair<String, ? extends Species<?>>> result = new ArrayList<>(); + public List<Pair<String, ? extends CellDesignerSpecies<?>>> parseIncludedSpeciesCollection(Node spieciesNode) throws InvalidXmlSchemaException { + List<Pair<String, ? extends CellDesignerSpecies<?>>> result = new ArrayList<>(); // What should be done here? // What are the inclusions? // Probably this should be improved, this part of a CD model is really @@ -404,8 +394,8 @@ public class SpeciesCollectionXmlParser extends XmlParser { } else { Node spNode = getNode("celldesigner:speciesIdentity", annNode.getChildNodes()); if (spNode != null) { - Pair<String, Species<?>> row = parser.parseSpeciesIdentity(spNode); - Species<?> sp = row.getRight(); + Pair<String, CellDesignerSpecies<?>> row = parser.parseSpeciesIdentity(spNode); + CellDesignerSpecies<?> sp = row.getRight(); sp.setElementId(idIncluded); sp.setName(helpParser.decodeName(nameIncluded)); sp.setNotes(rap.getNotes(notesNode)); @@ -433,14 +423,14 @@ public class SpeciesCollectionXmlParser extends XmlParser { * list of Species * @return CellDesigner included species xml node */ - public String speciesCollectionToXmlIncludedString(Collection<SpeciesAlias> collection) { + public String speciesCollectionToXmlIncludedString(Collection<Species> collection) { StringBuilder sb = new StringBuilder(""); sb.append("<celldesigner:listOfIncludedSpecies>\n"); - for (Alias species : collection) { - if (species instanceof ComplexAlias) { - ComplexAlias cs = (ComplexAlias) species; - for (Alias element : cs.getAliases()) { - SpeciesAlias child = (SpeciesAlias) element; + for (Element species : collection) { + if (species instanceof Complex) { + Complex cs = (Complex) species; + for (Element element : cs.getAliases()) { + Species child = (Species) element; sb.append( "<celldesigner:species id=\"" + elements.getElementId(child) + "\" name=\"" + StringEscapeUtils.escapeXml(helpParser.encodeName(child.getName())) + "\">"); diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesMapping.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesMapping.java index abe71c3ce1..857c7e4454 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesMapping.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesMapping.java @@ -1,34 +1,34 @@ package lcsb.mapviewer.converter.model.celldesigner.species; import lcsb.mapviewer.common.exception.InvalidStateException; -import lcsb.mapviewer.converter.model.celldesigner.structure.AntisenseRna; -import lcsb.mapviewer.converter.model.celldesigner.structure.ComplexSpecies; -import lcsb.mapviewer.converter.model.celldesigner.structure.Degraded; -import lcsb.mapviewer.converter.model.celldesigner.structure.Drug; -import lcsb.mapviewer.converter.model.celldesigner.structure.Gene; -import lcsb.mapviewer.converter.model.celldesigner.structure.Ion; -import lcsb.mapviewer.converter.model.celldesigner.structure.Phenotype; -import lcsb.mapviewer.converter.model.celldesigner.structure.Protein; -import lcsb.mapviewer.converter.model.celldesigner.structure.Rna; -import lcsb.mapviewer.converter.model.celldesigner.structure.SimpleMolecule; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; -import lcsb.mapviewer.converter.model.celldesigner.structure.Unknown; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.DegradedAlias; -import lcsb.mapviewer.model.map.layout.alias.DrugAlias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.IonAlias; -import lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; -import lcsb.mapviewer.model.map.layout.alias.UnknownAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerAntisenseRna; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerComplexSpecies; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerDegraded; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerDrug; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerGene; +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.CellDesignerSimpleMolecule; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerUnknown; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.AntisenseRna; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Degraded; +import lcsb.mapviewer.model.map.species.Drug; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.Ion; +import lcsb.mapviewer.model.map.species.Phenotype; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Rna; +import lcsb.mapviewer.model.map.species.SimpleMolecule; +import lcsb.mapviewer.model.map.species.Unknown; /** * This enum contains information about mapping between CellDesigner xml nodes - * and classes that extend {@link Species}. + * and classes that extend {@link CellDesignerSpecies}. * * @author Piotr Gawron * @@ -37,57 +37,57 @@ public enum SpeciesMapping { /** * {@link Protein}. */ - PROTEIN(Protein.class, ProteinAlias.class, "PROTEIN"), // + PROTEIN(CellDesignerProtein.class, Protein.class, "PROTEIN"), // /** * {@link Gene}. */ - GENE(Gene.class, GeneAlias.class, "GENE"), // + GENE(CellDesignerGene.class, Gene.class, "GENE"), // /** * {@link ComplexSpecies}. */ - COMPLEX(ComplexSpecies.class, ComplexAlias.class, "COMPLEX"), // + COMPLEX(CellDesignerComplexSpecies.class, Complex.class, "COMPLEX"), // /** * {@link SimpleMolecule}. */ - SIMPLE_MOLECULE(SimpleMolecule.class, SimpleMoleculeAlias.class, "SIMPLE_MOLECULE"), // + SIMPLE_MOLECULE(CellDesignerSimpleMolecule.class, SimpleMolecule.class, "SIMPLE_MOLECULE"), // /** * {@link Ion}. */ - ION(Ion.class, IonAlias.class, "ION"), // + ION(CellDesignerIon.class, Ion.class, "ION"), // /** * {@link Phenotype}. */ - PHENOTYPE(Phenotype.class, PhenotypeAlias.class, "PHENOTYPE"), // + PHENOTYPE(CellDesignerPhenotype.class, Phenotype.class, "PHENOTYPE"), // /** * {@link Drug}. */ - DRUG(Drug.class, DrugAlias.class, "DRUG"), // + DRUG(CellDesignerDrug.class, Drug.class, "DRUG"), // /** * {@link Rna}. */ - RNA(Rna.class, RnaAlias.class, "RNA"), // + RNA(CellDesignerRna.class, Rna.class, "RNA"), // /** * {@link AntisenseRna}. */ - ANTISENSE_RNA(AntisenseRna.class, AntisenseRnaAlias.class, "ANTISENSE_RNA"), // + ANTISENSE_RNA(CellDesignerAntisenseRna.class, AntisenseRna.class, "ANTISENSE_RNA"), // /** * {@link Unknown}. */ - UNKNOWN(Unknown.class, UnknownAlias.class, "UNKNOWN"), // + UNKNOWN(CellDesignerUnknown.class, Unknown.class, "UNKNOWN"), // /** * {@link Degraded}. */ - DEGRADED(Degraded.class, DegradedAlias.class, "DEGRADED"); + DEGRADED(CellDesignerDegraded.class, Degraded.class, "DEGRADED"); /** * CellDesigner xml node type. @@ -97,9 +97,9 @@ public enum SpeciesMapping { /** * Class that should be used to represent cell designer node. */ - private Class<? extends Species> cellDesignerClazz; + private Class<? extends CellDesignerSpecies> cellDesignerClazz; - private Class<? extends Alias> modelClazz; + private Class<? extends Element> modelClazz; /** * Default constructor. @@ -109,7 +109,7 @@ public enum SpeciesMapping { * @param cellDesignerString * {@link #cellDesignerString} */ - SpeciesMapping(Class<? extends Species> cellDesignerClazz, Class<? extends Alias> modelClazz, String cellDesignerString) { + SpeciesMapping(Class<? extends CellDesignerSpecies> cellDesignerClazz, Class<? extends Element> modelClazz, String cellDesignerString) { this.cellDesignerString = cellDesignerString; this.cellDesignerClazz = cellDesignerClazz; this.modelClazz = modelClazz; @@ -127,24 +127,24 @@ public enum SpeciesMapping { * @return the clazz * @see #clazz */ - public Class<? extends Species> getCellDesignerClazz() { + public Class<? extends CellDesignerSpecies> getCellDesignerClazz() { return cellDesignerClazz; } - public Class<? extends Alias> getModelClazz() { + public Class<? extends Element> getModelClazz() { return modelClazz; } /** - * Creates instance of {@link Species} specific for this + * Creates instance of {@link CellDesignerSpecies} specific for this * {@link SpeciesMapping}. * * @param result * parameter that should be passed to the constructor - * @return new instance of {@link Species} specific for this + * @return new instance of {@link CellDesignerSpecies} specific for this * {@link SpeciesMapping}. */ - public Species createSpecies(Species result) { + public CellDesignerSpecies createSpecies(CellDesignerSpecies result) { try { return cellDesignerClazz.getConstructor(result.getClass()).newInstance(result); } catch (Exception e) { @@ -169,13 +169,13 @@ public enum SpeciesMapping { } /** - * Returns {@link SpeciesMapping} for given {@link Species} class. + * Returns {@link SpeciesMapping} for given {@link CellDesignerSpecies} class. * * @param searchClazz - * {@link Species} class - * @return {@link SpeciesMapping} for given {@link Species} class + * {@link CellDesignerSpecies} class + * @return {@link SpeciesMapping} for given {@link CellDesignerSpecies} class */ - public static SpeciesMapping getMappingByCellDesignerClass(Class<? extends Species> searchClazz) { + public static SpeciesMapping getMappingByCellDesignerClass(Class<? extends CellDesignerSpecies> searchClazz) { for (SpeciesMapping mapping : SpeciesMapping.values()) { if (mapping.getCellDesignerClazz().isAssignableFrom(searchClazz)) { return mapping; @@ -184,7 +184,7 @@ public enum SpeciesMapping { return null; } - public static SpeciesMapping getMappingByModelClass(Class<? extends Alias> searchClazz) { + public static SpeciesMapping getMappingByModelClass(Class<? extends Element> searchClazz) { for (SpeciesMapping mapping : SpeciesMapping.values()) { if (mapping.getModelClazz().isAssignableFrom(searchClazz)) { return mapping; 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 439b5d9b5a..fd0bfcbd71 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 @@ -11,26 +11,26 @@ import lcsb.mapviewer.common.exception.NotImplementedException; 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.AntisenseRna; -import lcsb.mapviewer.converter.model.celldesigner.structure.AntisenseRnaRegion; -import lcsb.mapviewer.converter.model.celldesigner.structure.Compartment; -import lcsb.mapviewer.converter.model.celldesigner.structure.ComplexSpecies; -import lcsb.mapviewer.converter.model.celldesigner.structure.Gene; -import lcsb.mapviewer.converter.model.celldesigner.structure.ModificationResidue; -import lcsb.mapviewer.converter.model.celldesigner.structure.Protein; -import lcsb.mapviewer.converter.model.celldesigner.structure.Rna; -import lcsb.mapviewer.converter.model.celldesigner.structure.RnaRegion; -import lcsb.mapviewer.converter.model.celldesigner.structure.SimpleMolecule; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; -import lcsb.mapviewer.converter.model.celldesigner.structure.SpeciesState; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaAlias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; -import lcsb.mapviewer.model.map.layout.alias.PositionToCompartment; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +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.CellDesignerModificationResidue; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.SpeciesState; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.species.AntisenseRna; +import lcsb.mapviewer.model.map.species.Gene; +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.ModificationState; +import lcsb.mapviewer.model.map.species.field.PositionToCompartment; /** * Parser for sbml part of CellDesigner format. It's used for retrieving Species @@ -39,7 +39,7 @@ import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; * @author Piotr Gawron * */ -public class SpeciesSbmlParser extends AbstractElementXmlParser<Species<?>, SpeciesAlias> { +public class SpeciesSbmlParser extends AbstractElementXmlParser<CellDesignerSpecies<?>, Species> { /** * Default class logger. @@ -58,7 +58,7 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<Species<?>, Spec } @Override - public Pair<String, Species<?>> parseXmlElement(Node spieciesNode) throws InvalidXmlSchemaException { + public Pair<String, CellDesignerSpecies<?>> parseXmlElement(Node spieciesNode) throws InvalidXmlSchemaException { NodeList list = spieciesNode.getChildNodes(); @@ -126,9 +126,9 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<Species<?>, Spec throw new InvalidXmlSchemaException("No celldesigner:speciesIdentity node in SBML/model/listOfSpecies/species/annotation/extension"); } - Pair<String, Species<?>> result = parseSpeciesIdentity(speciesIdentity); + Pair<String, CellDesignerSpecies<?>> result = parseSpeciesIdentity(speciesIdentity); - Species<?> species = result.getRight(); + CellDesignerSpecies<?> species = result.getRight(); if (positionToCompartment != null) { PositionToCompartment position = PositionToCompartment.getByString(getNodeValue(positionToCompartment)); if (position == null) { @@ -146,7 +146,7 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<Species<?>, Spec species.setCharge(getNodeAttr("charge", spieciesNode)); species.setOnlySubstanceUnits(getNodeAttr("hasOnlySubstanceUnits", spieciesNode)); - Compartment compartment = elements.getCompartmentByCompartmentId(getNodeAttr("compartment", spieciesNode)); + CellDesignerCompartment compartment = elements.getCompartmentByCompartmentId(getNodeAttr("compartment", spieciesNode)); if (compartment != null) { species.setParent(compartment); } @@ -164,7 +164,7 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<Species<?>, Spec } @Override - public String toXml(SpeciesAlias species) { + public String toXml(Species species) { StringBuilder builder = new StringBuilder(); StringBuilder attributesBuilder = new StringBuilder(); attributesBuilder.append(" name=\"" + escapeXml(encodeName(species.getName())) + "\""); @@ -182,8 +182,8 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<Species<?>, Spec if (species.hasOnlySubstanceUnits() != null) { attributesBuilder.append(" hasOnlySubstanceUnits=\"" + species.hasOnlySubstanceUnits() + "\""); } - if (species.getParent() != null && species.getParent() instanceof CompartmentAlias) { - CompartmentAlias comp = (CompartmentAlias) species.getParent(); + if (species.getParent() != null && species.getParent() instanceof Compartment) { + Compartment comp = (Compartment) species.getParent(); attributesBuilder.append(" compartment=\"" + elements.getElementId(comp) + "\""); } else { attributesBuilder.append(" compartment=\"default\""); @@ -221,13 +221,13 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<Species<?>, Spec } /** - * Creates speciesIdentity xml node for the {@link Species}. + * Creates speciesIdentity xml node for the {@link CellDesignerSpecies}. * * @param species * species to be transformed into xml * @return speciesIdentity xml node */ - String speciesIdentityToXml(SpeciesAlias species) { + String speciesIdentityToXml(Species species) { StringBuilder sb = new StringBuilder(); String classType = ""; SpeciesMapping mapping = SpeciesMapping.getMappingByModelClass(species.getClass()); @@ -238,13 +238,13 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<Species<?>, Spec } sb.append("<celldesigner:speciesIdentity>"); sb.append("<celldesigner:class>" + classType + "</celldesigner:class>\n"); - if (species instanceof RnaAlias) { + if (species instanceof Rna) { sb.append("<celldesigner:rnaReference>r_" + elements.getElementId(species) + "</celldesigner:rnaReference>\n"); - } else if (species instanceof ProteinAlias) { + } else if (species instanceof Protein) { sb.append("<celldesigner:proteinReference>p_" + elements.getElementId(species) + "</celldesigner:proteinReference>\n"); - } else if (species instanceof GeneAlias) { + } else if (species instanceof Gene) { sb.append("<celldesigner:geneReference>g_" + elements.getElementId(species) + "</celldesigner:geneReference>\n"); - } else if (species instanceof AntisenseRnaAlias) { + } else if (species instanceof AntisenseRna) { sb.append("<celldesigner:antisensernaReference>ar_" + elements.getElementId(species) + "</celldesigner:antisensernaReference>\n"); } SpeciesState state = new SpeciesState(species); @@ -281,7 +281,7 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<Species<?>, Spec } if (state.getModifications().size() > 0) { sb.append("<celldesigner:listOfModifications>\n"); - for (ModificationResidue mr : state.getModifications()) { + for (CellDesignerModificationResidue mr : state.getModifications()) { sb.append(modificationResidueToXml(mr)); } sb.append("</celldesigner:listOfModifications>\n"); @@ -294,7 +294,7 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<Species<?>, Spec } /** - * Parses CellDesigner SpeciesIdentity node into {@link Species}. + * Parses CellDesigner SpeciesIdentity node into {@link CellDesignerSpecies}. * * @param rootNode * xml node to parse @@ -303,9 +303,9 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<Species<?>, Spec * @throws InvalidXmlSchemaException * thrown when there is a problem with xml */ - public Pair<String, Species<?>> parseSpeciesIdentity(Node rootNode) throws InvalidXmlSchemaException { + public Pair<String, CellDesignerSpecies<?>> parseSpeciesIdentity(Node rootNode) throws InvalidXmlSchemaException { NodeList nodes = rootNode.getChildNodes(); - Species<?> result = new Species(); + CellDesignerSpecies<?> result = new CellDesignerSpecies(); Node classNode = getNode("celldesigner:class", nodes); if (classNode == null) { throw new InvalidXmlSchemaException("Species node in Sbml model doesn't contain node \"celldesigner:class\"."); @@ -325,25 +325,25 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<Species<?>, Spec if (node.getNodeName().equalsIgnoreCase("celldesigner:class")) { continue; } else if (node.getNodeName().equalsIgnoreCase("celldesigner:proteinReference")) { - if (result instanceof Protein) { + if (result instanceof CellDesignerProtein) { identifier = getNodeValue(node); } else { throw new InvalidXmlSchemaException("Wrong class type for protein reference: " + result.getClass().getName()); } } else if (node.getNodeName().equalsIgnoreCase("celldesigner:geneReference")) { - if (result instanceof Gene) { + if (result instanceof CellDesignerGene) { identifier = getNodeValue(node); } else { throw new InvalidXmlSchemaException("Wrong class type for gene reference: " + result.getClass().getName()); } } else if (node.getNodeName().equalsIgnoreCase("celldesigner:rnaReference")) { - if (result instanceof Rna) { + if (result instanceof CellDesignerRna) { identifier = getNodeValue(node); } else { throw new InvalidXmlSchemaException("Wrong class type for rna reference: " + result.getClass().getName()); } } else if (node.getNodeName().equalsIgnoreCase("celldesigner:antisensernaReference")) { - if (result instanceof AntisenseRna) { + if (result instanceof CellDesignerAntisenseRna) { identifier = getNodeValue(node); } else { throw new InvalidXmlSchemaException("Wrong class type for antisense rna reference: " + result.getClass().getName()); @@ -361,7 +361,7 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<Species<?>, Spec } } - return new Pair<String, Species<?>>(identifier, result); + return new Pair<String, CellDesignerSpecies<?>>(identifier, result); } /** @@ -374,39 +374,39 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<Species<?>, Spec * @param species * where the data should be saved */ - void processStateDataInSpecies(Species<?> species, SpeciesState state) { + void processStateDataInSpecies(CellDesignerSpecies<?> species, SpeciesState state) { species.setHomodimer(state.getHomodimer()); - if (species instanceof ComplexSpecies) { - ComplexSpecies complex = (ComplexSpecies) species; + if (species instanceof CellDesignerComplexSpecies) { + CellDesignerComplexSpecies complex = (CellDesignerComplexSpecies) species; complex.setStructuralState(state.getStructuralState()); if (state.getModifications().size() != 0) { throw new NotImplementedException("Modification not supported in Complex"); } - } else if (species instanceof Gene) { - Gene gene = (Gene) species; + } else if (species instanceof CellDesignerGene) { + CellDesignerGene gene = (CellDesignerGene) species; if (state.getStructuralState() != null) { throw new NotImplementedException("StructuralState not supported in Gene"); } - for (ModificationResidue mr : state.getModifications()) { + for (CellDesignerModificationResidue mr : state.getModifications()) { gene.addModificationResidue(mr); } - } else if (species instanceof Protein) { - Protein<?> protein = (Protein<?>) species; + } else if (species instanceof CellDesignerProtein) { + CellDesignerProtein<?> protein = (CellDesignerProtein<?>) species; protein.setStructuralState(state.getStructuralState()); - for (ModificationResidue mr : state.getModifications()) { + for (CellDesignerModificationResidue mr : state.getModifications()) { protein.addModificationResidue(mr); } - } else if (species instanceof Rna) { - Rna rna = (Rna) species; + } else if (species instanceof CellDesignerRna) { + CellDesignerRna rna = (CellDesignerRna) species; if (state.getStructuralState() != null && !state.getStructuralState().isEmpty()) { throw new NotImplementedException("Structural state not supported in RNA"); } - for (ModificationResidue mr : state.getModifications()) { + for (CellDesignerModificationResidue mr : state.getModifications()) { rna.addRegion(createRnaRegion(mr)); } - } else if (species instanceof SimpleMolecule) { + } else if (species instanceof CellDesignerSimpleMolecule) { if (state.getStructuralState() != null && !state.getStructuralState().isEmpty()) { throw new NotImplementedException("Structural state not supported in SimpleMolecule"); } @@ -414,14 +414,14 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<Species<?>, Spec throw new NotImplementedException("Modification not supported in SimpleMolecule"); } - } else if (species instanceof AntisenseRna) { - AntisenseRna antisenseRna = (AntisenseRna) species; + } else if (species instanceof CellDesignerAntisenseRna) { + CellDesignerAntisenseRna antisenseRna = (CellDesignerAntisenseRna) species; if (state.getStructuralState() != null && !state.getStructuralState().isEmpty()) { throw new NotImplementedException("Structural state not supported in AntisenseRna"); } - for (ModificationResidue mr : state.getModifications()) { - AntisenseRnaRegion region = createAntisenseRnaRegion(mr); + for (CellDesignerModificationResidue mr : state.getModifications()) { + CellDesignerAntisenseRnaRegion region = createAntisenseRnaRegion(mr); antisenseRna.addRegion(region); } } else { @@ -475,7 +475,7 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<Species<?>, Spec Node structureNode = modificationNodeList.item(y); if (structureNode.getNodeType() == Node.ELEMENT_NODE) { if (structureNode.getNodeName().equalsIgnoreCase("celldesigner:modification")) { - ModificationResidue modification = getSpeciesModification(structureNode); + CellDesignerModificationResidue modification = getSpeciesModification(structureNode); result.addModificationResidue(modification); } else { @@ -492,17 +492,17 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<Species<?>, Spec } /** - * Creates {@link ModificationResidue} from the apropriate xml node. + * Creates {@link CellDesignerModificationResidue} from the apropriate xml node. * * @param rootNode * xml node - * @return {@link ModificationResidue} retrieved from the node + * @return {@link CellDesignerModificationResidue} retrieved from the node * @throws InvalidXmlSchemaException * thrown when xml node contains data that is not supported by xml * schema */ - private ModificationResidue getSpeciesModification(Node rootNode) throws InvalidXmlSchemaException { - ModificationResidue modification = new ModificationResidue(); + private CellDesignerModificationResidue getSpeciesModification(Node rootNode) throws InvalidXmlSchemaException { + CellDesignerModificationResidue modification = new CellDesignerModificationResidue(); modification.setIdModificationResidue(getNodeAttr("residue", rootNode)); String state = getNodeAttr("state", rootNode); if (state != null) { @@ -529,13 +529,13 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<Species<?>, Spec } /** - * Creates xml node representing {@link ModificationResidue}. + * Creates xml node representing {@link CellDesignerModificationResidue}. * * @param mr * object to be transformed into xml * @return xml node representing param object */ - private String modificationResidueToXml(ModificationResidue mr) { + private String modificationResidueToXml(CellDesignerModificationResidue mr) { String state = ""; if (mr.getState() != null) { state = mr.getState().getFullName(); @@ -547,15 +547,15 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<Species<?>, Spec } /** - * Creates {@link AntisenseRnaRegion} from {@link ModificationResidue} + * Creates {@link CellDesignerAntisenseRnaRegion} from {@link CellDesignerModificationResidue} * description. * * @param mr - * object from which we create {@link AntisenseRnaRegion} - * @return {@link AntisenseRnaRegion} object created from param + * object from which we create {@link CellDesignerAntisenseRnaRegion} + * @return {@link CellDesignerAntisenseRnaRegion} object created from param */ - AntisenseRnaRegion createAntisenseRnaRegion(ModificationResidue mr) { - AntisenseRnaRegion region = new AntisenseRnaRegion(); + CellDesignerAntisenseRnaRegion createAntisenseRnaRegion(CellDesignerModificationResidue mr) { + CellDesignerAntisenseRnaRegion region = new CellDesignerAntisenseRnaRegion(); region.setIdAntisenseRnaRegion(mr.getIdModificationResidue()); if (mr.getSize() != null) { region.setSize(mr.getSize()); @@ -569,14 +569,14 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<Species<?>, Spec } /** - * Creates {@link RnaRegion} from {@link ModificationResidue} description. + * Creates {@link CellDesignerRnaRegion} from {@link CellDesignerModificationResidue} description. * * @param mr - * object from which we create {@link RnaRegion} - * @return {@link RnaRegion} object created from param + * object from which we create {@link CellDesignerRnaRegion} + * @return {@link CellDesignerRnaRegion} object created from param */ - public RnaRegion createRnaRegion(ModificationResidue mr) { - RnaRegion result = new RnaRegion(); + public CellDesignerRnaRegion createRnaRegion(CellDesignerModificationResidue mr) { + CellDesignerRnaRegion result = new CellDesignerRnaRegion(); result.setIdRnaRegion(mr.getIdModificationResidue()); if (mr.getSize() != null) { result.setSize(mr.getSize()); diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/package-info.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/package-info.java index a0c3c1535f..7b15345c0e 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/package-info.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/package-info.java @@ -1,6 +1,6 @@ -/** - * This package contains parsers used for parsing CellDesiger xml for - * {@link lcsb.mapviewer.db.model.map.species.Species Species}. - */ -package lcsb.mapviewer.converter.model.celldesigner.species; - +/** + * This package contains parsers used for parsing CellDesiger xml for + * {@link lcsb.mapviewer.db.model.map.species.CellDesignerSpecies Species}. + */ +package lcsb.mapviewer.converter.model.celldesigner.species; + diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRna.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRna.java similarity index 54% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRna.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRna.java index d1aa4bfb89..190eeac25e 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRna.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRna.java @@ -6,7 +6,7 @@ import java.util.List; import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaAlias; +import lcsb.mapviewer.model.map.species.AntisenseRna; /** * Class representing antisense rna in the model. @@ -14,7 +14,7 @@ import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaAlias; * @author Piotr Gawron * */ -public class AntisenseRna extends Species<AntisenseRnaAlias> { +public class CellDesignerAntisenseRna extends CellDesignerSpecies<AntisenseRna> { /** * @@ -25,12 +25,12 @@ public class AntisenseRna extends Species<AntisenseRnaAlias> { * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(AntisenseRna.class); + private static Logger logger = Logger.getLogger(CellDesignerAntisenseRna.class); /** * List of antisense rna regions (some rna sequences) in this object. */ - private List<AntisenseRnaRegion> regions = new ArrayList<AntisenseRnaRegion>(); + private List<CellDesignerAntisenseRnaRegion> regions = new ArrayList<CellDesignerAntisenseRnaRegion>(); /** * Constructor that copies the data from species given in the argument. @@ -38,12 +38,12 @@ public class AntisenseRna extends Species<AntisenseRnaAlias> { * @param species * parent species from which we want to copy data */ - public AntisenseRna(Species<?> species) { + public CellDesignerAntisenseRna(CellDesignerSpecies<?> species) { super(species); - if (species instanceof AntisenseRna) { - AntisenseRna asRna = (AntisenseRna) species; - for (AntisenseRnaRegion region : asRna.getRegions()) { - addRegion(new AntisenseRnaRegion(region)); + if (species instanceof CellDesignerAntisenseRna) { + CellDesignerAntisenseRna asRna = (CellDesignerAntisenseRna) species; + for (CellDesignerAntisenseRnaRegion region : asRna.getRegions()) { + addRegion(new CellDesignerAntisenseRnaRegion(region)); } } } @@ -51,14 +51,14 @@ public class AntisenseRna extends Species<AntisenseRnaAlias> { /** * Default constructor. */ - public AntisenseRna() { + public CellDesignerAntisenseRna() { super(); } @Override - public AntisenseRna copy() { - if (this.getClass() == AntisenseRna.class) { - return new AntisenseRna(this); + public CellDesignerAntisenseRna copy() { + if (this.getClass() == CellDesignerAntisenseRna.class) { + return new CellDesignerAntisenseRna(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } @@ -72,14 +72,14 @@ public class AntisenseRna extends Species<AntisenseRnaAlias> { /** * 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 AntisenseRna}. + * is copied to the one that is already in the {@link CellDesignerAntisenseRna}. * * * @param region * region to add */ - public void addRegion(AntisenseRnaRegion region) { - for (AntisenseRnaRegion region2 : regions) { + public void addRegion(CellDesignerAntisenseRnaRegion region) { + for (CellDesignerAntisenseRnaRegion region2 : regions) { if (region2.getIdAntisenseRnaRegion().equals(region.getIdAntisenseRnaRegion())) { region2.update(region); return; @@ -91,15 +91,15 @@ public class AntisenseRna extends Species<AntisenseRnaAlias> { } @Override - public void update(Species<?> sp) { + public void update(CellDesignerSpecies<?> sp) { super.update(sp); - if (sp instanceof AntisenseRna) { - AntisenseRna rna = (AntisenseRna) sp; - for (AntisenseRnaRegion mr : getRegions()) { + if (sp instanceof CellDesignerAntisenseRna) { + CellDesignerAntisenseRna rna = (CellDesignerAntisenseRna) sp; + for (CellDesignerAntisenseRnaRegion mr : getRegions()) { mr.setState(null); } - for (AntisenseRnaRegion region : rna.getRegions()) { + for (CellDesignerAntisenseRnaRegion region : rna.getRegions()) { updateRegion(region); } } @@ -113,8 +113,8 @@ public class AntisenseRna extends Species<AntisenseRnaAlias> { * @param param * - object with new data from where update should be performed */ - private void updateRegion(AntisenseRnaRegion param) { - for (AntisenseRnaRegion region : regions) { + private void updateRegion(CellDesignerAntisenseRnaRegion param) { + for (CellDesignerAntisenseRnaRegion region : regions) { if (region.getIdAntisenseRnaRegion().equals(param.getIdAntisenseRnaRegion())) { region.update(param); return; @@ -127,7 +127,7 @@ public class AntisenseRna extends Species<AntisenseRnaAlias> { * @return the regions * @see #regions */ - public List<AntisenseRnaRegion> getRegions() { + public List<CellDesignerAntisenseRnaRegion> getRegions() { return regions; } @@ -136,15 +136,15 @@ public class AntisenseRna extends Species<AntisenseRnaAlias> { * the regions to set * @see #regions */ - public void setRegions(List<AntisenseRnaRegion> regions) { + public void setRegions(List<CellDesignerAntisenseRnaRegion> regions) { this.regions = regions; } @Override - public AntisenseRnaAlias createAlias(String aliasId) { - AntisenseRnaAlias result = new AntisenseRnaAlias(aliasId); + public AntisenseRna createAlias(String aliasId) { + AntisenseRna result = new AntisenseRna(aliasId); super.setAliasFields(result); - for (AntisenseRnaRegion region : regions) { + for (CellDesignerAntisenseRnaRegion region : regions) { result.addRegion(region.createAntisenseRegionAlias()); } return result; diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRnaComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRnaComparator.java similarity index 71% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRnaComparator.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRnaComparator.java index 2bb9ff7cb0..e63de6bd26 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRnaComparator.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRnaComparator.java @@ -14,7 +14,7 @@ import lcsb.mapviewer.common.exception.NotImplementedException; * @author Piotr Gawron * */ -public class AntisenseRnaComparator implements Comparator<AntisenseRna> { +public class CellDesignerAntisenseRnaComparator implements Comparator<CellDesignerAntisenseRna> { /** * Epsilon value used for comparison of doubles. @@ -27,19 +27,19 @@ public class AntisenseRnaComparator implements Comparator<AntisenseRna> { * @param epsilon * {@link #epsilon} */ - public AntisenseRnaComparator(double epsilon) { + public CellDesignerAntisenseRnaComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public AntisenseRnaComparator() { + public CellDesignerAntisenseRnaComparator() { this(Configuration.EPSILON); } @Override - public int compare(AntisenseRna arg0, AntisenseRna arg1) { + public int compare(CellDesignerAntisenseRna arg0, CellDesignerAntisenseRna arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -51,7 +51,7 @@ public class AntisenseRnaComparator implements Comparator<AntisenseRna> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(AntisenseRna.class)) { + if (arg0.getClass().equals(CellDesignerAntisenseRna.class)) { return internalCompare(arg0, arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); @@ -73,8 +73,8 @@ public class AntisenseRnaComparator implements Comparator<AntisenseRna> { * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(AntisenseRna arg0, AntisenseRna arg1) { - SpeciesComparator speciesComparator = new SpeciesComparator(epsilon); + private int internalCompare(CellDesignerAntisenseRna arg0, CellDesignerAntisenseRna arg1) { + CellDesignerSpeciesComparator speciesComparator = new CellDesignerSpeciesComparator(epsilon); int result = speciesComparator.internalCompare(arg0, arg1); if (result != 0) { return result; @@ -84,11 +84,11 @@ public class AntisenseRnaComparator implements Comparator<AntisenseRna> { Set<String> set1 = new HashSet<String>(); Set<String> set2 = new HashSet<String>(); - for (AntisenseRnaRegion region : arg0.getRegions()) { + for (CellDesignerAntisenseRnaRegion region : arg0.getRegions()) { set1.add(region.toString()); } - for (AntisenseRnaRegion region : arg1.getRegions()) { + for (CellDesignerAntisenseRnaRegion region : arg1.getRegions()) { set2.add(region.toString()); } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRnaRegion.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRnaRegion.java similarity index 80% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRnaRegion.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRnaRegion.java index 8ec3bb9181..e2c933ab7d 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRnaRegion.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRnaRegion.java @@ -6,20 +6,20 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaRegionAlias; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaRegionAlias.AntisenseRnaRegionType; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; +import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion; +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 * of interest) for a specific - * {@link lcsb.mapviewer.converter.model.celldesigner.structure.AntisenseRna + * {@link lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerAntisenseRna * AntisenseRna}. * * @author Piotr Gawron * */ -public class AntisenseRnaRegion implements Serializable { +public class CellDesignerAntisenseRnaRegion implements Serializable { /** * @@ -35,7 +35,7 @@ public class AntisenseRnaRegion implements Serializable { * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(AntisenseRnaRegion.class.getName()); + private static Logger logger = Logger.getLogger(CellDesignerAntisenseRnaRegion.class.getName()); /** * Unique identifier in the database. @@ -82,12 +82,12 @@ public class AntisenseRnaRegion implements Serializable { /** * Defines a species where the region belongs to. */ - private AntisenseRna species; + private CellDesignerAntisenseRna species; /** * Default constructor. */ - public AntisenseRnaRegion() { + public CellDesignerAntisenseRnaRegion() { } @@ -97,7 +97,7 @@ public class AntisenseRnaRegion implements Serializable { * @param original * object from which we initialize data */ - public AntisenseRnaRegion(AntisenseRnaRegion original) { + public CellDesignerAntisenseRnaRegion(CellDesignerAntisenseRnaRegion original) { this.idAntisenseRnaRegion = original.idAntisenseRnaRegion; this.name = original.name; this.size = original.size; @@ -110,9 +110,9 @@ public class AntisenseRnaRegion implements Serializable { * * @return copy of the object */ - public AntisenseRnaRegion copy() { - if (this.getClass() == AntisenseRnaRegion.class) { - return new AntisenseRnaRegion(this); + public CellDesignerAntisenseRnaRegion copy() { + if (this.getClass() == CellDesignerAntisenseRnaRegion.class) { + return new CellDesignerAntisenseRnaRegion(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } @@ -156,7 +156,7 @@ public class AntisenseRnaRegion implements Serializable { * @param mr * object from which we are updating data */ - public void update(AntisenseRnaRegion mr) { + public void update(CellDesignerAntisenseRnaRegion mr) { if (this.idAntisenseRnaRegion != null && !this.idAntisenseRnaRegion.equals("") && !this.idAntisenseRnaRegion.equals(mr.getIdAntisenseRnaRegion())) { throw new InvalidArgumentException("Cannot update from mr with different id"); } @@ -285,7 +285,7 @@ public class AntisenseRnaRegion implements Serializable { * @return the species * @see #species */ - public AntisenseRna getSpecies() { + public CellDesignerAntisenseRna getSpecies() { return species; } @@ -294,7 +294,7 @@ public class AntisenseRnaRegion implements Serializable { * the species to set * @see #species */ - public void setSpecies(AntisenseRna species) { + public void setSpecies(CellDesignerAntisenseRna species) { this.species = species; } @@ -315,8 +315,8 @@ public class AntisenseRnaRegion implements Serializable { this.id = id; } - public AntisenseRnaRegionAlias createAntisenseRegionAlias() { - AntisenseRnaRegionAlias result = new AntisenseRnaRegionAlias(); + public AntisenseRnaRegion createAntisenseRegionAlias() { + AntisenseRnaRegion result = new AntisenseRnaRegion(); result.setIdAntisenseRnaRegion(idAntisenseRnaRegion); result.setName(name); result.setSize(size); diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Chemical.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerChemical.java similarity index 80% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Chemical.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerChemical.java index 200e0d5882..bd53e231ea 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Chemical.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerChemical.java @@ -1,6 +1,6 @@ package lcsb.mapviewer.converter.model.celldesigner.structure; -import lcsb.mapviewer.model.map.layout.alias.ChemicalAlias; +import lcsb.mapviewer.model.map.species.Chemical; /** * Class representing chemical in the model. @@ -8,7 +8,7 @@ import lcsb.mapviewer.model.map.layout.alias.ChemicalAlias; * @author Piotr Gawron * */ -public abstract class Chemical<T extends ChemicalAlias> extends Species<T> { +public abstract class CellDesignerChemical<T extends Chemical> extends CellDesignerSpecies<T> { /** * @@ -43,10 +43,10 @@ public abstract class Chemical<T extends ChemicalAlias> extends Species<T> { * @param species * original species from which this chemical will be created */ - public Chemical(Species<?> species) { + public CellDesignerChemical(CellDesignerSpecies<?> species) { super(species); - if (species instanceof Chemical) { - Chemical<?> chemical = (Chemical<?>) species; + if (species instanceof CellDesignerChemical) { + CellDesignerChemical<?> chemical = (CellDesignerChemical<?>) species; this.smiles = chemical.smiles; this.inChI = chemical.inChI; this.inChIKey = chemical.inChIKey; @@ -56,7 +56,7 @@ public abstract class Chemical<T extends ChemicalAlias> extends Species<T> { /** * Default constructor. */ - public Chemical() { + public CellDesignerChemical() { super(); } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Compartment.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerCompartment.java similarity index 64% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Compartment.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerCompartment.java index bd710e3e22..93bfaf9a7e 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Compartment.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerCompartment.java @@ -6,7 +6,7 @@ import java.util.Set; import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; /** * This class describes compartment element in the model. @@ -14,7 +14,7 @@ import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; * @author Piotr Gawron * */ -public class Compartment extends Element<CompartmentAlias> implements Comparable<Compartment> { +public class CellDesignerCompartment extends CellDesignerElement<Compartment> implements Comparable<CellDesignerCompartment> { /** * @@ -25,7 +25,7 @@ public class Compartment extends Element<CompartmentAlias> implements Comparable * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(Compartment.class); + private static Logger logger = Logger.getLogger(CellDesignerCompartment.class); /** * Identifier of the compartment. Unique in the model @@ -35,7 +35,7 @@ public class Compartment extends Element<CompartmentAlias> implements Comparable /** * List of agregated elements. */ - private Set<Element<?>> elements = new HashSet<>(); + private Set<CellDesignerElement<?>> elements = new HashSet<>(); /** * Default constructor with identifier given as a parameter. @@ -43,14 +43,14 @@ public class Compartment extends Element<CompartmentAlias> implements Comparable * @param id * identifier of the compartment */ - public Compartment(String id) { + public CellDesignerCompartment(String id) { compartmentId = id; } /** * Default constructor. */ - public Compartment() { + public CellDesignerCompartment() { super(); } @@ -61,16 +61,16 @@ public class Compartment extends Element<CompartmentAlias> implements Comparable * @param compartment * object which is used for data intialization */ - public Compartment(Compartment compartment) { + public CellDesignerCompartment(CellDesignerCompartment compartment) { super(compartment); setElementId(compartment.getElementId()); - for (Element<?> element : compartment.getElements()) { + for (CellDesignerElement<?> element : compartment.getElements()) { addElement(element.copy()); } } @Override - public int compareTo(Compartment param) { + public int compareTo(CellDesignerCompartment param) { if (param == null) { return -1; } @@ -88,11 +88,11 @@ public class Compartment extends Element<CompartmentAlias> implements Comparable if (this == param) { return true; } - if (!(param instanceof Compartment)) { + if (!(param instanceof CellDesignerCompartment)) { return false; } - return compareTo((Compartment) param) == 0; + return compareTo((CellDesignerCompartment) param) == 0; } @Override @@ -102,11 +102,11 @@ public class Compartment extends Element<CompartmentAlias> implements Comparable } @Override - public Compartment copy() { - if (this.getClass() != Compartment.class) { + public CellDesignerCompartment copy() { + if (this.getClass() != CellDesignerCompartment.class) { throw new NotImplementedException("this method should be overloaded"); } - return new Compartment(this); + return new CellDesignerCompartment(this); } @Override @@ -130,7 +130,7 @@ public class Compartment extends Element<CompartmentAlias> implements Comparable * @param element * element to add */ - public void addElement(Element<?> element) { + public void addElement(CellDesignerElement<?> element) { elements.add(element); element.setParent(this); } @@ -139,13 +139,13 @@ public class Compartment extends Element<CompartmentAlias> implements Comparable * * @return {@link #elements} */ - public Set<Element<?>> getElements() { + public Set<CellDesignerElement<?>> getElements() { return elements; } @Override - public CompartmentAlias createAlias(String aliasId) { - CompartmentAlias result = new CompartmentAlias(aliasId); + public Compartment createAlias(String aliasId) { + Compartment result = new Compartment(aliasId); super.setAliasFields(result); if (elements.size() > 0) { throw new NotImplementedException(); diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CompartmentComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerCompartmentComparator.java similarity index 71% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CompartmentComparator.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerCompartmentComparator.java index 0034469773..5cc8147618 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CompartmentComparator.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerCompartmentComparator.java @@ -10,10 +10,10 @@ import lcsb.mapviewer.common.exception.InvalidClassException; * * @author Piotr Gawron * - * @see Compartment + * @see CellDesignerCompartment * */ -public class CompartmentComparator implements Comparator<Compartment> { +public class CellDesignerCompartmentComparator implements Comparator<CellDesignerCompartment> { /** * Epsilon value used for comparison of doubles. @@ -26,19 +26,19 @@ public class CompartmentComparator implements Comparator<Compartment> { * @param epsilon * {@link #epsilon} */ - public CompartmentComparator(double epsilon) { + public CellDesignerCompartmentComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public CompartmentComparator() { + public CellDesignerCompartmentComparator() { this(Configuration.EPSILON); } @Override - public int compare(Compartment arg0, Compartment arg1) { + public int compare(CellDesignerCompartment arg0, CellDesignerCompartment arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -50,7 +50,7 @@ public class CompartmentComparator implements Comparator<Compartment> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(Compartment.class)) { + if (arg0.getClass().equals(CellDesignerCompartment.class)) { return internalCompare(arg0, arg1); } else { throw new InvalidClassException("Don't know how to compare classes: " + arg0.getClass()); @@ -72,8 +72,8 @@ public class CompartmentComparator implements Comparator<Compartment> { * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(Compartment arg0, Compartment arg1) { - ElementComparator elementComparator = new ElementComparator(epsilon); + private int internalCompare(CellDesignerCompartment arg0, CellDesignerCompartment arg1) { + CellDesignerElementComparator elementComparator = new CellDesignerElementComparator(epsilon); int result = elementComparator.internalCompare(arg0, arg1); if (result != 0) { diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/ComplexSpecies.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerComplexSpecies.java similarity index 59% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/ComplexSpecies.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerComplexSpecies.java index 2da11f9215..a4458341b8 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/ComplexSpecies.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerComplexSpecies.java @@ -7,7 +7,7 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; +import lcsb.mapviewer.model.map.species.Complex; /** * Class representing complex in the model. @@ -15,7 +15,7 @@ import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; * @author Piotr Gawron * */ -public class ComplexSpecies extends Species<ComplexAlias> { +public class CellDesignerComplexSpecies extends CellDesignerSpecies<Complex> { /** * @@ -25,12 +25,12 @@ public class ComplexSpecies extends Species<ComplexAlias> { /** * Default class logger. */ - private static Logger logger = Logger.getLogger(ComplexSpecies.class.getName()); + private static Logger logger = Logger.getLogger(CellDesignerComplexSpecies.class.getName()); /** * Elements that exists in this complex. */ - private Set<Element<?>> elements = new HashSet<>(); + private Set<CellDesignerElement<?>> elements = new HashSet<>(); /** * State of the complex species. @@ -40,7 +40,7 @@ public class ComplexSpecies extends Species<ComplexAlias> { /** * Default constructor. */ - public ComplexSpecies() { + public CellDesignerComplexSpecies() { super(); } @@ -51,12 +51,12 @@ public class ComplexSpecies extends Species<ComplexAlias> { * @param original * object used for initializing data */ - public ComplexSpecies(Species<?> original) { + public CellDesignerComplexSpecies(CellDesignerSpecies<?> original) { super(original); - if (original instanceof ComplexSpecies) { - ComplexSpecies complex = (ComplexSpecies) original; + if (original instanceof CellDesignerComplexSpecies) { + CellDesignerComplexSpecies complex = (CellDesignerComplexSpecies) original; structuralState = complex.getStructuralState(); - for (Element<?> element : complex.getElements()) { + for (CellDesignerElement<?> element : complex.getElements()) { addElement(element.copy()); } } @@ -66,16 +66,16 @@ public class ComplexSpecies extends Species<ComplexAlias> { * Constructor with species id. * * @param complexId - * {@link Species#idSpecies} + * {@link CellDesignerSpecies#idSpecies} */ - public ComplexSpecies(String complexId) { + public CellDesignerComplexSpecies(String complexId) { super(complexId); } @Override - public ComplexSpecies copy() { - if (this.getClass() == ComplexSpecies.class) { - return new ComplexSpecies(this); + public CellDesignerComplexSpecies copy() { + if (this.getClass() == CellDesignerComplexSpecies.class) { + return new CellDesignerComplexSpecies(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } @@ -92,10 +92,10 @@ public class ComplexSpecies extends Species<ComplexAlias> { * @param element * object to add */ - public void addElement(Element<?> element) { - if (element instanceof Species) { - for (Element<?> el : elements) { - if (el instanceof Species) { + public void addElement(CellDesignerElement<?> element) { + if (element instanceof CellDesignerSpecies) { + for (CellDesignerElement<?> el : elements) { + if (el instanceof CellDesignerSpecies) { if (el.getElementId().equals(element.getElementId())) { throw new InvalidArgumentException("Cannot add two species with the same id: " + el.getElementId()); } @@ -110,13 +110,13 @@ public class ComplexSpecies extends Species<ComplexAlias> { * * @return list of all elements in the complex. */ - public Set<Species<?>> getAllSimpleChildren() { - Set<Species<?>> result = new HashSet<>(); - for (Element<?> element : getElements()) { - if (element instanceof ComplexSpecies) { - result.addAll(((ComplexSpecies) element).getAllSimpleChildren()); - } else if (element instanceof Species) { - result.add((Species<?>) element); + public Set<CellDesignerSpecies<?>> getAllSimpleChildren() { + Set<CellDesignerSpecies<?>> result = new HashSet<>(); + for (CellDesignerElement<?> element : getElements()) { + if (element instanceof CellDesignerComplexSpecies) { + result.addAll(((CellDesignerComplexSpecies) element).getAllSimpleChildren()); + } else if (element instanceof CellDesignerSpecies) { + result.add((CellDesignerSpecies<?>) element); } } return result; @@ -146,7 +146,7 @@ public class ComplexSpecies extends Species<ComplexAlias> { * @return the elements * @see #elements */ - public Set<Element<?>> getElements() { + public Set<CellDesignerElement<?>> getElements() { return elements; } @@ -155,12 +155,12 @@ public class ComplexSpecies extends Species<ComplexAlias> { * the elements to set * @see #elements */ - public void setElements(Set<Element<?>> elements) { + public void setElements(Set<CellDesignerElement<?>> elements) { this.elements = elements; } - public ComplexAlias createAlias(String aliasId) { - ComplexAlias result = new ComplexAlias(aliasId); + public Complex createAlias(String aliasId) { + Complex result = new Complex(aliasId); super.setAliasFields(result); if (elements.size() > 0) { diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/ComplexSpeciesComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerComplexSpeciesComparator.java similarity index 69% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/ComplexSpeciesComparator.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerComplexSpeciesComparator.java index bf2c6f38dd..d0b0c10207 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/ComplexSpeciesComparator.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerComplexSpeciesComparator.java @@ -15,11 +15,11 @@ import lcsb.mapviewer.common.exception.NotImplementedException; * @author Piotr Gawron * */ -public class ComplexSpeciesComparator implements Comparator<ComplexSpecies> { +public class CellDesignerComplexSpeciesComparator implements Comparator<CellDesignerComplexSpecies> { /** * Default class logger. */ - private Logger logger = Logger.getLogger(ComplexSpeciesComparator.class); + private Logger logger = Logger.getLogger(CellDesignerComplexSpeciesComparator.class); /** * Epsilon value used for comparison of doubles. @@ -32,19 +32,19 @@ public class ComplexSpeciesComparator implements Comparator<ComplexSpecies> { * @param epsilon * {@link #epsilon} */ - public ComplexSpeciesComparator(double epsilon) { + public CellDesignerComplexSpeciesComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public ComplexSpeciesComparator() { + public CellDesignerComplexSpeciesComparator() { this(Configuration.EPSILON); } @Override - public int compare(ComplexSpecies arg0, ComplexSpecies arg1) { + public int compare(CellDesignerComplexSpecies arg0, CellDesignerComplexSpecies arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -56,7 +56,7 @@ public class ComplexSpeciesComparator implements Comparator<ComplexSpecies> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(ComplexSpecies.class)) { + if (arg0.getClass().equals(CellDesignerComplexSpecies.class)) { return internalCompare(arg0, arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); @@ -78,10 +78,10 @@ public class ComplexSpeciesComparator implements Comparator<ComplexSpecies> { * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(ComplexSpecies arg0, ComplexSpecies arg1) { - ElementComparator elementComparator = new ElementComparator(epsilon); + private int internalCompare(CellDesignerComplexSpecies arg0, CellDesignerComplexSpecies arg1) { + CellDesignerElementComparator elementComparator = new CellDesignerElementComparator(epsilon); - SpeciesComparator speciesComparator = new SpeciesComparator(epsilon); + CellDesignerSpeciesComparator speciesComparator = new CellDesignerSpeciesComparator(epsilon); int result = speciesComparator.internalCompare(arg0, arg1); if (result != 0) { return result; @@ -105,12 +105,12 @@ public class ComplexSpeciesComparator implements Comparator<ComplexSpecies> { return stringComparator.compare(arg0.getStructuralState(), arg1.getStructuralState()); } - for (Element<?> element : arg0.getElements()) { + for (CellDesignerElement<?> element : arg0.getElements()) { boolean found = false; - if (element instanceof Species) { - for (Element<?> element1 : arg1.getElements()) { - if (element1 instanceof Species) { + 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()); @@ -122,9 +122,9 @@ public class ComplexSpeciesComparator implements Comparator<ComplexSpecies> { } } - } else if (element instanceof Compartment) { - for (Element<?> element1 : arg1.getElements()) { - if (element1 instanceof Compartment) { + } 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()); @@ -139,9 +139,9 @@ public class ComplexSpeciesComparator implements Comparator<ComplexSpecies> { throw new NotImplementedException("Don't know how to compare: " + element.getClass()); } if (!found) { - if (element instanceof Species) { + if (element instanceof CellDesignerSpecies) { logger.debug("Cannot find element: " + element.getElementId() + " in:"); - for (Element<?> el : arg1.getElements()) { + for (CellDesignerElement<?> el : arg1.getElements()) { logger.debug(el.getElementId()); } } @@ -149,12 +149,12 @@ public class ComplexSpeciesComparator implements Comparator<ComplexSpecies> { } } - for (Element<?> element : arg1.getElements()) { + for (CellDesignerElement<?> element : arg1.getElements()) { boolean found = false; - if (element instanceof Species) { - for (Element<?> element1 : arg0.getElements()) { - if (element1 instanceof Species) { + 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; @@ -163,9 +163,9 @@ public class ComplexSpeciesComparator implements Comparator<ComplexSpecies> { } } - } else if (element instanceof Compartment) { - for (Element<?> element1 : arg0.getElements()) { - if (element1 instanceof Compartment) { + } 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; diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Degraded.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDegraded.java similarity index 60% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Degraded.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDegraded.java index 5d0ef0d4c4..2289b0707f 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Degraded.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDegraded.java @@ -1,7 +1,7 @@ package lcsb.mapviewer.converter.model.celldesigner.structure; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.DegradedAlias; +import lcsb.mapviewer.model.map.species.Degraded; /** * Class representing degraded objects in the model. @@ -9,7 +9,7 @@ import lcsb.mapviewer.model.map.layout.alias.DegradedAlias; * @author Piotr Gawron * */ -public class Degraded extends Species<DegradedAlias> { +public class CellDesignerDegraded extends CellDesignerSpecies<Degraded> { /** * @@ -22,20 +22,20 @@ public class Degraded extends Species<DegradedAlias> { * @param species * parent species from which we want to copy data */ - public Degraded(Species species) { + public CellDesignerDegraded(CellDesignerSpecies<?> species) { super(species); } /** * Default constructor. */ - public Degraded() { + public CellDesignerDegraded() { } @Override - public Degraded copy() { - if (this.getClass() == Degraded.class) { - return new Degraded(super.copy()); + public CellDesignerDegraded copy() { + if (this.getClass() == CellDesignerDegraded.class) { + return new CellDesignerDegraded(super.copy()); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } @@ -47,8 +47,8 @@ public class Degraded extends Species<DegradedAlias> { } @Override - public DegradedAlias createAlias(String aliasId) { - DegradedAlias result = new DegradedAlias(aliasId); + public Degraded createAlias(String aliasId) { + Degraded result = new Degraded(aliasId); super.setAliasFields(result); return result; } 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 new file mode 100644 index 0000000000..a5e4b021fe --- /dev/null +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDegradedComparator.java @@ -0,0 +1,82 @@ +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/Drug.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDrug.java similarity index 62% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Drug.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDrug.java index b3d86a5568..b0ea4d29f9 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Drug.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDrug.java @@ -1,7 +1,7 @@ package lcsb.mapviewer.converter.model.celldesigner.structure; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.DrugAlias; +import lcsb.mapviewer.model.map.species.Drug; /** * Class representing drug in the model. @@ -9,7 +9,7 @@ import lcsb.mapviewer.model.map.layout.alias.DrugAlias; * @author Piotr Gawron * */ -public class Drug extends Species<DrugAlias> { +public class CellDesignerDrug extends CellDesignerSpecies<Drug> { /** * @@ -22,20 +22,20 @@ public class Drug extends Species<DrugAlias> { * @param species * parent species from which we want to copy data */ - public Drug(Species species) { + public CellDesignerDrug(CellDesignerSpecies<?> species) { super(species); } /** * Default constructor. */ - public Drug() { + public CellDesignerDrug() { } @Override - public Drug copy() { - if (this.getClass() == Drug.class) { - return new Drug(this); + public CellDesignerDrug copy() { + if (this.getClass() == CellDesignerDrug.class) { + return new CellDesignerDrug(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } @@ -47,8 +47,8 @@ public class Drug extends Species<DrugAlias> { } @Override - public DrugAlias createAlias(String aliasId) { - DrugAlias result = new DrugAlias(aliasId); + public Drug createAlias(String aliasId) { + Drug result = new Drug(aliasId); super.setAliasFields(result); return result; } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/DrugComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDrugComparator.java similarity index 72% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/DrugComparator.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDrugComparator.java index 46522e97af..b79fd9f364 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/DrugComparator.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerDrugComparator.java @@ -10,9 +10,9 @@ import lcsb.mapviewer.common.exception.NotImplementedException; * * @author Piotr Gawron * - * @see Drug + * @see CellDesignerDrug */ -public class DrugComparator implements Comparator<Drug> { +public class CellDesignerDrugComparator implements Comparator<CellDesignerDrug> { /** * Epsilon value used for comparison of doubles. @@ -25,19 +25,19 @@ public class DrugComparator implements Comparator<Drug> { * @param epsilon * {@link #epsilon} */ - public DrugComparator(double epsilon) { + public CellDesignerDrugComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public DrugComparator() { + public CellDesignerDrugComparator() { this(Configuration.EPSILON); } @Override - public int compare(Drug arg0, Drug arg1) { + public int compare(CellDesignerDrug arg0, CellDesignerDrug arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -49,7 +49,7 @@ public class DrugComparator implements Comparator<Drug> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(Drug.class)) { + if (arg0.getClass().equals(CellDesignerDrug.class)) { return internalCompare(arg0, arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); @@ -70,8 +70,8 @@ public class DrugComparator implements Comparator<Drug> { * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(Drug arg0, Drug arg1) { - SpeciesComparator speciesComparator = new SpeciesComparator(epsilon); + private int internalCompare(CellDesignerDrug arg0, CellDesignerDrug arg1) { + CellDesignerSpeciesComparator speciesComparator = new CellDesignerSpeciesComparator(epsilon); int result = speciesComparator.internalCompare(arg0, arg1); if (result != 0) { return result; diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Element.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerElement.java similarity index 91% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Element.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerElement.java index fadaa2a653..77aaad3138 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Element.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerElement.java @@ -11,9 +11,9 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; 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 @@ -22,7 +22,7 @@ import lcsb.mapviewer.model.map.model.ModelData; * @author Piotr Gawron * */ -public abstract class Element<T extends Alias> implements Serializable { +public abstract class CellDesignerElement<T extends Element> implements Serializable { /** * @@ -37,7 +37,7 @@ public abstract class Element<T extends Alias> implements Serializable { /** * Default class logger. */ - private static Logger logger = Logger.getLogger(Element.class); + private static Logger logger = Logger.getLogger(CellDesignerElement.class); /** * Notes describing this element. @@ -82,12 +82,12 @@ public abstract class Element<T extends Alias> implements Serializable { /** * Where this element lies on. */ - private Compartment parent; + private CellDesignerCompartment parent; /** * In which complex this element is located. */ - private ComplexSpecies complex; + private CellDesignerComplexSpecies complex; /** * In which model this element is located. @@ -106,7 +106,7 @@ public abstract class Element<T extends Alias> implements Serializable { * @param element * original object from which data should be initialized */ - protected Element(Element<?> element) { + protected CellDesignerElement(CellDesignerElement<?> element) { this.parent = element.parent; this.complex = element.complex; this.notes = element.notes; @@ -126,7 +126,7 @@ public abstract class Element<T extends Alias> implements Serializable { /** * Default constructor. */ - protected Element() { + protected CellDesignerElement() { this.notes = ""; } @@ -161,7 +161,7 @@ public abstract class Element<T extends Alias> implements Serializable { * * @return copy of the object */ - public abstract Element<T> copy(); + public abstract CellDesignerElement<T> copy(); /** * Adds synonyms to the element. @@ -259,7 +259,7 @@ public abstract class Element<T extends Alias> implements Serializable { * @return the parent * @see #parent */ - public Compartment getParent() { + public CellDesignerCompartment getParent() { return parent; } @@ -268,7 +268,7 @@ public abstract class Element<T extends Alias> implements Serializable { * the parent to set * @see #parent */ - public void setParent(Compartment parent) { + public void setParent(CellDesignerCompartment parent) { this.parent = parent; } @@ -276,7 +276,7 @@ public abstract class Element<T extends Alias> implements Serializable { * @return the complex * @see #complex */ - public ComplexSpecies getComplex() { + public CellDesignerComplexSpecies getComplex() { return complex; } @@ -285,7 +285,7 @@ public abstract class Element<T extends Alias> implements Serializable { * the complex to set * @see #complex */ - public void setComplex(ComplexSpecies complex) { + public void setComplex(CellDesignerComplexSpecies complex) { this.complex = complex; } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/ElementComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerElementComparator.java similarity index 82% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/ElementComparator.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerElementComparator.java index a1167275a4..d56b62c7bc 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/ElementComparator.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerElementComparator.java @@ -20,11 +20,11 @@ import org.apache.log4j.Logger; * @author Piotr Gawron * */ -public class ElementComparator implements Comparator<Element<?>> { +public class CellDesignerElementComparator implements Comparator<CellDesignerElement<?>> { /** * Default class logger. */ - private static Logger logger = Logger.getLogger(ElementComparator.class); + private static Logger logger = Logger.getLogger(CellDesignerElementComparator.class); /** * Epsilon value used for comparison of doubles. @@ -37,14 +37,14 @@ public class ElementComparator implements Comparator<Element<?>> { * @param epsilon * {@link #epsilon} */ - public ElementComparator(double epsilon) { + public CellDesignerElementComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public ElementComparator() { + public CellDesignerElementComparator() { this(Configuration.EPSILON); } @@ -60,7 +60,7 @@ public class ElementComparator implements Comparator<Element<?>> { * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - public int internalCompare(Element<?> arg0, Element<?> arg1) { + public int internalCompare(CellDesignerElement<?> arg0, CellDesignerElement<?> arg1) { StringComparator stringComparator = new StringComparator(); if (arg0 == null) { if (arg1 == null) { @@ -152,7 +152,7 @@ public class ElementComparator implements Comparator<Element<?>> { } @Override - public int compare(Element<?> arg0, Element<?> arg1) { + public int compare(CellDesignerElement<?> arg0, CellDesignerElement<?> arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -164,12 +164,12 @@ public class ElementComparator implements Comparator<Element<?>> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0 instanceof Species) { - SpeciesComparator speciesComparator = new SpeciesComparator(epsilon); - return speciesComparator.compare((Species<?>) arg0, (Species<?>) arg1); - } else if (arg0 instanceof Compartment) { - CompartmentComparator compartmentComparator = new CompartmentComparator(epsilon); - return compartmentComparator.compare((Compartment) arg0, (Compartment) arg1); + 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()); } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Gene.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGene.java similarity index 51% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Gene.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGene.java index d573c97bc9..aae01214f4 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Gene.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGene.java @@ -4,7 +4,8 @@ import java.util.ArrayList; import java.util.List; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue; +import lcsb.mapviewer.model.map.species.Gene; /** * Class representing gene in the model. @@ -12,7 +13,7 @@ import lcsb.mapviewer.model.map.layout.alias.GeneAlias; * @author Piotr Gawron * */ -public class Gene extends Species<GeneAlias> { +public class CellDesignerGene extends CellDesignerSpecies<Gene> { /** * @@ -22,7 +23,7 @@ public class Gene extends Species<GeneAlias> { /** * List of modifications for the Gene. */ - private List<ModificationResidue> modificationResidues = new ArrayList<>(); + private List<CellDesignerModificationResidue> modificationResidues = new ArrayList<>(); /** * Constructor that initializes gene with the data passed in the argument. @@ -30,23 +31,23 @@ public class Gene extends Species<GeneAlias> { * @param species * original species used for data initialization */ - public Gene(Species species) { + public CellDesignerGene(CellDesignerSpecies<?> species) { super(species); - if (species instanceof Gene) { - Gene gene = (Gene) species; - for (ModificationResidue mr : gene.getModificationResidues()) { - addModificationResidue(new ModificationResidue(mr)); + if (species instanceof CellDesignerGene) { + CellDesignerGene gene = (CellDesignerGene) species; + for (CellDesignerModificationResidue mr : gene.getModificationResidues()) { + addModificationResidue(new CellDesignerModificationResidue(mr)); } } } @Override - public void update(Species species) { + public void update(CellDesignerSpecies<?> species) { super.update(species); - if (species instanceof Gene) { - Gene gene = (Gene) species; + if (species instanceof CellDesignerGene) { + CellDesignerGene gene = (CellDesignerGene) species; - for (ModificationResidue mr : gene.getModificationResidues()) { + for (CellDesignerModificationResidue mr : gene.getModificationResidues()) { addModificationResidue(mr); } } @@ -55,14 +56,14 @@ public class Gene extends Species<GeneAlias> { /** * Default constructor. */ - public Gene() { + public CellDesignerGene() { super(); } @Override - public Gene copy() { - if (this.getClass() == Gene.class) { - return new Gene(this); + public CellDesignerGene copy() { + if (this.getClass() == CellDesignerGene.class) { + return new CellDesignerGene(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } @@ -79,8 +80,8 @@ public class Gene extends Species<GeneAlias> { * @param modificationResidue * modifiaction to add */ - public void addModificationResidue(ModificationResidue modificationResidue) { - for (ModificationResidue mr : modificationResidues) { + public void addModificationResidue(CellDesignerModificationResidue modificationResidue) { + for (CellDesignerModificationResidue mr : modificationResidues) { if (mr.getIdModificationResidue().equals(modificationResidue.getIdModificationResidue())) { mr.update(modificationResidue); return; @@ -95,7 +96,7 @@ public class Gene extends Species<GeneAlias> { * @return the modificationResidues * @see #modificationResidues */ - public List<ModificationResidue> getModificationResidues() { + public List<CellDesignerModificationResidue> getModificationResidues() { return modificationResidues; } @@ -104,15 +105,15 @@ public class Gene extends Species<GeneAlias> { * the modificationResidues to set * @see #modificationResidues */ - public void setModificationResidues(List<ModificationResidue> modificationResidues) { + public void setModificationResidues(List<CellDesignerModificationResidue> modificationResidues) { this.modificationResidues = modificationResidues; } @Override - public GeneAlias createAlias(String aliasId) { - GeneAlias result = new GeneAlias(aliasId); + public Gene createAlias(String aliasId) { + Gene result = new Gene(aliasId); super.setAliasFields(result); - for (ModificationResidue mr : modificationResidues) { + for (CellDesignerModificationResidue mr : modificationResidues) { result.addModificationResidue(mr.createModificationResidueAlias()); } return result; diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/GeneComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGeneComparator.java similarity index 67% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/GeneComparator.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGeneComparator.java index 9f5ea4b31c..8e051533ed 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/GeneComparator.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGeneComparator.java @@ -7,15 +7,16 @@ 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 Gene + * @see CellDesignerGene */ -public class GeneComparator implements Comparator<Gene> { +public class CellDesignerGeneComparator implements Comparator<CellDesignerGene> { /** * Epsilon value used for comparison of doubles. @@ -28,19 +29,19 @@ public class GeneComparator implements Comparator<Gene> { * @param epsilon * {@link #epsilon} */ - public GeneComparator(double epsilon) { + public CellDesignerGeneComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public GeneComparator() { + public CellDesignerGeneComparator() { this(Configuration.EPSILON); } @Override - public int compare(Gene arg0, Gene arg1) { + public int compare(CellDesignerGene arg0, CellDesignerGene arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -52,7 +53,7 @@ public class GeneComparator implements Comparator<Gene> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(Gene.class)) { + if (arg0.getClass().equals(CellDesignerGene.class)) { return internalCompare(arg0, arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); @@ -65,7 +66,7 @@ public class GeneComparator implements Comparator<Gene> { /** * 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 Species}): {@link SpeciesComparator}. + * {@link CellDesignerSpecies}): {@link CellDesignerSpeciesComparator}. * * @param arg0 * first object to compare @@ -74,8 +75,8 @@ public class GeneComparator implements Comparator<Gene> { * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(Gene arg0, Gene arg1) { - SpeciesComparator speciesComparator = new SpeciesComparator(epsilon); + private int internalCompare(CellDesignerGene arg0, CellDesignerGene arg1) { + CellDesignerSpeciesComparator speciesComparator = new CellDesignerSpeciesComparator(epsilon); int result = speciesComparator.internalCompare(arg0, arg1); if (result != 0) { return result; @@ -86,11 +87,11 @@ public class GeneComparator implements Comparator<Gene> { Set<String> set1 = new HashSet<String>(); Set<String> set2 = new HashSet<String>(); - for (ModificationResidue region : arg0.getModificationResidues()) { + for (CellDesignerModificationResidue region : arg0.getModificationResidues()) { set1.add(region.toString()); } - for (ModificationResidue region : arg1.getModificationResidues()) { + for (CellDesignerModificationResidue region : arg1.getModificationResidues()) { set2.add(region.toString()); } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/GenericProtein.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGenericProtein.java similarity index 51% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/GenericProtein.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGenericProtein.java index 54ba04d6a5..562f55a0e5 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/GenericProtein.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGenericProtein.java @@ -1,7 +1,7 @@ package lcsb.mapviewer.converter.model.celldesigner.structure; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; +import lcsb.mapviewer.model.map.species.GenericProtein; /** * Generic protein. @@ -9,7 +9,7 @@ import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; * @author Piotr Gawron * */ -public class GenericProtein extends Protein<GenericProteinAlias> { +public class CellDesignerGenericProtein extends CellDesignerProtein<GenericProtein> { /** * @@ -19,7 +19,7 @@ public class GenericProtein extends Protein<GenericProteinAlias> { /** * Default constructor. */ - public GenericProtein() { + public CellDesignerGenericProtein() { super(); } @@ -29,25 +29,25 @@ public class GenericProtein extends Protein<GenericProteinAlias> { * @param species * original species */ - public GenericProtein(Species<?> species) { + public CellDesignerGenericProtein(CellDesignerSpecies<?> species) { super(species); } - public GenericProtein(String id) { + public CellDesignerGenericProtein(String id) { setElementId(id); } @Override - public GenericProtein copy() { - if (this.getClass().equals(GenericProtein.class)) { - return new GenericProtein(this); + public CellDesignerGenericProtein copy() { + if (this.getClass().equals(CellDesignerGenericProtein.class)) { + return new CellDesignerGenericProtein(this); } else { throw new NotImplementedException("Copy method for " + this.getClass() + " class not implemented"); } } - public GenericProteinAlias createAlias(String aliasId) { - GenericProteinAlias result = new GenericProteinAlias(aliasId); + public GenericProtein createAlias(String aliasId) { + GenericProtein result = new GenericProtein(aliasId); super.setAliasFields(result); return result; diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Ion.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerIon.java similarity index 63% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Ion.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerIon.java index 7fc1abda1d..568bc61f13 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Ion.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerIon.java @@ -1,7 +1,7 @@ package lcsb.mapviewer.converter.model.celldesigner.structure; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.IonAlias; +import lcsb.mapviewer.model.map.species.Ion; /** * Class representing ion in the model. @@ -9,7 +9,7 @@ import lcsb.mapviewer.model.map.layout.alias.IonAlias; * @author Piotr Gawron * */ -public class Ion extends Chemical<IonAlias> { +public class CellDesignerIon extends CellDesignerChemical<Ion> { /** * @@ -22,21 +22,21 @@ public class Ion extends Chemical<IonAlias> { * @param species * original species used for data initialization */ - public Ion(Species species) { + public CellDesignerIon(CellDesignerSpecies<?> species) { super(species); } /** * Default constructor. */ - public Ion() { + public CellDesignerIon() { super(); } @Override - public Ion copy() { - if (this.getClass() == Ion.class) { - return new Ion(this); + public CellDesignerIon copy() { + if (this.getClass() == CellDesignerIon.class) { + return new CellDesignerIon(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } @@ -48,8 +48,8 @@ public class Ion extends Chemical<IonAlias> { } @Override - public IonAlias createAlias(String aliasId) { - IonAlias result = new IonAlias(aliasId); + public Ion createAlias(String aliasId) { + Ion result = new Ion(aliasId); super.setAliasFields(result); return result; } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/IonChannelProtein.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerIonChannelProtein.java similarity index 51% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/IonChannelProtein.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerIonChannelProtein.java index 9bfe21e7d8..d73d22cf5f 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/IonChannelProtein.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerIonChannelProtein.java @@ -1,7 +1,7 @@ package lcsb.mapviewer.converter.model.celldesigner.structure; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.IonChannelProteinAlias; +import lcsb.mapviewer.model.map.species.IonChannelProtein; /** * Ion channel protein. @@ -9,7 +9,7 @@ import lcsb.mapviewer.model.map.layout.alias.IonChannelProteinAlias; * @author Piotr Gawron * */ -public class IonChannelProtein extends Protein<IonChannelProteinAlias> { +public class CellDesignerIonChannelProtein extends CellDesignerProtein<IonChannelProtein> { /** * @@ -19,7 +19,7 @@ public class IonChannelProtein extends Protein<IonChannelProteinAlias> { /** * Default constructor. */ - public IonChannelProtein() { + public CellDesignerIonChannelProtein() { super(); } @@ -29,22 +29,22 @@ public class IonChannelProtein extends Protein<IonChannelProteinAlias> { * @param species * original species */ - public IonChannelProtein(Species species) { + public CellDesignerIonChannelProtein(CellDesignerSpecies<?> species) { super(species); } @Override - public IonChannelProtein copy() { - if (this.getClass().equals(IonChannelProtein.class)) { - return new IonChannelProtein(this); + public CellDesignerIonChannelProtein copy() { + if (this.getClass().equals(CellDesignerIonChannelProtein.class)) { + return new CellDesignerIonChannelProtein(this); } else { throw new NotImplementedException("Copy method for " + this.getClass() + " class not implemented"); } } @Override - public IonChannelProteinAlias createAlias(String aliasId) { - IonChannelProteinAlias result = new IonChannelProteinAlias(aliasId); + public IonChannelProtein createAlias(String aliasId) { + IonChannelProtein result = new IonChannelProtein(aliasId); super.setAliasFields(result); return result; } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/PhenotypeComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerIonComparator.java similarity index 62% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/PhenotypeComparator.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerIonComparator.java index b0a691dc86..528dc4b2ed 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/PhenotypeComparator.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerIonComparator.java @@ -2,23 +2,17 @@ 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. + * This class implements comparator interface for Ion. * * @author Piotr Gawron * - * @see Phenotype + * @see CellDesignerIon */ -public class PhenotypeComparator implements Comparator<Phenotype> { - /** - * Default class logger. - */ - private Logger logger = Logger.getLogger(PhenotypeComparator.class); +public class CellDesignerIonComparator implements Comparator<CellDesignerIon> { /** * Epsilon value used for comparison of doubles. @@ -31,19 +25,19 @@ public class PhenotypeComparator implements Comparator<Phenotype> { * @param epsilon * {@link #epsilon} */ - public PhenotypeComparator(double epsilon) { + public CellDesignerIonComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public PhenotypeComparator() { + public CellDesignerIonComparator() { this(Configuration.EPSILON); } @Override - public int compare(Phenotype arg0, Phenotype arg1) { + public int compare(CellDesignerIon arg0, CellDesignerIon arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -55,7 +49,7 @@ public class PhenotypeComparator implements Comparator<Phenotype> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(Phenotype.class)) { + if (arg0.getClass().equals(CellDesignerIon.class)) { return internalCompare(arg0, arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); @@ -66,9 +60,9 @@ public class PhenotypeComparator implements Comparator<Phenotype> { } /** - * This method compares only the fields that are defined in {@link Phenotype} - * class in inheritence tree. It also calls the {@link SpeciesComparator} for - * the super class ( {@link Species}). + * 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 @@ -77,13 +71,12 @@ public class PhenotypeComparator implements Comparator<Phenotype> { * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(Phenotype arg0, Phenotype arg1) { - SpeciesComparator speciesComparator = new SpeciesComparator(epsilon); + 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/Phenotype.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerPhenotype.java similarity index 60% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Phenotype.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerPhenotype.java index ddb9639f1c..625a4f16b6 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Phenotype.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerPhenotype.java @@ -1,7 +1,7 @@ package lcsb.mapviewer.converter.model.celldesigner.structure; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias; +import lcsb.mapviewer.model.map.species.Phenotype; /** * Class representing phenotype in the model. @@ -9,7 +9,7 @@ import lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias; * @author Piotr Gawron * */ -public class Phenotype extends Species<PhenotypeAlias> { +public class CellDesignerPhenotype extends CellDesignerSpecies<Phenotype> { /** * @@ -23,20 +23,20 @@ public class Phenotype extends Species<PhenotypeAlias> { * @param species * original species used for data initialization */ - public Phenotype(Species species) { + public CellDesignerPhenotype(CellDesignerSpecies<?> species) { super(species); } /** * Default constructor. */ - public Phenotype() { + public CellDesignerPhenotype() { } @Override - public Phenotype copy() { - if (this.getClass() == Phenotype.class) { - return new Phenotype(this); + public CellDesignerPhenotype copy() { + if (this.getClass() == CellDesignerPhenotype.class) { + return new CellDesignerPhenotype(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } @@ -48,8 +48,8 @@ public class Phenotype extends Species<PhenotypeAlias> { } @Override - public PhenotypeAlias createAlias(String aliasId) { - PhenotypeAlias result = new PhenotypeAlias(aliasId); + public Phenotype createAlias(String aliasId) { + Phenotype result = new Phenotype(aliasId); super.setAliasFields(result); return result; } 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 new file mode 100644 index 0000000000..e49f8cbb7f --- /dev/null +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerPhenotypeComparator.java @@ -0,0 +1,91 @@ +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/Protein.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerProtein.java similarity index 61% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Protein.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerProtein.java index afecc5eb38..4e94d37da3 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Protein.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerProtein.java @@ -6,7 +6,8 @@ import java.util.List; import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue; +import lcsb.mapviewer.model.map.species.Protein; /** * Class representing protein in the model. @@ -14,7 +15,7 @@ import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; * @author Piotr Gawron * */ -public class Protein<T extends ProteinAlias> extends Species<T> { +public class CellDesignerProtein<T extends Protein> extends CellDesignerSpecies<T> { /** * */ @@ -23,7 +24,7 @@ public class Protein<T extends ProteinAlias> extends Species<T> { /** * Default class logger. */ - private static Logger logger = Logger.getLogger(Protein.class.getName()); + private static Logger logger = Logger.getLogger(CellDesignerProtein.class.getName()); /** * State of the protein. @@ -33,7 +34,7 @@ public class Protein<T extends ProteinAlias> extends Species<T> { /** * List of modifications for the Protein. */ - private List<ModificationResidue> modificationResidues = new ArrayList<ModificationResidue>(); + private List<CellDesignerModificationResidue> modificationResidues = new ArrayList<CellDesignerModificationResidue>(); /** * Constructor that initializes protein with the data passed in the argument. @@ -41,28 +42,28 @@ public class Protein<T extends ProteinAlias> extends Species<T> { * @param species * original species used for data initialization */ - public Protein(Species<?> species) { + public CellDesignerProtein(CellDesignerSpecies<?> species) { super(species); - if (species instanceof Protein) { - Protein<?> protein = (Protein) species; + if (species instanceof CellDesignerProtein) { + CellDesignerProtein<?> protein = (CellDesignerProtein<?>) species; if (protein.getStructuralState() != null) { setStructuralState(new String(protein.getStructuralState())); } - for (ModificationResidue mr : protein.getModificationResidues()) { - addModificationResidue(new ModificationResidue(mr)); + for (CellDesignerModificationResidue mr : protein.getModificationResidues()) { + addModificationResidue(new CellDesignerModificationResidue(mr)); } } } @Override - public void update(Species<?> species) { + public void update(CellDesignerSpecies<?> species) { super.update(species); - if (species instanceof Protein) { - Protein<?> protein = (Protein) species; + if (species instanceof CellDesignerProtein) { + CellDesignerProtein<?> protein = (CellDesignerProtein<?>) species; if (getStructuralState() == null || getStructuralState().equals("")) { setStructuralState(protein.getStructuralState()); } - for (ModificationResidue mr : protein.getModificationResidues()) { + for (CellDesignerModificationResidue mr : protein.getModificationResidues()) { addModificationResidue(mr); } } @@ -71,14 +72,14 @@ public class Protein<T extends ProteinAlias> extends Species<T> { /** * Default constructor. */ - public Protein() { + public CellDesignerProtein() { super(); } @Override - public Protein copy() { - if (this.getClass().equals(Protein.class)) { - return new Protein(this); + public CellDesignerProtein<T> copy() { + if (this.getClass().equals(CellDesignerProtein.class)) { + return new CellDesignerProtein<T>(this); } else { throw new NotImplementedException("Copy method for " + this.getClass() + " class not implemented"); } @@ -95,8 +96,8 @@ public class Protein<T extends ProteinAlias> extends Species<T> { * @param modificationResidue * modification to add */ - public void addModificationResidue(ModificationResidue modificationResidue) { - for (ModificationResidue mr : modificationResidues) { + public void addModificationResidue(CellDesignerModificationResidue modificationResidue) { + for (CellDesignerModificationResidue mr : modificationResidues) { if (mr.getIdModificationResidue().equals(modificationResidue.getIdModificationResidue())) { mr.update(modificationResidue); return; @@ -130,7 +131,7 @@ public class Protein<T extends ProteinAlias> extends Species<T> { * @return the modificationResidues * @see #modificationResidues */ - public List<ModificationResidue> getModificationResidues() { + public List<CellDesignerModificationResidue> getModificationResidues() { return modificationResidues; } @@ -139,7 +140,7 @@ public class Protein<T extends ProteinAlias> extends Species<T> { * the modificationResidues to set * @see #modificationResidues */ - public void setModificationResidues(List<ModificationResidue> modificationResidues) { + public void setModificationResidues(List<CellDesignerModificationResidue> modificationResidues) { this.modificationResidues = modificationResidues; } @@ -152,7 +153,7 @@ public class Protein<T extends ProteinAlias> extends Species<T> { protected void setAliasFields(T result) { super.setAliasFields(result); result.setStructuralState(structuralState); - for (ModificationResidue mr : modificationResidues) { + for (CellDesignerModificationResidue mr : modificationResidues) { result.addModificationResidue(mr.createModificationResidueAlias()); } } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/ProteinComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerProteinComparator.java similarity index 70% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/ProteinComparator.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerProteinComparator.java index 0c3f33d7f0..681761fd54 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/ProteinComparator.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerProteinComparator.java @@ -10,19 +10,20 @@ 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 Protein + * @see CellDesignerProtein */ -public class ProteinComparator implements Comparator<Protein<?>> { +public class CellDesignerProteinComparator implements Comparator<CellDesignerProtein<?>> { /** * Default class logger. */ - private Logger logger = Logger.getLogger(ProteinComparator.class); + private Logger logger = Logger.getLogger(CellDesignerProteinComparator.class); /** * Epsilon value used for comparison of doubles. @@ -35,19 +36,19 @@ public class ProteinComparator implements Comparator<Protein<?>> { * @param epsilon * {@link #epsilon} */ - public ProteinComparator(double epsilon) { + public CellDesignerProteinComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public ProteinComparator() { + public CellDesignerProteinComparator() { this(Configuration.EPSILON); } @Override - public int compare(Protein arg0, Protein arg1) { + public int compare(CellDesignerProtein<?> arg0, CellDesignerProtein<?> arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -66,9 +67,9 @@ public class ProteinComparator implements Comparator<Protein<?>> { } /** - * This method compares only the fields that are defined in {@link Protein} - * class in inheritence tree. It also calls the {@link SpeciesComparator} for - * the super class ( {@link Species}). + * 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 @@ -77,8 +78,8 @@ public class ProteinComparator implements Comparator<Protein<?>> { * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(Protein<?> arg0, Protein<?> arg1) { - SpeciesComparator speciesComparator = new SpeciesComparator(epsilon); + private int internalCompare(CellDesignerProtein<?> arg0, CellDesignerProtein<?> arg1) { + CellDesignerSpeciesComparator speciesComparator = new CellDesignerSpeciesComparator(epsilon); int result = speciesComparator.internalCompare(arg0, arg1); if (result != 0) { return result; @@ -101,11 +102,11 @@ public class ProteinComparator implements Comparator<Protein<?>> { Set<String> set1 = new HashSet<String>(); Set<String> set2 = new HashSet<String>(); - for (ModificationResidue region : arg0.getModificationResidues()) { + for (CellDesignerModificationResidue region : arg0.getModificationResidues()) { set1.add(region.toString()); } - for (ModificationResidue region : arg1.getModificationResidues()) { + for (CellDesignerModificationResidue region : arg1.getModificationResidues()) { set2.add(region.toString()); } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/ReceptorProtein.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerReceptorProtein.java similarity index 52% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/ReceptorProtein.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerReceptorProtein.java index a3cb1b0446..8473383ecd 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/ReceptorProtein.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerReceptorProtein.java @@ -1,7 +1,7 @@ package lcsb.mapviewer.converter.model.celldesigner.structure; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.ReceptorProteinAlias; +import lcsb.mapviewer.model.map.species.ReceptorProtein; /** * Receptor protein. @@ -9,7 +9,7 @@ import lcsb.mapviewer.model.map.layout.alias.ReceptorProteinAlias; * @author Piotr Gawron * */ -public class ReceptorProtein extends Protein<ReceptorProteinAlias> { +public class CellDesignerReceptorProtein extends CellDesignerProtein<ReceptorProtein> { /** * @@ -19,7 +19,7 @@ public class ReceptorProtein extends Protein<ReceptorProteinAlias> { /** * Default constructor. */ - public ReceptorProtein() { + public CellDesignerReceptorProtein() { super(); } @@ -29,22 +29,22 @@ public class ReceptorProtein extends Protein<ReceptorProteinAlias> { * @param species * original species */ - public ReceptorProtein(Species species) { + public CellDesignerReceptorProtein(CellDesignerSpecies<?> species) { super(species); } @Override - public ReceptorProtein copy() { - if (this.getClass().equals(ReceptorProtein.class)) { - return new ReceptorProtein(this); + public CellDesignerReceptorProtein copy() { + if (this.getClass().equals(CellDesignerReceptorProtein.class)) { + return new CellDesignerReceptorProtein(this); } else { throw new NotImplementedException("Copy method for " + this.getClass() + " class not implemented"); } } @Override - public ReceptorProteinAlias createAlias(String aliasId) { - ReceptorProteinAlias result = new ReceptorProteinAlias(aliasId); + public ReceptorProtein createAlias(String aliasId) { + ReceptorProtein result = new ReceptorProtein(aliasId); super.setAliasFields(result); return result; } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Rna.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRna.java similarity index 53% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Rna.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRna.java index 95ad0b3e7f..4a59e2bc09 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Rna.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRna.java @@ -6,7 +6,7 @@ import java.util.List; import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; +import lcsb.mapviewer.model.map.species.Rna; /** * Class representing rna in the model. @@ -14,7 +14,7 @@ import lcsb.mapviewer.model.map.layout.alias.RnaAlias; * @author Piotr Gawron * */ -public class Rna extends Species<RnaAlias> { +public class CellDesignerRna extends CellDesignerSpecies<Rna> { /** * @@ -25,12 +25,12 @@ public class Rna extends Species<RnaAlias> { * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(Rna.class.getName()); + private static Logger logger = Logger.getLogger(CellDesignerRna.class.getName()); /** * List of rna regions (some rna sequences) in this object. */ - private List<RnaRegion> regions = new ArrayList<>(); + private List<CellDesignerRnaRegion> regions = new ArrayList<>(); /** * Constructor that initializes rna with the data passed in the argument. @@ -38,12 +38,12 @@ public class Rna extends Species<RnaAlias> { * @param species * original species used for data initialization */ - public Rna(Species species) { + public CellDesignerRna(CellDesignerSpecies<?> species) { super(species); - if (species instanceof Rna) { - Rna rna = (Rna) species; - for (RnaRegion region : rna.getRegions()) { - addRegion(new RnaRegion(region)); + if (species instanceof CellDesignerRna) { + CellDesignerRna rna = (CellDesignerRna) species; + for (CellDesignerRnaRegion region : rna.getRegions()) { + addRegion(new CellDesignerRnaRegion(region)); } } } @@ -51,29 +51,29 @@ public class Rna extends Species<RnaAlias> { /** * Default constructor. */ - public Rna() { + public CellDesignerRna() { super(); } @Override - public Rna copy() { - if (this.getClass() == Rna.class) { - return new Rna(this); + public CellDesignerRna copy() { + if (this.getClass() == CellDesignerRna.class) { + return new CellDesignerRna(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } } @Override - public void update(Species species) { + public void update(CellDesignerSpecies<?> species) { super.update(species); - if (species instanceof Rna) { - Rna rna = (Rna) species; - for (RnaRegion mr : getRegions()) { + if (species instanceof CellDesignerRna) { + CellDesignerRna rna = (CellDesignerRna) species; + for (CellDesignerRnaRegion mr : getRegions()) { mr.setState(null); } - for (RnaRegion region : rna.getRegions()) { + for (CellDesignerRnaRegion region : rna.getRegions()) { updateRegion(region); } } @@ -85,14 +85,14 @@ public class Rna extends Species<RnaAlias> { * @param param * region that with the data to update */ - private void updateRegion(RnaRegion param) { - for (RnaRegion region : regions) { + private void updateRegion(CellDesignerRnaRegion param) { + for (CellDesignerRnaRegion region : regions) { if (region.getIdRnaRegion().equals(param.getIdRnaRegion())) { region.update(param); return; } } - addRegion(new RnaRegion(param)); + addRegion(new CellDesignerRnaRegion(param)); } @Override @@ -102,13 +102,13 @@ public class Rna extends Species<RnaAlias> { /** * Adds region. If the region with given id exists then the data of this - * region is copied to the one that is already in the {@link Rna}. + * region is copied to the one that is already in the {@link CellDesignerRna}. * * @param rnaRegion * region to add */ - public void addRegion(RnaRegion rnaRegion) { - for (RnaRegion region2 : regions) { + public void addRegion(CellDesignerRnaRegion rnaRegion) { + for (CellDesignerRnaRegion region2 : regions) { if (region2.getIdRnaRegion().equals(rnaRegion.getIdRnaRegion())) { region2.update(rnaRegion); return; @@ -124,7 +124,7 @@ public class Rna extends Species<RnaAlias> { * @return the regions * @see #regions */ - public List<RnaRegion> getRegions() { + public List<CellDesignerRnaRegion> getRegions() { return regions; } @@ -133,15 +133,15 @@ public class Rna extends Species<RnaAlias> { * the regions to set * @see #regions */ - public void setRegions(List<RnaRegion> regions) { + public void setRegions(List<CellDesignerRnaRegion> regions) { this.regions = regions; } @Override - public RnaAlias createAlias(String aliasId) { - RnaAlias result = new RnaAlias(aliasId); + public Rna createAlias(String aliasId) { + Rna result = new Rna(aliasId); super.setAliasFields(result); - for (RnaRegion region : regions) { + for (CellDesignerRnaRegion region : regions) { result.addRegion(region.createRnaRegionAlias()); } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/RnaComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRnaComparator.java similarity index 68% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/RnaComparator.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRnaComparator.java index d1982ef413..52b674dd77 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/RnaComparator.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRnaComparator.java @@ -13,9 +13,9 @@ import lcsb.mapviewer.common.exception.NotImplementedException; * * @author Piotr Gawron * - * @see Rna + * @see CellDesignerRna */ -public class RnaComparator implements Comparator<Rna> { +public class CellDesignerRnaComparator implements Comparator<CellDesignerRna> { /** * Epsilon value used for comparison of doubles. @@ -28,19 +28,19 @@ public class RnaComparator implements Comparator<Rna> { * @param epsilon * {@link #epsilon} */ - public RnaComparator(double epsilon) { + public CellDesignerRnaComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public RnaComparator() { + public CellDesignerRnaComparator() { this(Configuration.EPSILON); } @Override - public int compare(Rna arg0, Rna arg1) { + public int compare(CellDesignerRna arg0, CellDesignerRna arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -52,7 +52,7 @@ public class RnaComparator implements Comparator<Rna> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(Rna.class)) { + if (arg0.getClass().equals(CellDesignerRna.class)) { return internalCompare(arg0, arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); @@ -63,9 +63,9 @@ public class RnaComparator implements Comparator<Rna> { } /** - * This method compares only the fields that are defined in {@link Rna} class - * in inheritence tree. It also calls the {@link SpeciesComparator} for the - * super class ({@link Species}). + * 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 @@ -74,8 +74,8 @@ public class RnaComparator implements Comparator<Rna> { * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(Rna arg0, Rna arg1) { - SpeciesComparator speciesComparator = new SpeciesComparator(epsilon); + private int internalCompare(CellDesignerRna arg0, CellDesignerRna arg1) { + CellDesignerSpeciesComparator speciesComparator = new CellDesignerSpeciesComparator(epsilon); int result = speciesComparator.internalCompare(arg0, arg1); if (result != 0) { return result; @@ -86,11 +86,11 @@ public class RnaComparator implements Comparator<Rna> { Set<String> set1 = new HashSet<String>(); Set<String> set2 = new HashSet<String>(); - for (RnaRegion region : arg0.getRegions()) { + for (CellDesignerRnaRegion region : arg0.getRegions()) { set1.add(region.toString()); } - for (RnaRegion region : arg1.getRegions()) { + for (CellDesignerRnaRegion region : arg1.getRegions()) { set2.add(region.toString()); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/RnaRegionAlias.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRnaRegion.java similarity index 69% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/RnaRegionAlias.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRnaRegion.java index ee5053a324..b67c6ec919 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/RnaRegionAlias.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRnaRegion.java @@ -1,33 +1,22 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.converter.model.celldesigner.structure; import java.io.Serializable; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; - import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.InvalidArgumentException; +import lcsb.mapviewer.model.map.species.field.ModificationState; +import lcsb.mapviewer.model.map.species.field.RnaRegion; /** * This structure contains information about rna region (rna fragment of * interest) for a specific - * {@link lcsb.mapviewer.converter.model.celldesigner.structure.Rna Rna}. + * {@link lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerRna Rna}. * * @author Piotr Gawron * */ -@Entity -@Table(name = "rna_region_table_new") -@org.hibernate.annotations.GenericGenerator(name = "test-increment-strategy", strategy = "increment") -public class RnaRegionAlias implements Serializable { +public class CellDesignerRnaRegion implements Serializable { /** * @@ -43,22 +32,14 @@ public class RnaRegionAlias implements Serializable { * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(RnaRegionAlias.class.getName()); - - /** - * Unique identifier in the database. - */ - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "iddb", unique = true, nullable = false) - private int id; + private static Logger logger = Logger.getLogger(CellDesignerRnaRegion.class.getName()); /** * Identifier of the region. Unique in the * {@link lcsb.mapviewer.model.map.model.Model}. */ - @Column(name = "idrnaregion") private String idRnaRegion = ""; + /** * Type of the region in the rna. There are three possible values: * <ul> @@ -67,8 +48,6 @@ public class RnaRegionAlias implements Serializable { * <li>Modification site.</li> * </ul> */ - - @Column(name = "type") private String type = ""; /** @@ -76,38 +55,32 @@ public class RnaRegionAlias implements Serializable { * * @see ModificationState */ - @Column(name = "state") private ModificationState state = null; /** * Name of the region. */ - @Column(name = "name") private String name = ""; /** * Size of the region in the graphic representation. */ - @Column(name = "size") private double size = DEFAULT_SIZE; /** * Position on the species in graphic representation. */ - @Column(name = "pos") private Double pos; /** * Defines a species where the region belongs to. */ - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "idSpeciesDb") - private RnaAlias species; + private CellDesignerRna species; /** * Default constructor. */ - public RnaRegionAlias() { + public CellDesignerRnaRegion() { } @@ -115,10 +88,9 @@ public class RnaRegionAlias implements Serializable { * Creates object with the data taken from paramter region. * * @param mr - * original {@link RnaRegionAlias} + * original {@link CellDesignerRnaRegion} */ - public RnaRegionAlias(RnaRegionAlias mr) { - this.id = mr.id; + public CellDesignerRnaRegion(CellDesignerRnaRegion mr) { this.idRnaRegion = mr.idRnaRegion; this.size = mr.size; setPos(mr.getPos()); @@ -162,9 +134,9 @@ public class RnaRegionAlias implements Serializable { * region. * * @param mr - * {@link RnaRegionAlias} from which data will be used to update + * {@link CellDesignerRnaRegion} from which data will be used to update */ - public void update(RnaRegionAlias mr) { + public void update(CellDesignerRnaRegion mr) { if (this.idRnaRegion != null && !this.idRnaRegion.equals("") && !this.idRnaRegion.equals(mr.getIdRnaRegion())) { throw new InvalidArgumentException("Cannot update from mr with different id"); } @@ -188,23 +160,6 @@ public class RnaRegionAlias implements Serializable { } - /** - * @return the idRnaRegion - * @see #idRnaRegion - */ - public int getId() { - return id; - } - - /** - * @param id - * the idRnaRegion to set - * @see #id - */ - public void setId(int id) { - this.id = id; - } - /** * @return the id * @see #id @@ -311,7 +266,7 @@ public class RnaRegionAlias implements Serializable { * @return the species * @see #species */ - public RnaAlias getSpecies() { + public CellDesignerRna getSpecies() { return species; } @@ -320,8 +275,19 @@ public class RnaRegionAlias implements Serializable { * the species to set * @see #species */ - public void setSpecies(RnaAlias species) { + public void setSpecies(CellDesignerRna species) { this.species = species; } + public RnaRegion createRnaRegionAlias() { + RnaRegion result = new RnaRegion(); + result.setIdRnaRegion(this.idRnaRegion); + result.setSize(this.size); + result.setPos(this.getPos()); + result.setType(this.type); + result.setState(this.state); + result.setName(this.name); + return result; + } + } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/SimpleMolecule.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSimpleMolecule.java similarity index 56% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/SimpleMolecule.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSimpleMolecule.java index 75f255eaa8..45521fc3ab 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/SimpleMolecule.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSimpleMolecule.java @@ -3,7 +3,7 @@ package lcsb.mapviewer.converter.model.celldesigner.structure; import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; +import lcsb.mapviewer.model.map.species.SimpleMolecule; /** * Class representing molecule in the model. @@ -11,7 +11,7 @@ import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; * @author Piotr Gawron * */ -public class SimpleMolecule extends Chemical<SimpleMoleculeAlias> { +public class CellDesignerSimpleMolecule extends CellDesignerChemical<SimpleMolecule> { /** * @@ -22,7 +22,7 @@ public class SimpleMolecule extends Chemical<SimpleMoleculeAlias> { * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(SimpleMolecule.class.getName()); + private static Logger logger = Logger.getLogger(CellDesignerSimpleMolecule.class.getName()); /** * Constructor that initializes molecule with the data passed in the argument. @@ -30,20 +30,20 @@ public class SimpleMolecule extends Chemical<SimpleMoleculeAlias> { * @param species * original species used for data initialization */ - public SimpleMolecule(Species<?> species) { + public CellDesignerSimpleMolecule(CellDesignerSpecies<?> species) { super(species); } /** * Default constructor. */ - public SimpleMolecule() { + public CellDesignerSimpleMolecule() { } @Override - public SimpleMolecule copy() { - if (this.getClass() == SimpleMolecule.class) { - return new SimpleMolecule(this); + public CellDesignerSimpleMolecule copy() { + if (this.getClass() == CellDesignerSimpleMolecule.class) { + return new CellDesignerSimpleMolecule(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } @@ -55,8 +55,8 @@ public class SimpleMolecule extends Chemical<SimpleMoleculeAlias> { } @Override - public SimpleMoleculeAlias createAlias(String aliasId) { - SimpleMoleculeAlias result = new SimpleMoleculeAlias(aliasId); + public SimpleMolecule createAlias(String aliasId) { + SimpleMolecule result = new SimpleMolecule(aliasId); super.setAliasFields(result); return result; } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/SimpleMoleculeComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSimpleMoleculeComparator.java similarity index 72% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/SimpleMoleculeComparator.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSimpleMoleculeComparator.java index bb24f976d6..c6e47e7eee 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/SimpleMoleculeComparator.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSimpleMoleculeComparator.java @@ -13,13 +13,13 @@ import lcsb.mapviewer.common.exception.NotImplementedException; * * @author Piotr Gawron * - * @see SimpleMolecule + * @see CellDesignerSimpleMolecule */ -public class SimpleMoleculeComparator implements Comparator<SimpleMolecule> { +public class CellDesignerSimpleMoleculeComparator implements Comparator<CellDesignerSimpleMolecule> { /** * Default class logger. */ - private Logger logger = Logger.getLogger(SimpleMoleculeComparator.class); + private Logger logger = Logger.getLogger(CellDesignerSimpleMoleculeComparator.class); /** * Epsilon value used for comparison of doubles. @@ -32,19 +32,19 @@ public class SimpleMoleculeComparator implements Comparator<SimpleMolecule> { * @param epsilon * {@link #epsilon} */ - public SimpleMoleculeComparator(double epsilon) { + public CellDesignerSimpleMoleculeComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public SimpleMoleculeComparator() { + public CellDesignerSimpleMoleculeComparator() { this(Configuration.EPSILON); } @Override - public int compare(SimpleMolecule arg0, SimpleMolecule arg1) { + public int compare(CellDesignerSimpleMolecule arg0, CellDesignerSimpleMolecule arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -56,7 +56,7 @@ public class SimpleMoleculeComparator implements Comparator<SimpleMolecule> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(SimpleMolecule.class)) { + if (arg0.getClass().equals(CellDesignerSimpleMolecule.class)) { return internalCompare(arg0, arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); @@ -68,8 +68,8 @@ public class SimpleMoleculeComparator implements Comparator<SimpleMolecule> { /** * This method compares only the fields that are defined in - * {@link SimpleMolecule} class in inheritence tree. It also calls the - * {@link SpeciesComparator} for the super class ( {@link Species}). + * {@link CellDesignerSimpleMolecule} class in inheritence tree. It also calls the + * {@link CellDesignerSpeciesComparator} for the super class ( {@link CellDesignerSpecies}). * * @param arg0 * first object to compare @@ -78,8 +78,8 @@ public class SimpleMoleculeComparator implements Comparator<SimpleMolecule> { * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(SimpleMolecule arg0, SimpleMolecule arg1) { - SpeciesComparator speciesComparator = new SpeciesComparator(epsilon); + private int internalCompare(CellDesignerSimpleMolecule arg0, CellDesignerSimpleMolecule arg1) { + CellDesignerSpeciesComparator speciesComparator = new CellDesignerSpeciesComparator(epsilon); int result = speciesComparator.internalCompare(arg0, arg1); if (result != 0) { return result; diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Species.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSpecies.java similarity index 91% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Species.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSpecies.java index 0066fb92cc..f776c8f417 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Species.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSpecies.java @@ -5,8 +5,8 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.PositionToCompartment; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Species; +import lcsb.mapviewer.model.map.species.field.PositionToCompartment; /** * Generic species of the map. @@ -14,7 +14,7 @@ import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; * @author Piotr Gawron * */ -public class Species<T extends SpeciesAlias> extends Element<T> { +public class CellDesignerSpecies<T extends Species> extends CellDesignerElement<T> { /** * */ @@ -23,7 +23,7 @@ public class Species<T extends SpeciesAlias> extends Element<T> { /** * Default class logger. */ - private static Logger logger = Logger.getLogger(Species.class.getName()); + private static Logger logger = Logger.getLogger(CellDesignerSpecies.class.getName()); /** * Identifier of the species. It must be unique within the model. @@ -82,7 +82,7 @@ public class Species<T extends SpeciesAlias> extends Element<T> { * @param species * parent species from which we want to copy data */ - public Species(Species species) { + public CellDesignerSpecies(CellDesignerSpecies<?> species) { super(species); this.hypothetical = species.hypothetical; this.idSpecies = species.idSpecies; @@ -97,7 +97,7 @@ public class Species<T extends SpeciesAlias> extends Element<T> { /** * Default constructor. */ - public Species() { + public CellDesignerSpecies() { super(); idSpecies = ""; } @@ -108,14 +108,14 @@ public class Species<T extends SpeciesAlias> extends Element<T> { * @param id * species identifier */ - public Species(String id) { + public CellDesignerSpecies(String id) { this(); this.idSpecies = id; } @Override - public Species copy() { - Species result = new Species(this); + public CellDesignerSpecies<T> copy() { + CellDesignerSpecies<T> result = new CellDesignerSpecies<T>(this); result.idSpecies = idSpecies; result.setNotes(getNotes()); @@ -139,7 +139,7 @@ public class Species<T extends SpeciesAlias> extends Element<T> { * @param species * object from which we are updating information */ - public void update(Species<?> species) { + public void update(CellDesignerSpecies<?> species) { if (getName() == null || getName().equals("")) { setName(species.getName()); } else if (!getName().trim().equals(species.getName().trim())) { 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 new file mode 100644 index 0000000000..2604e8c88f --- /dev/null +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerSpeciesComparator.java @@ -0,0 +1,231 @@ +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/TruncatedProtein.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerTruncatedProtein.java similarity index 52% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/TruncatedProtein.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerTruncatedProtein.java index c05d481c5b..c26379a941 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/TruncatedProtein.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerTruncatedProtein.java @@ -1,7 +1,7 @@ package lcsb.mapviewer.converter.model.celldesigner.structure; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.TruncatedProteinAlias; +import lcsb.mapviewer.model.map.species.TruncatedProtein; /** * Truncated protein. @@ -9,7 +9,7 @@ import lcsb.mapviewer.model.map.layout.alias.TruncatedProteinAlias; * @author Piotr Gawron * */ -public class TruncatedProtein extends Protein { +public class CellDesignerTruncatedProtein extends CellDesignerProtein<TruncatedProtein> { /** * @@ -19,7 +19,7 @@ public class TruncatedProtein extends Protein { /** * Default constructor. */ - public TruncatedProtein() { + public CellDesignerTruncatedProtein() { super(); } @@ -29,22 +29,22 @@ public class TruncatedProtein extends Protein { * @param species * original species */ - public TruncatedProtein(Species species) { + public CellDesignerTruncatedProtein(CellDesignerSpecies<?> species) { super(species); } @Override - public TruncatedProtein copy() { - if (this.getClass().equals(TruncatedProtein.class)) { - return new TruncatedProtein(this); + public CellDesignerTruncatedProtein copy() { + if (this.getClass().equals(CellDesignerTruncatedProtein.class)) { + return new CellDesignerTruncatedProtein(this); } else { throw new NotImplementedException("Copy method for " + this.getClass() + " class not implemented"); } } @Override - public TruncatedProteinAlias createAlias(String aliasId) { - TruncatedProteinAlias result = new TruncatedProteinAlias(aliasId); + public TruncatedProtein createAlias(String aliasId) { + TruncatedProtein result = new TruncatedProtein(aliasId); super.setAliasFields(result); return result; diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Unknown.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerUnknown.java similarity index 61% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Unknown.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerUnknown.java index 4fc711dffd..6e66e20ef8 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/Unknown.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerUnknown.java @@ -1,7 +1,7 @@ package lcsb.mapviewer.converter.model.celldesigner.structure; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.UnknownAlias; +import lcsb.mapviewer.model.map.species.Unknown; /** * Class representing unknown element in the model. @@ -9,7 +9,7 @@ import lcsb.mapviewer.model.map.layout.alias.UnknownAlias; * @author Piotr Gawron * */ -public class Unknown extends Species<UnknownAlias> { +public class CellDesignerUnknown extends CellDesignerSpecies<Unknown> { /** * */ @@ -21,20 +21,20 @@ public class Unknown extends Species<UnknownAlias> { * @param species * original species used for data initialization */ - public Unknown(Species species) { + public CellDesignerUnknown(CellDesignerSpecies<?> species) { super(species); } /** * Default constructor. */ - public Unknown() { + public CellDesignerUnknown() { } @Override - public Unknown copy() { - if (this.getClass() == Unknown.class) { - return new Unknown(this); + public CellDesignerUnknown copy() { + if (this.getClass() == CellDesignerUnknown.class) { + return new CellDesignerUnknown(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } @@ -46,8 +46,8 @@ public class Unknown extends Species<UnknownAlias> { } @Override - public UnknownAlias createAlias(String aliasId) { - UnknownAlias result = new UnknownAlias(aliasId); + public Unknown createAlias(String aliasId) { + Unknown result = new Unknown(aliasId); super.setAliasFields(result); return result; } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/UnknownComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerUnknownComparator.java similarity index 64% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/UnknownComparator.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerUnknownComparator.java index 2e064d10ee..c80d46491c 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/UnknownComparator.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerUnknownComparator.java @@ -10,9 +10,9 @@ import lcsb.mapviewer.common.exception.NotImplementedException; * * @author Piotr Gawron * - * @see Unknown + * @see CellDesignerUnknown */ -public class UnknownComparator implements Comparator<Unknown> { +public class CellDesignerUnknownComparator implements Comparator<CellDesignerUnknown> { /** * Epsilon value used for comparison of doubles. */ @@ -24,19 +24,19 @@ public class UnknownComparator implements Comparator<Unknown> { * @param epsilon * {@link #epsilon} */ - public UnknownComparator(double epsilon) { + public CellDesignerUnknownComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public UnknownComparator() { + public CellDesignerUnknownComparator() { this(Configuration.EPSILON); } @Override - public int compare(Unknown arg0, Unknown arg1) { + public int compare(CellDesignerUnknown arg0, CellDesignerUnknown arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -48,7 +48,7 @@ public class UnknownComparator implements Comparator<Unknown> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(Unknown.class)) { + if (arg0.getClass().equals(CellDesignerUnknown.class)) { return internalCompare(arg0, arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); @@ -59,9 +59,9 @@ public class UnknownComparator implements Comparator<Unknown> { } /** - * This method compares only the fields that are defined in {@link Unknown} - * class in inheritence tree. It also calls the {@link SpeciesComparator} for - * the super class ({@link Species}). + * 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 @@ -70,8 +70,8 @@ public class UnknownComparator implements Comparator<Unknown> { * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(Unknown arg0, Unknown arg1) { - SpeciesComparator speciesComparator = new SpeciesComparator(epsilon); + private int internalCompare(CellDesignerUnknown arg0, CellDesignerUnknown arg1) { + CellDesignerSpeciesComparator speciesComparator = new CellDesignerSpeciesComparator(epsilon); int result = speciesComparator.internalCompare(arg0, arg1); if (result != 0) { return result; diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/SpeciesComparator.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/SpeciesComparator.java deleted file mode 100644 index 486f9d6881..0000000000 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/SpeciesComparator.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 Species - */ -public class SpeciesComparator implements Comparator<Species> { - /** - * Default class logger. - */ - private static Logger logger = Logger.getLogger(SpeciesComparator.class); - - /** - * Comparator for {@link AntisenseRna}. - */ - private AntisenseRnaComparator antisenseRnaComparator; - - /** - * Comparator for {@link ComplexSpecies}. - */ - private ComplexSpeciesComparator complexSpeciesComparator; - - /** - * Comparator for {@link Degraded}. - */ - private DegradedComparator degradedComparator; - - /** - * Comparator for {@link Drug}. - */ - private DrugComparator drugComparator; - - /** - * Comparator for {@link Gene}. - */ - private GeneComparator geneComparator; - - /** - * Comparator for {@link Ion}. - */ - private IonComparator ionComparator; - - /** - * Comparator for {@link Phenotype}. - */ - private PhenotypeComparator phenotypeComparator; - - /** - * Comparator for {@link Protein}. - */ - private ProteinComparator proteinComparator; - - /** - * Comparator for {@link Rna}. - */ - private RnaComparator rnaComparator; - - /** - * Comparator for {@link SimpleMolecule}. - */ - private SimpleMoleculeComparator simpleMoleculeComparator; - - /** - * Comparator for {@link Unknown}. - */ - private UnknownComparator unknownComparator; - - /** - * Epsilon value used for comparison of doubles. - */ - private double epsilon; - - /** - * Constructor that requires {@link #epsilon} parameter. - * - * @param epsilon - * {@link #epsilon} - */ - public SpeciesComparator(double epsilon) { - this.epsilon = epsilon; - antisenseRnaComparator = new AntisenseRnaComparator(epsilon); - complexSpeciesComparator = new ComplexSpeciesComparator(epsilon); - degradedComparator = new DegradedComparator(epsilon); - drugComparator = new DrugComparator(epsilon); - geneComparator = new GeneComparator(epsilon); - ionComparator = new IonComparator(epsilon); - phenotypeComparator = new PhenotypeComparator(epsilon); - proteinComparator = new ProteinComparator(epsilon); - rnaComparator = new RnaComparator(epsilon); - simpleMoleculeComparator = new SimpleMoleculeComparator(epsilon); - unknownComparator = new UnknownComparator(epsilon); - - } - - /** - * Default constructor. - */ - public SpeciesComparator() { - this(Configuration.EPSILON); - } - - @Override - public int compare(Species arg0, Species 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 AntisenseRna) { - return antisenseRnaComparator.compare((AntisenseRna) arg0, (AntisenseRna) arg1); - } else if (arg0 instanceof ComplexSpecies) { - return complexSpeciesComparator.compare((ComplexSpecies) arg0, (ComplexSpecies) arg1); - } else if (arg0 instanceof Degraded) { - return degradedComparator.compare((Degraded) arg0, (Degraded) arg1); - } else if (arg0 instanceof Drug) { - return drugComparator.compare((Drug) arg0, (Drug) arg1); - } else if (arg0 instanceof Gene) { - return geneComparator.compare((Gene) arg0, (Gene) arg1); - } else if (arg0 instanceof Ion) { - return ionComparator.compare((Ion) arg0, (Ion) arg1); - } else if (arg0 instanceof Phenotype) { - return phenotypeComparator.compare((Phenotype) arg0, (Phenotype) arg1); - } else if (arg0 instanceof Protein) { - return proteinComparator.compare((Protein) arg0, (Protein) arg1); - } else if (arg0 instanceof Rna) { - return rnaComparator.compare((Rna) arg0, (Rna) arg1); - } else if (arg0 instanceof SimpleMolecule) { - return simpleMoleculeComparator.compare((SimpleMolecule) arg0, (SimpleMolecule) arg1); - } else if (arg0 instanceof Unknown) { - return unknownComparator.compare((Unknown) arg0, (Unknown) 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 Species} - * class in inheritence tree. It also calls the {@link ElementComparator} for - * the super class ({@link lcsb.mapviewer.db.model.map.Element 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(Species arg0, Species arg1) { - ElementComparator elementComparator = new ElementComparator(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/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ModificationResidueAlias.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerModificationResidue.java similarity index 67% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ModificationResidueAlias.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerModificationResidue.java index 475464ccce..abd1d04166 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ModificationResidueAlias.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerModificationResidue.java @@ -1,21 +1,14 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.converter.model.celldesigner.structure.fields; import java.io.Serializable; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; - import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; +import lcsb.mapviewer.model.map.species.field.ModificationState; /** * This class represent modification residue in protein and gene. However, it is @@ -25,72 +18,59 @@ import lcsb.mapviewer.common.exception.NotImplementedException; * @author Piotr Gawron * */ -@Entity -@Table(name = "modification_residue_table_new") -@org.hibernate.annotations.GenericGenerator(name = "test-increment-strategy", strategy = "increment") -public class ModificationResidueAlias implements Serializable { +public class CellDesignerModificationResidue implements Serializable { /** * */ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(ModificationResidueAlias.class.getName()); - - /** - * Unique identifier in the database. - */ - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "iddb", unique = true, nullable = false) - private int id; + private static Logger logger = Logger.getLogger(CellDesignerModificationResidue.class.getName()); /** * Identifier of the modification. Must be unique in single map model. */ - private String idModificationResidue = ""; + private String idModificationResidue = ""; /** * Name of the modification. */ - private String name = ""; + private String name = ""; /** * Some strange param in CellDesigner. No idea what is it for. */ - private String side = ""; + private String side = ""; /** * State in which this modification is. */ - private ModificationState state = null; + private ModificationState state = null; /** * Where this modification is located (on which side of the border). */ - private Double angle = null; + private Double angle = null; /** * How big is this modification (used only for some types of the * modification). */ - private Double size = null; + private Double size = null; /** * Species to which this modification belong to. */ - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "idSpeciesDb", nullable = false) - private SpeciesAlias species; + private CellDesignerSpecies<?> species; /** * Default constructor. */ - public ModificationResidueAlias() { + public CellDesignerModificationResidue() { } /** @@ -99,7 +79,7 @@ public class ModificationResidueAlias implements Serializable { * @param mr * original object from which data is taken */ - public ModificationResidueAlias(ModificationResidueAlias mr) { + public CellDesignerModificationResidue(CellDesignerModificationResidue mr) { this.idModificationResidue = mr.idModificationResidue; this.name = mr.name; this.angle = mr.angle; @@ -108,6 +88,15 @@ public class ModificationResidueAlias implements Serializable { this.state = mr.state; } + public CellDesignerModificationResidue(ModificationResidue mr) { + this.idModificationResidue = mr.getIdModificationResidue(); + this.name = mr.getName(); + this.angle = mr.getAngle(); + this.size = mr.getSize(); + this.side = mr.getSide(); + this.state = mr.getState(); + } + /** * Updates fields in the object with the data given in the parameter * modification. @@ -115,7 +104,7 @@ public class ModificationResidueAlias implements Serializable { * @param mr * modification residue from which data will be used to update */ - public void update(ModificationResidueAlias mr) { + public void update(CellDesignerModificationResidue mr) { if (mr.getName() != null && !mr.getName().equals("")) { this.name = mr.name; } @@ -144,9 +133,9 @@ public class ModificationResidueAlias implements Serializable { * * @return copy of the object. */ - public ModificationResidueAlias copy() { - if (this.getClass() == ModificationResidueAlias.class) { - return new ModificationResidueAlias(this); + public CellDesignerModificationResidue copy() { + if (this.getClass() == CellDesignerModificationResidue.class) { + return new CellDesignerModificationResidue(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } @@ -189,23 +178,6 @@ public class ModificationResidueAlias implements Serializable { } } - /** - * @return the idModificationResidue - * @see #id - */ - public int getId() { - return id; - } - - /** - * @param id - * the idModificationResidue to set - * @see #id - */ - public void setId(int id) { - this.id = id; - } - /** * @return the id * @see #idModificationResidue @@ -312,7 +284,7 @@ public class ModificationResidueAlias implements Serializable { * @return the species * @see #species */ - public SpeciesAlias getSpecies() { + public CellDesignerSpecies<?> getSpecies() { return species; } @@ -321,8 +293,20 @@ public class ModificationResidueAlias implements Serializable { * the species to set * @see #species */ - public void setSpecies(SpeciesAlias species) { + public void setSpecies(CellDesignerSpecies<?> species) { this.species = species; } + public ModificationResidue createModificationResidueAlias() { + ModificationResidue result = new ModificationResidue(); + + result.setIdModificationResidue(this.getIdModificationResidue()); + result.setName(this.getName()); + result.setAngle(this.getAngle()); + result.setSize(this.getSize()); + result.setSide(this.getSide()); + result.setState(this.getState()); + return result; + } + } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/ConnectScheme.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/ConnectScheme.java similarity index 91% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/ConnectScheme.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/ConnectScheme.java index 76a7ed039a..b301451164 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/ConnectScheme.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/ConnectScheme.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.converter.model.celldesigner.structure.fields; import java.util.HashMap; import java.util.Map; diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/EditPoints.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/EditPoints.java similarity index 93% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/EditPoints.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/EditPoints.java index 361675938d..a207ce0239 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/EditPoints.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/EditPoints.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.converter.model.celldesigner.structure.fields; import java.awt.geom.Point2D; import java.util.ArrayList; diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/LineProperties.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/LineProperties.java similarity index 88% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/LineProperties.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/LineProperties.java index d0d1da9452..c8c4203e2b 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/LineProperties.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/LineProperties.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.converter.model.celldesigner.structure.fields; import java.awt.Color; diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/SingleLine.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/SingleLine.java similarity index 80% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/SingleLine.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/SingleLine.java index 63defd059d..406d3d651c 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/SingleLine.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/SingleLine.java @@ -1,33 +1,33 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; - -/** - * Strange CellDEsigner structure to store width of single line... - * - * @author Piotr Gawron - * - */ -public class SingleLine { - - /** - * Width of the line. - */ - private Double width; - - /** - * @return the width - * @see #width - */ - public Double getWidth() { - return width; - } - - /** - * @param width - * the width to set - * @see #width - */ - public void setWidth(Double width) { - this.width = width; - } - -} +package lcsb.mapviewer.converter.model.celldesigner.structure.fields; + +/** + * Strange CellDEsigner structure to store width of single line... + * + * @author Piotr Gawron + * + */ +public class SingleLine { + + /** + * Width of the line. + */ + private Double width; + + /** + * @return the width + * @see #width + */ + public Double getWidth() { + return width; + } + + /** + * @param width + * the width to set + * @see #width + */ + public void setWidth(Double width) { + this.width = width; + } + +} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/SpeciesState.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/SpeciesState.java similarity index 60% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/SpeciesState.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/SpeciesState.java index 41f82d6aa0..c6a42cda6e 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/SpeciesState.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/SpeciesState.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.converter.model.celldesigner.structure.fields; import java.util.ArrayList; import java.util.List; @@ -6,13 +6,13 @@ import java.util.List; import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationResidueAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaRegionAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Gene; +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.ModificationResidue; +import lcsb.mapviewer.model.map.species.field.RnaRegion; /** * Structure for storing the state of the Species in CellDesigner format. @@ -41,7 +41,7 @@ public class SpeciesState { /** * List of species modification. */ - private List<ModificationResidue> modifications = new ArrayList<ModificationResidue>(); + private List<CellDesignerModificationResidue> modifications = new ArrayList<CellDesignerModificationResidue>(); /** * Adds modification to the state. @@ -49,8 +49,8 @@ public class SpeciesState { * @param modificationResidue * modification to add */ - public void addModificationResidue(ModificationResidue modificationResidue) { - for (ModificationResidue modification : modifications) { + public void addModificationResidue(CellDesignerModificationResidue modificationResidue) { + for (CellDesignerModificationResidue modification : modifications) { if (modification.getIdModificationResidue().equals(modificationResidue.getIdModificationResidue())) { modification.update(modificationResidue); return; @@ -71,30 +71,30 @@ public class SpeciesState { * @param species * object for which description is created */ - public SpeciesState(SpeciesAlias species) { - if (species instanceof ProteinAlias) { - ProteinAlias protein = (ProteinAlias) species; + public SpeciesState(Species species) { + if (species instanceof Protein) { + Protein protein = (Protein) species; setStructuralState(protein.getStructuralState()); - for (ModificationResidueAlias mr : protein.getModificationResidues()) { - addModificationResidue(new ModificationResidue(mr)); + for (ModificationResidue mr : protein.getModificationResidues()) { + addModificationResidue(new CellDesignerModificationResidue(mr)); } - } else if (species instanceof ComplexAlias) { - ComplexAlias complex = (ComplexAlias) species; + } else if (species instanceof Complex) { + Complex complex = (Complex) species; setStructuralState(complex.getStructuralState()); - } else if (species instanceof RnaAlias) { - RnaAlias rna = (RnaAlias) species; - for (RnaRegionAlias region : rna.getRegions()) { - ModificationResidue mr = new ModificationResidue(); + } else if (species instanceof Rna) { + Rna rna = (Rna) species; + for (RnaRegion region : rna.getRegions()) { + CellDesignerModificationResidue mr = new CellDesignerModificationResidue(); mr.setIdModificationResidue(region.getIdRnaRegion()); mr.setSize(region.getSize()); mr.setState(region.getState()); addModificationResidue(mr); } - } else if (species instanceof GeneAlias) { - GeneAlias gene = (GeneAlias) species; - for (ModificationResidueAlias mr : gene.getModificationResidues()) { - addModificationResidue(new ModificationResidue(mr)); + } else if (species instanceof Gene) { + Gene gene = (Gene) species; + for (ModificationResidue mr : gene.getModificationResidues()) { + addModificationResidue(new CellDesignerModificationResidue(mr)); } } setHomodimer(species.getHomodimer()); @@ -151,7 +151,7 @@ public class SpeciesState { * @return the modifications * @see #modifications */ - public List<ModificationResidue> getModifications() { + public List<CellDesignerModificationResidue> getModifications() { return modifications; } @@ -160,7 +160,7 @@ public class SpeciesState { * the modifications to set * @see #modifications */ - public void setModifications(List<ModificationResidue> modifications) { + public void setModifications(List<CellDesignerModificationResidue> modifications) { this.modifications = modifications; } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/View.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/View.java similarity index 89% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/View.java rename to converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/View.java index 7cd66b3131..9960909347 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/View.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/View.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.converter.model.celldesigner.structure.fields; import java.awt.Color; import java.awt.Dimension; diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/types/ModifierTypeUtils.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/types/ModifierTypeUtils.java index 3ec3162c47..8f137652ac 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/types/ModifierTypeUtils.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/types/ModifierTypeUtils.java @@ -10,11 +10,11 @@ import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.common.geometry.PointTransformation; import lcsb.mapviewer.converter.model.celldesigner.geometry.ReactionCellDesignerConverter; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.reaction.AbstractNode; import lcsb.mapviewer.model.map.reaction.Modifier; import lcsb.mapviewer.model.map.reaction.NodeOperator; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Species; /** * Util class that helps in transformation of CellDesigner modifiers into @@ -73,14 +73,14 @@ public class ModifierTypeUtils { * alias to which modifier point to * @return {@link Modifier} for the CellDesigner type */ - public Modifier createModifierForStringType(String type, SpeciesAlias alias) { + public Modifier createModifierForStringType(String type, Species alias) { Modifier mod = null; ModifierType modType = getModifierTypeForStringType(type); if (modType == null) { throw new InvalidArgumentException("Unknown modifier type: " + type); } try { - mod = modType.getClazz().getConstructor(SpeciesAlias.class).newInstance(alias); + mod = modType.getClazz().getConstructor(Species.class).newInstance(alias); } catch (Exception e) { throw new InvalidStateException("Problem with instantiation of Modifier class: " + type); } 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 c4dc7f4b95..5ae846b9b2 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 @@ -28,11 +28,6 @@ import lcsb.mapviewer.converter.ConverterParams; import lcsb.mapviewer.converter.InvalidInputDataExecption; import lcsb.mapviewer.converter.model.celldesigner.annotation.RestAnnotationParser; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.layout.graphics.LayerOval; import lcsb.mapviewer.model.map.layout.graphics.LayerRect; @@ -40,6 +35,11 @@ import lcsb.mapviewer.model.map.layout.graphics.LayerText; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelComparator; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.SimpleMolecule; +import lcsb.mapviewer.model.map.species.Species; public class CellDesignerXmlParserTest extends CellDesignerTestFunctions { Logger logger = Logger.getLogger(CellDesignerXmlParserTest.class); @@ -447,7 +447,7 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions { model.setIdModel("as"); model.setWidth(10); model.setHeight(10); - SpeciesAlias speciesAlias = new GenericProteinAlias("id1"); + Species speciesAlias = new GenericProtein("id1"); speciesAlias.setName("ROS"); RestAnnotationParser rap = new RestAnnotationParser(); rap.processNotes( @@ -455,18 +455,18 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions { speciesAlias); model.addAlias(speciesAlias); - GenericProteinAlias alias = new GenericProteinAlias("id"); + GenericProtein alias = new GenericProtein("id"); alias.setName("ROS"); model.addAlias(alias); - SimpleMoleculeAlias speciesAlias2 = new SimpleMoleculeAlias("id2"); + SimpleMolecule speciesAlias2 = new SimpleMolecule("id2"); speciesAlias2.setName("PDK1"); rap.processNotes( "Symbol: ROS1\r\nName: c-ros oncogene 1 , receptor tyrosine kinase\r\nDescription: RecName: Full=Proto-oncogene tyrosine-protein kinase ROS; EC=2.7.10.1; AltName: Full=Proto-oncogene c-Ros; AltName: Full=Proto-oncogene c-Ros-1; AltName: Full=Receptor tyrosine kinase c-ros oncogene 1; AltName: Full=c-Ros receptor tyrosine kinase; Flags: Precursor;\r\nPrevious Symbols:\r\nSynonyms: ROS, MCF3", speciesAlias2); model.addAlias(speciesAlias2); - SimpleMoleculeAlias alias2 = new SimpleMoleculeAlias("id3"); + SimpleMolecule alias2 = new SimpleMolecule("id3"); alias2.setName("PDK1"); model.addAlias(alias2); @@ -519,7 +519,7 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions { model.setHeight(20); model.setNotes(null); model.setIdModel("id"); - SpeciesAlias alias = new GenericProteinAlias("a"); + Species alias = new GenericProtein("a"); alias.setName("AA"); model.addAlias(alias); @@ -577,9 +577,9 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions { CellDesignerXmlParser parser = new CellDesignerXmlParser(); FileInputStream fis = new FileInputStream("testFiles/homodimer.xml"); Model model = parser.createModel(new ConverterParams().inputStream(fis)); - for (Alias element : model.getAliases()) { - if (element instanceof SpeciesAlias) { - assertTrue("Homodimer value for class" + element.getClass() + " not upadted", ((SpeciesAlias) element).getHomodimer() > 1); + for (Element element : model.getAliases()) { + if (element instanceof Species) { + assertTrue("Homodimer value for class" + element.getClass() + " not upadted", ((Species) element).getHomodimer() > 1); } } } catch (Exception e) { @@ -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")); - Alias p = model.getAliasByAliasId("sa1"); + Element p = model.getAliasByAliasId("sa1"); assertEquals(">symbol<", p.getSymbol()); @@ -804,7 +804,7 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions { Model model = new ModelFullIndexed(null); model.setWidth(100); model.setHeight(100); - GeneAlias gene = new GeneAlias("gene_id_1"); + Gene gene = new Gene("gene_id_1"); gene.setName("geneNAME"); model.addAlias(gene); String xmlString = parser.toXml(model); @@ -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")); - Alias element = model.getAliasByAliasId("sa2338"); + Element element = model.getAliasByAliasId("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 7e4fd481ab..f8834afcbc 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 @@ -21,18 +21,18 @@ import org.junit.Test; import lcsb.mapviewer.converter.ConverterParams; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationResidueAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelComparator; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.AntisenseRna; +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.Rna; +import lcsb.mapviewer.model.map.species.Species; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; +import lcsb.mapviewer.model.map.species.field.ModificationState; import lcsb.mapviewer.modelutils.map.ElementUtils; public class ComplexParserTests extends CellDesignerTestFunctions { @@ -68,9 +68,9 @@ public class ComplexParserTests extends CellDesignerTestFunctions { try { model = getModelForFile("testFiles/bubbles.xml"); - Alias species = model.getAliasByAliasId("sa6"); + Element species = model.getAliasByAliasId("sa6"); assertNotNull(species); - ProteinAlias protein = (ProteinAlias) species; + Protein protein = (Protein) species; assertTrue(protein.getModificationResidues().size() > 0); assertNotNull(protein.getStructuralState()); assertFalse(protein.getStructuralState().equals("")); @@ -87,7 +87,7 @@ public class ComplexParserTests extends CellDesignerTestFunctions { try { model = getModelForFile("testFiles/problematic/elements_in_compartments.xml"); - List<Alias> aliases = new ArrayList<>(); + List<Element> aliases = new ArrayList<>(); aliases.add(model.getAliasByAliasId("csa3")); aliases.add(model.getAliasByAliasId("csa4")); aliases.add(model.getAliasByAliasId("csa5")); @@ -109,7 +109,7 @@ public class ComplexParserTests extends CellDesignerTestFunctions { aliases.add(model.getAliasByAliasId("sa18")); aliases.add(model.getAliasByAliasId("sa19")); aliases.add(model.getAliasByAliasId("sa20")); - for (Alias alias : aliases) { + for (Element alias : aliases) { assertNotNull(eu.getElementTag(alias) + " does not contain info about compartment", alias.getParent()); } @@ -126,10 +126,10 @@ public class ComplexParserTests extends CellDesignerTestFunctions { model = getModelForFile("testFiles/problematic/acetyled_protein.xml"); Set<ModificationState> residues = new HashSet<ModificationState>(); - for (Alias element : model.getAliases()) { - if (element instanceof SpeciesAlias) { - ProteinAlias p = (ProteinAlias) element; - for (ModificationResidueAlias mr : p.getModificationResidues()) { + for (Element element : model.getAliases()) { + if (element instanceof Species) { + Protein p = (Protein) element; + for (ModificationResidue mr : p.getModificationResidues()) { residues.add(mr.getState()); } } @@ -138,7 +138,7 @@ public class ComplexParserTests extends CellDesignerTestFunctions { // of residues assertEquals(2, residues.size()); - assertEquals(ModificationState.ACETYLATED, ((ProteinAlias) model.getAliasByAliasId("sa2")).getModificationResidues().get(0).getState()); + assertEquals(ModificationState.ACETYLATED, ((Protein) model.getAliasByAliasId("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"); - Alias species = model.getAliasByAliasId("sa1"); + Element species = model.getAliasByAliasId("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"); - ComplexAlias species = (ComplexAlias) model.getAliasByAliasId("csa1"); + Complex species = (Complex) model.getAliasByAliasId("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"); - ProteinAlias p1 = (ProteinAlias) model.getAliasByAliasId("sa73"); - ProteinAlias p2 = (ProteinAlias) model.getAliasByAliasId("sa27"); + Protein p1 = (Protein) model.getAliasByAliasId("sa73"); + Protein p2 = (Protein) model.getAliasByAliasId("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"); - ProteinAlias p1 = (ProteinAlias) model.getAliasByAliasId("sa1"); + Protein p1 = (Protein) model.getAliasByAliasId("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"); - Alias species = model.getAliasByAliasId("sa1"); + Element species = model.getAliasByAliasId("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(((SpeciesAlias) model.getAliasByAliasId("sa3")).isHypothetical()); - assertTrue(((SpeciesAlias) model.getAliasByAliasId("sa4")).isHypothetical()); - assertTrue(((SpeciesAlias) model.getAliasByAliasId("sa5")).isHypothetical()); + assertTrue(((Species) model.getAliasByAliasId("sa3")).isHypothetical()); + assertTrue(((Species) model.getAliasByAliasId("sa4")).isHypothetical()); + assertTrue(((Species) model.getAliasByAliasId("sa5")).isHypothetical()); - assertFalse(((SpeciesAlias) model.getAliasByAliasId("sa12")).isHypothetical()); - assertFalse(((SpeciesAlias) model.getAliasByAliasId("sa13")).isHypothetical()); - assertFalse(((SpeciesAlias) model.getAliasByAliasId("sa14")).isHypothetical()); - assertFalse(((SpeciesAlias) model.getAliasByAliasId("sa15")).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()); } catch (Exception e) { e.printStackTrace(); @@ -254,7 +254,7 @@ public class ComplexParserTests extends CellDesignerTestFunctions { model.setIdModel("as"); model.setWidth(100); model.setHeight(100); - GenericProteinAlias alias = new GenericProteinAlias("aid"); + GenericProtein alias = new GenericProtein("aid"); alias.setName("name & no-name"); model.addAlias(alias); @@ -284,7 +284,7 @@ public class ComplexParserTests extends CellDesignerTestFunctions { model.setIdModel("as"); model.setWidth(100); model.setHeight(100); - GenericProteinAlias alias = new GenericProteinAlias("aid"); + GenericProtein alias = new GenericProtein("aid"); alias.setName("name\rno-name"); model.addAlias(alias); @@ -322,8 +322,8 @@ public class ComplexParserTests extends CellDesignerTestFunctions { public void testRnaWithRegion() throws Exception { try { Model model = getModelForFile("testFiles/rnaWithRegion.xml"); - for (Alias species : model.getNotComplexSpeciesAliases()) { - RnaAlias rna = (RnaAlias) species; + for (Element species : model.getNotComplexSpeciesAliases()) { + Rna rna = (Rna) species; assertEquals(1, rna.getRegions().size()); } } catch (Exception e) { @@ -336,7 +336,7 @@ public class ComplexParserTests extends CellDesignerTestFunctions { public void testProtinWithModifications() throws Exception { try { Model model = getModelForFile("testFiles/proteinWithEverPossibleModification.xml"); - ProteinAlias protein = (ProteinAlias) model.getAliasByAliasId("sa1"); + Protein protein = (Protein) model.getAliasByAliasId("sa1"); assertEquals(14, protein.getModificationResidues().size()); } catch (Exception e) { e.printStackTrace(); @@ -348,8 +348,8 @@ public class ComplexParserTests extends CellDesignerTestFunctions { public void testAntisenseRnaWithRegion() throws Exception { try { Model model = getModelForFile("testFiles/antisenseRnaWithRegion.xml"); - for (SpeciesAlias species : model.getNotComplexSpeciesAliases()) { - AntisenseRnaAlias rna = (AntisenseRnaAlias) species; + for (Species species : model.getNotComplexSpeciesAliases()) { + AntisenseRna rna = (AntisenseRna) species; assertEquals(1, rna.getRegions().size()); } } catch (Exception e) { diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/LayerXmlParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/LayerXmlParserTest.java index 6b8c0b31a8..2353bd3dc5 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/LayerXmlParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/LayerXmlParserTest.java @@ -17,9 +17,7 @@ import org.w3c.dom.Node; import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; import lcsb.mapviewer.model.graphics.PolylineData; import lcsb.mapviewer.model.graphics.PolylineDataComparator; -import lcsb.mapviewer.model.map.layout.alias.AliasGroup; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.layout.ElementGroup; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.layout.graphics.LayerComparator; import lcsb.mapviewer.model.map.layout.graphics.LayerOval; @@ -30,6 +28,8 @@ import lcsb.mapviewer.model.map.layout.graphics.LayerText; import lcsb.mapviewer.model.map.layout.graphics.LayerTextComparator; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class LayerXmlParserTest extends CellDesignerTestFunctions { Logger logger = Logger.getLogger(LayerXmlParserTest.class); @@ -147,7 +147,7 @@ public class LayerXmlParserTest extends CellDesignerTestFunctions { public void testParseInvalidGroups3() throws Exception { try { Model model = new ModelFullIndexed(null); - GenericProteinAlias alias = new GenericProteinAlias("sa1"); + GenericProtein alias = new GenericProtein("sa1"); model.addAlias(alias); String xmlString = readFile("testFiles/invalid/group_collection3.xml"); @@ -408,21 +408,21 @@ public class LayerXmlParserTest extends CellDesignerTestFunctions { public void testGetAliasGroup() throws Exception { try { Model model = new ModelFullIndexed(null); - SpeciesAlias alias = new GenericProteinAlias("sa1035"); + Species alias = new GenericProtein("sa1035"); model.addAlias(alias); - alias = new GenericProteinAlias("sa1036"); + alias = new GenericProtein("sa1036"); model.addAlias(alias); - alias = new GenericProteinAlias("sa1037"); + alias = new GenericProtein("sa1037"); model.addAlias(alias); - alias = new GenericProteinAlias("sa1038"); + alias = new GenericProtein("sa1038"); model.addAlias(alias); String string = "<celldesigner:group id=\"g74\" members=\"sa1035,sa1036,sa1037,sa1038\"/>"; Node node = getNodeFromXmlString(string); - AliasGroup group = parser.getAliasGroup(node, model); + ElementGroup group = parser.getAliasGroup(node, model); assertNotNull(group); assertEquals(4, group.getAliases().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 913a958c65..5c3a6edf02 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 @@ -8,9 +8,9 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Complex; public class NestedComplexParsingTests extends CellDesignerTestFunctions { Logger logger = Logger.getLogger(NestedComplexParsingTests.class); @@ -29,30 +29,30 @@ public class NestedComplexParsingTests extends CellDesignerTestFunctions { try { model = getModelForFile("testFiles/xmlNodeTestExamples/nested_complex.xml"); - Alias s1 = model.getAliasByAliasId("csa1"); - Alias s2 = model.getAliasByAliasId("csa2"); - Alias s3 = model.getAliasByAliasId("csa3"); - Alias s4 = model.getAliasByAliasId("csa4"); - Alias s5 = model.getAliasByAliasId("csa5"); - Alias s6 = model.getAliasByAliasId("csa6"); - Alias s7 = model.getAliasByAliasId("sa1"); - Alias s8 = model.getAliasByAliasId("sa2"); - Alias s9 = model.getAliasByAliasId("sa3"); - Alias s10 = model.getAliasByAliasId("sa4"); - Alias s11 = model.getAliasByAliasId("sa5"); - Alias s12 = model.getAliasByAliasId("sa6"); - assertTrue(s1 instanceof ComplexAlias); - assertTrue(s2 instanceof ComplexAlias); - assertTrue(s3 instanceof ComplexAlias); - assertTrue(s4 instanceof ComplexAlias); - assertTrue(s5 instanceof ComplexAlias); - assertTrue(s6 instanceof ComplexAlias); - ComplexAlias cs1 = (ComplexAlias) s1; - ComplexAlias cs2 = (ComplexAlias) s2; - ComplexAlias cs3 = (ComplexAlias) s3; - ComplexAlias cs4 = (ComplexAlias) s4; - ComplexAlias cs5 = (ComplexAlias) s5; - ComplexAlias cs6 = (ComplexAlias) s6; + 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"); + assertTrue(s1 instanceof Complex); + assertTrue(s2 instanceof Complex); + assertTrue(s3 instanceof Complex); + assertTrue(s4 instanceof Complex); + assertTrue(s5 instanceof Complex); + assertTrue(s6 instanceof Complex); + Complex cs1 = (Complex) s1; + Complex cs2 = (Complex) s2; + Complex cs3 = (Complex) s3; + Complex cs4 = (Complex) s4; + Complex cs5 = (Complex) s5; + Complex cs6 = (Complex) s6; assertEquals(2,cs1.getAliases().size()); assertEquals(2,cs2.getAliases().size()); assertEquals(0,cs3.getAliases().size()); 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 45e1c12047..37e3ba1d29 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 @@ -10,9 +10,9 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.converter.ConverterParams; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Species; public class ReconDataInCellDesignerXmlParserTest extends CellDesignerTestFunctions { Logger logger = Logger.getLogger(ReconDataInCellDesignerXmlParserTest.class); @@ -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); - SpeciesAlias species = (SpeciesAlias)model.getAliasByAliasId("sa1"); + Species species = (Species)model.getAliasByAliasId("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 a85efa5a63..9a2ac88f38 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 @@ -16,14 +16,14 @@ import org.w3c.dom.Node; 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.Compartment; -import lcsb.mapviewer.converter.model.celldesigner.structure.ComplexSpecies; -import lcsb.mapviewer.converter.model.celldesigner.structure.GenericProtein; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerCompartment; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerComplexSpecies; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerGenericProtein; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Species; public class AliasCollectionXmlParserTest extends CellDesignerTestFunctions { @@ -49,21 +49,21 @@ public class AliasCollectionXmlParserTest extends CellDesignerTestFunctions { @Test public void testParseXmlSpeciesAliasCollection() throws Exception { try { - elements.addElement(new GenericProtein("s2594")); - elements.addElement(new GenericProtein("s2595")); - elements.addElement(new GenericProtein("s2596")); - elements.addElement(new GenericProtein("s2506")); + elements.addElement(new CellDesignerGenericProtein("s2594")); + elements.addElement(new CellDesignerGenericProtein("s2595")); + elements.addElement(new CellDesignerGenericProtein("s2596")); + elements.addElement(new CellDesignerGenericProtein("s2506")); String xmlString = readFile("testFiles/xmlNodeTestExamples/cd_species_alias_collection.xml"); Node node = getNodeFromXmlString(xmlString); - List<SpeciesAlias> list = parser.parseXmlSpeciesAliasCollection(node); + List<Species> list = parser.parseXmlSpeciesAliasCollection(node); assertEquals(0, getWarnings().size()); assertNotNull(list); assertEquals(4, list.size()); - SpeciesAlias aliasSa8 = null; - SpeciesAlias aliasSa9 = null; - SpeciesAlias aliasSa10 = null; - SpeciesAlias aliasSa11 = null; - for (SpeciesAlias alias : list) { + Species aliasSa8 = null; + Species aliasSa9 = null; + Species aliasSa10 = null; + Species aliasSa11 = null; + for (Species alias : list) { if (alias.getAliasId().equals("sa8")) aliasSa8 = alias; if (alias.getAliasId().equals("sa9")) @@ -132,21 +132,21 @@ public class AliasCollectionXmlParserTest extends CellDesignerTestFunctions { @Test public void testSpeciesAliasCollectionToXmlString() throws Exception { try { - elements.addElement(new GenericProtein("s2594")); - elements.addElement(new GenericProtein("s2506")); - elements.addElement(new GenericProtein("s2595")); - elements.addElement(new GenericProtein("s2596")); + elements.addElement(new CellDesignerGenericProtein("s2594")); + elements.addElement(new CellDesignerGenericProtein("s2506")); + elements.addElement(new CellDesignerGenericProtein("s2595")); + elements.addElement(new CellDesignerGenericProtein("s2596")); String xmlString = readFile("testFiles/xmlNodeTestExamples/cd_species_alias_collection.xml"); Node node = getNodeFromXmlString(xmlString); - List<SpeciesAlias> list = parser.parseXmlSpeciesAliasCollection(node); + List<Species> list = parser.parseXmlSpeciesAliasCollection(node); assertEquals(0, getWarnings().size()); String xmlString2 = parser.speciesAliasCollectionToXmlString(list); assertNotNull(xmlString2); // add position to elements list, because parser forgot CD ids and created // new for them - for (SpeciesAlias alias : list) { - elements.addElement(new GenericProtein(elements.getElementId(alias))); + for (Species alias : list) { + elements.addElement(new CellDesignerGenericProtein(elements.getElementId(alias))); } node = getNodeFromXmlString(xmlString2); @@ -154,11 +154,11 @@ public class AliasCollectionXmlParserTest extends CellDesignerTestFunctions { assertEquals(0, getWarnings().size()); assertNotNull(list); assertEquals(4, list.size()); - SpeciesAlias aliasSa8 = null; - SpeciesAlias aliasSa9 = null; - SpeciesAlias aliasSa10 = null; - SpeciesAlias aliasSa11 = null; - for (SpeciesAlias alias : list) { + Species aliasSa8 = null; + Species aliasSa9 = null; + Species aliasSa10 = null; + Species aliasSa11 = null; + for (Species alias : list) { if (alias.getAliasId().equals("sa8")) aliasSa8 = alias; if (alias.getAliasId().equals("sa9")) @@ -182,19 +182,19 @@ public class AliasCollectionXmlParserTest extends CellDesignerTestFunctions { @Test public void testParseXmlComplexAliasCollection() throws Exception { try { - elements.addElement(new ComplexSpecies("s2597")); - elements.addElement(new ComplexSpecies("s2598")); - elements.addElement(new ComplexSpecies("s2599")); + elements.addElement(new CellDesignerComplexSpecies("s2597")); + elements.addElement(new CellDesignerComplexSpecies("s2598")); + elements.addElement(new CellDesignerComplexSpecies("s2599")); String xmlString = readFile("testFiles/xmlNodeTestExamples/cd_complex_alias_collection.xml"); Node node = getNodeFromXmlString(xmlString); - List<ComplexAlias> list = parser.parseXmlComplexAliasCollection(node); + List<Complex> list = parser.parseXmlComplexAliasCollection(node); assertEquals(0, getWarnings().size()); assertNotNull(list); assertEquals(3, list.size()); - ComplexAlias aliasSa1 = null; - ComplexAlias aliasSa2 = null; - ComplexAlias aliasSa3 = null; - for (ComplexAlias alias : list) { + Complex aliasSa1 = null; + Complex aliasSa2 = null; + Complex aliasSa3 = null; + for (Complex alias : list) { if (alias.getAliasId().equals("csa1")) aliasSa1 = alias; if (alias.getAliasId().equals("csa2")) @@ -214,20 +214,20 @@ public class AliasCollectionXmlParserTest extends CellDesignerTestFunctions { @Test public void testComplexAliasCollectionToXmlString() throws Exception { try { - elements.addElement(new ComplexSpecies("s2597")); - elements.addElement(new ComplexSpecies("s2598")); - elements.addElement(new ComplexSpecies("s2599")); + elements.addElement(new CellDesignerComplexSpecies("s2597")); + elements.addElement(new CellDesignerComplexSpecies("s2598")); + elements.addElement(new CellDesignerComplexSpecies("s2599")); String xmlString = readFile("testFiles/xmlNodeTestExamples/cd_complex_alias_collection.xml"); Node node = getNodeFromXmlString(xmlString); - List<ComplexAlias> list = parser.parseXmlComplexAliasCollection(node); + List<Complex> list = parser.parseXmlComplexAliasCollection(node); assertEquals(0, getWarnings().size()); String xmlString2 = parser.complexAliasCollectionToXmlString(list); assertNotNull(xmlString2); // add position to elements list, because parser forgot CD ids and created // new for them - for (ComplexAlias complexAlias : list) { - elements.addElement(new ComplexSpecies(elements.getElementId(complexAlias))); + for (Complex complexAlias : list) { + elements.addElement(new CellDesignerComplexSpecies(elements.getElementId(complexAlias))); } node = getNodeFromXmlString(xmlString2); @@ -235,10 +235,10 @@ public class AliasCollectionXmlParserTest extends CellDesignerTestFunctions { assertEquals(0, getWarnings().size()); assertNotNull(list); assertEquals(3, list.size()); - ComplexAlias aliasSa1 = null; - ComplexAlias aliasSa2 = null; - ComplexAlias aliasSa3 = null; - for (ComplexAlias alias : list) { + Complex aliasSa1 = null; + Complex aliasSa2 = null; + Complex aliasSa3 = null; + for (Complex alias : list) { if (alias.getAliasId().equals("csa1")) aliasSa1 = alias; if (alias.getAliasId().equals("csa2")) @@ -258,20 +258,20 @@ public class AliasCollectionXmlParserTest extends CellDesignerTestFunctions { @Test public void testParseXmlCompartmentAliasCollection() throws Exception { try { - elements.addElement(new Compartment("c1")); - elements.addElement(new Compartment("c2")); - elements.addElement(new Compartment("c3")); + elements.addElement(new CellDesignerCompartment("c1")); + elements.addElement(new CellDesignerCompartment("c2")); + elements.addElement(new CellDesignerCompartment("c3")); String xmlString = readFile("testFiles/xmlNodeTestExamples/cd_compartment_alias_collection.xml"); Node node = getNodeFromXmlString(xmlString); - List<CompartmentAlias> list = parser.parseXmlCompartmentAliasCollection(node); + List<Compartment> list = parser.parseXmlCompartmentAliasCollection(node); assertEquals(0, getWarnings().size()); assertNotNull(list); assertEquals(3, list.size()); - CompartmentAlias aliasCa1 = null; - CompartmentAlias aliasCa2 = null; - CompartmentAlias aliasCa3 = null; - for (CompartmentAlias alias : list) { + Compartment aliasCa1 = null; + Compartment aliasCa2 = null; + Compartment aliasCa3 = null; + for (Compartment alias : list) { if (alias.getAliasId().equals("ca1")) aliasCa1 = alias; if (alias.getAliasId().equals("ca2")) @@ -291,13 +291,13 @@ public class AliasCollectionXmlParserTest extends CellDesignerTestFunctions { @Test public void testCompartmentAliasCollectionToXmlString() throws Exception { try { - elements.addElement(new Compartment("c1")); - elements.addElement(new Compartment("c2")); - elements.addElement(new Compartment("c3")); + elements.addElement(new CellDesignerCompartment("c1")); + elements.addElement(new CellDesignerCompartment("c2")); + elements.addElement(new CellDesignerCompartment("c3")); String xmlString = readFile("testFiles/xmlNodeTestExamples/cd_compartment_alias_collection.xml"); Node node = getNodeFromXmlString(xmlString); - List<CompartmentAlias> list = parser.parseXmlCompartmentAliasCollection(node); + List<Compartment> list = parser.parseXmlCompartmentAliasCollection(node); assertEquals(0, getWarnings().size()); String xmlString2 = parser.compartmentAliasCollectionToXmlString(list); @@ -305,8 +305,8 @@ public class AliasCollectionXmlParserTest extends CellDesignerTestFunctions { // add position to elements list, because parser forgot CD ids and created // new for them - for (CompartmentAlias alias : list) { - elements.addElement(new Compartment(elements.getElementId(alias))); + for (Compartment alias : list) { + elements.addElement(new CellDesignerCompartment(elements.getElementId(alias))); } node = getNodeFromXmlString(xmlString2); @@ -315,10 +315,10 @@ public class AliasCollectionXmlParserTest extends CellDesignerTestFunctions { assertNotNull(list); assertEquals(3, list.size()); - CompartmentAlias aliasSa1 = null; - CompartmentAlias aliasSa2 = null; - CompartmentAlias aliasSa3 = null; - for (CompartmentAlias alias : list) { + Compartment aliasSa1 = null; + Compartment aliasSa2 = null; + Compartment aliasSa3 = null; + for (Compartment alias : list) { if (alias.getAliasId().equals("ca1")) aliasSa1 = alias; if (alias.getAliasId().equals("ca2")) 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 52989043a4..39ec8b2440 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 @@ -16,13 +16,13 @@ import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; 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.Compartment; -import lcsb.mapviewer.model.map.layout.alias.BottomSquareCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.LeftSquareCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.RightSquareCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.SquareCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.TopSquareCompartmentAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerCompartment; +import lcsb.mapviewer.model.map.compartment.BottomSquareCompartment; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.compartment.LeftSquareCompartment; +import lcsb.mapviewer.model.map.compartment.RightSquareCompartment; +import lcsb.mapviewer.model.map.compartment.SquareCompartment; +import lcsb.mapviewer.model.map.compartment.TopSquareCompartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; @@ -47,18 +47,18 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions { @Test public void testToXml() throws Exception { try { - elements.addElement(new Compartment("c1")); + elements.addElement(new CellDesignerCompartment("c1")); String xmlString = readFile("testFiles/xmlNodeTestExamples/cd_compartment_alias.xml"); - CompartmentAlias alias = parser.parseXmlAlias(xmlString); + Compartment alias = parser.parseXmlAlias(xmlString); assertEquals(0, getWarnings().size()); assertEquals(0, getWarnings().size()); String xmlString2 = parser.toXml(alias); assertNotNull(xmlString2); - elements.addElement(new Compartment(elements.getElementId(alias))); + elements.addElement(new CellDesignerCompartment(elements.getElementId(alias))); - CompartmentAlias alias2 = parser.parseXmlAlias(xmlString2); + Compartment alias2 = parser.parseXmlAlias(xmlString2); assertEquals(0, getWarnings().size()); assertEquals(alias.getAliasId(), alias2.getAliasId()); @@ -96,7 +96,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions { public void parseInvalidAlias2() throws Exception { try { Model model = new ModelFullIndexed(null); - Compartment comp = new Compartment(); + CellDesignerCompartment comp = new CellDesignerCompartment(); comp.setElementId("c1"); elements.addElement(comp); parser = new CompartmentAliasXmlParser(elements, model); @@ -115,7 +115,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions { public void parseInvalidAlias3() throws Exception { try { Model model = new ModelFullIndexed(null); - Compartment comp = new Compartment(); + CellDesignerCompartment comp = new CellDesignerCompartment(); comp.setElementId("c1"); elements.addElement(comp); parser = new CompartmentAliasXmlParser(elements, model); @@ -134,7 +134,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions { public void parseInvalidAlias4() throws Exception { try { Model model = new ModelFullIndexed(null); - Compartment comp = new Compartment(); + CellDesignerCompartment comp = new CellDesignerCompartment(); comp.setElementId("c1"); elements.addElement(comp); parser = new CompartmentAliasXmlParser(elements, model); @@ -152,15 +152,15 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions { @Test public void testParseXmlAliasNode() throws Exception { try { - elements.addElement(new Compartment("c1")); + elements.addElement(new CellDesignerCompartment("c1")); String xmlString = readFile("testFiles/xmlNodeTestExamples/cd_compartment_alias.xml"); - CompartmentAlias alias = (CompartmentAlias) parser.parseXmlAlias(xmlString); + Compartment alias = (Compartment) parser.parseXmlAlias(xmlString); assertEquals(0, getWarnings().size()); assertNotNull(alias); assertEquals("ca1", alias.getAliasId()); assertNotNull(alias.getName()); - assertTrue(alias instanceof SquareCompartmentAlias); + assertTrue(alias instanceof SquareCompartment); assertEquals(139.0, alias.getX(), 1e-6); assertEquals(55.0, alias.getY(), 1e-6); assertEquals(522.0, alias.getWidth(), 1e-6); @@ -189,7 +189,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions { @Test public void testLeftToXml() throws Exception { try { - CompartmentAlias alias = new LeftSquareCompartmentAlias(); + Compartment alias = new LeftSquareCompartment(); String xml = parser.toXml(alias); assertNotNull(xml); } catch (Exception e) { @@ -202,7 +202,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions { @Test public void testRightToXml() throws Exception { try { - CompartmentAlias alias = new RightSquareCompartmentAlias(); + Compartment alias = new RightSquareCompartment(); String xml = parser.toXml(alias); assertNotNull(xml); } catch (Exception e) { @@ -215,7 +215,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions { @Test public void testTopToXml() throws Exception { try { - CompartmentAlias alias = new TopSquareCompartmentAlias(); + Compartment alias = new TopSquareCompartment(); String xml = parser.toXml(alias); assertNotNull(xml); } catch (Exception e) { @@ -228,7 +228,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions { @Test public void testBotttomToXml() throws Exception { try { - CompartmentAlias alias = new BottomSquareCompartmentAlias(); + Compartment alias = new BottomSquareCompartment(); String xml = parser.toXml(alias); assertNotNull(xml); } catch (Exception e) { @@ -241,7 +241,7 @@ public class CompartmentAliasXmlParserTest extends CellDesignerTestFunctions { @Test public void testUnknownToXml() throws Exception { try { - CompartmentAlias alias = Mockito.mock(BottomSquareCompartmentAlias.class); + Compartment alias = Mockito.mock(BottomSquareCompartment.class); parser.toXml(alias); fail("Exception expected"); } catch (NotImplementedException e) { 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 7d620bb070..f59f2c1826 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 @@ -9,10 +9,10 @@ import org.junit.Test; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerTestFunctions; -import lcsb.mapviewer.converter.model.celldesigner.structure.ComplexSpecies; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerComplexSpecies; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.Complex; public class ComplexAliasXmlParserTest extends CellDesignerTestFunctions { Model model; @@ -33,15 +33,15 @@ public class ComplexAliasXmlParserTest extends CellDesignerTestFunctions { @Test public void testToXml() throws Exception { try { - elements.addElement(new ComplexSpecies("s2597")); + elements.addElement(new CellDesignerComplexSpecies("s2597")); String xmlString = readFile("testFiles/xmlNodeTestExamples/cd_complex_alias.xml"); - ComplexAlias alias = (ComplexAlias) parser.parseXmlAlias(xmlString); + Complex alias = (Complex) parser.parseXmlAlias(xmlString); assertEquals(0, getWarnings().size()); String xmlString2 = parser.toXml(alias); assertNotNull(xmlString2); - elements.addElement(new ComplexSpecies(elements.getElementId(alias))); - ComplexAlias alias2 = (ComplexAlias) parser.parseXmlAlias(xmlString2); + elements.addElement(new CellDesignerComplexSpecies(elements.getElementId(alias))); + Complex alias2 = (Complex) parser.parseXmlAlias(xmlString2); assertEquals(0, getWarnings().size()); assertEquals(alias.getAliasId(), alias2.getAliasId()); @@ -60,10 +60,10 @@ public class ComplexAliasXmlParserTest extends CellDesignerTestFunctions { @Test public void testParseXmlAliasNode() throws Exception { try { - elements.addElement(new ComplexSpecies("s2597")); + elements.addElement(new CellDesignerComplexSpecies("s2597")); String xmlString = readFile("testFiles/xmlNodeTestExamples/cd_complex_alias.xml"); - ComplexAlias alias = (ComplexAlias) parser.parseXmlAlias(xmlString); + Complex alias = (Complex) parser.parseXmlAlias(xmlString); assertEquals(0, getWarnings().size()); assertEquals(false, alias.getActivity()); assertEquals("csa1", alias.getAliasId()); 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 3692a7f973..ec07f044b6 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 @@ -20,14 +20,14 @@ import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; 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.ComplexSpecies; -import lcsb.mapviewer.converter.model.celldesigner.structure.GenericProtein; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerComplexSpecies; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerGenericProtein; +import lcsb.mapviewer.model.map.compartment.Compartment; 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.Complex; +import lcsb.mapviewer.model.map.species.Species; public class SpeciesAliasXmlParserTest extends CellDesignerTestFunctions { static Logger logger = Logger.getLogger(SpeciesAliasXmlParser.class); @@ -35,8 +35,6 @@ public class SpeciesAliasXmlParserTest extends CellDesignerTestFunctions { Model model; private SpeciesAliasXmlParser parser; - private String testCompartmentId2 = "s1"; - private String testCompartmentId = "s2"; private String testCompartmentAliasId2 = "s3"; private String testCompartmentAliasId = "s4"; private String testSpeciesId = "s5"; @@ -49,7 +47,7 @@ public class SpeciesAliasXmlParserTest extends CellDesignerTestFunctions { model = createStubModel(); - GenericProtein species = new GenericProtein(); + CellDesignerGenericProtein species = new CellDesignerGenericProtein(); species.setElementId("s78"); elements.addElement(species); @@ -58,7 +56,7 @@ public class SpeciesAliasXmlParserTest extends CellDesignerTestFunctions { private Model createStubModel() { Model model = new ModelFullIndexed(null); - model.addAlias(new CompartmentAlias("ca1")); + model.addAlias(new Compartment("ca1")); return model; } @@ -70,7 +68,7 @@ public class SpeciesAliasXmlParserTest extends CellDesignerTestFunctions { public void testParseXmlAliasNode() throws Exception { try { String xmlString = readFile("testFiles/xmlNodeTestExamples/species_alias.xml"); - SpeciesAlias alias = parser.parseXmlAlias(xmlString); + Species alias = parser.parseXmlAlias(xmlString); assertEquals(0, getWarnings().size()); assertEquals(false, alias.getActivity()); assertEquals("sa36", alias.getAliasId()); @@ -90,7 +88,7 @@ public class SpeciesAliasXmlParserTest extends CellDesignerTestFunctions { public void testParseXmlAliasFont() throws Exception { try { String xmlString = readFile("testFiles/xmlNodeTestExamples/species_alias_with_font.xml"); - SpeciesAlias alias = parser.parseXmlAlias(xmlString); + Species alias = parser.parseXmlAlias(xmlString); assertEquals(30.0, alias.getFontSize(), 1e-6); } catch (Exception e) { e.printStackTrace(); @@ -102,17 +100,17 @@ public class SpeciesAliasXmlParserTest extends CellDesignerTestFunctions { public void testToXml() throws Exception { try { String xmlString = readFile("testFiles/xmlNodeTestExamples/species_alias.xml"); - SpeciesAlias alias = parser.parseXmlAlias(xmlString); + Species alias = parser.parseXmlAlias(xmlString); assertEquals(0, getWarnings().size()); String xmlString2 = parser.toXml(alias); assertNotNull(xmlString2); - elements.addElement(new GenericProtein(elements.getElementId(alias))); + elements.addElement(new CellDesignerGenericProtein(elements.getElementId(alias))); Model model2 = createStubModel(); parser = new SpeciesAliasXmlParser(elements, model2); - SpeciesAlias alias2 = parser.parseXmlAlias(xmlString2); + Species alias2 = parser.parseXmlAlias(xmlString2); assertEquals(0, getWarnings().size()); assertEquals(alias.getActivity(), alias2.getActivity()); @@ -135,13 +133,13 @@ public class SpeciesAliasXmlParserTest extends CellDesignerTestFunctions { public void testToXmlAliasWithStateNode() throws Exception { try { String xmlString = readFile("testFiles/xmlNodeTestExamples/species_alias_with_state.xml"); - SpeciesAlias alias = parser.parseXmlAlias(xmlString); + Species alias = parser.parseXmlAlias(xmlString); assertEquals(0, getWarnings().size()); String xmlString2 = parser.toXml(alias); assertNotNull(xmlString2); - elements.addElement(new GenericProtein(elements.getElementId(alias))); - SpeciesAlias alias2 = parser.parseXmlAlias(xmlString2); + elements.addElement(new CellDesignerGenericProtein(elements.getElementId(alias))); + Species alias2 = parser.parseXmlAlias(xmlString2); assertEquals(0, getWarnings().size()); assertEquals("Alias state label different", alias.getAliasStateLabel(), alias2.getAliasStateLabel()); @@ -156,7 +154,7 @@ public class SpeciesAliasXmlParserTest extends CellDesignerTestFunctions { public void testParseXmlAliasWithStateNode() throws Exception { try { String xmlString = readFile("testFiles/xmlNodeTestExamples/species_alias_with_state.xml"); - SpeciesAlias alias = parser.parseXmlAlias(xmlString); + Species alias = parser.parseXmlAlias(xmlString); assertEquals(0, getWarnings().size()); assertNotNull(alias); assertEquals("test", alias.getAliasStateLabel()); @@ -171,7 +169,7 @@ public class SpeciesAliasXmlParserTest extends CellDesignerTestFunctions { public void testParseXmlAliasWithoutStateNode() throws Exception { try { String xmlString = readFile("testFiles/xmlNodeTestExamples/species_alias_without_state.xml"); - SpeciesAlias alias = parser.parseXmlAlias(xmlString); + Species alias = parser.parseXmlAlias(xmlString); assertEquals(0, getWarnings().size()); assertNotNull(alias); assertNull(alias.getAliasStateLabel()); @@ -279,21 +277,21 @@ public class SpeciesAliasXmlParserTest extends CellDesignerTestFunctions { ModelData md = new ModelData(); md.setModel(model); - CompartmentAlias ca2 = new CompartmentAlias(testCompartmentAliasId2); + Compartment ca2 = new Compartment(testCompartmentAliasId2); ca2.setAliasId(testCompartmentAliasId2); ca2.setX(6); ca2.setY(6); ca2.setWidth(190); ca2.setHeight(190); - CompartmentAlias ca = new CompartmentAlias(testCompartmentAliasId); + Compartment ca = new Compartment(testCompartmentAliasId); ca.setAliasId(testCompartmentAliasId); ca.setX(5); ca.setY(5); ca.setWidth(200); ca.setHeight(200); - List<CompartmentAlias> list = new ArrayList<>(); + List<Compartment> list = new ArrayList<>(); list.add(ca); list.add(ca2); @@ -301,7 +299,7 @@ public class SpeciesAliasXmlParserTest extends CellDesignerTestFunctions { when(model.getCompartmentsAliases()).thenReturn(list); when(model.getModelData()).thenReturn(md); - SpeciesAlias alias = new ComplexAlias(testAliasId); + Species alias = new Complex(testAliasId); alias.setX(10); alias.setY(10); alias.setWidth(100); @@ -309,7 +307,7 @@ public class SpeciesAliasXmlParserTest extends CellDesignerTestFunctions { alias.setModel(model); alias.setActivity(true); - elements.addElement(new ComplexSpecies(testSpeciesId)); + elements.addElement(new CellDesignerComplexSpecies(testSpeciesId)); model.addAlias(alias); SpeciesAliasXmlParser parser = new SpeciesAliasXmlParser(elements, model); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/annotation/RestAnnotationParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/annotation/RestAnnotationParserTest.java index bd02f9c653..473a5ba731 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/annotation/RestAnnotationParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/annotation/RestAnnotationParserTest.java @@ -26,11 +26,11 @@ import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamRelationType; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class RestAnnotationParserTest extends CellDesignerTestFunctions { Logger logger = Logger.getLogger(RestAnnotationParserTest.class); @@ -70,7 +70,7 @@ public class RestAnnotationParserTest extends CellDesignerTestFunctions { try { RestAnnotationParser parser = new RestAnnotationParser(); Document node = getXmlDocumentFromFile("testFiles/xmlNodeTestExamples/notes.xml"); - SpeciesAlias proteinAlias = new GenericProteinAlias("id"); + Species proteinAlias = new GenericProtein("id"); parser.processNotes(node.getFirstChild(), proteinAlias); String notes = proteinAlias.getNotes(); assertNotNull(notes); @@ -93,7 +93,7 @@ public class RestAnnotationParserTest extends CellDesignerTestFunctions { try { RestAnnotationParser parser = new RestAnnotationParser(); Document node = getXmlDocumentFromFile("testFiles/xmlNodeTestExamples/notes3.xml"); - SpeciesAlias proteinAlias = new GenericProteinAlias("id"); + Species proteinAlias = new GenericProtein("id"); parser.processNotes(node.getFirstChild(), proteinAlias); String notes = proteinAlias.getNotes(); assertNotNull(notes); @@ -116,7 +116,7 @@ public class RestAnnotationParserTest extends CellDesignerTestFunctions { try { RestAnnotationParser parser = new RestAnnotationParser(); Document node = getXmlDocumentFromFile("testFiles/xmlNodeTestExamples/notes4.xml"); - SpeciesAlias proteinAlias = new GenericProteinAlias("id"); + Species proteinAlias = new GenericProtein("id"); proteinAlias.setNotes("text"); parser.processNotes(node.getFirstChild(), proteinAlias); String notes = proteinAlias.getNotes(); @@ -141,7 +141,7 @@ public class RestAnnotationParserTest extends CellDesignerTestFunctions { RestAnnotationParser parser = new RestAnnotationParser(); Document node = getXmlDocumentFromFile("testFiles/xmlNodeTestExamples/notes2.xml"); - GenericProteinAlias protein = new GenericProteinAlias("pr_id1"); + GenericProtein protein = new GenericProtein("pr_id1"); protein.addSynonym("a1"); protein.addFormerSymbol("a1"); protein.setFullName("yyy"); @@ -166,7 +166,7 @@ public class RestAnnotationParserTest extends CellDesignerTestFunctions { RestAnnotationParser parser = new RestAnnotationParser(); Document node = getXmlDocumentFromFile("testFiles/xmlNodeTestExamples/notes_invalid_charge.xml"); - SpeciesAlias proteinAlias = new GenericProteinAlias("id"); + Species proteinAlias = new GenericProtein("id"); parser.processNotes(node.getFirstChild(), proteinAlias); assertEquals(1, getWarnings().size()); @@ -207,8 +207,8 @@ public class RestAnnotationParserTest extends CellDesignerTestFunctions { try { Model model = getModelForFile("testFiles/copyingAnnotationModel.xml"); - Set<Alias> elements = model.getAliases(); - for (Alias element : elements) { + Set<Element> elements = model.getAliases(); + for (Element element : elements) { if (element.getName().equals("blabla")) { assertEquals(2, element.getMiriamData().size()); element.getMiriamData().add(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.PUBMED, "12345")); @@ -228,7 +228,7 @@ public class RestAnnotationParserTest extends CellDesignerTestFunctions { public void testProcessRdfDescription() throws Exception { try { RestAnnotationParser rap = new RestAnnotationParser(); - SpeciesAlias speciesAlias = new GenericProteinAlias("id"); + Species speciesAlias = new GenericProtein("id"); speciesAlias.setNotes( "begining\n" + "<rdf:RDF>" + "<rdf:Description rdf:about=\"#s2157\">\n" + "<bqmodel:is>\n" + "<rdf:Bag>\n" + "<rdf:li rdf:resource=\"urn:miriam:obo.chebi:CHEBI%3A17515\"/>\n" + "</rdf:Bag>\n" + "</bqmodel:is>\n" + "</rdf:Description>\n" + "</rdf:RDF>" @@ -283,7 +283,7 @@ public class RestAnnotationParserTest extends CellDesignerTestFunctions { String former1 = "form1"; String former2 = "form2"; - GenericProteinAlias element = new GenericProteinAlias("id"); + GenericProtein element = new GenericProtein("id"); element.addFormerSymbol(former1); element.addFormerSymbol(former2); String str = rap.createAnnotationString(element); @@ -420,7 +420,7 @@ public class RestAnnotationParserTest extends CellDesignerTestFunctions { RestAnnotationParser parser = new RestAnnotationParser(); String str = super.readFile("testFiles/xmlNodeTestExamples/notes5.xml"); - parser.processNotes(str, new GenericProteinAlias("id")); + parser.processNotes(str, new GenericProtein("id")); assertEquals(1, getWarnings().size()); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/compartment/CompartmentCollectionXmlParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/compartment/CompartmentCollectionXmlParserTest.java index f85656e82b..caba87a708 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/compartment/CompartmentCollectionXmlParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/compartment/CompartmentCollectionXmlParserTest.java @@ -17,8 +17,8 @@ import org.w3c.dom.Node; 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.Compartment; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerCompartment; +import lcsb.mapviewer.model.map.compartment.Compartment; public class CompartmentCollectionXmlParserTest extends CellDesignerTestFunctions { static Logger logger = Logger.getLogger(CompartmentCollectionXmlParserTest.class); @@ -44,7 +44,7 @@ public class CompartmentCollectionXmlParserTest extends CellDesignerTestFunction String xmlString = readFile("testFiles/compartment/listOfCompartments.xml"); Node node = getNodeFromXmlString(xmlString); - List<Compartment> compartments = parser.parseXmlCompartmentCollection(node); + List<CellDesignerCompartment> compartments = parser.parseXmlCompartmentCollection(node); assertEquals(4, compartments.size()); @@ -75,10 +75,10 @@ public class CompartmentCollectionXmlParserTest extends CellDesignerTestFunction String xmlString = readFile("testFiles/compartment/listOfCompartments.xml"); Node node = getNodeFromXmlString(xmlString); - List<Compartment> compartments = parser.parseXmlCompartmentCollection(node); + List<CellDesignerCompartment> compartments = parser.parseXmlCompartmentCollection(node); - List<CompartmentAlias> aliases = new ArrayList<>(); - for (Compartment compartment : compartments) { + List<Compartment> aliases = new ArrayList<>(); + for (CellDesignerCompartment compartment : compartments) { aliases.add(compartment.createAlias("ca" + aliasIdCounter)); } @@ -87,10 +87,10 @@ public class CompartmentCollectionXmlParserTest extends CellDesignerTestFunction node = getNodeFromXmlString(xmlString2); - List<Compartment> compartments2 = parser.parseXmlCompartmentCollection(node); + List<CellDesignerCompartment> compartments2 = parser.parseXmlCompartmentCollection(node); for (int i = 0; i < compartments.size(); i++) { - Compartment compartmentA = compartments.get(i); - Compartment compartmentB = compartments2.get(i); + CellDesignerCompartment compartmentA = compartments.get(i); + CellDesignerCompartment compartmentB = compartments2.get(i); assertEquals(compartmentA.getName(), compartmentB.getName()); } diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/compartment/CompartmentXmlParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/compartment/CompartmentXmlParserTest.java index 2286da47dc..fd6c3adb9f 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/compartment/CompartmentXmlParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/compartment/CompartmentXmlParserTest.java @@ -23,8 +23,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.species.ProteinXmlParserTest; -import lcsb.mapviewer.converter.model.celldesigner.structure.Compartment; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerCompartment; +import lcsb.mapviewer.model.map.compartment.Compartment; public class CompartmentXmlParserTest extends CellDesignerTestFunctions { protected Logger logger = Logger.getLogger(ProteinXmlParserTest.class.getName()); @@ -48,8 +48,8 @@ public class CompartmentXmlParserTest extends CellDesignerTestFunctions { try { String xmlString = readFile(testProteinFile); - Pair<String, Compartment> result = compartmentParser.parseXmlElement(xmlString); - Compartment compartment = result.getRight(); + Pair<String, CellDesignerCompartment> result = compartmentParser.parseXmlElement(xmlString); + CellDesignerCompartment compartment = result.getRight(); assertNotNull(compartment); assertEquals("c1", compartment.getElementId()); assertEquals(1, compartment.getMiriamData().size()); @@ -66,9 +66,9 @@ public class CompartmentXmlParserTest extends CellDesignerTestFunctions { try { String xmlString = readFile(testProteinFile); - Pair<String, Compartment> result = compartmentParser.parseXmlElement(xmlString); - Compartment compartment = result.getRight(); - CompartmentAlias alias = compartment.createAlias("id"); + Pair<String, CellDesignerCompartment> result = compartmentParser.parseXmlElement(xmlString); + CellDesignerCompartment compartment = result.getRight(); + Compartment alias = compartment.createAlias("id"); String transformedXml = compartmentParser.toXml(alias); assertNotNull(transformedXml); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); @@ -78,8 +78,8 @@ public class CompartmentXmlParserTest extends CellDesignerTestFunctions { NodeList root = doc.getChildNodes(); assertEquals("compartment", root.item(0).getNodeName()); - Pair<String, Compartment> result2 = compartmentParser.parseXmlElement(compartmentParser.toXml(alias)); - Compartment compartment2 = result2.getRight(); + Pair<String, CellDesignerCompartment> result2 = compartmentParser.parseXmlElement(compartmentParser.toXml(alias)); + CellDesignerCompartment compartment2 = result2.getRight(); assertEquals(alias.getMiriamData().size(), compartment2.getMiriamData().size()); assertEquals(alias.getName(), compartment2.getName()); } catch (Exception e) { @@ -133,8 +133,8 @@ public class CompartmentXmlParserTest extends CellDesignerTestFunctions { @Test public void testToXmlWithParent() throws Exception { try { - CompartmentAlias child = new CompartmentAlias("c_1"); - CompartmentAlias parent = new CompartmentAlias("p_1"); + Compartment child = new Compartment("c_1"); + Compartment parent = new Compartment("p_1"); parent.setName("PARENTNAME"); child.setParent(parent); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AbstractCellDesignerAliasConverterTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AbstractCellDesignerAliasConverterTest.java index 6e7f4b63cb..a3d82e3f36 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AbstractCellDesignerAliasConverterTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AbstractCellDesignerAliasConverterTest.java @@ -17,21 +17,21 @@ import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerA import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerEllipseTransformation; import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerPolygonTransformation; import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerRectangleTransformation; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Species; public class AbstractCellDesignerAliasConverterTest { - AbstractCellDesignerAliasConverter<SpeciesAlias> converter = new AbstractCellDesignerAliasConverter<SpeciesAlias>() { + AbstractCellDesignerAliasConverter<Species> converter = new AbstractCellDesignerAliasConverter<Species>() { @Override - public Point2D getPointCoordinates(SpeciesAlias alias, CellDesignerAnchor anchor) { + public Point2D getPointCoordinates(Species alias, CellDesignerAnchor anchor) { return null; } @Override - protected PathIterator getBoundPathIterator(SpeciesAlias alias) { + protected PathIterator getBoundPathIterator(Species alias) { return null; } }; @@ -53,7 +53,7 @@ public class AbstractCellDesignerAliasConverterTest { EventStorageLoggerAppender appender = new EventStorageLoggerAppender(); Logger.getRootLogger().addAppender(appender); try { - ProteinAlias alias = new GenericProteinAlias("id"); + Protein alias = new GenericProtein("id"); alias.setWidth(1); alias.setHeight(1); converter.getAnchorPointCoordinates(alias, 0); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AntisenseRnaCellDesignerAliasConverterTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AntisenseRnaCellDesignerAliasConverterTest.java index 44b126517b..b9f94cbb14 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AntisenseRnaCellDesignerAliasConverterTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AntisenseRnaCellDesignerAliasConverterTest.java @@ -11,10 +11,10 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class AntisenseRnaCellDesignerAliasConverterTest { AntisenseRnaCellDesignerAliasConverter converter = new AntisenseRnaCellDesignerAliasConverter(); @@ -35,7 +35,7 @@ public class AntisenseRnaCellDesignerAliasConverterTest { public void testGetPointCoordinatesForSbgn() { Model model = new ModelFullIndexed(null); model.setSbgnFormat(true); - SpeciesAlias alias = new GenericProteinAlias("id"); + Species alias = new GenericProtein("id"); alias.setWidth(10); alias.setHeight(10); alias.setModel(model); @@ -47,7 +47,7 @@ public class AntisenseRnaCellDesignerAliasConverterTest { public void testGetAntisenseRnaPathForSbgn() { Model model = new ModelFullIndexed(null); model.setSbgnFormat(true); - SpeciesAlias alias = new GenericProteinAlias("id"); + Species alias = new GenericProtein("id"); alias.setWidth(10); alias.setHeight(10); alias.setModel(model); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/CellDesignerAliasConverterTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/CellDesignerAliasConverterTest.java index 0d43ab1fa2..559e5c7ccc 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/CellDesignerAliasConverterTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/CellDesignerAliasConverterTest.java @@ -10,7 +10,7 @@ import org.junit.Test; import org.mockito.Mockito; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Species; public class CellDesignerAliasConverterTest { @@ -39,7 +39,7 @@ public class CellDesignerAliasConverterTest { @Test public void testConstructorWithInvalidArg2() { try { - SpeciesAlias alias = Mockito.mock(SpeciesAlias.class); + Species alias = Mockito.mock(Species.class); new CellDesignerAliasConverter(alias); fail("Exception expected"); } catch (InvalidArgumentException e) { diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/DegradedCellDesignerAliasConverterTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/DegradedCellDesignerAliasConverterTest.java index cb170f67bb..b62b4ffd3c 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/DegradedCellDesignerAliasConverterTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/DegradedCellDesignerAliasConverterTest.java @@ -11,8 +11,8 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.DegradedAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Degraded; +import lcsb.mapviewer.model.map.species.Species; public class DegradedCellDesignerAliasConverterTest { @@ -32,7 +32,7 @@ public class DegradedCellDesignerAliasConverterTest { @Test public void testGetAnchorPointCoordinatesForInvalidAlias() { - DegradedAlias alias = new DegradedAlias("id"); + Degraded alias = new Degraded("id"); alias.setWidth(-1); Point2D point = converter.getAnchorPointCoordinates(alias, 0); assertNotNull(point); @@ -40,7 +40,7 @@ public class DegradedCellDesignerAliasConverterTest { @Test public void testGetAnchorPointCoordinatesForInvalidAlias2() { - SpeciesAlias alias = new DegradedAlias("id"); + Species alias = new Degraded("id"); Point2D point = converter.getAnchorPointCoordinates(alias, 0); assertNotNull(point); } diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/GeneCellDesignerAliasConverterTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/GeneCellDesignerAliasConverterTest.java index 7c9ac6426b..67a112af5f 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/GeneCellDesignerAliasConverterTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/GeneCellDesignerAliasConverterTest.java @@ -9,10 +9,10 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.Species; public class GeneCellDesignerAliasConverterTest { @@ -32,7 +32,7 @@ public class GeneCellDesignerAliasConverterTest { @Test public void testGetInvalidAliasPointCoordinates() { - SpeciesAlias alias = new GeneAlias("id"); + Species alias = new Gene("id"); alias.setX(1); alias.setY(12); alias.setWidth(10); @@ -43,7 +43,7 @@ public class GeneCellDesignerAliasConverterTest { @Test public void testGetPath() { Model model = new ModelFullIndexed(null); - SpeciesAlias alias = new GeneAlias("id"); + Species alias = new Gene("id"); alias.setX(1); alias.setY(12); alias.setWidth(10); @@ -59,7 +59,7 @@ public class GeneCellDesignerAliasConverterTest { public void testGetPath2() { Model model = new ModelFullIndexed(null); model.setSbgnFormat(true); - SpeciesAlias alias = new GeneAlias("id"); + Species alias = new Gene("id"); alias.setX(1); alias.setY(12); alias.setWidth(10); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/IonCellDesignerAliasConverterTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/IonCellDesignerAliasConverterTest.java index 38bf992ff3..c43dd83f5e 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/IonCellDesignerAliasConverterTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/IonCellDesignerAliasConverterTest.java @@ -11,8 +11,8 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.IonAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Ion; +import lcsb.mapviewer.model.map.species.Species; public class IonCellDesignerAliasConverterTest { @@ -32,7 +32,7 @@ public class IonCellDesignerAliasConverterTest { @Test public void testGetAnchorPointCoordinatesForInvalidAlias() { - SpeciesAlias alias = new IonAlias("id"); + Species alias = new Ion("id"); alias.setWidth(-1); Point2D point = converter.getAnchorPointCoordinates(alias, 0); assertNotNull(point); @@ -40,7 +40,7 @@ public class IonCellDesignerAliasConverterTest { @Test public void testGetAnchorPointCoordinatesForInvalidAlias2() { - SpeciesAlias alias = new IonAlias("id"); + Species alias = new Ion("id"); Point2D point = converter.getAnchorPointCoordinates(alias, 0); assertNotNull(point); } diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/ProteinCellDesignerAliasConverterTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/ProteinCellDesignerAliasConverterTest.java index e1c0b73dca..53505a973f 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/ProteinCellDesignerAliasConverterTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/ProteinCellDesignerAliasConverterTest.java @@ -9,7 +9,7 @@ import org.junit.Test; import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; +import lcsb.mapviewer.model.map.species.Protein; public class ProteinCellDesignerAliasConverterTest { @@ -30,7 +30,7 @@ public class ProteinCellDesignerAliasConverterTest { @Test public void testNotImplementedMethod() { try { - ProteinAlias alias = Mockito.mock(ProteinAlias.class); + Protein alias = Mockito.mock(Protein.class); converter.getBoundPathIterator(alias); } catch (NotImplementedException e) { assertTrue(e.getMessage().contains("Not implemented protein converter for type")); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/ProteinConverterTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/ProteinConverterTest.java index 33169890e6..8d1ba4016a 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/ProteinConverterTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/ProteinConverterTest.java @@ -11,7 +11,7 @@ import org.junit.Test; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerTestFunctions; import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; +import lcsb.mapviewer.model.map.species.GenericProtein; public class ProteinConverterTest extends CellDesignerTestFunctions { static Logger logger = Logger.getLogger(ProteinConverterTest.class); @@ -28,7 +28,7 @@ public class ProteinConverterTest extends CellDesignerTestFunctions { public void testGetAnchorForAlias() throws Exception { try { - GenericProteinAlias alias = new GenericProteinAlias("id"); + GenericProtein alias = new GenericProtein("id"); alias.setWidth(200); alias.setHeight(300); alias.setX(100.0); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/RnaCellDesignerAliasConverterTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/RnaCellDesignerAliasConverterTest.java index 0441df9efe..51dd5de673 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/RnaCellDesignerAliasConverterTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/RnaCellDesignerAliasConverterTest.java @@ -11,10 +11,10 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class RnaCellDesignerAliasConverterTest { RnaCellDesignerAliasConverter converter = new RnaCellDesignerAliasConverter(); @@ -35,7 +35,7 @@ public class RnaCellDesignerAliasConverterTest { public void testGetPointCoordinatesForSbgn() { Model model = new ModelFullIndexed(null); model.setSbgnFormat(true); - SpeciesAlias alias = new GenericProteinAlias("id"); + Species alias = new GenericProtein("id"); alias.setWidth(10); alias.setHeight(10); alias.setModel(model); @@ -47,7 +47,7 @@ public class RnaCellDesignerAliasConverterTest { public void testGetAntisebseRnaPathForSbgn() { Model model = new ModelFullIndexed(null); model.setSbgnFormat(true); - SpeciesAlias alias = new GenericProteinAlias("id"); + Species alias = new GenericProtein("id"); alias.setWidth(10); alias.setHeight(10); alias.setModel(model); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/SimpleMoleculeCellDesignerAliasConverterTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/SimpleMoleculeCellDesignerAliasConverterTest.java index b3ce0f3999..bf696af247 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/SimpleMoleculeCellDesignerAliasConverterTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/SimpleMoleculeCellDesignerAliasConverterTest.java @@ -14,10 +14,10 @@ import org.junit.Test; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.SimpleMolecule; +import lcsb.mapviewer.model.map.species.Species; public class SimpleMoleculeCellDesignerAliasConverterTest { @@ -49,7 +49,7 @@ public class SimpleMoleculeCellDesignerAliasConverterTest { public void testGetSbgnPointCoordinates() { Model model = new ModelFullIndexed(null); model.setSbgnFormat(true); - SpeciesAlias alias = new SimpleMoleculeAlias("id"); + Species alias = new SimpleMolecule("id"); alias.setX(4); alias.setY(5); alias.setWidth(6); @@ -65,7 +65,7 @@ public class SimpleMoleculeCellDesignerAliasConverterTest { public void testGetSbgnAnchorPointCoordinates() { Model model = new ModelFullIndexed(null); model.setSbgnFormat(true); - SpeciesAlias alias = new SimpleMoleculeAlias("id"); + Species alias = new SimpleMolecule("id"); alias.setX(4); alias.setY(5); alias.setWidth(6); @@ -81,7 +81,7 @@ public class SimpleMoleculeCellDesignerAliasConverterTest { public void testGetAnchorPointCoordinatesForEmptyAlias() { Model model = new ModelFullIndexed(null); model.setSbgnFormat(true); - SpeciesAlias alias = new SimpleMoleculeAlias("id"); + Species alias = new SimpleMolecule("id"); alias.setX(4); alias.setY(5); alias.setWidth(0); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/UnknownCellDesignerAliasConverterTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/UnknownCellDesignerAliasConverterTest.java index 4630f2acd9..d6c5a8a117 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/UnknownCellDesignerAliasConverterTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/geometry/UnknownCellDesignerAliasConverterTest.java @@ -11,8 +11,8 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class UnknownCellDesignerAliasConverterTest { UnknownCellDesignerAliasConverter converter = new UnknownCellDesignerAliasConverter(); @@ -40,7 +40,7 @@ public class UnknownCellDesignerAliasConverterTest { @Test public void testGetAnchorPointCoordinates() { - SpeciesAlias alias = new GenericProteinAlias("id"); + Species alias = new GenericProtein("id"); alias.setWidth(0); alias.setHeight(0); Point2D point = converter.getAnchorPointCoordinates(alias, 0); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionCollectionXmlParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionCollectionXmlParserTest.java index 1f606a0f4c..269ea1ad7b 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionCollectionXmlParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionCollectionXmlParserTest.java @@ -14,11 +14,11 @@ import org.w3c.dom.Node; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerTestFunctions; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class ReactionCollectionXmlParserTest extends CellDesignerTestFunctions { Logger logger = Logger.getLogger(ReactionCollectionXmlParserTest.class); @@ -99,84 +99,84 @@ public class ReactionCollectionXmlParserTest extends CellDesignerTestFunctions { private Model getModelFilledWithSpecies() { Model model = new ModelFullIndexed(null); - SpeciesAlias sa1 = new GenericProteinAlias("sa1"); + Species sa1 = new GenericProtein("sa1"); sa1.setX(100.0); sa1.setY(200.0); sa1.setWidth(300.0); sa1.setHeight(400.0); model.addAlias(sa1); - SpeciesAlias sa2 = new GenericProteinAlias("sa2"); + Species sa2 = new GenericProtein("sa2"); sa2.setX(1050.0); sa2.setY(2050.0); sa2.setWidth(300.0); sa2.setHeight(450.0); model.addAlias(sa2); - SpeciesAlias sa3 = new GenericProteinAlias("sa3"); + Species sa3 = new GenericProtein("sa3"); sa3.setX(600.0); sa3.setY(250.0); sa3.setWidth(300.0); sa3.setHeight(400.0); model.addAlias(sa3); - SpeciesAlias sa4 = new GenericProteinAlias("sa4"); + Species sa4 = new GenericProtein("sa4"); sa4.setX(550.0); sa4.setY(350.0); sa4.setWidth(300.0); sa4.setHeight(450.0); model.addAlias(sa4); - SpeciesAlias sa5 = new GenericProteinAlias("sa5"); + Species sa5 = new GenericProtein("sa5"); sa5.setX(10.0); sa5.setY(250.0); sa5.setWidth(300.0); sa5.setHeight(450.0); model.addAlias(sa5); - SpeciesAlias sa6 = new GenericProteinAlias("sa6"); + Species sa6 = new GenericProtein("sa6"); sa6.setX(10.0); sa6.setY(250.0); sa6.setWidth(300.0); sa6.setHeight(450.0); model.addAlias(sa6); - SpeciesAlias sa10 = new GenericProteinAlias("sa10"); + Species sa10 = new GenericProtein("sa10"); sa10.setX(210.0); sa10.setY(220.0); sa10.setWidth(320.0); sa10.setHeight(250.0); model.addAlias(sa10); - SpeciesAlias sa11 = new GenericProteinAlias("sa11"); + Species sa11 = new GenericProtein("sa11"); sa11.setX(11.0); sa11.setY(320.0); sa11.setWidth(321.0); sa11.setHeight(150.0); model.addAlias(sa11); - SpeciesAlias sa12 = new GenericProteinAlias("sa12"); + Species sa12 = new GenericProtein("sa12"); sa12.setX(12.0); sa12.setY(20.0); sa12.setWidth(321.0); sa12.setHeight(150.0); model.addAlias(sa12); - SpeciesAlias sa13 = new GenericProteinAlias("sa13"); + Species sa13 = new GenericProtein("sa13"); sa13.setX(513.0); sa13.setY(20.0); sa13.setWidth(321.0); sa13.setHeight(150.0); model.addAlias(sa13); - SpeciesAlias sa14 = new GenericProteinAlias("sa14"); + Species sa14 = new GenericProtein("sa14"); sa14.setX(14.0); sa14.setY(820.0); sa14.setWidth(321.0); sa14.setHeight(150.0); model.addAlias(sa14); - SpeciesAlias sa15 = new GenericProteinAlias("sa15"); + Species sa15 = new GenericProtein("sa15"); sa15.setX(815.0); sa15.setY(620.0); sa15.setWidth(321.0); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionFromXmlTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionFromXmlTest.java index 3c89a78565..9e568dd336 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionFromXmlTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionFromXmlTest.java @@ -11,9 +11,7 @@ import org.junit.Test; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerTestFunctions; -import lcsb.mapviewer.converter.model.celldesigner.structure.GenericProtein; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerGenericProtein; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; import lcsb.mapviewer.model.map.reaction.Product; @@ -21,6 +19,8 @@ import lcsb.mapviewer.model.map.reaction.Reactant; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.type.TwoProductReactionInterface; import lcsb.mapviewer.model.map.reaction.type.TwoReactantReactionInterface; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class ReactionFromXmlTest extends CellDesignerTestFunctions { ReactionXmlParser parser; @@ -37,22 +37,22 @@ public class ReactionFromXmlTest extends CellDesignerTestFunctions { elements = new CellDesignerElementCollection(); parser = new ReactionXmlParser(elements); - SpeciesAlias alias = new GenericProteinAlias("sa1"); + Species alias = new GenericProtein("sa1"); model.addAlias(alias); - alias = new GenericProteinAlias("sa2"); + alias = new GenericProtein("sa2"); model.addAlias(alias); - alias = new GenericProteinAlias("sa3"); + alias = new GenericProtein("sa3"); model.addAlias(alias); - alias = new GenericProteinAlias("sa4"); + alias = new GenericProtein("sa4"); model.addAlias(alias); - elements.addElement(new GenericProtein("s1")); - elements.addElement(new GenericProtein("s2")); - elements.addElement(new GenericProtein("s3")); - elements.addElement(new GenericProtein("s4")); + elements.addElement(new CellDesignerGenericProtein("s1")); + elements.addElement(new CellDesignerGenericProtein("s2")); + elements.addElement(new CellDesignerGenericProtein("s3")); + elements.addElement(new CellDesignerGenericProtein("s4")); } @After 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 aa91b51a14..a0fe14ccff 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 @@ -22,14 +22,10 @@ import lcsb.mapviewer.converter.ConverterParams; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerTestFunctions; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser; -import lcsb.mapviewer.converter.model.celldesigner.structure.GenericProtein; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerGenericProtein; import lcsb.mapviewer.model.graphics.ArrowType; import lcsb.mapviewer.model.graphics.LineType; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelComparator; import lcsb.mapviewer.model.map.model.ModelFullIndexed; @@ -56,6 +52,10 @@ import lcsb.mapviewer.model.map.reaction.type.TranscriptionReaction; import lcsb.mapviewer.model.map.reaction.type.TranslationReaction; import lcsb.mapviewer.model.map.reaction.type.TransportReaction; import lcsb.mapviewer.model.map.reaction.type.TruncationReaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Species; public class ReactionParserTests extends CellDesignerTestFunctions { @@ -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 GenericProteinAlias); + assertTrue(model.getAliasByAliasId("sa5003") instanceof GenericProtein); Set<Reaction> list = model.getReactions(); for (Reaction reaction : list) { // reaction re1607 in this model was problematic, but in fact the @@ -739,8 +739,8 @@ public class ReactionParserTests extends CellDesignerTestFunctions { reaction2 = reaction; } Reactant reactant = reaction1.getReactants().get(0); - Alias alias1 = reaction1.getReactants().get(0).getAlias(); - Alias alias2 = reaction1.getProducts().get(0).getAlias(); + Element alias1 = reaction1.getReactants().get(0).getAlias(); + Element alias2 = reaction1.getProducts().get(0).getAlias(); Product product = reaction1.getProducts().get(0); Point2D point = new Point2D.Double(alias1.getX() + alias1.getWidth() / 2, alias1.getY() + alias1.getHeight()); Point2D point2 = new Point2D.Double(alias2.getX(), alias2.getY() + alias2.getHeight() / 2); @@ -1545,102 +1545,102 @@ public class ReactionParserTests extends CellDesignerTestFunctions { private Model getModelFilledWithSpecies() { Model model = new ModelFullIndexed(null); - SpeciesAlias sa1 = new GenericProteinAlias("sa1"); + Species sa1 = new GenericProtein("sa1"); sa1.setX(100.0); sa1.setY(200.0); sa1.setWidth(300.0); sa1.setHeight(400.0); model.addAlias(sa1); - elements.addAlias(sa1, new GenericProtein("s1")); + elements.addAlias(sa1, new CellDesignerGenericProtein("s1")); - SpeciesAlias sa2 = new GenericProteinAlias("sa2"); + Species sa2 = new GenericProtein("sa2"); sa2.setX(1050.0); sa2.setY(2050.0); sa2.setWidth(300.0); sa2.setHeight(450.0); model.addAlias(sa2); - elements.addAlias(sa2, new GenericProtein("s2")); + elements.addAlias(sa2, new CellDesignerGenericProtein("s2")); - SpeciesAlias sa3 = new GenericProteinAlias("sa3"); + Species sa3 = new GenericProtein("sa3"); sa3.setX(600.0); sa3.setY(250.0); sa3.setWidth(300.0); sa3.setHeight(400.0); model.addAlias(sa3); - elements.addAlias(sa3, new GenericProtein("s3")); + elements.addAlias(sa3, new CellDesignerGenericProtein("s3")); - SpeciesAlias sa4 = new GenericProteinAlias("sa4"); + Species sa4 = new GenericProtein("sa4"); sa4.setX(550.0); sa4.setY(350.0); sa4.setWidth(300.0); sa4.setHeight(450.0); model.addAlias(sa4); - elements.addElement(new GenericProtein("s4")); + elements.addElement(new CellDesignerGenericProtein("s4")); - SpeciesAlias sa5 = new GenericProteinAlias("sa5"); + Species sa5 = new GenericProtein("sa5"); sa5.setX(10.0); sa5.setY(250.0); sa5.setWidth(300.0); sa5.setHeight(450.0); model.addAlias(sa5); - elements.addElement(new GenericProtein("s5")); + elements.addElement(new CellDesignerGenericProtein("s5")); - SpeciesAlias sa6 = new GenericProteinAlias("sa6"); + Species sa6 = new GenericProtein("sa6"); sa6.setX(10.0); sa6.setY(250.0); sa6.setWidth(300.0); sa6.setHeight(450.0); model.addAlias(sa6); - elements.addElement(new GenericProtein("s6")); + elements.addElement(new CellDesignerGenericProtein("s6")); - SpeciesAlias sa10 = new GenericProteinAlias("sa10"); + Species sa10 = new GenericProtein("sa10"); sa10.setX(210.0); sa10.setY(220.0); sa10.setWidth(320.0); sa10.setHeight(250.0); model.addAlias(sa10); - elements.addElement(new GenericProtein("s10")); + elements.addElement(new CellDesignerGenericProtein("s10")); - SpeciesAlias sa11 = new GenericProteinAlias("sa11"); + Species sa11 = new GenericProtein("sa11"); sa11.setX(11.0); sa11.setY(320.0); sa11.setWidth(321.0); sa11.setHeight(150.0); model.addAlias(sa11); - elements.addElement(new GenericProtein("s11")); + elements.addElement(new CellDesignerGenericProtein("s11")); - SpeciesAlias sa12 = new GenericProteinAlias("sa12"); + Species sa12 = new GenericProtein("sa12"); sa12.setX(12.0); sa12.setY(20.0); sa12.setWidth(321.0); sa12.setHeight(150.0); model.addAlias(sa12); - elements.addElement(new GenericProtein("s12")); + elements.addElement(new CellDesignerGenericProtein("s12")); - SpeciesAlias sa13 = new GenericProteinAlias("sa13"); + Species sa13 = new GenericProtein("sa13"); sa13.setX(513.0); sa13.setY(20.0); sa13.setWidth(321.0); sa13.setHeight(150.0); model.addAlias(sa13); - elements.addElement(new GenericProtein("s13")); + elements.addElement(new CellDesignerGenericProtein("s13")); - SpeciesAlias sa14 = new GenericProteinAlias("sa14"); + Species sa14 = new GenericProtein("sa14"); sa14.setX(14.0); sa14.setY(820.0); sa14.setWidth(321.0); sa14.setHeight(150.0); model.addAlias(sa14); - elements.addElement(new GenericProtein("s14")); + elements.addElement(new CellDesignerGenericProtein("s14")); - SpeciesAlias sa15 = new GenericProteinAlias("sa15"); + Species sa15 = new GenericProtein("sa15"); sa15.setX(815.0); sa15.setY(620.0); sa15.setWidth(321.0); sa15.setHeight(150.0); model.addAlias(sa15); - elements.addElement(new GenericProtein("s15")); + elements.addElement(new CellDesignerGenericProtein("s15")); return model; } @@ -1785,8 +1785,8 @@ public class ReactionParserTests extends CellDesignerTestFunctions { public void testProteinsInsideComplex() throws Exception { try { Model model = getModelForFile("testFiles/problematic/proteins_inside_complex.xml"); - for (Alias el : model.getAliases()) { - assertFalse(el.getClass().equals(ProteinAlias.class)); + for (Element el : model.getAliases()) { + assertFalse(el.getClass().equals(Protein.class)); } } catch (Exception e) { e.printStackTrace(); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionToXmlTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionToXmlTest.java index efc1a6ca89..09d2068026 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionToXmlTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionToXmlTest.java @@ -18,9 +18,6 @@ import lcsb.mapviewer.common.EventStorageLoggerAppender; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; import lcsb.mapviewer.model.map.modifier.Catalysis; @@ -32,6 +29,9 @@ import lcsb.mapviewer.model.map.reaction.Reactant; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.type.DissociationReaction; import lcsb.mapviewer.model.map.reaction.type.TransportReaction; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class ReactionToXmlTest { Logger logger = Logger.getLogger(ReactionToXmlTest.class); @@ -56,7 +56,7 @@ public class ReactionToXmlTest { @Test public void testInvalidModification() { Model model = new ModelFullIndexed(null); - SpeciesAlias alias = new GenericProteinAlias("2"); + Species alias = new GenericProtein("2"); model.addAlias(alias); @@ -113,11 +113,11 @@ public class ReactionToXmlTest { public void testModificationFromInsideComplex() { Model model = new ModelFullIndexed(null); - SpeciesAlias alias = new GenericProteinAlias("2"); + Species alias = new GenericProtein("2"); model.addAlias(alias); - ComplexAlias complex = new ComplexAlias("4"); + Complex complex = new Complex("4"); complex.addAlias(alias); alias.setParent(complex); @@ -150,7 +150,7 @@ public class ReactionToXmlTest { public void testInvalidReaction() { Model model = new ModelFullIndexed(null); - SpeciesAlias alias = new GenericProteinAlias("2"); + Species alias = new GenericProtein("2"); model.addAlias(alias); 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 7fec98632d..d89c8ac115 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 @@ -21,9 +21,9 @@ import lcsb.mapviewer.common.Pair; 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.AntisenseRna; -import lcsb.mapviewer.converter.model.celldesigner.structure.AntisenseRnaRegion; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaRegionAlias.AntisenseRnaRegionType; +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; public class AntisenseRnaXmlParserTest extends CellDesignerTestFunctions { protected Logger logger = Logger.getLogger(AntisenseRnaXmlParserTest.class.getName()); @@ -47,13 +47,13 @@ public class AntisenseRnaXmlParserTest extends CellDesignerTestFunctions { public void testParseXmlSpecies() throws Exception { try { String xmlString = readFile(testAntisenseRnaFile); - Pair<String, AntisenseRna> result = antisenseRnaParser.parseXmlElement(xmlString); - AntisenseRna antisenseRna = result.getRight(); + Pair<String, CellDesignerAntisenseRna> result = antisenseRnaParser.parseXmlElement(xmlString); + CellDesignerAntisenseRna antisenseRna = result.getRight(); assertEquals("arn1", result.getLeft()); assertEquals("s1", antisenseRna.getName()); assertTrue(antisenseRna.getNotes().contains("some notes")); assertEquals(1, antisenseRna.getRegions().size()); - AntisenseRnaRegion region = antisenseRna.getRegions().get(0); + CellDesignerAntisenseRnaRegion region = antisenseRna.getRegions().get(0); assertEquals("tr1", region.getIdAntisenseRnaRegion()); assertEquals("zzz", region.getName()); assertEquals(0.3, region.getSize(), 1e-6); @@ -125,8 +125,8 @@ public class AntisenseRnaXmlParserTest extends CellDesignerTestFunctions { public void testToXml() throws Exception { try { String xmlString = readFile(testAntisenseRnaFile); - Pair<String, AntisenseRna> result = antisenseRnaParser.parseXmlElement(xmlString); - AntisenseRna antisenseRna = result.getRight(); + Pair<String, CellDesignerAntisenseRna> result = antisenseRnaParser.parseXmlElement(xmlString); + CellDesignerAntisenseRna antisenseRna = result.getRight(); String transformedXml = antisenseRnaParser.toXml(antisenseRna.createAlias()); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); @@ -136,15 +136,15 @@ public class AntisenseRnaXmlParserTest extends CellDesignerTestFunctions { NodeList root = doc.getChildNodes(); assertEquals("celldesigner:AntisenseRNA", root.item(0).getNodeName()); - Pair<String, AntisenseRna> result2 = antisenseRnaParser.parseXmlElement(xmlString); - AntisenseRna antisenseRna2 = result2.getRight(); + Pair<String, CellDesignerAntisenseRna> result2 = antisenseRnaParser.parseXmlElement(xmlString); + CellDesignerAntisenseRna antisenseRna2 = result2.getRight(); assertEquals(result.getLeft(), result2.getLeft()); assertEquals(antisenseRna.getName(), antisenseRna2.getName()); assertEquals(antisenseRna.getNotes().trim(), antisenseRna2.getNotes().trim()); assertEquals(1, antisenseRna2.getRegions().size()); - AntisenseRnaRegion region = antisenseRna.getRegions().get(0); - AntisenseRnaRegion region2 = antisenseRna2.getRegions().get(0); + CellDesignerAntisenseRnaRegion region = antisenseRna.getRegions().get(0); + CellDesignerAntisenseRnaRegion region2 = antisenseRna2.getRegions().get(0); assertEquals(region.getIdAntisenseRnaRegion(), region2.getIdAntisenseRnaRegion()); assertEquals(region.getName(), region2.getName()); assertEquals(region.getSize(), region2.getSize(), 1e-6); 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 7cb2a41be7..fbaa3f2481 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 @@ -22,12 +22,12 @@ 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.alias.ComplexAliasXmlParser; -import lcsb.mapviewer.converter.model.celldesigner.structure.ComplexSpecies; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerComplexSpecies; +import lcsb.mapviewer.model.map.compartment.Compartment; 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.Complex; public class ComplexParserTest extends CellDesignerTestFunctions { Logger logger = Logger.getLogger(ComplexParserTest.class); @@ -54,7 +54,7 @@ public class ComplexParserTest extends CellDesignerTestFunctions { public void testComplexState() throws Exception { try { Model model = getModelForFile("testFiles/problematic/complex_with_state.xml"); - ComplexAlias complex = (ComplexAlias) model.getAliasByAliasId("csa1"); + Complex complex = (Complex) model.getAliasByAliasId("csa1"); assertEquals("test state", complex.getStructuralState()); } catch (Exception e) { e.printStackTrace(); @@ -83,7 +83,7 @@ public class ComplexParserTest extends CellDesignerTestFunctions { public void testParseInvalidInputNode2() throws Exception { try { Model model = new ModelFullIndexed(null); - ComplexSpecies element = new ComplexSpecies(); + CellDesignerComplexSpecies element = new CellDesignerComplexSpecies(); element.setElementId("s3"); elements.addElement(element); ComplexAliasXmlParser parser = new ComplexAliasXmlParser(elements, model); @@ -103,7 +103,7 @@ public class ComplexParserTest extends CellDesignerTestFunctions { public void testParseInvalidInputNode3() throws Exception { try { Model model = new ModelFullIndexed(null); - ComplexSpecies element = new ComplexSpecies(); + CellDesignerComplexSpecies element = new CellDesignerComplexSpecies(); element.setElementId("s3"); elements.addElement(element); ComplexAliasXmlParser parser = new ComplexAliasXmlParser(elements, model); @@ -123,7 +123,7 @@ public class ComplexParserTest extends CellDesignerTestFunctions { public void testParseInvalidInputNode4() throws Exception { try { Model model = new ModelFullIndexed(null); - ComplexSpecies element = new ComplexSpecies(); + CellDesignerComplexSpecies element = new CellDesignerComplexSpecies(); element.setElementId("s3"); elements.addElement(element); ComplexAliasXmlParser parser = new ComplexAliasXmlParser(elements, model); @@ -143,7 +143,7 @@ public class ComplexParserTest extends CellDesignerTestFunctions { public void testParseInvalidInputNode5() throws Exception { try { Model model = new ModelFullIndexed(null); - ComplexSpecies element = new ComplexSpecies(); + CellDesignerComplexSpecies element = new CellDesignerComplexSpecies(); element.setElementId("s3"); elements.addElement(element); ComplexAliasXmlParser parser = new ComplexAliasXmlParser(elements, model); @@ -164,9 +164,9 @@ public class ComplexParserTest extends CellDesignerTestFunctions { try { Model model = new ModelFullIndexed(null); - CompartmentAlias ca = new CompartmentAlias(testCompartmentAliasId); + Compartment ca = new Compartment(testCompartmentAliasId); - ComplexAlias alias = new ComplexAlias(testAliasId); + Complex alias = new Complex(testAliasId); alias.setParent(ca); @@ -189,9 +189,9 @@ public class ComplexParserTest extends CellDesignerTestFunctions { try { Model model = new ModelFullIndexed(null); - CompartmentAlias ca = new CompartmentAlias(testCompartmentAliasId); + Compartment ca = new Compartment(testCompartmentAliasId); - ComplexAlias alias = new ComplexAlias(testAliasId); + Complex alias = new Complex(testAliasId); alias.setCompartmentAlias(ca); @@ -216,19 +216,19 @@ public class ComplexParserTest extends CellDesignerTestFunctions { ModelData md = new ModelData(); md.setModel(model); - CompartmentAlias ca2 = new CompartmentAlias(testCompartmentAliasId2); + Compartment ca2 = new Compartment(testCompartmentAliasId2); ca2.setX(6); ca2.setY(6); ca2.setWidth(190); ca2.setHeight(190); - CompartmentAlias ca = new CompartmentAlias(testCompartmentAliasId); + Compartment ca = new Compartment(testCompartmentAliasId); ca.setX(5); ca.setY(5); ca.setWidth(200); ca.setHeight(200); - List<CompartmentAlias> list = new ArrayList<>(); + List<Compartment> list = new ArrayList<>(); list.add(ca); list.add(ca2); @@ -236,7 +236,7 @@ public class ComplexParserTest extends CellDesignerTestFunctions { when(model.getCompartmentsAliases()).thenReturn(list); when(model.getModelData()).thenReturn(md); - ComplexAlias alias = new ComplexAlias(testAliasId); + Complex alias = new Complex(testAliasId); alias.setX(10); alias.setY(10); alias.setWidth(100); @@ -262,9 +262,9 @@ public class ComplexParserTest extends CellDesignerTestFunctions { try { Model model = new ModelFullIndexed(null); - ComplexAlias ca = new ComplexAlias(testCompartmentAliasId); + Complex ca = new Complex(testCompartmentAliasId); - ComplexAlias alias = new ComplexAlias(testAliasId); + Complex alias = new Complex(testAliasId); alias.setParent(ca); @@ -287,7 +287,7 @@ public class ComplexParserTest extends CellDesignerTestFunctions { try { Model model = new ModelFullIndexed(null); - ComplexAlias alias = new ComplexAlias(testAliasId); + Complex alias = new Complex(testAliasId); alias.setActivity(true); @@ -309,13 +309,13 @@ public class ComplexParserTest extends CellDesignerTestFunctions { public void testAddInvalidReference() throws Exception { try { Model model = new ModelFullIndexed(null); - ComplexSpecies element = new ComplexSpecies(); + CellDesignerComplexSpecies element = new CellDesignerComplexSpecies(); element.setElementId("s2"); elements.addElement(element); ComplexAliasXmlParser parser = new ComplexAliasXmlParser(elements, model); - ComplexAlias child = parser.parseXmlAlias(readFile("testFiles/xmlNodeTestExamples/cd_complex_alias_with_parent.xml")); + Complex child = parser.parseXmlAlias(readFile("testFiles/xmlNodeTestExamples/cd_complex_alias_with_parent.xml")); parser.addReference(child); fail("Exception expected"); @@ -332,12 +332,12 @@ public class ComplexParserTest extends CellDesignerTestFunctions { public void testParseWithEmptyState() throws Exception { try { Model model = new ModelFullIndexed(null); - ComplexSpecies element = new ComplexSpecies("s2597"); + CellDesignerComplexSpecies element = new CellDesignerComplexSpecies("s2597"); elements.addElement(element); ComplexAliasXmlParser parser = new ComplexAliasXmlParser(elements, model); - ComplexAlias child = parser.parseXmlAlias(readFile("testFiles/xmlNodeTestExamples/cd_complex_alias_with_empty_state.xml")); + Complex child = parser.parseXmlAlias(readFile("testFiles/xmlNodeTestExamples/cd_complex_alias_with_empty_state.xml")); assertNotNull(child); assertNull(child.getAliasStateLabel()); 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 f36a847416..6bbec67745 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 @@ -22,11 +22,11 @@ import lcsb.mapviewer.common.Pair; 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.Gene; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationResidueAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerGene; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; +import lcsb.mapviewer.model.map.species.field.ModificationState; public class GeneXmlParserTest extends CellDesignerTestFunctions { Logger logger = Logger.getLogger(GeneXmlParserTest.class.getName()); @@ -51,8 +51,8 @@ public class GeneXmlParserTest extends CellDesignerTestFunctions { public void testParseXmlSpecies() { try { String xmlString = readFile(testGeneFile); - Pair<String, Gene> result = geneParser.parseXmlElement(xmlString); - Gene gene = result.getRight(); + Pair<String, CellDesignerGene> result = geneParser.parseXmlElement(xmlString); + CellDesignerGene gene = result.getRight(); assertEquals("gn3", result.getLeft()); assertEquals("BCL6", gene.getName()); assertTrue(gene.getNotes().contains("B-cell CLL/lymphoma 6")); @@ -66,8 +66,8 @@ public class GeneXmlParserTest extends CellDesignerTestFunctions { public void testToXml() throws Exception { try { String xmlString = readFile(testGeneFile); - Pair<String, Gene> result = geneParser.parseXmlElement(xmlString); - Gene gene = result.getRight(); + Pair<String, CellDesignerGene> result = geneParser.parseXmlElement(xmlString); + CellDesignerGene gene = result.getRight(); String transformedXml = geneParser.toXml(gene.createAlias()); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); @@ -76,8 +76,8 @@ public class GeneXmlParserTest extends CellDesignerTestFunctions { NodeList root = doc.getChildNodes(); assertEquals("celldesigner:gene", root.item(0).getNodeName()); - Pair<String, Gene> result2 = geneParser.parseXmlElement(geneParser.toXml(gene.createAlias())); - Gene gene2 = result2.getRight(); + Pair<String, CellDesignerGene> result2 = geneParser.parseXmlElement(geneParser.toXml(gene.createAlias())); + CellDesignerGene gene2 = result2.getRight(); assertEquals(gene.getName(), gene2.getName()); assertTrue(gene2.getNotes().trim().contains(gene.getNotes().trim())); } catch (Exception e) { @@ -90,9 +90,9 @@ public class GeneXmlParserTest extends CellDesignerTestFunctions { public void testParsePhosphorylatedGene() throws Exception { try { Model model = getModelForFile("testFiles/problematic/phosphorylated_gene.xml"); - GeneAlias gene = (GeneAlias) model.getAliasByAliasId("sa1"); + Gene gene = (Gene) model.getAliasByAliasId("sa1"); assertEquals(1, gene.getModificationResidues().size()); - ModificationResidueAlias residue = gene.getModificationResidues().get(0); + ModificationResidue residue = gene.getModificationResidues().get(0); assertEquals(ModificationState.PHOSPHORYLATED, residue.getState()); assertEquals("some name", residue.getName()); @@ -147,7 +147,7 @@ public class GeneXmlParserTest extends CellDesignerTestFunctions { @Test public void testModificationResidueToXml() throws Exception { try { - ModificationResidueAlias mr = new ModificationResidueAlias(); + ModificationResidue mr = new ModificationResidue(); mr.setIdModificationResidue("i"); mr.setName("a"); mr.setSide("2"); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/InternalModelSpeciesDataTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/InternalModelSpeciesDataTest.java index c3277a4455..314077d9dc 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/InternalModelSpeciesDataTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/InternalModelSpeciesDataTest.java @@ -10,7 +10,8 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; +import lcsb.mapviewer.model.map.species.GenericProtein; public class InternalModelSpeciesDataTest { @@ -40,7 +41,7 @@ public class InternalModelSpeciesDataTest { public void testUpdateUnknownSpecies() { InternalModelSpeciesData data = new InternalModelSpeciesData(); try { - data.updateSpecies(new Species(), null); + data.updateSpecies(new CellDesignerSpecies<GenericProtein>(), null); fail("Exception expected"); } catch (InvalidArgumentException e) { assertTrue(e.getMessage().contains("Unknown species type")); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/ProteinMappingTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/ProteinMappingTest.java index 2ba1853a76..4404192113 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/ProteinMappingTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/ProteinMappingTest.java @@ -13,7 +13,8 @@ import org.junit.Test; import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.Protein; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerProtein; +import lcsb.mapviewer.model.map.species.TruncatedProtein; public class ProteinMappingTest { Logger logger = Logger.getLogger(ProteinMappingTest.class); @@ -40,7 +41,7 @@ public class ProteinMappingTest { @Test public void testCreateInvalidProteinImpl() throws Exception { // artificial implementation of Protein that is invalid - class InvalidProtein extends Protein { + class InvalidProtein extends CellDesignerProtein<TruncatedProtein> { private static final long serialVersionUID = 1L; @SuppressWarnings("unused") @@ -52,7 +53,7 @@ public class ProteinMappingTest { // mopdify one of the elements of ProteinMapping so it will have invalid // implementation ProteinMapping typeToModify = ProteinMapping.GENERIC_PROTEIN; - Class<? extends Protein> clazz = typeToModify.getCellDesignerClazz(); + Class<? extends CellDesignerProtein<?>> clazz = typeToModify.getCellDesignerClazz(); try { Field field = typeToModify.getClass().getDeclaredField("cellDesignerClazz"); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/ProteinXmlParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/ProteinXmlParserTest.java index c411af0320..b09e9356c8 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/ProteinXmlParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/ProteinXmlParserTest.java @@ -23,9 +23,9 @@ import lcsb.mapviewer.common.exception.InvalidArgumentException; 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.GenericProtein; -import lcsb.mapviewer.converter.model.celldesigner.structure.Protein; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerGenericProtein; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerProtein; +import lcsb.mapviewer.model.map.species.Protein; public class ProteinXmlParserTest extends CellDesignerTestFunctions { Logger logger = Logger.getLogger(ProteinXmlParserTest.class.getName()); @@ -50,11 +50,11 @@ public class ProteinXmlParserTest extends CellDesignerTestFunctions { public void testParseXmlSpecies() throws Exception { try { String xmlString = readFile(testProteinFile); - Pair<String, Protein<?>> result = proteinParser.parseXmlElement(xmlString); - Protein<?> protein = result.getRight(); + Pair<String, CellDesignerProtein<?>> result = proteinParser.parseXmlElement(xmlString); + CellDesignerProtein<?> protein = result.getRight(); assertEquals("pr23", result.getLeft()); assertEquals("SDHA", protein.getName()); - assertTrue(protein instanceof GenericProtein); + assertTrue(protein instanceof CellDesignerGenericProtein); assertEquals(1, protein.getModificationResidues().size()); assertEquals("rs1", protein.getModificationResidues().get(0).getIdModificationResidue()); assertEquals("S176 bla bla", protein.getModificationResidues().get(0).getName()); @@ -72,8 +72,8 @@ public class ProteinXmlParserTest extends CellDesignerTestFunctions { try { String xmlString = readFile(testProteinFile); - Pair<String, Protein<?>> result = proteinParser.parseXmlElement(xmlString); - Protein<?> protein = result.getRight(); + Pair<String, CellDesignerProtein<?>> result = proteinParser.parseXmlElement(xmlString); + CellDesignerProtein<?> protein = result.getRight(); String transformedXml = proteinParser.toXml(protein.createAlias("id")); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); @@ -82,8 +82,8 @@ public class ProteinXmlParserTest extends CellDesignerTestFunctions { NodeList root = doc.getChildNodes(); assertEquals("celldesigner:protein", root.item(0).getNodeName()); - Pair<String, Protein<?>> result2 = proteinParser.parseXmlElement(proteinParser.toXml(protein.createAlias("id"))); - Protein<?> protein2 = result2.getRight(); + Pair<String, CellDesignerProtein<?>> result2 = proteinParser.parseXmlElement(proteinParser.toXml(protein.createAlias("id"))); + CellDesignerProtein<?> protein2 = result2.getRight(); assertEquals(protein.getName(), protein2.getName()); assertEquals(protein.getClass(), protein2.getClass()); assertEquals(protein.getModificationResidues().size(), protein2.getModificationResidues().size()); @@ -160,7 +160,7 @@ public class ProteinXmlParserTest extends CellDesignerTestFunctions { @Test public void testInvalidProteinToXml() throws Exception { try { - proteinParser.toXml(Mockito.mock(ProteinAlias.class)); + proteinParser.toXml(Mockito.mock(Protein.class)); fail("Exception expected"); } catch (InvalidArgumentException e) { assertTrue(e.getMessage().contains("Invalid protein class type")); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/RnaXmlParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/RnaXmlParserTest.java index 34757ada7c..e5624c6569 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/RnaXmlParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/RnaXmlParserTest.java @@ -22,7 +22,7 @@ import lcsb.mapviewer.common.Pair; 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.Rna; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerRna; public class RnaXmlParserTest extends CellDesignerTestFunctions { protected Logger logger = Logger.getLogger(RnaXmlParserTest.class.getName()); @@ -49,8 +49,8 @@ public class RnaXmlParserTest extends CellDesignerTestFunctions { public void testParseXmlSpecies() throws Exception { try { String xmlString = readFile(testRnaFile); - Pair<String, Rna> result = rnaParser.parseXmlElement(xmlString); - Rna rna = result.getRight(); + Pair<String, CellDesignerRna> result = rnaParser.parseXmlElement(xmlString); + CellDesignerRna rna = result.getRight(); assertEquals("rn36", result.getLeft()); assertEquals("BCL6", rna.getName()); assertTrue(rna.getNotes().contains("B-cell CLL/lymphoma ")); @@ -64,8 +64,8 @@ public class RnaXmlParserTest extends CellDesignerTestFunctions { public void testParseXmlSpeciesWithRegion() throws Exception { try { String xmlString = readFile(testRnaFile2); - Pair<String, Rna> result = rnaParser.parseXmlElement(xmlString); - Rna rna = result.getRight(); + Pair<String, CellDesignerRna> result = rnaParser.parseXmlElement(xmlString); + CellDesignerRna rna = result.getRight(); assertNotNull(rna); assertNotNull(rna.getRegions()); assertEquals(1, rna.getRegions().size()); @@ -80,8 +80,8 @@ public class RnaXmlParserTest extends CellDesignerTestFunctions { public void testToXml() throws Exception { try { String xmlString = readFile(testRnaFile); - Pair<String, Rna> result = rnaParser.parseXmlElement(xmlString); - Rna rna = result.getRight(); + Pair<String, CellDesignerRna> result = rnaParser.parseXmlElement(xmlString); + CellDesignerRna rna = result.getRight(); String transformedXml = rnaParser.toXml(rna.createAlias("id")); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); @@ -91,8 +91,8 @@ public class RnaXmlParserTest extends CellDesignerTestFunctions { NodeList root = doc.getChildNodes(); assertEquals("celldesigner:RNA", root.item(0).getNodeName()); - Pair<String, Rna> result2 = rnaParser.parseXmlElement(rnaParser.toXml(rna.createAlias("id"))); - Rna rna2 = result2.getRight(); + Pair<String, CellDesignerRna> result2 = rnaParser.parseXmlElement(rnaParser.toXml(rna.createAlias("id"))); + CellDesignerRna rna2 = result2.getRight(); assertEquals(rna.getName(), rna2.getName()); assertTrue(rna2.getNotes().trim().contains(rna.getNotes().trim())); } catch (Exception e) { diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesCollectionTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesCollectionTest.java index 7a59c5abe6..c44b0e7632 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesCollectionTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesCollectionTest.java @@ -12,10 +12,11 @@ import org.junit.Test; import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.Gene; -import lcsb.mapviewer.converter.model.celldesigner.structure.GenericProtein; -import lcsb.mapviewer.converter.model.celldesigner.structure.Protein; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerGene; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerGenericProtein; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerProtein; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; +import lcsb.mapviewer.model.map.species.Species; public class SpeciesCollectionTest { Logger logger = Logger.getLogger(SpeciesCollectionTest.class); @@ -31,8 +32,8 @@ public class SpeciesCollectionTest { @Test public void testAdd() { try { - SpeciesCollection<Gene> coll = new SpeciesCollection<Gene>(); - Gene g = new Gene(); + SpeciesCollection<CellDesignerGene> coll = new SpeciesCollection<CellDesignerGene>(); + CellDesignerGene g = new CellDesignerGene(); g.setElementId("general Id"); coll.add(g, "geneId"); assertNotNull(coll.getSpeciesListByLocalId("geneId")); @@ -46,16 +47,16 @@ public class SpeciesCollectionTest { @Test public void testUpdate() { try { - SpeciesCollection<Protein> coll = new SpeciesCollection<>(); - Protein protein = new GenericProtein(); + SpeciesCollection<CellDesignerProtein<?>> coll = new SpeciesCollection<>(); + CellDesignerProtein<?> protein = new CellDesignerGenericProtein(); protein.setElementId(""); coll.add(protein, "prot id"); - Protein p2 = new GenericProtein(); + CellDesignerProtein<?> p2 = new CellDesignerGenericProtein(); p2.setElementId("id2"); coll.updateSpeciesByLocalId(p2, "prot id"); assertEquals(1, coll.getSpeciesListByLocalId("prot id").size()); - Protein p3 = coll.getSpeciesListByLocalId("prot id").get(0); + CellDesignerProtein<?> p3 = coll.getSpeciesListByLocalId("prot id").get(0); assertEquals(protein, p3); @@ -68,16 +69,16 @@ public class SpeciesCollectionTest { @Test public void testUpdateWithTypeChange() { try { - SpeciesCollection<Protein> coll = new SpeciesCollection<Protein>(); - Protein p = new Protein(); + SpeciesCollection<CellDesignerProtein<?>> coll = new SpeciesCollection<>(); + CellDesignerProtein<?> p = new CellDesignerProtein<>(); p.setElementId(""); coll.add(p, "prot id"); - GenericProtein p2 = new GenericProtein(); + CellDesignerGenericProtein p2 = new CellDesignerGenericProtein(); p2.setElementId("id2"); coll.updateSpeciesByLocalId(p2, "prot id"); assertEquals(1, coll.getSpeciesListByLocalId("prot id").size()); - Protein p3 = coll.getSpeciesListByLocalId("prot id").get(0); + CellDesignerProtein<?> p3 = coll.getSpeciesListByLocalId("prot id").get(0); // we don't have generic data anymore but new instance assertFalse(p3.equals(p)); @@ -92,15 +93,15 @@ public class SpeciesCollectionTest { @Test public void testCreateNewInstance() { try { - SpeciesCollection<Species> coll = new SpeciesCollection<>(); - class InvalidSpecies extends Species { + SpeciesCollection<CellDesignerSpecies<?>> coll = new SpeciesCollection<>(); + class InvalidSpecies extends CellDesignerSpecies<Species> { private static final long serialVersionUID = 1L; public InvalidSpecies() { } @SuppressWarnings("unused") - public InvalidSpecies(final Species sp) { + public InvalidSpecies(final CellDesignerSpecies<?> sp) { throw new NotImplementedException(); } } diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesCollectionXmlParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesCollectionXmlParserTest.java index 67222b2161..ca6b5b5173 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesCollectionXmlParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesCollectionXmlParserTest.java @@ -20,21 +20,21 @@ import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; 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.AntisenseRna; -import lcsb.mapviewer.converter.model.celldesigner.structure.ComplexSpecies; -import lcsb.mapviewer.converter.model.celldesigner.structure.Gene; -import lcsb.mapviewer.converter.model.celldesigner.structure.GenericProtein; -import lcsb.mapviewer.converter.model.celldesigner.structure.Protein; -import lcsb.mapviewer.converter.model.celldesigner.structure.Rna; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaAlias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerAntisenseRna; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerComplexSpecies; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerGene; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerGenericProtein; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerProtein; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerRna; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.AntisenseRna; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Rna; +import lcsb.mapviewer.model.map.species.Species; public class SpeciesCollectionXmlParserTest extends CellDesignerTestFunctions { static Logger logger = Logger.getLogger(SpeciesCollectionXmlParserTest.class); @@ -58,7 +58,7 @@ public class SpeciesCollectionXmlParserTest extends CellDesignerTestFunctions { @Before public void setUp() throws Exception { elements = new CellDesignerElementCollection(); - parser = new SpeciesCollectionXmlParser(model, elements); + parser = new SpeciesCollectionXmlParser(elements); } @After @@ -70,9 +70,9 @@ public class SpeciesCollectionXmlParserTest extends CellDesignerTestFunctions { try { String xmlString = readFile(testDirectory + testRnaListXmlFile); Node node = getNodeFromXmlString(xmlString); - List<Pair<String, ? extends Species<?>>> list = parser.parseXmlRnaCollection(node); + List<Pair<String, ? extends CellDesignerSpecies<?>>> list = parser.parseXmlRnaCollection(node); assertEquals(2, list.size()); - assertTrue(list.get(0).getRight() instanceof Rna); + assertTrue(list.get(0).getRight() instanceof CellDesignerRna); } catch (Exception e) { throw e; } @@ -139,16 +139,16 @@ public class SpeciesCollectionXmlParserTest extends CellDesignerTestFunctions { try { String xmlString = readFile(testDirectory + testRnaListXmlFile); Node node = getNodeFromXmlString(xmlString); - List<Pair<String, ? extends Species<?>>> list = parser.parseXmlRnaCollection(node); - List<RnaAlias> arList = new ArrayList<>(); - for (Pair<String, ? extends Species<?>> pair : list) { - arList.add((RnaAlias) pair.getRight().createAlias()); + List<Pair<String, ? extends CellDesignerSpecies<?>>> list = parser.parseXmlRnaCollection(node); + List<Rna> arList = new ArrayList<>(); + for (Pair<String, ? extends CellDesignerSpecies<?>> pair : list) { + arList.add((Rna) pair.getRight().createAlias()); } String convertedString = parser.rnaCollectionToXmlString(arList); assertNotNull(convertedString); node = getNodeFromXmlString(convertedString); assertEquals("celldesigner:listOfRNAs", node.getNodeName()); - List<Pair<String, ? extends Species<?>>> list2 = parser.parseXmlRnaCollection(node); + List<Pair<String, ? extends CellDesignerSpecies<?>>> list2 = parser.parseXmlRnaCollection(node); assertNotNull(list2); assertEquals(list.size(), list2.size()); assertEquals(list.get(0).getClass().getName(), list2.get(0).getClass().getName()); @@ -162,9 +162,9 @@ public class SpeciesCollectionXmlParserTest extends CellDesignerTestFunctions { try { String xmlString = readFile(testDirectory + testGeneListXmlFile); Node node = getNodeFromXmlString(xmlString); - List<Pair<String, ? extends Species<?>>> list = parser.parseXmlGeneCollection(node); + List<Pair<String, ? extends CellDesignerSpecies<?>>> list = parser.parseXmlGeneCollection(node); assertEquals(2, list.size()); - assertTrue(list.get(0).getRight() instanceof Gene); + assertTrue(list.get(0).getRight() instanceof CellDesignerGene); } catch (Exception exception) { fail("Unexpected exception occurred"); } @@ -175,16 +175,16 @@ public class SpeciesCollectionXmlParserTest extends CellDesignerTestFunctions { try { String xmlString = readFile(testDirectory + testGeneListXmlFile); Node node = getNodeFromXmlString(xmlString); - List<Pair<String, ? extends Species<?>>> list = parser.parseXmlGeneCollection(node); - List<GeneAlias> arList = new ArrayList<>(); - for (Pair<String, ? extends Species> pair : list) { - arList.add((GeneAlias) pair.getRight().createAlias()); + List<Pair<String, ? extends CellDesignerSpecies<?>>> list = parser.parseXmlGeneCollection(node); + List<Gene> arList = new ArrayList<>(); + for (Pair<String, ? extends CellDesignerSpecies<?>> pair : list) { + arList.add((Gene) pair.getRight().createAlias()); } String convertedString = parser.geneCollectionToXmlString(arList); assertNotNull(convertedString); node = getNodeFromXmlString(convertedString); assertEquals("celldesigner:listOfGenes", node.getNodeName()); - List<Pair<String, ? extends Species<?>>> list2 = parser.parseXmlGeneCollection(node); + List<Pair<String, ? extends CellDesignerSpecies<?>>> list2 = parser.parseXmlGeneCollection(node); assertNotNull(list2); assertEquals(list.size(), list2.size()); assertEquals(list.get(0).getClass().getName(), list2.get(0).getClass().getName()); @@ -198,9 +198,9 @@ public class SpeciesCollectionXmlParserTest extends CellDesignerTestFunctions { try { String xmlString = readFile(testDirectory + testProteinListXmlFile); Node node = getNodeFromXmlString(xmlString); - List<Pair<String, ? extends Species<?>>> list = parser.parseXmlProteinCollection(node); + List<Pair<String, ? extends CellDesignerSpecies<?>>> list = parser.parseXmlProteinCollection(node); assertEquals(4, list.size()); - assertTrue(list.get(0).getRight() instanceof Protein); + assertTrue(list.get(0).getRight() instanceof CellDesignerProtein); } catch (Exception exception) { fail("Unexpected exception occurred"); } @@ -211,16 +211,16 @@ public class SpeciesCollectionXmlParserTest extends CellDesignerTestFunctions { try { String xmlString = readFile(testDirectory + testProteinListXmlFile); Node node = getNodeFromXmlString(xmlString); - List<Pair<String, ? extends Species<?>>> list = parser.parseXmlProteinCollection(node); - List<ProteinAlias> arList = new ArrayList<>(); - for (Pair<String, ? extends Species<?>> pair : list) { - arList.add((ProteinAlias) pair.getRight().createAlias("" + idCounter++)); + List<Pair<String, ? extends CellDesignerSpecies<?>>> list = parser.parseXmlProteinCollection(node); + List<Protein> arList = new ArrayList<>(); + for (Pair<String, ? extends CellDesignerSpecies<?>> pair : list) { + arList.add((Protein) pair.getRight().createAlias("" + idCounter++)); } String convertedString = parser.proteinCollectionToXmlString(arList); assertNotNull(convertedString); node = getNodeFromXmlString(convertedString); assertEquals("celldesigner:listOfProteins", node.getNodeName()); - List<Pair<String, ? extends Species<?>>> list2 = parser.parseXmlProteinCollection(node); + List<Pair<String, ? extends CellDesignerSpecies<?>>> list2 = parser.parseXmlProteinCollection(node); assertNotNull(list2); assertEquals(list.size(), list2.size()); assertEquals(list.get(0).getClass().getName(), list2.get(0).getClass().getName()); @@ -235,9 +235,9 @@ public class SpeciesCollectionXmlParserTest extends CellDesignerTestFunctions { try { String xmlString = readFile(testDirectory + testAntisenseRnaListXmlFile); Node node = getNodeFromXmlString(xmlString); - List<Pair<String, ? extends Species<?>>> list = parser.parseXmlAntisenseRnaCollection(node); + List<Pair<String, ? extends CellDesignerSpecies<?>>> list = parser.parseXmlAntisenseRnaCollection(node); assertEquals(2, list.size()); - assertTrue(list.get(0).getRight() instanceof AntisenseRna); + assertTrue(list.get(0).getRight() instanceof CellDesignerAntisenseRna); } catch (Exception exception) { fail("Unexpected exception occurred"); } @@ -248,16 +248,16 @@ public class SpeciesCollectionXmlParserTest extends CellDesignerTestFunctions { try { String xmlString = readFile(testDirectory + testAntisenseRnaListXmlFile); Node node = getNodeFromXmlString(xmlString); - List<Pair<String, ? extends Species<?>>> list = parser.parseXmlAntisenseRnaCollection(node); - List<AntisenseRnaAlias> arList = new ArrayList<>(); - for (Pair<String, ? extends Species<?>> pair : list) { - arList.add((AntisenseRnaAlias) pair.getRight().createAlias()); + List<Pair<String, ? extends CellDesignerSpecies<?>>> list = parser.parseXmlAntisenseRnaCollection(node); + List<AntisenseRna> arList = new ArrayList<>(); + for (Pair<String, ? extends CellDesignerSpecies<?>> pair : list) { + arList.add((AntisenseRna) pair.getRight().createAlias()); } String convertedString = parser.antisenseRnaCollectionToXmlString(arList); assertNotNull(convertedString); node = getNodeFromXmlString(convertedString); assertEquals("celldesigner:listOfAntisenseRNAs", node.getNodeName()); - List<Pair<String, ? extends Species<?>>> list2 = parser.parseXmlAntisenseRnaCollection(node); + List<Pair<String, ? extends CellDesignerSpecies<?>>> list2 = parser.parseXmlAntisenseRnaCollection(node); assertNotNull(list2); assertEquals(list.size(), list2.size()); assertEquals(list.get(0).getClass().getName(), list2.get(0).getClass().getName()); @@ -272,7 +272,7 @@ public class SpeciesCollectionXmlParserTest extends CellDesignerTestFunctions { try { String xmlString = readFile(testDirectory + testSbmlListXmlFile); Node node = getNodeFromXmlString(xmlString); - List<Pair<String, ? extends Species<?>>> list = parser.parseSbmlSpeciesCollection(node); + List<Pair<String, ? extends CellDesignerSpecies<?>>> list = parser.parseSbmlSpeciesCollection(node); assertEquals(9, list.size()); } catch (Exception e) { e.printStackTrace(); @@ -299,27 +299,27 @@ public class SpeciesCollectionXmlParserTest extends CellDesignerTestFunctions { try { String xmlString = readFile(testDirectory + testSbmlListXmlFile); Node node = getNodeFromXmlString(xmlString); - List<Pair<String, ? extends Species<?>>> list = parser.parseSbmlSpeciesCollection(node); + List<Pair<String, ? extends CellDesignerSpecies<?>>> list = parser.parseSbmlSpeciesCollection(node); Model model = new ModelFullIndexed(null); int x = 0; - List<SpeciesAlias> speciesList = new ArrayList<>(); - for (Pair<String, ? extends Species<?>> el : list) { - Species<?> species = el.getRight(); - if (species.getClass() == Protein.class) { - species = new GenericProtein(species); + List<Species> speciesList = new ArrayList<>(); + for (Pair<String, ? extends CellDesignerSpecies<?>> el : list) { + CellDesignerSpecies<?> species = el.getRight(); + if (species.getClass() == CellDesignerProtein.class) { + species = new CellDesignerGenericProtein(species); } species.setModel(model); - SpeciesAlias alias = species.createAlias("alias" + (x++)); + Species alias = species.createAlias("alias" + (x++)); model.addAlias(alias); speciesList.add(alias); } - model.addAlias(new CompartmentAlias("default")); + model.addAlias(new Compartment("default")); String convertedString = parser.speciesCollectionToSbmlString(speciesList); assertNotNull(convertedString); node = getNodeFromXmlString(convertedString); assertEquals("listOfSpecies", node.getNodeName()); - List<Pair<String, ? extends Species<?>>> list2 = parser.parseSbmlSpeciesCollection(node); + List<Pair<String, ? extends CellDesignerSpecies<?>>> list2 = parser.parseSbmlSpeciesCollection(node); assertNotNull(list2); assertEquals(list.size(), list2.size()); assertEquals(list.get(0).getClass().getName(), list2.get(0).getClass().getName()); @@ -334,14 +334,14 @@ public class SpeciesCollectionXmlParserTest extends CellDesignerTestFunctions { try { String xmlString = readFile(testDirectory + testIncludedListXmlFile); Node node = getNodeFromXmlString(xmlString); - List<Pair<String, ? extends Species<?>>> list = parser.parseIncludedSpeciesCollection(node); + List<Pair<String, ? extends CellDesignerSpecies<?>>> list = parser.parseIncludedSpeciesCollection(node); assertEquals(3, list.size()); int complexes = 0; int proteins = 0; - for (Pair<String, ? extends Species<?>> species : list) { - if (species.getRight() instanceof ComplexSpecies) + for (Pair<String, ? extends CellDesignerSpecies<?>> species : list) { + if (species.getRight() instanceof CellDesignerComplexSpecies) complexes++; - if (species.getRight() instanceof Protein) + if (species.getRight() instanceof CellDesignerProtein) proteins++; } assertEquals(1, complexes); @@ -435,7 +435,7 @@ public class SpeciesCollectionXmlParserTest extends CellDesignerTestFunctions { // this is only for test coverage puropse - SpeciesCollectionXmlParser parser = new SpeciesCollectionXmlParser(new ModelFullIndexed(null), elements); + SpeciesCollectionXmlParser parser = new SpeciesCollectionXmlParser(elements); Field field = SpeciesCollectionXmlParser.class.getDeclaredField("helpParser"); field.setAccessible(true); try { diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesMappingTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesMappingTest.java index 1d70306270..c4a2530988 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesMappingTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesMappingTest.java @@ -11,7 +11,8 @@ import org.junit.Test; import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; +import lcsb.mapviewer.model.map.species.Protein; public class SpeciesMappingTest { @@ -38,7 +39,7 @@ public class SpeciesMappingTest { @Test public void testCreateInvalidSpeciesImpl() throws Exception { // artificial implementation of Species that is invalid - class InvalidSpecies extends Species { + class InvalidSpecies extends CellDesignerSpecies<Protein> { private static final long serialVersionUID = 1L; @SuppressWarnings("unused") @@ -50,7 +51,7 @@ public class SpeciesMappingTest { // mopdify one of the elements of SpeciesMapping so it will have invalid // implementation SpeciesMapping typeToModify = SpeciesMapping.ANTISENSE_RNA; - Class<? extends Species> clazz = typeToModify.getCellDesignerClazz(); + Class<? extends CellDesignerSpecies> clazz = typeToModify.getCellDesignerClazz(); try { Field field = typeToModify.getClass().getDeclaredField("cellDesignerClazz"); @@ -59,7 +60,7 @@ public class SpeciesMappingTest { // and check if we catch properly information about problematic // implementation - typeToModify.createSpecies(new Species()); + typeToModify.createSpecies(new CellDesignerSpecies<Protein>()); fail("Exceptione expected"); } catch (InvalidStateException e) { } catch (Exception e) { 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 a9f75e8ea8..5e35e8399e 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 @@ -26,26 +26,26 @@ import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; 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.AntisenseRna; -import lcsb.mapviewer.converter.model.celldesigner.structure.AntisenseRnaRegion; -import lcsb.mapviewer.converter.model.celldesigner.structure.ComplexSpecies; -import lcsb.mapviewer.converter.model.celldesigner.structure.Degraded; -import lcsb.mapviewer.converter.model.celldesigner.structure.Drug; -import lcsb.mapviewer.converter.model.celldesigner.structure.Gene; -import lcsb.mapviewer.converter.model.celldesigner.structure.GenericProtein; -import lcsb.mapviewer.converter.model.celldesigner.structure.Ion; -import lcsb.mapviewer.converter.model.celldesigner.structure.ModificationResidue; -import lcsb.mapviewer.converter.model.celldesigner.structure.Phenotype; -import lcsb.mapviewer.converter.model.celldesigner.structure.Protein; -import lcsb.mapviewer.converter.model.celldesigner.structure.Rna; -import lcsb.mapviewer.converter.model.celldesigner.structure.RnaRegion; -import lcsb.mapviewer.converter.model.celldesigner.structure.SimpleMolecule; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; -import lcsb.mapviewer.converter.model.celldesigner.structure.SpeciesState; -import lcsb.mapviewer.converter.model.celldesigner.structure.Unknown; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; -import lcsb.mapviewer.model.map.model.Model; +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; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerGene; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerGenericProtein; +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.CellDesignerModificationResidue; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.SpeciesState; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { @SuppressWarnings("unused") @@ -85,8 +85,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testParseXmlSpeciesAntisenseRna() throws Exception { try { String xmlString = readFile(testDirectory + testAntisenseRnaFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - AntisenseRna species = (AntisenseRna) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerAntisenseRna species = (CellDesignerAntisenseRna) result.getRight(); assertEquals("s2", species.getElementId()); assertEquals("s3", species.getName()); assertEquals(new Integer(2), species.getInitialAmount()); @@ -102,8 +102,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testToXmlAntisenseRna() throws Exception { try { String xmlString = readFile(testDirectory + testAntisenseRnaFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - AntisenseRna species = (AntisenseRna) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerAntisenseRna species = (CellDesignerAntisenseRna) result.getRight(); String transformedXml = parser.toXml(species.createAlias()); assertNotNull(transformedXml); @@ -114,8 +114,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { NodeList root = doc.getChildNodes(); assertEquals("species", root.item(0).getNodeName()); - Pair<String, ? extends Species> result2 = parser.parseXmlElement(parser.toXml(species.createAlias())); - AntisenseRna species2 = (AntisenseRna) result2.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result2 = parser.parseXmlElement(parser.toXml(species.createAlias())); + CellDesignerAntisenseRna species2 = (CellDesignerAntisenseRna) result2.getRight(); assertEquals(species.getName(), species2.getName()); assertEquals(species.getParent(), species2.getParent()); @@ -134,8 +134,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testParseXmlSpeciesComplex() throws Exception { try { String xmlString = readFile(testDirectory + testComplexFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - ComplexSpecies species = (ComplexSpecies) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerComplexSpecies species = (CellDesignerComplexSpecies) result.getRight(); assertNotNull(species); assertEquals("s6549", species.getElementId()); assertEquals("LC3-II", species.getName()); @@ -150,8 +150,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testToXmlComplex() throws Exception { try { String xmlString = readFile(testDirectory + testComplexFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - ComplexSpecies species = (ComplexSpecies) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerComplexSpecies species = (CellDesignerComplexSpecies) result.getRight(); String transformedXml = parser.toXml(species.createAlias()); assertNotNull(transformedXml); @@ -162,8 +162,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { NodeList root = doc.getChildNodes(); assertEquals("species", root.item(0).getNodeName()); - Pair<String, ? extends Species> result2 = parser.parseXmlElement(parser.toXml(species.createAlias())); - ComplexSpecies species2 = (ComplexSpecies) result2.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result2 = parser.parseXmlElement(parser.toXml(species.createAlias())); + CellDesignerComplexSpecies species2 = (CellDesignerComplexSpecies) result2.getRight(); assertNotNull(species2); assertEquals(species.getName(), species2.getName()); @@ -182,8 +182,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testParseXmlSpeciesDegraded() throws Exception { try { String xmlString = readFile(testDirectory + testDegradedFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - Degraded species = (Degraded) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerDegraded species = (CellDesignerDegraded) result.getRight(); assertNotNull(species); assertEquals("s1275", species.getElementId()); assertEquals("s1275", species.getName()); @@ -199,8 +199,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testToXmlDegraded() throws Exception { try { String xmlString = readFile(testDirectory + testDegradedFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - Degraded species = (Degraded) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerDegraded species = (CellDesignerDegraded) result.getRight(); String transformedXml = parser.toXml(species.createAlias()); assertNotNull(transformedXml); @@ -211,8 +211,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { NodeList root = doc.getChildNodes(); assertEquals("species", root.item(0).getNodeName()); - Pair<String, ? extends Species> result2 = parser.parseXmlElement(parser.toXml(species.createAlias())); - Degraded species2 = (Degraded) result2.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result2 = parser.parseXmlElement(parser.toXml(species.createAlias())); + CellDesignerDegraded species2 = (CellDesignerDegraded) result2.getRight(); assertNotNull(species2); assertEquals(species.getName(), species2.getName()); @@ -230,8 +230,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testParseXmlSpeciesDrug() throws Exception { try { String xmlString = readFile(testDirectory + testDrugFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - Drug species = (Drug) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerDrug species = (CellDesignerDrug) result.getRight(); assertEquals("s6104", species.getElementId()); assertEquals("geldanamycin", species.getName()); assertEquals(new Integer(0), species.getCharge()); @@ -245,8 +245,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testToXmlDrug() throws Exception { try { String xmlString = readFile(testDirectory + testDrugFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - Drug species = (Drug) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerDrug species = (CellDesignerDrug) result.getRight(); String transformedXml = parser.toXml(species.createAlias()); assertNotNull(transformedXml); @@ -257,8 +257,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { NodeList root = doc.getChildNodes(); assertEquals("species", root.item(0).getNodeName()); - Pair<String, ? extends Species> result2 = parser.parseXmlElement(parser.toXml(species.createAlias())); - Drug species2 = (Drug) result2.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result2 = parser.parseXmlElement(parser.toXml(species.createAlias())); + CellDesignerDrug species2 = (CellDesignerDrug) result2.getRight(); assertNotNull(species2); assertEquals(species.getName(), species2.getName()); @@ -276,8 +276,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testParseXmlSpeciesGene() throws Exception { try { String xmlString = readFile(testDirectory + testGeneFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - Gene species = (Gene) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerGene species = (CellDesignerGene) result.getRight(); assertEquals("s5916", species.getElementId()); assertEquals("Ptgr1", species.getName()); @@ -292,20 +292,20 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { @Test public void testParseXmlSpeciesGeneWithModelUpdate() throws Exception { try { - Species gene = new Gene(); + CellDesignerSpecies<?> gene = new CellDesignerGene(); gene.setElementId("s5916"); InternalModelSpeciesData modelData = new InternalModelSpeciesData(); modelData.updateSpecies(gene, ""); SpeciesSbmlParser complexParser = new SpeciesSbmlParser(elements); - Gene oldGene = new Gene(); + CellDesignerGene oldGene = new CellDesignerGene(); oldGene.setElementId("s5916"); oldGene.setName("Ptgr1"); modelData.updateSpecies(oldGene, "gn95"); String xmlString = readFile(testDirectory + testGeneFile); - Pair<String, ? extends Species> result = complexParser.parseXmlElement(xmlString); - Gene species = (Gene) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = complexParser.parseXmlElement(xmlString); + CellDesignerGene species = (CellDesignerGene) result.getRight(); modelData.updateSpecies(species, result.getLeft()); assertEquals("s5916", species.getElementId()); @@ -321,8 +321,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testToXmlGene() throws Exception { try { String xmlString = readFile(testDirectory + testGeneFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - Gene species = (Gene) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerGene species = (CellDesignerGene) result.getRight(); String transformedXml = parser.toXml(species.createAlias()); assertNotNull(transformedXml); @@ -333,8 +333,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { NodeList root = doc.getChildNodes(); assertEquals("species", root.item(0).getNodeName()); - Pair<String, ? extends Species> result2 = parser.parseXmlElement(parser.toXml(species.createAlias())); - Gene species2 = (Gene) result2.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result2 = parser.parseXmlElement(parser.toXml(species.createAlias())); + CellDesignerGene species2 = (CellDesignerGene) result2.getRight(); assertNotNull(species2); assertEquals(species.getName(), species2.getName()); @@ -355,8 +355,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testParseXmlSpeciesIon() throws Exception { try { String xmlString = readFile(testDirectory + testIonFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - Ion species = (Ion) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerIon species = (CellDesignerIon) result.getRight(); assertEquals("s6029", species.getElementId()); assertEquals("Pi", species.getName()); @@ -372,8 +372,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testToXmlIon() throws Exception { try { String xmlString = readFile(testDirectory + testIonFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - Ion species = (Ion) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerIon species = (CellDesignerIon) result.getRight(); String transformedXml = parser.toXml(species.createAlias()); assertNotNull(transformedXml); @@ -384,8 +384,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { NodeList root = doc.getChildNodes(); assertEquals("species", root.item(0).getNodeName()); - Pair<String, ? extends Species> result2 = parser.parseXmlElement(xmlString); - Ion species2 = (Ion) result2.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result2 = parser.parseXmlElement(xmlString); + CellDesignerIon species2 = (CellDesignerIon) result2.getRight(); assertNotNull(species2); assertEquals(species.getElementId(), species2.getElementId()); @@ -408,8 +408,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testParseXmlSpeciesPhenotype() throws Exception { try { String xmlString = readFile(testDirectory + testPhenotypeFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - Phenotype species = (Phenotype) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerPhenotype species = (CellDesignerPhenotype) result.getRight(); assertEquals("s5462", species.getElementId()); assertEquals("Neuronal damage and death", species.getName()); @@ -424,8 +424,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testToXmlPhenotype() throws Exception { try { String xmlString = readFile(testDirectory + testPhenotypeFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - Phenotype species = (Phenotype) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerPhenotype species = (CellDesignerPhenotype) result.getRight(); String transformedXml = parser.toXml(species.createAlias()); assertNotNull(transformedXml); @@ -436,8 +436,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { NodeList root = doc.getChildNodes(); assertEquals("species", root.item(0).getNodeName()); - Pair<String, ? extends Species> result2 = parser.parseXmlElement(parser.toXml(species.createAlias())); - Phenotype species2 = (Phenotype) result2.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result2 = parser.parseXmlElement(parser.toXml(species.createAlias())); + CellDesignerPhenotype species2 = (CellDesignerPhenotype) result2.getRight(); assertNotNull(species2); assertEquals(species.getName(), species2.getName()); @@ -458,8 +458,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testParseXmlSpeciesProtein() throws Exception { try { String xmlString = readFile(testDirectory + testProteinFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - Protein species = (Protein) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerProtein<?> species = (CellDesignerProtein<?>) result.getRight(); assertEquals("s5456", species.getElementId()); assertEquals("PTPRC", species.getName()); @@ -477,8 +477,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testToXmlProtein() throws Exception { try { String xmlString = readFile(testDirectory + testProteinFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - GenericProtein species = new GenericProtein(result.getRight()); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerGenericProtein species = new CellDesignerGenericProtein(result.getRight()); String transformedXml = parser.toXml(species.createAlias("" + idCounter++)); assertNotNull(transformedXml); @@ -489,8 +489,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { NodeList root = doc.getChildNodes(); assertEquals("species", root.item(0).getNodeName()); - Pair<String, ? extends Species> result2 = parser.parseXmlElement(parser.toXml(species.createAlias("" + idCounter++))); - Protein species2 = (Protein) result2.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result2 = parser.parseXmlElement(parser.toXml(species.createAlias("" + idCounter++))); + CellDesignerProtein<?> species2 = (CellDesignerProtein<?>) result2.getRight(); assertNotNull(species2); assertEquals(species.getName(), species2.getName()); @@ -511,8 +511,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testParseXmlSpeciesRna() throws Exception { try { String xmlString = readFile(testDirectory + testRnaFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - Rna species = (Rna) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerRna species = (CellDesignerRna) result.getRight(); assertEquals("s5914", species.getElementId()); assertEquals("Fmo3", species.getName()); @@ -529,8 +529,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testToXmlRna() throws Exception { try { String xmlString = readFile(testDirectory + testRnaFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - Rna species = (Rna) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerRna species = (CellDesignerRna) result.getRight(); String transformedXml = parser.toXml(species.createAlias()); assertNotNull(transformedXml); @@ -541,8 +541,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { NodeList root = doc.getChildNodes(); assertEquals("species", root.item(0).getNodeName()); - Pair<String, ? extends Species> result2 = parser.parseXmlElement(parser.toXml(species.createAlias())); - Rna species2 = (Rna) result2.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result2 = parser.parseXmlElement(parser.toXml(species.createAlias())); + CellDesignerRna species2 = (CellDesignerRna) result2.getRight(); assertNotNull(species2); assertEquals(species.getName(), species2.getName()); @@ -563,8 +563,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testParseXmlSpeciesSimpleMolecule() throws Exception { try { String xmlString = readFile(testDirectory + testSimpleMoleculeFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - SimpleMolecule species = (SimpleMolecule) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerSimpleMolecule species = (CellDesignerSimpleMolecule) result.getRight(); assertEquals("s5463", species.getElementId()); assertEquals("Peroxides", species.getName()); assertEquals(new Integer(0), species.getInitialAmount()); @@ -578,8 +578,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testToXmlSimpleMolecule() throws Exception { try { String xmlString = readFile(testDirectory + testSimpleMoleculeFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - SimpleMolecule species = (SimpleMolecule) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerSimpleMolecule species = (CellDesignerSimpleMolecule) result.getRight(); String transformedXml = parser.toXml(species.createAlias("" + idCounter++)); assertNotNull(transformedXml); @@ -590,8 +590,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { NodeList root = doc.getChildNodes(); assertEquals("species", root.item(0).getNodeName()); - Pair<String, ? extends Species> result2 = parser.parseXmlElement(parser.toXml(species.createAlias("" + idCounter++))); - SimpleMolecule species2 = (SimpleMolecule) result2.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result2 = parser.parseXmlElement(parser.toXml(species.createAlias("" + idCounter++))); + CellDesignerSimpleMolecule species2 = (CellDesignerSimpleMolecule) result2.getRight(); assertNotNull(species2); assertEquals(species.getName(), species2.getName()); @@ -612,8 +612,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testParseXmlSpeciesUnknown() throws Exception { try { String xmlString = readFile(testDirectory + testUnknownFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - Unknown species = (Unknown) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerUnknown species = (CellDesignerUnknown) result.getRight(); assertEquals("s1356", species.getElementId()); assertEquals("unidentified caspase acting on Occludin", species.getName()); assertEquals(new Integer(0), species.getInitialAmount()); @@ -628,8 +628,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testToXmlUnknown() throws Exception { try { String xmlString = readFile(testDirectory + testUnknownFile); - Pair<String, ? extends Species> result = parser.parseXmlElement(xmlString); - Unknown species = (Unknown) result.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result = parser.parseXmlElement(xmlString); + CellDesignerUnknown species = (CellDesignerUnknown) result.getRight(); String transformedXml = parser.toXml(species.createAlias()); assertNotNull(transformedXml); @@ -640,8 +640,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { NodeList root = doc.getChildNodes(); assertEquals("species", root.item(0).getNodeName()); - Pair<String, ? extends Species> result2 = parser.parseXmlElement(parser.toXml(species.createAlias())); - Unknown species2 = (Unknown) result2.getRight(); + Pair<String, ? extends CellDesignerSpecies<?>> result2 = parser.parseXmlElement(parser.toXml(species.createAlias())); + CellDesignerUnknown species2 = (CellDesignerUnknown) result2.getRight(); assertNotNull(species2); assertEquals(species.getName(), species2.getName()); @@ -857,7 +857,7 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { @Test public void testToXmlWithDefaultCompartment() throws Exception { try { - GenericProtein species = new GenericProtein(); + CellDesignerGenericProtein species = new CellDesignerGenericProtein(); String xml = parser.toXml(species.createAlias("EL_ID")); assertTrue(xml.contains("EL_ID")); } catch (Exception e) { @@ -869,7 +869,7 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { @Test public void testInvalidSpeciesIdentityToXml() throws Exception { try { - SpeciesAlias species = Mockito.mock(SpeciesAlias.class); + Species species = Mockito.mock(Species.class); parser.speciesIdentityToXml(species); fail("Excepiton expected"); } catch (InvalidArgumentException e) { @@ -883,7 +883,7 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { @Test public void testSpeciesIdentityToXml() throws Exception { try { - GenericProteinAlias species = new GenericProteinAlias("xx"); + GenericProtein species = new GenericProtein("xx"); species.setHypothetical(true); String xml = parser.speciesIdentityToXml(species); assertTrue(xml.contains("<celldesigner:hypothetical>true</celldesigner:hypothetical>")); @@ -912,8 +912,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testProcessInvalidStateDataInSpecies() throws Exception { try { SpeciesState state = new SpeciesState(); - state.addModificationResidue(new ModificationResidue()); - Species species = new ComplexSpecies(); + state.addModificationResidue(new CellDesignerModificationResidue()); + CellDesignerComplexSpecies species = new CellDesignerComplexSpecies(); parser.processStateDataInSpecies(species, state); fail("Exception expected"); @@ -930,7 +930,7 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { try { SpeciesState state = new SpeciesState(); state.setStructuralState("state"); - Species species = new Gene(); + CellDesignerGene species = new CellDesignerGene(); parser.processStateDataInSpecies(species, state); fail("Exception expected"); @@ -947,7 +947,7 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { try { SpeciesState state = new SpeciesState(); state.setStructuralState("state"); - Species species = new Rna(); + CellDesignerRna species = new CellDesignerRna(); parser.processStateDataInSpecies(species, state); fail("Exception expected"); @@ -963,8 +963,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testProcessInvalidStateDataInSpecies4() throws Exception { try { SpeciesState state = new SpeciesState(); - state.addModificationResidue(new ModificationResidue()); - Species species = new SimpleMolecule(); + state.addModificationResidue(new CellDesignerModificationResidue()); + CellDesignerSimpleMolecule species = new CellDesignerSimpleMolecule(); parser.processStateDataInSpecies(species, state); fail("Exception expected"); @@ -981,7 +981,7 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { try { SpeciesState state = new SpeciesState(); state.setStructuralState("state"); - Species species = new SimpleMolecule(); + CellDesignerSimpleMolecule species = new CellDesignerSimpleMolecule(); parser.processStateDataInSpecies(species, state); fail("Exception expected"); @@ -998,7 +998,7 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { try { SpeciesState state = new SpeciesState(); state.setStructuralState("state"); - Species species = new AntisenseRna(); + CellDesignerAntisenseRna species = new CellDesignerAntisenseRna(); parser.processStateDataInSpecies(species, state); fail("Exception expected"); @@ -1015,7 +1015,7 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { try { SpeciesState state = new SpeciesState(); state.setStructuralState("state"); - Species species = new Species(); + CellDesignerSpecies<?> species = new CellDesignerSpecies<Gene>(); parser.processStateDataInSpecies(species, state); fail("Exception expected"); @@ -1031,8 +1031,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testProcessInvalidStateDataInSpecies8() throws Exception { try { SpeciesState state = new SpeciesState(); - state.addModificationResidue(new ModificationResidue()); - Species species = new Species(); + state.addModificationResidue(new CellDesignerModificationResidue()); + CellDesignerSpecies<?> species = new CellDesignerSpecies<Gene>(); parser.processStateDataInSpecies(species, state); fail("Exception expected"); @@ -1048,8 +1048,8 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { public void testProcessAntisenseRnaStateDataInSpecies() throws Exception { try { SpeciesState state = new SpeciesState(); - state.addModificationResidue(new ModificationResidue()); - AntisenseRna species = new AntisenseRna(); + state.addModificationResidue(new CellDesignerModificationResidue()); + CellDesignerAntisenseRna species = new CellDesignerAntisenseRna(); parser.processStateDataInSpecies(species, state); @@ -1064,11 +1064,11 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { @Test public void testCreateRnaRegion() throws Exception { try { - ModificationResidue mr = new ModificationResidue(); + CellDesignerModificationResidue mr = new CellDesignerModificationResidue(); mr.setSize(1.0); mr.setAngle(1.0); - RnaRegion region = parser.createRnaRegion(mr); + CellDesignerRnaRegion region = parser.createRnaRegion(mr); assertNotNull(region.getPos()); } catch (Exception e) { @@ -1080,11 +1080,11 @@ public class SpeciesSbmlParserTest extends CellDesignerTestFunctions { @Test public void testCreateAntisenseRnaRegion() throws Exception { try { - ModificationResidue mr = new ModificationResidue(); + CellDesignerModificationResidue mr = new CellDesignerModificationResidue(); mr.setSize(1.0); mr.setAngle(1.0); - AntisenseRnaRegion region = parser.createAntisenseRnaRegion(mr); + CellDesignerAntisenseRnaRegion region = parser.createAntisenseRnaRegion(mr); assertNotNull(region.getPos()); } catch (Exception e) { diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRnaComparatorTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRnaComparatorTest.java index 842bdd559e..0b09958461 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRnaComparatorTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/AntisenseRnaComparatorTest.java @@ -9,14 +9,14 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.AntisenseRna; -import lcsb.mapviewer.converter.model.celldesigner.structure.AntisenseRnaComparator; -import lcsb.mapviewer.converter.model.celldesigner.structure.AntisenseRnaRegion; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaRegionAlias.AntisenseRnaRegionType; +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; public class AntisenseRnaComparatorTest { - AntisenseRnaComparator comparator = new AntisenseRnaComparator(); + CellDesignerAntisenseRnaComparator comparator = new CellDesignerAntisenseRnaComparator(); @Before public void setUp() throws Exception { @@ -29,18 +29,14 @@ public class AntisenseRnaComparatorTest { @Test public void testEquals() { try { - AntisenseRna aRna1 = createAntisenseRna(); - AntisenseRna aRna2 = createAntisenseRna(); + CellDesignerAntisenseRna aRna1 = createAntisenseRna(); + CellDesignerAntisenseRna aRna2 = createAntisenseRna(); assertEquals(0, comparator.compare(aRna1, aRna1)); assertEquals(0, comparator.compare(aRna1, aRna2)); assertEquals(0, comparator.compare(aRna2, aRna1)); - aRna1.setElementId("AAA"); - assertEquals(0, comparator.compare(aRna1, aRna2)); - assertEquals(0, comparator.compare(aRna2, aRna1)); - } catch (Exception e) { e.printStackTrace(); fail("Unknowne exception occurred"); @@ -50,8 +46,8 @@ public class AntisenseRnaComparatorTest { @Test public void testDifferent() { try { - AntisenseRna aRna1 = createAntisenseRna(); - AntisenseRna aRna2 = createAntisenseRna(); + CellDesignerAntisenseRna aRna1 = createAntisenseRna(); + CellDesignerAntisenseRna aRna2 = createAntisenseRna(); aRna1.getRegions().get(0).setName("bla"); assertTrue(comparator.compare(aRna1, aRna2) != 0); assertTrue(comparator.compare(aRna2, aRna1) != 0); @@ -68,11 +64,11 @@ public class AntisenseRnaComparatorTest { assertTrue(comparator.compare(aRna2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - AntisenseRna unknown = createAntisenseRna(); + CellDesignerAntisenseRna unknown = createAntisenseRna(); unknown.setName("n"); assertTrue(comparator.compare(unknown, aRna2) != 0); - assertTrue(comparator.compare(unknown, new AntisenseRna() { + assertTrue(comparator.compare(unknown, new CellDesignerAntisenseRna() { private static final long serialVersionUID = 1L; }) != 0); } catch (Exception e) { @@ -81,10 +77,10 @@ public class AntisenseRnaComparatorTest { } } - public AntisenseRna createAntisenseRna() { - AntisenseRna result = new AntisenseRna(); + public CellDesignerAntisenseRna createAntisenseRna() { + CellDesignerAntisenseRna result = new CellDesignerAntisenseRna(); - AntisenseRnaRegion region1 = new AntisenseRnaRegion(); + CellDesignerAntisenseRnaRegion region1 = new CellDesignerAntisenseRnaRegion(); result.addRegion(region1); region1.setIdAntisenseRnaRegion("a"); region1.setName("name"); @@ -98,7 +94,7 @@ public class AntisenseRnaComparatorTest { @Test public void testInvalid() { try { - class Tmp extends AntisenseRna { + class Tmp extends CellDesignerAntisenseRna { private static final long serialVersionUID = 1L; } Tmp object = new Tmp(); 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 12841cda2a..ac90daa015 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,8 @@ 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.layout.alias.AntisenseRnaRegionAlias.AntisenseRnaRegionType; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; +import lcsb.mapviewer.model.map.species.field.ModificationState; +import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion.AntisenseRnaRegionType; public class AntisenseRnaRegionTest { @@ -29,7 +29,7 @@ public class AntisenseRnaRegionTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new AntisenseRnaRegion()); + SerializationUtils.serialize(new CellDesignerAntisenseRnaRegion()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -67,8 +67,8 @@ public class AntisenseRnaRegionTest { @Test public void testConstructor1() { try { - AntisenseRnaRegion antisenseRna = new AntisenseRnaRegion(); - AntisenseRnaRegion antisenseRna2 = new AntisenseRnaRegion(antisenseRna); + CellDesignerAntisenseRnaRegion antisenseRna = new CellDesignerAntisenseRnaRegion(); + CellDesignerAntisenseRnaRegion antisenseRna2 = new CellDesignerAntisenseRnaRegion(antisenseRna); assertNotNull(antisenseRna2); } catch (Exception e) { e.printStackTrace(); @@ -79,11 +79,11 @@ public class AntisenseRnaRegionTest { @Test public void testUpdate() { try { - AntisenseRnaRegion antisenseRna = new AntisenseRnaRegion(); + CellDesignerAntisenseRnaRegion antisenseRna = new CellDesignerAntisenseRnaRegion(); antisenseRna.setState(ModificationState.EMPTY); antisenseRna.setName("as"); antisenseRna.setPos(3.0); - AntisenseRnaRegion antisenseRna2 = new AntisenseRnaRegion(); + CellDesignerAntisenseRnaRegion antisenseRna2 = new CellDesignerAntisenseRnaRegion(); antisenseRna2.update(antisenseRna); assertEquals(antisenseRna.getState(), antisenseRna2.getState()); } catch (Exception e) { @@ -95,8 +95,8 @@ public class AntisenseRnaRegionTest { @Test public void testInvalidUpdate() { try { - AntisenseRnaRegion antisenseRna = new AntisenseRnaRegion(); - AntisenseRnaRegion antisenseRna2 = new AntisenseRnaRegion(); + CellDesignerAntisenseRnaRegion antisenseRna = new CellDesignerAntisenseRnaRegion(); + CellDesignerAntisenseRnaRegion antisenseRna2 = new CellDesignerAntisenseRnaRegion(); antisenseRna.setIdAntisenseRnaRegion("@1"); antisenseRna2.setIdAntisenseRnaRegion("@"); antisenseRna2.update(antisenseRna); @@ -111,9 +111,9 @@ public class AntisenseRnaRegionTest { @Test public void testGetters() { try { - AntisenseRnaRegion region = new AntisenseRnaRegion(new AntisenseRnaRegion()); + CellDesignerAntisenseRnaRegion region = new CellDesignerAntisenseRnaRegion(new CellDesignerAntisenseRnaRegion()); int id = 91; - AntisenseRna species = new AntisenseRna(); + CellDesignerAntisenseRna species = new CellDesignerAntisenseRna(); double pos = 4.6; double size = 5.3; AntisenseRnaRegionType type = AntisenseRnaRegionType.CODING_REGION; @@ -164,7 +164,7 @@ public class AntisenseRnaRegionTest { @Test public void testToString() { try { - assertNotNull(new AntisenseRnaRegion().toString()); + assertNotNull(new CellDesignerAntisenseRnaRegion().toString()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -174,7 +174,7 @@ public class AntisenseRnaRegionTest { @Test public void testCopy() { try { - AntisenseRnaRegion degraded = new AntisenseRnaRegion().copy(); + CellDesignerAntisenseRnaRegion degraded = new CellDesignerAntisenseRnaRegion().copy(); assertNotNull(degraded); } catch (Exception e) { e.printStackTrace(); @@ -185,7 +185,7 @@ public class AntisenseRnaRegionTest { @Test public void testInvalidCopy() { try { - new AntisenseRnaRegion() { + new CellDesignerAntisenseRnaRegion() { /** * 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 4e4b7fa223..c6b3142eae 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,7 +14,8 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; +import lcsb.mapviewer.model.map.species.AntisenseRna; +import lcsb.mapviewer.model.map.species.field.ModificationState; public class AntisenseRnaTest { @@ -29,7 +30,7 @@ public class AntisenseRnaTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new AntisenseRna()); + SerializationUtils.serialize(new CellDesignerAntisenseRna()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -39,9 +40,9 @@ public class AntisenseRnaTest { @Test public void testConstructor1() { try { - AntisenseRna original = new AntisenseRna(); - original.addRegion(new AntisenseRnaRegion()); - AntisenseRna aRna = new AntisenseRna(original); + CellDesignerAntisenseRna original = new CellDesignerAntisenseRna(); + original.addRegion(new CellDesignerAntisenseRnaRegion()); + CellDesignerAntisenseRna aRna = new CellDesignerAntisenseRna(original); assertNotNull(aRna); } catch (Exception e) { e.printStackTrace(); @@ -52,12 +53,12 @@ public class AntisenseRnaTest { @Test public void testAddRnaRegion() { try { - AntisenseRna original = new AntisenseRna(); - AntisenseRnaRegion region = new AntisenseRnaRegion(); + CellDesignerAntisenseRna original = new CellDesignerAntisenseRna(); + CellDesignerAntisenseRnaRegion region = new CellDesignerAntisenseRnaRegion(); region.setIdAntisenseRnaRegion("id1"); original.addRegion(region); - AntisenseRnaRegion region2 = new AntisenseRnaRegion(); + CellDesignerAntisenseRnaRegion region2 = new CellDesignerAntisenseRnaRegion(); region2.setIdAntisenseRnaRegion("id1"); region2.setName("nam"); original.addRegion(region2); @@ -66,7 +67,7 @@ public class AntisenseRnaTest { assertEquals("nam", original.getRegions().get(0).getName()); - AntisenseRnaRegion region3 = new AntisenseRnaRegion(); + CellDesignerAntisenseRnaRegion region3 = new CellDesignerAntisenseRnaRegion(); region3.setIdAntisenseRnaRegion("id2"); region3.setName("nam"); original.addRegion(region3); @@ -81,24 +82,24 @@ public class AntisenseRnaTest { @Test public void testUpdate() { try { - AntisenseRna original = new AntisenseRna(); - AntisenseRnaRegion region2 = new AntisenseRnaRegion(); + CellDesignerAntisenseRna original = new CellDesignerAntisenseRna(); + CellDesignerAntisenseRnaRegion region2 = new CellDesignerAntisenseRnaRegion(); region2.setIdAntisenseRnaRegion("id1"); region2.setName("nam"); original.addRegion(region2); - AntisenseRnaRegion region3 = new AntisenseRnaRegion(); + CellDesignerAntisenseRnaRegion region3 = new CellDesignerAntisenseRnaRegion(); region3.setIdAntisenseRnaRegion("id2"); region3.setName("nam"); original.addRegion(region3); - AntisenseRna copy = new AntisenseRna(original); - copy.addRegion(new AntisenseRnaRegion()); + CellDesignerAntisenseRna copy = new CellDesignerAntisenseRna(original); + copy.addRegion(new CellDesignerAntisenseRnaRegion()); copy.getRegions().get(0).setState(ModificationState.ACETYLATED); original.update(copy); boolean acetylatedFound = false; - for (AntisenseRnaRegion region : copy.getRegions()) { + for (CellDesignerAntisenseRnaRegion region : copy.getRegions()) { if (ModificationState.ACETYLATED.equals(region.getState())) { acetylatedFound = true; } @@ -106,7 +107,7 @@ public class AntisenseRnaTest { assertTrue(acetylatedFound); assertEquals(3, copy.getRegions().size()); - original.update(new GenericProtein()); + original.update(new CellDesignerGenericProtein()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -116,10 +117,10 @@ public class AntisenseRnaTest { @Test public void testGetters() { try { - AntisenseRna aRna = new AntisenseRna(new Species()); + CellDesignerAntisenseRna aRna = new CellDesignerAntisenseRna(new CellDesignerSpecies<AntisenseRna>()); assertNotNull(aRna.getStringType()); - List<AntisenseRnaRegion> regions = new ArrayList<>(); + List<CellDesignerAntisenseRnaRegion> regions = new ArrayList<>(); aRna.setRegions(regions); @@ -133,7 +134,7 @@ public class AntisenseRnaTest { @Test public void testCopy() { try { - AntisenseRna aRna = new AntisenseRna().copy(); + CellDesignerAntisenseRna aRna = new CellDesignerAntisenseRna().copy(); assertNotNull(aRna); } catch (Exception e) { e.printStackTrace(); @@ -144,7 +145,7 @@ public class AntisenseRnaTest { @Test public void testInvalidCopy() { try { - new AntisenseRna() { + new CellDesignerAntisenseRna() { /** * 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 index 2bd397c337..28971eabb4 100644 --- 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 @@ -12,7 +12,7 @@ import lcsb.mapviewer.common.exception.InvalidClassException; public class CompartmentComparatorTest { - CompartmentComparator comparator = new CompartmentComparator(); + CellDesignerCompartmentComparator comparator = new CellDesignerCompartmentComparator(); @Before public void setUp() throws Exception { @@ -25,18 +25,14 @@ public class CompartmentComparatorTest { @Test public void testEquals() { try { - Compartment comp1 = createCompartment(); - Compartment comp2 = createCompartment(); + CellDesignerCompartment comp1 = createCompartment(); + CellDesignerCompartment comp2 = createCompartment(); assertEquals(0, comparator.compare(comp1, comp1)); assertEquals(0, comparator.compare(comp1, comp2)); assertEquals(0, comparator.compare(comp2, comp1)); - comp1.setElementId("AAA"); - assertEquals(0, comparator.compare(comp1, comp2)); - assertEquals(0, comparator.compare(comp2, comp1)); - } catch (Exception e) { e.printStackTrace(); fail("Unknowne exception occurred"); @@ -46,8 +42,8 @@ public class CompartmentComparatorTest { @Test public void testDifferent() { try { - Compartment compartment1 = createCompartment(); - Compartment compartment2 = createCompartment(); + CellDesignerCompartment compartment1 = createCompartment(); + CellDesignerCompartment compartment2 = createCompartment(); compartment1.setElementId("id2"); assertTrue(comparator.compare(compartment1, compartment2) != 0); assertTrue(comparator.compare(compartment2, compartment1) != 0); @@ -70,8 +66,8 @@ public class CompartmentComparatorTest { } } - public Compartment createCompartment() { - Compartment result = new Compartment(); + public CellDesignerCompartment createCompartment() { + CellDesignerCompartment result = new CellDesignerCompartment(); result.setElementId("id1"); result.setName("bla"); return result; @@ -80,8 +76,8 @@ public class CompartmentComparatorTest { @Test public void testInvalid() { try { - Compartment compartment1 = new Compartment(); - Compartment compartment2 = new Compartment() { + CellDesignerCompartment compartment1 = new CellDesignerCompartment(); + CellDesignerCompartment compartment2 = new CellDesignerCompartment() { /** * @@ -100,7 +96,7 @@ public class CompartmentComparatorTest { @Test public void testInvalid2() { try { - Compartment compartment2 = new Compartment() { + CellDesignerCompartment compartment2 = new CellDesignerCompartment() { /** * diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/CompartmentTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/CompartmentTest.java index f1f04aa3f3..683467964a 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/CompartmentTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/CompartmentTest.java @@ -26,7 +26,7 @@ public class CompartmentTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new Compartment()); + SerializationUtils.serialize(new CellDesignerCompartment()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -36,9 +36,9 @@ public class CompartmentTest { @Test public void testConstructor1() { try { - Compartment original = new Compartment(); - original.addElement(new GenericProtein()); - Compartment compartment = new Compartment(original); + CellDesignerCompartment original = new CellDesignerCompartment(); + original.addElement(new CellDesignerGenericProtein()); + CellDesignerCompartment compartment = new CellDesignerCompartment(original); assertNotNull(compartment); } catch (Exception e) { @@ -50,12 +50,12 @@ public class CompartmentTest { @Test public void testEquals() { try { - Compartment original = new Compartment(); + CellDesignerCompartment original = new CellDesignerCompartment(); original.setName("anme"); - Compartment compartment = new Compartment(original); - Compartment compartment2 = new Compartment(); + CellDesignerCompartment compartment = new CellDesignerCompartment(original); + CellDesignerCompartment compartment2 = new CellDesignerCompartment(); - Compartment compartment3 = new Compartment(); + CellDesignerCompartment compartment3 = new CellDesignerCompartment(); compartment3.setElementId("q"); assertEquals(0, compartment.compareTo(original)); @@ -80,7 +80,7 @@ public class CompartmentTest { @Test public void testCopy() { try { - Compartment compartment = new Compartment().copy(); + CellDesignerCompartment compartment = new CellDesignerCompartment().copy(); assertNotNull(compartment); } catch (Exception e) { e.printStackTrace(); @@ -93,7 +93,7 @@ public class CompartmentTest { try { String elementId = "id"; - Compartment compartment = new Compartment(); + CellDesignerCompartment compartment = new CellDesignerCompartment(); compartment.setElementId(elementId); assertEquals(elementId, compartment.getElementId()); @@ -108,9 +108,9 @@ public class CompartmentTest { @Test public void testAddElements() { try { - GenericProtein protein = new GenericProtein(); + CellDesignerGenericProtein protein = new CellDesignerGenericProtein(); - Compartment compartment = new Compartment(); + CellDesignerCompartment compartment = new CellDesignerCompartment(); assertEquals(0, compartment.getElements().size()); compartment.addElement(protein); @@ -127,7 +127,7 @@ public class CompartmentTest { @Test public void testInvalidCopy() { try { - new Compartment() { + new CellDesignerCompartment() { /** * 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 index 0f9d38dd02..2d12d5c292 100644 --- 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 @@ -11,17 +11,17 @@ import org.junit.Test; import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.Compartment; -import lcsb.mapviewer.converter.model.celldesigner.structure.ComplexSpecies; -import lcsb.mapviewer.converter.model.celldesigner.structure.ComplexSpeciesComparator; -import lcsb.mapviewer.converter.model.celldesigner.structure.Element; -import lcsb.mapviewer.converter.model.celldesigner.structure.GenericProtein; -import lcsb.mapviewer.converter.model.celldesigner.structure.Protein; +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); - ComplexSpeciesComparator comparator = new ComplexSpeciesComparator(); + CellDesignerComplexSpeciesComparator comparator = new CellDesignerComplexSpeciesComparator(); @Before public void setUp() throws Exception { @@ -34,20 +34,16 @@ public class ComplexSpeciesComparatorTest { @Test public void testEquals() { try { - ComplexSpecies complex1 = createComplexSpecies(); - ComplexSpecies complex2 = createComplexSpecies(); + CellDesignerComplexSpecies complex1 = createComplexSpecies(); + CellDesignerComplexSpecies complex2 = createComplexSpecies(); assertEquals(0, comparator.compare(complex1, complex1)); assertEquals(0, comparator.compare(complex1, complex2)); assertEquals(0, comparator.compare(complex2, complex1)); - complex1.setElementId("AAA"); - assertEquals(0, comparator.compare(complex1, complex2)); - assertEquals(0, comparator.compare(complex2, complex1)); - - complex2.addElement(new Compartment("test")); - complex1.addElement(new Compartment("test")); + 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) { @@ -59,7 +55,7 @@ public class ComplexSpeciesComparatorTest { @Test public void testInvalidComp() throws Exception { try { - class Tmp extends ComplexSpecies { + class Tmp extends CellDesignerComplexSpecies { private static final long serialVersionUID = 1L; } @@ -76,11 +72,11 @@ public class ComplexSpeciesComparatorTest { @Test public void testInvalidComp2() throws Exception { try { - ComplexSpecies complex1 = createComplexSpecies(); - ComplexSpecies complex2 = createComplexSpecies(); + CellDesignerComplexSpecies complex1 = createComplexSpecies(); + CellDesignerComplexSpecies complex2 = createComplexSpecies(); - complex2.addElement(new Compartment("test")); - complex1.addElement(Mockito.mock(Element.class)); + complex2.addElement(new CellDesignerCompartment("test")); + complex1.addElement(Mockito.mock(CellDesignerElement.class)); comparator.compare(complex1, complex2); comparator.compare(complex2, complex1); fail("Exception expected"); @@ -95,15 +91,15 @@ public class ComplexSpeciesComparatorTest { @Test public void testInvalidComp3() throws Exception { try { - ComplexSpecies complex1 = createComplexSpecies(); - ComplexSpecies complex2 = createComplexSpecies(); - Compartment c = new Compartment("test"); + CellDesignerComplexSpecies complex1 = createComplexSpecies(); + CellDesignerComplexSpecies complex2 = createComplexSpecies(); + CellDesignerCompartment c = new CellDesignerCompartment("test"); c.setName("a"); complex2.addElement(c); c.setName(""); - complex2.addElement(new Compartment("test")); - complex1.addElement(new Compartment("test")); - complex1.addElement(Mockito.mock(Element.class)); + 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) { @@ -117,8 +113,8 @@ public class ComplexSpeciesComparatorTest { @Test public void testDifferent() throws Exception { try { - ComplexSpecies complex1 = createComplexSpecies(); - ComplexSpecies complex2 = createComplexSpecies(); + CellDesignerComplexSpecies complex1 = createComplexSpecies(); + CellDesignerComplexSpecies complex2 = createComplexSpecies(); complex1.setHomodimer(123); assertTrue(comparator.compare(complex1, complex2) != 0); assertTrue(comparator.compare(complex2, complex1) != 0); @@ -143,14 +139,14 @@ public class ComplexSpeciesComparatorTest { complex1 = createComplexSpecies(); complex2 = createComplexSpecies(); - ComplexSpecies child = (ComplexSpecies) complex1.getElements().iterator().next(); + 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(); - Protein prot = new GenericProtein(); + CellDesignerProtein<?> prot = new CellDesignerGenericProtein(); prot.setElementId("test"); complex1.addElement(prot); assertTrue(comparator.compare(complex1, complex2) != 0); @@ -162,7 +158,7 @@ public class ComplexSpeciesComparatorTest { assertTrue(comparator.compare(complex1, complex2) != 0); assertTrue(comparator.compare(complex2, complex1) != 0); - assertTrue(comparator.compare(new ComplexSpecies(), new ComplexSpecies() { + assertTrue(comparator.compare(new CellDesignerComplexSpecies(), new CellDesignerComplexSpecies() { /** * @@ -179,12 +175,12 @@ public class ComplexSpeciesComparatorTest { @Test public void testDifferent3() throws Exception { try { - ComplexSpecies complex1 = createComplexSpecies(); - ComplexSpecies complex2 = createComplexSpecies(); - Protein prot = new GenericProtein(); + CellDesignerComplexSpecies complex1 = createComplexSpecies(); + CellDesignerComplexSpecies complex2 = createComplexSpecies(); + CellDesignerGenericProtein prot = new CellDesignerGenericProtein(); prot.setElementId("test"); complex1.addElement(prot); - prot = new GenericProtein(); + prot = new CellDesignerGenericProtein(); prot.setElementId("test2"); complex2.addElement(prot); assertTrue(comparator.compare(complex1, complex2) != 0); @@ -199,16 +195,16 @@ public class ComplexSpeciesComparatorTest { @Test public void testDifferent4() throws Exception { try { - ComplexSpecies complex1 = createComplexSpecies(); - ComplexSpecies complex2 = createComplexSpecies(); - Compartment c = new Compartment("test"); + CellDesignerComplexSpecies complex1 = createComplexSpecies(); + CellDesignerComplexSpecies complex2 = createComplexSpecies(); + CellDesignerCompartment c = new CellDesignerCompartment("test"); c.setName("a"); complex2.addElement(c); - complex2.addElement(new Compartment("test")); + complex2.addElement(new CellDesignerCompartment("test")); c.setName(""); - complex1.addElement(new Compartment("test")); - Compartment d = new Compartment("test2"); + complex1.addElement(new CellDesignerCompartment("test")); + CellDesignerCompartment d = new CellDesignerCompartment("test2"); d.setName("a"); complex1.addElement(d); assertTrue(comparator.compare(complex1, complex2) != 0); @@ -223,13 +219,13 @@ public class ComplexSpeciesComparatorTest { @Test public void testDifferent2() throws Exception { try { - ComplexSpecies complex1 = createComplexSpecies(); - ComplexSpecies complex2 = createComplexSpecies(); - Compartment comp = new Compartment(); + CellDesignerComplexSpecies complex1 = createComplexSpecies(); + CellDesignerComplexSpecies complex2 = createComplexSpecies(); + CellDesignerCompartment comp = new CellDesignerCompartment(); comp.setElementId("test"); comp.setFullName("X"); complex1.addElement(comp); - complex2.addElement(new Compartment("test")); + complex2.addElement(new CellDesignerCompartment("test")); assertTrue(comparator.compare(complex1, complex2) != 0); assertTrue(comparator.compare(complex2, complex1) != 0); @@ -239,19 +235,19 @@ public class ComplexSpeciesComparatorTest { } } - public ComplexSpecies createComplexSpecies() { - ComplexSpecies result = new ComplexSpecies(); + public CellDesignerComplexSpecies createComplexSpecies() { + CellDesignerComplexSpecies result = new CellDesignerComplexSpecies(); result.setHypothetical(true); result.setHomodimer(3); - ComplexSpecies child = new ComplexSpecies(); + CellDesignerComplexSpecies child = new CellDesignerComplexSpecies(); result.addElement(child); child.setCharge(12); child.setName("buu"); child.setNotes("hey, hi, hello"); - ComplexSpecies grandChild = new ComplexSpecies(); + CellDesignerComplexSpecies grandChild = new CellDesignerComplexSpecies(); child.addElement(grandChild); child.setCharge(123); child.setName("buus"); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ComplexSpeciesTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ComplexSpeciesTest.java index 1c15f8cf5a..d4a46a3bce 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ComplexSpeciesTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ComplexSpeciesTest.java @@ -14,9 +14,10 @@ import org.junit.Test; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.ComplexSpecies; -import lcsb.mapviewer.converter.model.celldesigner.structure.Element; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerComplexSpecies; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerElement; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; +import lcsb.mapviewer.model.map.species.AntisenseRna; public class ComplexSpeciesTest { @@ -31,7 +32,7 @@ public class ComplexSpeciesTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new ComplexSpecies()); + SerializationUtils.serialize(new CellDesignerComplexSpecies()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -41,7 +42,7 @@ public class ComplexSpeciesTest { @Test public void testConstructor1() { try { - ComplexSpecies degraded = new ComplexSpecies(new Species()); + CellDesignerComplexSpecies degraded = new CellDesignerComplexSpecies(new CellDesignerSpecies<AntisenseRna>()); assertNotNull(degraded); } catch (Exception e) { e.printStackTrace(); @@ -52,12 +53,12 @@ public class ComplexSpeciesTest { @Test public void testGetters() { try { - ComplexSpecies species = new ComplexSpecies(); - species.addElement(new Species()); - ComplexSpecies complex = new ComplexSpecies(species); + CellDesignerComplexSpecies species = new CellDesignerComplexSpecies(); + species.addElement(new CellDesignerSpecies<AntisenseRna>()); + CellDesignerComplexSpecies complex = new CellDesignerComplexSpecies(species); assertNotNull(complex.getStringType()); - Set<Element<?>> elements = new HashSet<>(); + Set<CellDesignerElement<?>> elements = new HashSet<>(); complex.setElements(elements); assertEquals(elements, complex.getElements()); } catch (Exception e) { @@ -69,9 +70,9 @@ public class ComplexSpeciesTest { @Test public void testAddElement() { try { - ComplexSpecies species = new ComplexSpecies(); - species.addElement(new Species()); - species.addElement(new Species()); + CellDesignerComplexSpecies species = new CellDesignerComplexSpecies(); + species.addElement(new CellDesignerSpecies<AntisenseRna>()); + species.addElement(new CellDesignerSpecies<AntisenseRna>()); fail("Exception expected"); } catch (InvalidArgumentException e) { } catch (Exception e) { @@ -83,7 +84,7 @@ public class ComplexSpeciesTest { @Test public void testSetStructuralState() { try { - ComplexSpecies species = new ComplexSpecies(); + CellDesignerComplexSpecies species = new CellDesignerComplexSpecies(); species.setStructuralState("a"); species.setStructuralState("b"); assertEquals("b", species.getStructuralState()); @@ -96,11 +97,11 @@ public class ComplexSpeciesTest { @Test public void testGetAllSimpleChildren() { try { - ComplexSpecies species = new ComplexSpecies(); - species.addElement(new Species()); - ComplexSpecies complex = new ComplexSpecies("a"); - complex.addElement(new Species("s")); - complex.addElement(new Species("d")); + CellDesignerComplexSpecies species = new CellDesignerComplexSpecies(); + species.addElement(new CellDesignerSpecies<AntisenseRna>()); + CellDesignerComplexSpecies complex = new CellDesignerComplexSpecies("a"); + complex.addElement(new CellDesignerSpecies<AntisenseRna>("s")); + complex.addElement(new CellDesignerSpecies<AntisenseRna>("d")); species.addElement(complex); assertEquals(3, species.getAllSimpleChildren().size()); } catch (Exception e) { @@ -112,7 +113,7 @@ public class ComplexSpeciesTest { @Test public void testCopy() { try { - ComplexSpecies degraded = new ComplexSpecies().copy(); + CellDesignerComplexSpecies degraded = new CellDesignerComplexSpecies().copy(); assertNotNull(degraded); } catch (Exception e) { e.printStackTrace(); @@ -123,7 +124,7 @@ public class ComplexSpeciesTest { @Test public void testInvalidCopy() { try { - new ComplexSpecies() { + new CellDesignerComplexSpecies() { /** * diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ConnectSchemeTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ConnectSchemeTest.java index 1a5ebdc15a..e427ca6477 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ConnectSchemeTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ConnectSchemeTest.java @@ -10,6 +10,8 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.ConnectScheme; + public class ConnectSchemeTest { @AfterClass diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DegradedComparatorTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DegradedComparatorTest.java index 50364bb452..5725351d96 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DegradedComparatorTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DegradedComparatorTest.java @@ -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.Degraded; -import lcsb.mapviewer.converter.model.celldesigner.structure.DegradedComparator; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerDegraded; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerDegradedComparator; public class DegradedComparatorTest { - DegradedComparator comparator = new DegradedComparator(); + CellDesignerDegradedComparator comparator = new CellDesignerDegradedComparator(); @Before public void setUp() throws Exception { @@ -27,18 +27,14 @@ public class DegradedComparatorTest { @Test public void testEquals() { try { - Degraded degraded1 = createDegraded(); - Degraded degraded2 = createDegraded(); + CellDesignerDegraded degraded1 = createDegraded(); + CellDesignerDegraded degraded2 = createDegraded(); assertEquals(0, comparator.compare(degraded1, degraded1)); assertEquals(0, comparator.compare(degraded1, degraded2)); assertEquals(0, comparator.compare(degraded2, degraded1)); - degraded1.setElementId("AAA"); - assertEquals(0, comparator.compare(degraded1, degraded2)); - assertEquals(0, comparator.compare(degraded2, degraded1)); - } catch (Exception e) { e.printStackTrace(); fail("Unknowne exception occurred"); @@ -48,8 +44,8 @@ public class DegradedComparatorTest { @Test public void testDifferent() { try { - Degraded degraded1 = createDegraded(); - Degraded degraded2 = createDegraded(); + CellDesignerDegraded degraded1 = createDegraded(); + CellDesignerDegraded degraded2 = createDegraded(); degraded1 = createDegraded(); degraded2 = createDegraded(); degraded1.setCharge(54); @@ -62,11 +58,11 @@ public class DegradedComparatorTest { assertTrue(comparator.compare(degraded2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - Degraded degraded = createDegraded(); + CellDesignerDegraded degraded = createDegraded(); degraded.setName("n"); assertTrue(comparator.compare(degraded, degraded1) != 0); - assertTrue(comparator.compare(degraded, new Degraded() { + assertTrue(comparator.compare(degraded, new CellDesignerDegraded() { private static final long serialVersionUID = 1L; }) != 0); } catch (Exception e) { @@ -75,8 +71,8 @@ public class DegradedComparatorTest { } } - public Degraded createDegraded() { - Degraded result = new Degraded(); + public CellDesignerDegraded createDegraded() { + CellDesignerDegraded result = new CellDesignerDegraded(); result.setCharge(12); return result; } @@ -84,7 +80,7 @@ public class DegradedComparatorTest { @Test public void testInvalid() { try { - class Tmp extends Degraded{ + class Tmp extends CellDesignerDegraded{ private static final long serialVersionUID = 1L; } Tmp object = new Tmp(); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DegradedTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DegradedTest.java index fafbfa6f55..245d441ac1 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DegradedTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DegradedTest.java @@ -9,8 +9,9 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.Degraded; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerDegraded; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; +import lcsb.mapviewer.model.map.species.Degraded; public class DegradedTest { @@ -25,7 +26,7 @@ public class DegradedTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new Degraded()); + SerializationUtils.serialize(new CellDesignerDegraded()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -35,7 +36,7 @@ public class DegradedTest { @Test public void testConstructor1() { try { - Degraded degraded = new Degraded(new Species()); + CellDesignerDegraded degraded = new CellDesignerDegraded(new CellDesignerSpecies<Degraded>()); assertNotNull(degraded); } catch (Exception e) { e.printStackTrace(); @@ -46,7 +47,7 @@ public class DegradedTest { @Test public void testGetters() { try { - Degraded degraded = new Degraded(new Species()); + CellDesignerDegraded degraded = new CellDesignerDegraded(new CellDesignerSpecies<Degraded>()); assertNotNull(degraded.getStringType()); } catch (Exception e) { e.printStackTrace(); @@ -57,7 +58,7 @@ public class DegradedTest { @Test public void testCopy() { try { - Degraded degraded = new Degraded().copy(); + CellDesignerDegraded degraded = new CellDesignerDegraded().copy(); assertNotNull(degraded); } catch (Exception e) { e.printStackTrace(); @@ -68,7 +69,7 @@ public class DegradedTest { @Test public void testInvalidCopy() { try { - new Degraded() { + new CellDesignerDegraded() { /** * diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DrugComparatorTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DrugComparatorTest.java index c478814faa..90c5337753 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DrugComparatorTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DrugComparatorTest.java @@ -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.Drug; -import lcsb.mapviewer.converter.model.celldesigner.structure.DrugComparator; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerDrug; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerDrugComparator; public class DrugComparatorTest { - DrugComparator comparator = new DrugComparator(); + CellDesignerDrugComparator comparator = new CellDesignerDrugComparator(); @Before public void setUp() throws Exception { @@ -27,18 +27,14 @@ public class DrugComparatorTest { @Test public void testEquals() { try { - Drug drug1 = createDrug(); - Drug drug2 = createDrug(); + CellDesignerDrug drug1 = createDrug(); + CellDesignerDrug drug2 = createDrug(); assertEquals(0, comparator.compare(drug1, drug1)); assertEquals(0, comparator.compare(drug1, drug2)); assertEquals(0, comparator.compare(drug2, drug1)); - drug1.setElementId("AAA"); - assertEquals(0, comparator.compare(drug1, drug2)); - assertEquals(0, comparator.compare(drug2, drug1)); - } catch (Exception e) { e.printStackTrace(); fail("Unknowne exception occurred"); @@ -48,16 +44,16 @@ public class DrugComparatorTest { @Test public void testDifferent() { try { - Drug drug2 = createDrug(); + CellDesignerDrug drug2 = createDrug(); assertTrue(comparator.compare(null, drug2) != 0); assertTrue(comparator.compare(drug2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - Drug drug = createDrug(); + CellDesignerDrug drug = createDrug(); drug.setName("n"); assertTrue(comparator.compare(drug, drug2) != 0); - assertTrue(comparator.compare(drug, new Drug() { + assertTrue(comparator.compare(drug, new CellDesignerDrug() { private static final long serialVersionUID = 1L; }) != 0); @@ -67,15 +63,15 @@ public class DrugComparatorTest { } } - public Drug createDrug() { - Drug result = new Drug(); + public CellDesignerDrug createDrug() { + CellDesignerDrug result = new CellDesignerDrug(); return result; } @Test public void testInvalid() { try { - class Tmp extends Drug{ + class Tmp extends CellDesignerDrug{ private static final long serialVersionUID = 1L; } Tmp object = new Tmp(); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DrugTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DrugTest.java index 381663e7c4..67068e7b80 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DrugTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/DrugTest.java @@ -9,8 +9,9 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.Drug; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerDrug; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; +import lcsb.mapviewer.model.map.species.Drug; public class DrugTest { @@ -25,7 +26,7 @@ public class DrugTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new Drug()); + SerializationUtils.serialize(new CellDesignerDrug()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -36,7 +37,7 @@ public class DrugTest { @Test public void testConstructor1() { try { - Drug degraded = new Drug(new Species()); + CellDesignerDrug degraded = new CellDesignerDrug(new CellDesignerSpecies<Drug>()); assertNotNull(degraded); } catch (Exception e) { e.printStackTrace(); @@ -47,7 +48,7 @@ public class DrugTest { @Test public void testGetters() { try { - Drug degraded = new Drug(new Species()); + CellDesignerDrug degraded = new CellDesignerDrug(new CellDesignerSpecies<Drug>()); assertNotNull(degraded.getStringType()); } catch (Exception e) { e.printStackTrace(); @@ -58,7 +59,7 @@ public class DrugTest { @Test public void testCopy() { try { - Drug degraded = new Drug().copy(); + CellDesignerDrug degraded = new CellDesignerDrug().copy(); assertNotNull(degraded); } catch (Exception e) { e.printStackTrace(); @@ -69,7 +70,7 @@ public class DrugTest { @Test public void testInvalidCopy() { try { - new Drug() { + new CellDesignerDrug() { /** * diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ElementComparatorTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ElementComparatorTest.java index d3517fcfe4..2682e00a74 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ElementComparatorTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ElementComparatorTest.java @@ -13,11 +13,11 @@ 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.layout.alias.PositionToCompartment; +import lcsb.mapviewer.model.map.species.field.PositionToCompartment; public class ElementComparatorTest { - ElementComparator comparator = new ElementComparator(); + CellDesignerElementComparator comparator = new CellDesignerElementComparator(); @Before public void setUp() throws Exception { @@ -30,7 +30,7 @@ public class ElementComparatorTest { @Test public void testException() { try { - Element<?> el = Mockito.mock(Element.class); + CellDesignerElement<?> el = Mockito.mock(CellDesignerElement.class); comparator.compare(el, el); fail("Exception should occur"); @@ -45,7 +45,7 @@ public class ElementComparatorTest { @Test public void testException2() { try { - assertEquals(0, comparator.compare(new Compartment(), new Compartment())); + assertEquals(0, comparator.compare(new CellDesignerCompartment(), new CellDesignerCompartment())); } catch (Exception e) { e.printStackTrace(); @@ -56,8 +56,8 @@ public class ElementComparatorTest { @Test public void testEquals() { try { - SimpleMolecule species1 = createSimpleMolecule(); - SimpleMolecule species2 = createSimpleMolecule(); + CellDesignerSimpleMolecule species1 = createSimpleMolecule(); + CellDesignerSimpleMolecule species2 = createSimpleMolecule(); assertEquals(0, comparator.compare(species1, species2)); assertEquals(0, comparator.compare(null, null)); @@ -73,7 +73,7 @@ public class ElementComparatorTest { @Test public void testInternalCompare() { try { - SimpleMolecule species1 = createSimpleMolecule(); + CellDesignerSimpleMolecule species1 = createSimpleMolecule(); assertTrue(comparator.internalCompare(species1, null) != 0); assertTrue(comparator.internalCompare(null, species1) != 0); @@ -90,8 +90,8 @@ public class ElementComparatorTest { @Test public void testDifferent() { try { - SimpleMolecule species1 = createSimpleMolecule(); - SimpleMolecule species2 = createSimpleMolecule(); + CellDesignerSimpleMolecule species1 = createSimpleMolecule(); + CellDesignerSimpleMolecule species2 = createSimpleMolecule(); species1.setCharge(99); assertTrue(comparator.compare(species1, species2) != 0); @@ -158,8 +158,8 @@ public class ElementComparatorTest { @Test public void testDifferentNewFields() throws Exception { try { - SimpleMolecule species1 = createSimpleMolecule(); - SimpleMolecule species2 = createSimpleMolecule(); + CellDesignerSimpleMolecule species1 = createSimpleMolecule(); + CellDesignerSimpleMolecule species2 = createSimpleMolecule(); species1.setSymbol("some symbol"); assertTrue(comparator.compare(species1, species2) != 0); @@ -192,8 +192,8 @@ public class ElementComparatorTest { } } - public SimpleMolecule createSimpleMolecule() { - SimpleMolecule result = new SimpleMolecule(); + public CellDesignerSimpleMolecule createSimpleMolecule() { + CellDesignerSimpleMolecule result = new CellDesignerSimpleMolecule(); result.setHomodimer(12); result.setElementId("id"); result.setName("id"); @@ -211,9 +211,9 @@ public class ElementComparatorTest { @Test public void testDifferentNewReconFields() throws Exception { try { - SimpleMolecule element1 = createSimpleMolecule(); + CellDesignerSimpleMolecule element1 = createSimpleMolecule(); - SimpleMolecule element2 = createSimpleMolecule(); + CellDesignerSimpleMolecule element2 = createSimpleMolecule(); element2.setAbbreviation("ABRR"); assertTrue(comparator.compare(element1, element2) != 0); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ElementTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ElementTest.java index 7eac4d04d4..290c5f552d 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ElementTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ElementTest.java @@ -35,9 +35,9 @@ public class ElementTest extends CellDesignerTestFunctions { @Test public void testConstructor() { try { - Species<?> element = Mockito.spy(Species.class); + CellDesignerSpecies<?> element = Mockito.spy(CellDesignerSpecies.class); element.addMiriamData(new MiriamData()); - Element<?> copy = new GenericProtein(element); + CellDesignerElement<?> copy = new CellDesignerGenericProtein(element); assertNotNull(copy); } catch (Exception e) { e.printStackTrace(); @@ -51,7 +51,7 @@ public class ElementTest extends CellDesignerTestFunctions { 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); + CellDesignerElement<?> element = Mockito.spy(CellDesignerElement.class); element.addMiriamData(list); assertEquals(1, element.getMiriamData().size()); assertEquals(1, getWarnings().size()); @@ -67,7 +67,7 @@ public class ElementTest extends CellDesignerTestFunctions { @Test public void testSetNotes() { try { - Element<?> element = Mockito.spy(Element.class); + CellDesignerElement<?> element = Mockito.spy(CellDesignerElement.class); element.setNotes("</html>"); fail("Exception epxected"); } catch (InvalidArgumentException e) { @@ -80,7 +80,7 @@ public class ElementTest extends CellDesignerTestFunctions { @Test public void testAddSynonym() { try { - Element<?> element = Mockito.spy(Element.class); + CellDesignerElement<?> element = Mockito.spy(CellDesignerElement.class); List<String> synonyms = new ArrayList<>(); synonyms.add("syn"); element.addSynonyms(synonyms); @@ -103,10 +103,10 @@ public class ElementTest extends CellDesignerTestFunctions { @Test public void testGetters() { try { - Element<?> element = Mockito.spy(Element.class); + CellDesignerElement<?> element = Mockito.spy(CellDesignerElement.class); List<String> synonyms = new ArrayList<>(); List<String> formerSymbols = new ArrayList<>(); - ComplexSpecies complex = new ComplexSpecies(); + CellDesignerComplexSpecies complex = new CellDesignerComplexSpecies(); Model model = new ModelFullIndexed(null); String formula = "str"; diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/GeneComparatorTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/GeneComparatorTest.java index 7e4ded16e3..b671da3858 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/GeneComparatorTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/GeneComparatorTest.java @@ -9,11 +9,12 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue; +import lcsb.mapviewer.model.map.species.field.ModificationState; public class GeneComparatorTest { - GeneComparator comparator = new GeneComparator(); + CellDesignerGeneComparator comparator = new CellDesignerGeneComparator(); @Before public void setUp() throws Exception { @@ -26,18 +27,14 @@ public class GeneComparatorTest { @Test public void testEquals() { try { - Gene gene1 = createGene(); - Gene gene2 = createGene(); + CellDesignerGene gene1 = createGene(); + CellDesignerGene gene2 = createGene(); assertEquals(0, comparator.compare(gene1, gene1)); assertEquals(0, comparator.compare(gene1, gene2)); assertEquals(0, comparator.compare(gene2, gene1)); - gene1.setElementId("AAA"); - assertEquals(0, comparator.compare(gene1, gene2)); - assertEquals(0, comparator.compare(gene2, gene1)); - } catch (Exception e) { e.printStackTrace(); fail("Unknowne exception occurred"); @@ -47,8 +44,8 @@ public class GeneComparatorTest { @Test public void testDifferent() { try { - Gene gene1 = createGene(); - Gene gene2 = createGene(); + CellDesignerGene gene1 = createGene(); + CellDesignerGene gene2 = createGene(); gene1.getModificationResidues().get(0).setName("bla"); assertTrue(comparator.compare(gene1, gene2) != 0); assertTrue(comparator.compare(gene2, gene1) != 0); @@ -65,11 +62,11 @@ public class GeneComparatorTest { assertTrue(comparator.compare(gene2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - Gene gene = createGene(); + CellDesignerGene gene = createGene(); gene.setName("n"); assertTrue(comparator.compare(gene, gene2) != 0); - assertTrue(comparator.compare(gene, new Gene() { + assertTrue(comparator.compare(gene, new CellDesignerGene() { private static final long serialVersionUID = 1L; }) != 0); @@ -79,11 +76,11 @@ public class GeneComparatorTest { } } - public Gene createGene() { - Gene result = new Gene(); + public CellDesignerGene createGene() { + CellDesignerGene result = new CellDesignerGene(); result.setHypothetical(true); - ModificationResidue residue = new ModificationResidue(); + CellDesignerModificationResidue residue = new CellDesignerModificationResidue(); result.addModificationResidue(residue); residue.setIdModificationResidue("a"); @@ -97,7 +94,7 @@ public class GeneComparatorTest { @Test public void testInvalid() { try { - class Tmp extends Gene{ + class Tmp extends CellDesignerGene{ private static final long serialVersionUID = 1L; } Tmp object = new Tmp(); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/GeneTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/GeneTest.java index 9cd00ce899..3615ade99b 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/GeneTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/GeneTest.java @@ -13,9 +13,8 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.Gene; -import lcsb.mapviewer.converter.model.celldesigner.structure.ModificationResidue; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue; +import lcsb.mapviewer.model.map.species.Gene; public class GeneTest { @@ -30,7 +29,7 @@ public class GeneTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new Gene()); + SerializationUtils.serialize(new CellDesignerGene()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -40,9 +39,9 @@ public class GeneTest { @Test public void testConstructor1() { try { - Gene original = new Gene(); - original.addModificationResidue(new ModificationResidue()); - Gene gene = new Gene(original); + CellDesignerGene original = new CellDesignerGene(); + original.addModificationResidue(new CellDesignerModificationResidue()); + CellDesignerGene gene = new CellDesignerGene(original); assertNotNull(gene); } catch (Exception e) { e.printStackTrace(); @@ -53,8 +52,8 @@ public class GeneTest { @Test public void testGetters() { try { - List<ModificationResidue> modificationResidues = new ArrayList<>(); - Gene gene = new Gene(new Species()); + List<CellDesignerModificationResidue> modificationResidues = new ArrayList<>(); + CellDesignerGene gene = new CellDesignerGene(new CellDesignerSpecies<Gene>()); assertNotNull(gene.getStringType()); gene.setModificationResidues(modificationResidues); assertEquals(modificationResidues, gene.getModificationResidues()); @@ -67,7 +66,7 @@ public class GeneTest { @Test public void testCopy() { try { - Gene degraded = new Gene().copy(); + CellDesignerGene degraded = new CellDesignerGene().copy(); assertNotNull(degraded); } catch (Exception e) { e.printStackTrace(); @@ -78,7 +77,7 @@ public class GeneTest { @Test public void testInvalidCopy() { try { - new Gene() { + new CellDesignerGene() { /** * @@ -96,10 +95,10 @@ public class GeneTest { @Test public void testUpdate() { try { - Gene gene = new Gene(); - Gene gene2 = new Gene(); - List<ModificationResidue> residues = new ArrayList<>(); - residues.add(new ModificationResidue()); + CellDesignerGene gene = new CellDesignerGene(); + CellDesignerGene gene2 = new CellDesignerGene(); + List<CellDesignerModificationResidue> residues = new ArrayList<>(); + residues.add(new CellDesignerModificationResidue()); gene2.setModificationResidues(residues); @@ -114,11 +113,11 @@ public class GeneTest { @Test public void testAddModificationResidue() { try { - Gene gene = new Gene(); - ModificationResidue mr = new ModificationResidue(); + CellDesignerGene gene = new CellDesignerGene(); + CellDesignerModificationResidue mr = new CellDesignerModificationResidue(); mr.setIdModificationResidue("id1"); - ModificationResidue mr2 = new ModificationResidue(); + CellDesignerModificationResidue mr2 = new CellDesignerModificationResidue(); mr2.setIdModificationResidue("id1"); gene.addModificationResidue(mr); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/GenericProteinTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/GenericProteinTest.java index 308a7a8341..40507f0dce 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/GenericProteinTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/GenericProteinTest.java @@ -9,8 +9,9 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.GenericProtein; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerGenericProtein; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; +import lcsb.mapviewer.model.map.species.GenericProtein; public class GenericProteinTest { @@ -25,7 +26,7 @@ public class GenericProteinTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new GenericProtein()); + SerializationUtils.serialize(new CellDesignerGenericProtein()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -35,7 +36,7 @@ public class GenericProteinTest { @Test public void testConstructor() { try { - GenericProtein species = new GenericProtein(new Species()); + CellDesignerGenericProtein species = new CellDesignerGenericProtein(new CellDesignerSpecies<GenericProtein>()); assertNotNull(species); } catch (Exception e) { e.printStackTrace(); @@ -46,7 +47,7 @@ public class GenericProteinTest { @Test public void testCopy1() { try { - GenericProtein species = new GenericProtein(new Species()).copy(); + CellDesignerGenericProtein species = new CellDesignerGenericProtein(new CellDesignerSpecies<GenericProtein>()).copy(); assertNotNull(species); } catch (Exception e) { e.printStackTrace(); @@ -57,7 +58,7 @@ public class GenericProteinTest { @Test public void testCopy2() { try { - new GenericProtein() { + new CellDesignerGenericProtein() { /** * diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/IonChannelProteinTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/IonChannelProteinTest.java index df94d86afb..927e254d89 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/IonChannelProteinTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/IonChannelProteinTest.java @@ -9,8 +9,9 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.IonChannelProtein; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerIonChannelProtein; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; +import lcsb.mapviewer.model.map.species.IonChannelProtein; public class IonChannelProteinTest { @@ -25,7 +26,7 @@ public class IonChannelProteinTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new IonChannelProtein()); + SerializationUtils.serialize(new CellDesignerIonChannelProtein()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -35,7 +36,7 @@ public class IonChannelProteinTest { @Test public void testConstructor() { try { - IonChannelProtein species = new IonChannelProtein(new Species()); + CellDesignerIonChannelProtein species = new CellDesignerIonChannelProtein(new CellDesignerSpecies<IonChannelProtein>()); assertNotNull(species); } catch (Exception e) { e.printStackTrace(); @@ -46,7 +47,7 @@ public class IonChannelProteinTest { @Test public void testCopy1() { try { - IonChannelProtein species = new IonChannelProtein(new Species()).copy(); + CellDesignerIonChannelProtein species = new CellDesignerIonChannelProtein(new CellDesignerSpecies<IonChannelProtein>()).copy(); assertNotNull(species); } catch (Exception e) { e.printStackTrace(); @@ -57,7 +58,7 @@ public class IonChannelProteinTest { @Test public void testCopy2() { try { - new IonChannelProtein() { + new CellDesignerIonChannelProtein() { /** * diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/IonComparatorTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/IonComparatorTest.java index d30536e668..d0c3eae081 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/IonComparatorTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/IonComparatorTest.java @@ -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.Ion; -import lcsb.mapviewer.converter.model.celldesigner.structure.IonComparator; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerIon; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerIonComparator; public class IonComparatorTest { - IonComparator comparator = new IonComparator(); + CellDesignerIonComparator comparator = new CellDesignerIonComparator(); @Before public void setUp() throws Exception { @@ -27,18 +27,14 @@ public class IonComparatorTest { @Test public void testEquals() { try { - Ion ion1 = createIon(); - Ion ion2 = createIon(); + CellDesignerIon ion1 = createIon(); + CellDesignerIon ion2 = createIon(); assertEquals(0, comparator.compare(ion1, ion1)); assertEquals(0, comparator.compare(ion1, ion2)); assertEquals(0, comparator.compare(ion2, ion1)); - ion1.setElementId("AAA"); - assertEquals(0, comparator.compare(ion1, ion2)); - assertEquals(0, comparator.compare(ion2, ion1)); - } catch (Exception e) { e.printStackTrace(); fail("Ione exception occurred"); @@ -48,16 +44,16 @@ public class IonComparatorTest { @Test public void testDifferent() { try { - Ion ion2 = createIon(); + CellDesignerIon ion2 = createIon(); assertTrue(comparator.compare(null, ion2) != 0); assertTrue(comparator.compare(ion2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - Ion ion = createIon(); + CellDesignerIon ion = createIon(); ion.setName("n"); assertTrue(comparator.compare(ion, ion2) != 0); - assertTrue(comparator.compare(ion, new Ion() { + assertTrue(comparator.compare(ion, new CellDesignerIon() { private static final long serialVersionUID = 1L; }) != 0); } catch (Exception e) { @@ -66,15 +62,15 @@ public class IonComparatorTest { } } - public Ion createIon() { - Ion result = new Ion(); + public CellDesignerIon createIon() { + CellDesignerIon result = new CellDesignerIon(); return result; } @Test public void testInvalid() { try { - class Tmp extends Ion { + class Tmp extends CellDesignerIon { private static final long serialVersionUID = 1L; } Tmp object = new Tmp(); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/IonTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/IonTest.java index d97de2bcb6..6e234ae978 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/IonTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/IonTest.java @@ -9,8 +9,9 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.Ion; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerIon; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; +import lcsb.mapviewer.model.map.species.IonChannelProtein; public class IonTest { @@ -25,7 +26,7 @@ public class IonTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new Ion()); + SerializationUtils.serialize(new CellDesignerIon()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -36,7 +37,7 @@ public class IonTest { @Test public void testConstructor1() { try { - Ion degraded = new Ion(new Species()); + CellDesignerIon degraded = new CellDesignerIon(new CellDesignerSpecies<IonChannelProtein>()); assertNotNull(degraded); } catch (Exception e) { e.printStackTrace(); @@ -47,7 +48,7 @@ public class IonTest { @Test public void testGetters() { try { - Ion degraded = new Ion(new Species()); + CellDesignerIon degraded = new CellDesignerIon(new CellDesignerSpecies<IonChannelProtein>()); assertNotNull(degraded.getStringType()); } catch (Exception e) { e.printStackTrace(); @@ -58,7 +59,7 @@ public class IonTest { @Test public void testCopy() { try { - Ion degraded = new Ion().copy(); + CellDesignerIon degraded = new CellDesignerIon().copy(); assertNotNull(degraded); } catch (Exception e) { e.printStackTrace(); @@ -69,7 +70,7 @@ public class IonTest { @Test public void testInvalidCopy() { try { - new Ion() { + new CellDesignerIon() { /** * diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/LinePropertiesTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/LinePropertiesTest.java index 86d86e31c3..501161070d 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/LinePropertiesTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/LinePropertiesTest.java @@ -7,6 +7,8 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.LineProperties; + public class LinePropertiesTest { @AfterClass diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ModificationResidueTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ModificationResidueTest.java index 9f3f99119e..992af01828 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ModificationResidueTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ModificationResidueTest.java @@ -13,7 +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.model.map.layout.alias.ModificationState; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue; +import lcsb.mapviewer.model.map.species.IonChannelProtein; +import lcsb.mapviewer.model.map.species.field.ModificationState; public class ModificationResidueTest { @@ -28,7 +30,7 @@ public class ModificationResidueTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new ModificationResidue()); + SerializationUtils.serialize(new CellDesignerModificationResidue()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -38,8 +40,8 @@ public class ModificationResidueTest { @Test public void testConstructor() { try { - ModificationResidue original = new ModificationResidue(); - ModificationResidue copy = new ModificationResidue(original); + CellDesignerModificationResidue original = new CellDesignerModificationResidue(); + CellDesignerModificationResidue copy = new CellDesignerModificationResidue(original); assertNotNull(copy); } catch (Exception e) { e.printStackTrace(); @@ -50,8 +52,8 @@ public class ModificationResidueTest { @Test public void testUpdate() { try { - ModificationResidue original = new ModificationResidue(); - ModificationResidue update = new ModificationResidue(); + CellDesignerModificationResidue original = new CellDesignerModificationResidue(); + CellDesignerModificationResidue update = new CellDesignerModificationResidue(); String name = "n"; String side = "s"; @@ -81,13 +83,13 @@ public class ModificationResidueTest { @Test public void testGetters() { try { - ModificationResidue original = new ModificationResidue(); + CellDesignerModificationResidue original = new CellDesignerModificationResidue(); String doubleStr = "2.0"; String invalidDoubleStr = "a2.0"; String nullStr = null; Double angle = 2.0; - Species species = new Species(); + CellDesignerSpecies<?> species = new CellDesignerSpecies<IonChannelProtein>(); original.setAngle(doubleStr); assertEquals(angle, original.getAngle(), Configuration.EPSILON); @@ -122,7 +124,7 @@ public class ModificationResidueTest { @Test public void testCopy() { try { - ModificationResidue degraded = new ModificationResidue().copy(); + CellDesignerModificationResidue degraded = new CellDesignerModificationResidue().copy(); assertNotNull(degraded); } catch (Exception e) { e.printStackTrace(); @@ -133,7 +135,7 @@ public class ModificationResidueTest { @Test public void testInvalidCopy() { try { - new ModificationResidue() { + new CellDesignerModificationResidue() { /** * diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/PhenotypeComparatorTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/PhenotypeComparatorTest.java index 11e30dd99c..f2af6d00a9 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/PhenotypeComparatorTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/PhenotypeComparatorTest.java @@ -12,7 +12,7 @@ import lcsb.mapviewer.common.exception.NotImplementedException; public class PhenotypeComparatorTest { - PhenotypeComparator comparator = new PhenotypeComparator(); + CellDesignerPhenotypeComparator comparator = new CellDesignerPhenotypeComparator(); @Before public void setUp() throws Exception { @@ -25,18 +25,14 @@ public class PhenotypeComparatorTest { @Test public void testEquals() { try { - Phenotype phenotype1 = createPhenotype(); - Phenotype phenotype2 = createPhenotype(); + CellDesignerPhenotype phenotype1 = createPhenotype(); + CellDesignerPhenotype phenotype2 = createPhenotype(); assertEquals(0, comparator.compare(phenotype1, phenotype1)); assertEquals(0, comparator.compare(phenotype1, phenotype2)); assertEquals(0, comparator.compare(phenotype2, phenotype1)); - phenotype1.setElementId("AAA"); - assertEquals(0, comparator.compare(phenotype1, phenotype2)); - assertEquals(0, comparator.compare(phenotype2, phenotype1)); - } catch (Exception e) { e.printStackTrace(); fail("Unknowne exception occurred"); @@ -46,7 +42,7 @@ public class PhenotypeComparatorTest { @Test public void testInvalid() { try { - class Tmp extends Phenotype { + class Tmp extends CellDesignerPhenotype { private static final long serialVersionUID = 1L; } Tmp phenotype1 = new Tmp(); @@ -66,16 +62,16 @@ public class PhenotypeComparatorTest { @Test public void testDifferent() { try { - Phenotype phenotype2 = createPhenotype(); + CellDesignerPhenotype 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 Phenotype() { + assertTrue(comparator.compare(phenotype2, new CellDesignerPhenotype() { private static final long serialVersionUID = 1L; }) != 0); - Phenotype phenotype = createPhenotype(); + CellDesignerPhenotype phenotype = createPhenotype(); phenotype2 = createPhenotype(); phenotype.setName("n"); assertTrue(comparator.compare(phenotype, phenotype2) != 0); @@ -86,8 +82,8 @@ public class PhenotypeComparatorTest { } } - public Phenotype createPhenotype() { - Phenotype result = new Phenotype(); + public CellDesignerPhenotype createPhenotype() { + CellDesignerPhenotype result = new CellDesignerPhenotype(); return result; } diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/PhenotypeTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/PhenotypeTest.java index f137ee4d62..2c29ccafb2 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/PhenotypeTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/PhenotypeTest.java @@ -23,7 +23,7 @@ public class PhenotypeTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new Phenotype()); + SerializationUtils.serialize(new CellDesignerPhenotype()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -33,8 +33,8 @@ public class PhenotypeTest { @Test public void testConstructor1() { try { - Phenotype original = new Phenotype(); - Phenotype copy = new Phenotype(original); + CellDesignerPhenotype original = new CellDesignerPhenotype(); + CellDesignerPhenotype copy = new CellDesignerPhenotype(original); assertNotNull(copy); } catch (Exception e) { e.printStackTrace(); @@ -45,7 +45,7 @@ public class PhenotypeTest { @Test public void testCopy() { try { - Phenotype degraded = new Phenotype().copy(); + CellDesignerPhenotype degraded = new CellDesignerPhenotype().copy(); assertNotNull(degraded); } catch (Exception e) { e.printStackTrace(); @@ -56,7 +56,7 @@ public class PhenotypeTest { @Test public void testInvalidCopy() { try { - new Phenotype() { + new CellDesignerPhenotype() { /** * diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ProteinComparatorTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ProteinComparatorTest.java index 48bdfbb22e..1fef8ac670 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ProteinComparatorTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ProteinComparatorTest.java @@ -8,11 +8,12 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue; +import lcsb.mapviewer.model.map.species.field.ModificationState; public class ProteinComparatorTest { - ProteinComparator comparator = new ProteinComparator(); + CellDesignerProteinComparator comparator = new CellDesignerProteinComparator(); @Before public void setUp() throws Exception { @@ -25,18 +26,14 @@ public class ProteinComparatorTest { @Test public void testEquals() { try { - Protein aRna1 = createProtein(); - Protein aRna2 = createProtein(); + CellDesignerGenericProtein aRna1 = createProtein(); + CellDesignerGenericProtein aRna2 = createProtein(); assertEquals(0, comparator.compare(aRna1, aRna1)); assertEquals(0, comparator.compare(aRna1, aRna2)); assertEquals(0, comparator.compare(aRna2, aRna1)); - aRna1.setElementId("AAA"); - assertEquals(0, comparator.compare(aRna1, aRna2)); - assertEquals(0, comparator.compare(aRna2, aRna1)); - } catch (Exception e) { e.printStackTrace(); fail("Unknowne exception occurred"); @@ -46,8 +43,8 @@ public class ProteinComparatorTest { @Test public void testDifferent() { try { - GenericProtein aRna1 = createProtein(); - GenericProtein aRna2 = createProtein(); + CellDesignerGenericProtein aRna1 = createProtein(); + CellDesignerGenericProtein aRna2 = createProtein(); aRna1.getModificationResidues().get(0).setName("bla"); assertTrue(comparator.compare(aRna1, aRna2) != 0); assertTrue(comparator.compare(aRna2, aRna1) != 0); @@ -64,7 +61,7 @@ public class ProteinComparatorTest { assertTrue(comparator.compare(aRna2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - assertTrue(comparator.compare(aRna2, new GenericProtein()) != 0); + assertTrue(comparator.compare(aRna2, new CellDesignerGenericProtein()) != 0); aRna1 = createProtein(); aRna2 = createProtein(); @@ -90,13 +87,13 @@ public class ProteinComparatorTest { } } - public GenericProtein createProtein() { - GenericProtein result = new GenericProtein(); + public CellDesignerGenericProtein createProtein() { + CellDesignerGenericProtein result = new CellDesignerGenericProtein(); result.setHomodimer(12); result.setStructuralState("id1"); result.setHypothetical(true); - ModificationResidue residue = new ModificationResidue(); + CellDesignerModificationResidue residue = new CellDesignerModificationResidue(); result.addModificationResidue(residue); residue.setIdModificationResidue("a"); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ProteinTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ProteinTest.java index 6c7acf7e88..abfd04f7e1 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ProteinTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ProteinTest.java @@ -11,12 +11,11 @@ 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.converter.model.celldesigner.structure.GenericProtein; -import lcsb.mapviewer.converter.model.celldesigner.structure.ModificationResidue; -import lcsb.mapviewer.converter.model.celldesigner.structure.Protein; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue; +import lcsb.mapviewer.model.map.species.Protein; public class ProteinTest { @@ -31,24 +30,23 @@ public class ProteinTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new GenericProtein()); + SerializationUtils.serialize(new CellDesignerGenericProtein()); } catch (Exception e) { e.printStackTrace(); throw e; } } - @Test public void testConstructor1() { try { - Protein protein = new GenericProtein(); + CellDesignerProtein<?> protein = new CellDesignerGenericProtein(); protein.setStructuralState("srt"); - List<ModificationResidue> residues = new ArrayList<>(); - residues.add(new ModificationResidue()); - + List<CellDesignerModificationResidue> residues = new ArrayList<>(); + residues.add(new CellDesignerModificationResidue()); + protein.setModificationResidues(residues); - Protein protein2 = new GenericProtein(protein); + CellDesignerProtein<?> protein2 = new CellDesignerGenericProtein(protein); assertNotNull(protein2); } catch (Exception e) { e.printStackTrace(); @@ -59,17 +57,17 @@ public class ProteinTest { @Test public void testUpdate() { try { - Protein protein = new GenericProtein(); + CellDesignerProtein<?> protein = new CellDesignerGenericProtein(); protein.setStructuralState(""); - Protein protein2 = new GenericProtein(); + CellDesignerProtein<?> protein2 = new CellDesignerGenericProtein(); protein2.setStructuralState("srt"); - List<ModificationResidue> residues = new ArrayList<>(); - residues.add(new ModificationResidue()); - + List<CellDesignerModificationResidue> residues = new ArrayList<>(); + residues.add(new CellDesignerModificationResidue()); + protein2.setModificationResidues(residues); - + protein.update(protein2); - assertEquals(protein2.getStructuralState(),protein.getStructuralState()); + assertEquals(protein2.getStructuralState(), protein.getStructuralState()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -79,13 +77,13 @@ public class ProteinTest { @Test public void testAddModificationResidue() { try { - Protein protein = new GenericProtein(); - ModificationResidue mr = new ModificationResidue(); + CellDesignerProtein<?> protein = new CellDesignerGenericProtein(); + CellDesignerModificationResidue mr = new CellDesignerModificationResidue(); mr.setIdModificationResidue("id1"); - - ModificationResidue mr2 = new ModificationResidue(); + + CellDesignerModificationResidue mr2 = new CellDesignerModificationResidue(); mr2.setIdModificationResidue("id1"); - + protein.addModificationResidue(mr); assertEquals(1, protein.getModificationResidues().size()); protein.addModificationResidue(mr2); @@ -99,10 +97,10 @@ public class ProteinTest { @Test public void testSetStructuralState() { try { - Protein protein = new GenericProtein(); + CellDesignerProtein<?> protein = new CellDesignerGenericProtein(); protein.setStructuralState("str"); protein.setStructuralState("str1"); - + assertEquals("str1", protein.getStructuralState()); } catch (Exception e) { e.printStackTrace(); @@ -113,7 +111,7 @@ public class ProteinTest { @Test public void testGetters() { try { - Protein protein = new GenericProtein(new Species()); + CellDesignerProtein<?> protein = new CellDesignerGenericProtein(new CellDesignerSpecies<Protein>()); assertNotNull(protein.getStringType()); } catch (Exception e) { e.printStackTrace(); @@ -124,7 +122,7 @@ public class ProteinTest { @Test public void testCopy() { try { - Protein protein = new GenericProtein().copy(); + CellDesignerProtein<?> protein = new CellDesignerGenericProtein().copy(); assertNotNull(protein); } catch (Exception e) { e.printStackTrace(); @@ -135,13 +133,8 @@ public class ProteinTest { @Test public void testInvalidCopy() { try { - new Protein() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); + CellDesignerProtein<?> mock = Mockito.spy(CellDesignerProtein.class); + mock.copy(); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { @@ -150,5 +143,4 @@ public class ProteinTest { } } - } 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 0f9fad6249..6f0c2b58b8 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,8 +9,7 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.ReceptorProtein; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; +import lcsb.mapviewer.model.map.species.ReceptorProtein; public class ReceptorProteinTest { @@ -25,17 +24,17 @@ public class ReceptorProteinTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new ReceptorProtein()); + SerializationUtils.serialize(new CellDesignerReceptorProtein()); } catch (Exception e) { e.printStackTrace(); throw e; } } - + @Test public void testConstructor() { try { - ReceptorProtein species = new ReceptorProtein(new Species()); + CellDesignerReceptorProtein species = new CellDesignerReceptorProtein(new CellDesignerSpecies<ReceptorProtein>()); assertNotNull(species); } catch (Exception e) { e.printStackTrace(); @@ -46,7 +45,7 @@ public class ReceptorProteinTest { @Test public void testCopy1() { try { - ReceptorProtein species = new ReceptorProtein(new Species()).copy(); + CellDesignerReceptorProtein species = new CellDesignerReceptorProtein(new CellDesignerSpecies<ReceptorProtein>()).copy(); assertNotNull(species); } catch (Exception e) { e.printStackTrace(); @@ -57,7 +56,7 @@ public class ReceptorProteinTest { @Test public void testCopy2() { try { - new ReceptorProtein() { + new CellDesignerReceptorProtein() { /** * diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/RnaComparatorTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/RnaComparatorTest.java index e2aca98f8e..5fd31da294 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/RnaComparatorTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/RnaComparatorTest.java @@ -9,11 +9,11 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; +import lcsb.mapviewer.model.map.species.field.ModificationState; public class RnaComparatorTest { - RnaComparator comparator = new RnaComparator(); + CellDesignerRnaComparator comparator = new CellDesignerRnaComparator(); @Before public void setUp() throws Exception { @@ -26,18 +26,14 @@ public class RnaComparatorTest { @Test public void testEquals() { try { - Rna aRna1 = createRna(); - Rna aRna2 = createRna(); + CellDesignerRna aRna1 = createRna(); + CellDesignerRna aRna2 = createRna(); assertEquals(0, comparator.compare(aRna1, aRna1)); assertEquals(0, comparator.compare(aRna1, aRna2)); assertEquals(0, comparator.compare(aRna2, aRna1)); - aRna1.setElementId("AAA"); - assertEquals(0, comparator.compare(aRna1, aRna2)); - assertEquals(0, comparator.compare(aRna2, aRna1)); - } catch (Exception e) { e.printStackTrace(); fail("Unknowne exception occurred"); @@ -47,8 +43,8 @@ public class RnaComparatorTest { @Test public void testDifferent() { try { - Rna aRna1 = createRna(); - Rna aRna2 = createRna(); + CellDesignerRna aRna1 = createRna(); + CellDesignerRna aRna2 = createRna(); aRna1.getRegions().get(0).setState(ModificationState.ACETYLATED); assertTrue(comparator.compare(aRna1, aRna2) != 0); assertTrue(comparator.compare(aRna2, aRna1) != 0); @@ -65,11 +61,11 @@ public class RnaComparatorTest { assertTrue(comparator.compare(aRna2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - Rna rna = createRna(); + CellDesignerRna rna = createRna(); rna.setName("n"); assertTrue(comparator.compare(rna, aRna2) != 0); - assertTrue(comparator.compare(rna, new Rna() { + assertTrue(comparator.compare(rna, new CellDesignerRna() { private static final long serialVersionUID = 1L; }) != 0); @@ -79,11 +75,11 @@ public class RnaComparatorTest { } } - public Rna createRna() { - Rna result = new Rna(); + public CellDesignerRna createRna() { + CellDesignerRna result = new CellDesignerRna(); result.setHypothetical(true); - RnaRegion region1 = new RnaRegion(); + CellDesignerRnaRegion region1 = new CellDesignerRnaRegion(); result.addRegion(region1); region1.setIdRnaRegion("a"); region1.setState(ModificationState.DONT_CARE); @@ -96,7 +92,7 @@ public class RnaComparatorTest { @Test public void testInvalid() { try { - class Tmp extends Rna { + class Tmp extends CellDesignerRna { private static final long serialVersionUID = 1L; } Tmp object = new Tmp(); 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 fe45169fc0..ac16a87425 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,7 +11,7 @@ import org.junit.Test; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; +import lcsb.mapviewer.model.map.species.field.ModificationState; public class RnaRegionTest { @@ -26,7 +26,7 @@ public class RnaRegionTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new RnaRegion()); + SerializationUtils.serialize(new CellDesignerRnaRegion()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -36,7 +36,7 @@ public class RnaRegionTest { @Test public void testConstructor() { try { - RnaRegion region = new RnaRegion(new RnaRegion()); + CellDesignerRnaRegion region = new CellDesignerRnaRegion(new CellDesignerRnaRegion()); assertNotNull(region); } catch (Exception e) { e.printStackTrace(); @@ -47,7 +47,7 @@ public class RnaRegionTest { @Test public void testSetSize() { try { - RnaRegion region = new RnaRegion(); + CellDesignerRnaRegion region = new CellDesignerRnaRegion(); try { region.setSize("as"); fail("Exception expected"); @@ -64,7 +64,7 @@ public class RnaRegionTest { @Test public void testSetPos() { try { - RnaRegion region = new RnaRegion(); + CellDesignerRnaRegion region = new CellDesignerRnaRegion(); try { region.setPos("as"); fail("Exception expected"); @@ -81,8 +81,8 @@ public class RnaRegionTest { @Test public void testUpdate() { try { - RnaRegion region = new RnaRegion(); - RnaRegion region2 = new RnaRegion(); + CellDesignerRnaRegion region = new CellDesignerRnaRegion(); + CellDesignerRnaRegion region2 = new CellDesignerRnaRegion(); region2.setState(ModificationState.ACETYLATED); region2.setName("asd"); region2.setPos(2.2); @@ -99,9 +99,9 @@ public class RnaRegionTest { @Test public void testUpdate2() { try { - RnaRegion region = new RnaRegion(); + CellDesignerRnaRegion region = new CellDesignerRnaRegion(); region.setIdRnaRegion("1"); - RnaRegion region2 = new RnaRegion(); + CellDesignerRnaRegion region2 = new CellDesignerRnaRegion(); region2.setIdRnaRegion("2"); region.update(region2); fail("Exception expected"); @@ -115,9 +115,9 @@ public class RnaRegionTest { @Test public void testGetters() { try { - RnaRegion region = new RnaRegion(); + CellDesignerRnaRegion region = new CellDesignerRnaRegion(); double size = 2.5; - Rna species = new Rna(); + CellDesignerRna species = new CellDesignerRna(); region.setSize(size); region.setSpecies(species); assertEquals(size, region.getSize(), Configuration.EPSILON); 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 56e0c936a5..6ec2c5cb3c 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,7 +15,8 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; +import lcsb.mapviewer.model.map.species.Rna; +import lcsb.mapviewer.model.map.species.field.ModificationState; public class RnaTest { Logger logger = Logger.getLogger(RnaTest.class); @@ -31,18 +32,17 @@ public class RnaTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new Rna()); + SerializationUtils.serialize(new CellDesignerRna()); } catch (Exception e) { e.printStackTrace(); throw e; } } - @Test public void testConstructor1() { try { - Rna rna = new Rna(new Species()); + CellDesignerRna rna = new CellDesignerRna(new CellDesignerSpecies<Rna>()); assertNotNull(rna); } catch (Exception e) { e.printStackTrace(); @@ -53,9 +53,9 @@ public class RnaTest { @Test public void testGetters() { try { - Rna rna = new Rna(new Species()); + CellDesignerRna rna = new CellDesignerRna(new CellDesignerSpecies<Rna>()); assertNotNull(rna.getStringType()); - List<RnaRegion> regions = new ArrayList<>(); + List<CellDesignerRnaRegion> regions = new ArrayList<>(); rna.setRegions(regions); @@ -69,7 +69,7 @@ public class RnaTest { @Test public void testCopy() { try { - Rna rna = new Rna().copy(); + CellDesignerRna rna = new CellDesignerRna().copy(); assertNotNull(rna); } catch (Exception e) { e.printStackTrace(); @@ -80,7 +80,7 @@ public class RnaTest { @Test public void testInvalidCopy() { try { - new Rna() { + new CellDesignerRna() { /** * @@ -95,16 +95,15 @@ public class RnaTest { } } - @Test public void testAddRnaRegion() { try { - Rna original = new Rna(); - RnaRegion region = new RnaRegion(); + CellDesignerRna original = new CellDesignerRna(); + CellDesignerRnaRegion region = new CellDesignerRnaRegion(); region.setIdRnaRegion("id1"); original.addRegion(region); - RnaRegion region2 = new RnaRegion(); + CellDesignerRnaRegion region2 = new CellDesignerRnaRegion(); region2.setIdRnaRegion("id1"); region2.setName("nam"); original.addRegion(region2); @@ -113,7 +112,7 @@ public class RnaTest { assertEquals("nam", original.getRegions().get(0).getName()); - RnaRegion region3 = new RnaRegion(); + CellDesignerRnaRegion region3 = new CellDesignerRnaRegion(); region3.setIdRnaRegion("id2"); region3.setName("nam"); original.addRegion(region3); @@ -128,26 +127,26 @@ public class RnaTest { @Test public void testUpdate() { try { - Rna original = new Rna(); - RnaRegion region2 = new RnaRegion(); + CellDesignerRna original = new CellDesignerRna(); + CellDesignerRnaRegion region2 = new CellDesignerRnaRegion(); region2.setIdRnaRegion("id1"); region2.setName("nam"); original.addRegion(region2); - RnaRegion region3 = new RnaRegion(); + CellDesignerRnaRegion region3 = new CellDesignerRnaRegion(); region3.setIdRnaRegion("id2"); region3.setName("nam"); original.addRegion(region3); - Rna copy = new Rna(original); - copy.addRegion(new RnaRegion()); + CellDesignerRna copy = new CellDesignerRna(original); + copy.addRegion(new CellDesignerRnaRegion()); copy.getRegions().get(0).setState(ModificationState.ACETYLATED); - + logger.debug(copy.getRegions().size()); original.update(copy); boolean acetylatedFound = false; - for (RnaRegion region : copy.getRegions()) { + for (CellDesignerRnaRegion region : copy.getRegions()) { if (ModificationState.ACETYLATED.equals(region.getState())) { acetylatedFound = true; } @@ -156,7 +155,7 @@ public class RnaTest { assertEquals(3, original.getRegions().size()); assertEquals(3, copy.getRegions().size()); - original.update(new GenericProtein()); + original.update(new CellDesignerGenericProtein()); } catch (Exception e) { e.printStackTrace(); throw e; diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SimpleMoleculeComparatorTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SimpleMoleculeComparatorTest.java index 05dbd82998..65e44068bb 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SimpleMoleculeComparatorTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SimpleMoleculeComparatorTest.java @@ -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.SimpleMolecule; -import lcsb.mapviewer.converter.model.celldesigner.structure.SimpleMoleculeComparator; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSimpleMolecule; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSimpleMoleculeComparator; public class SimpleMoleculeComparatorTest { - SimpleMoleculeComparator comparator = new SimpleMoleculeComparator(); + CellDesignerSimpleMoleculeComparator comparator = new CellDesignerSimpleMoleculeComparator(); @Before public void setUp() throws Exception { @@ -27,18 +27,14 @@ public class SimpleMoleculeComparatorTest { @Test public void testEquals() { try { - SimpleMolecule simpleMolecule1 = createSimpleMolecule(); - SimpleMolecule simpleMolecule2 = createSimpleMolecule(); + CellDesignerSimpleMolecule simpleMolecule1 = createSimpleMolecule(); + CellDesignerSimpleMolecule simpleMolecule2 = createSimpleMolecule(); assertEquals(0, comparator.compare(simpleMolecule1, simpleMolecule1)); assertEquals(0, comparator.compare(simpleMolecule1, simpleMolecule2)); assertEquals(0, comparator.compare(simpleMolecule2, simpleMolecule1)); - simpleMolecule1.setElementId("AAA"); - assertEquals(0, comparator.compare(simpleMolecule1, simpleMolecule2)); - assertEquals(0, comparator.compare(simpleMolecule2, simpleMolecule1)); - } catch (Exception e) { e.printStackTrace(); fail("Unknowne exception occurred"); @@ -48,8 +44,8 @@ public class SimpleMoleculeComparatorTest { @Test public void testDifferent() { try { - SimpleMolecule simpleMolecule1 = createSimpleMolecule(); - SimpleMolecule simpleMolecule2 = createSimpleMolecule(); + CellDesignerSimpleMolecule simpleMolecule1 = createSimpleMolecule(); + CellDesignerSimpleMolecule simpleMolecule2 = createSimpleMolecule(); simpleMolecule1.setHomodimer(3); assertTrue(comparator.compare(simpleMolecule1, simpleMolecule2) != 0); assertTrue(comparator.compare(simpleMolecule2, simpleMolecule1) != 0); @@ -72,7 +68,7 @@ public class SimpleMoleculeComparatorTest { assertTrue(comparator.compare(simpleMolecule2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - assertTrue(comparator.compare(simpleMolecule1, new SimpleMolecule() { + assertTrue(comparator.compare(simpleMolecule1, new CellDesignerSimpleMolecule() { private static final long serialVersionUID = 1L; }) != 0); @@ -85,7 +81,7 @@ public class SimpleMoleculeComparatorTest { @Test public void testInvalid() { try { - class Tmp extends SimpleMolecule { + class Tmp extends CellDesignerSimpleMolecule { private static final long serialVersionUID = 1L; } ; @@ -103,8 +99,8 @@ public class SimpleMoleculeComparatorTest { @Test public void testDifferentNewFields() throws Exception { try { - SimpleMolecule species1 = createSimpleMolecule(); - SimpleMolecule species2 = createSimpleMolecule(); + CellDesignerSimpleMolecule species1 = createSimpleMolecule(); + CellDesignerSimpleMolecule species2 = createSimpleMolecule(); species1.setSmiles("some symbol"); assertTrue(comparator.compare(species1, species2) != 0); @@ -123,8 +119,8 @@ public class SimpleMoleculeComparatorTest { } } - public SimpleMolecule createSimpleMolecule() { - SimpleMolecule result = new SimpleMolecule(); + public CellDesignerSimpleMolecule createSimpleMolecule() { + CellDesignerSimpleMolecule result = new CellDesignerSimpleMolecule(); result.setHomodimer(12); return result; diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SimpleMoleculeTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SimpleMoleculeTest.java index 82db2cc5d4..6b819c24c4 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SimpleMoleculeTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SimpleMoleculeTest.java @@ -9,8 +9,7 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.SimpleMolecule; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; +import lcsb.mapviewer.model.map.species.SimpleMolecule; public class SimpleMoleculeTest { @@ -25,7 +24,7 @@ public class SimpleMoleculeTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new SimpleMolecule()); + SerializationUtils.serialize(new CellDesignerSimpleMolecule()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -36,7 +35,7 @@ public class SimpleMoleculeTest { @Test public void testConstructor1() { try { - SimpleMolecule degraded = new SimpleMolecule(new Species()); + CellDesignerSimpleMolecule degraded = new CellDesignerSimpleMolecule(new CellDesignerSpecies<SimpleMolecule>()); assertNotNull(degraded); } catch (Exception e) { e.printStackTrace(); @@ -47,7 +46,7 @@ public class SimpleMoleculeTest { @Test public void testGetters() { try { - SimpleMolecule degraded = new SimpleMolecule(new Species()); + CellDesignerSimpleMolecule degraded = new CellDesignerSimpleMolecule(new CellDesignerSpecies<SimpleMolecule>()); assertNotNull(degraded.getStringType()); } catch (Exception e) { e.printStackTrace(); @@ -58,7 +57,7 @@ public class SimpleMoleculeTest { @Test public void testCopy() { try { - SimpleMolecule degraded = new SimpleMolecule().copy(); + CellDesignerSimpleMolecule degraded = new CellDesignerSimpleMolecule().copy(); assertNotNull(degraded); } catch (Exception e) { e.printStackTrace(); @@ -69,7 +68,7 @@ public class SimpleMoleculeTest { @Test public void testInvalidCopy() { try { - new SimpleMolecule() { + new CellDesignerSimpleMolecule() { /** * 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 index 1f6cc0aea6..fb7c885891 100644 --- 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 @@ -4,41 +4,24 @@ 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 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.layout.alias.PositionToCompartment; +import lcsb.mapviewer.model.map.species.field.PositionToCompartment; public class SpeciesComparatorTest { - SpeciesComparator comparator = new SpeciesComparator(); - - class Mock extends Species { - - /** - * - */ - private static final long serialVersionUID = 1L; - - } - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } + CellDesignerSpeciesComparator comparator = new CellDesignerSpeciesComparator(); @Test public void testException() { try { - comparator.compare(new Mock(), new Mock()); + CellDesignerSpecies<?> mock = Mockito.mock(CellDesignerSpecies.class); + comparator.compare(mock, mock); fail("Exception should occur"); } catch (InvalidClassException e) { @@ -52,18 +35,18 @@ public class SpeciesComparatorTest { @Test public void testEquals() { try { - Species species1 = createSimpleMolecule(); - Species species2 = createSimpleMolecule(); + CellDesignerSimpleMolecule species1 = createSimpleMolecule(); + CellDesignerSimpleMolecule 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())); + 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(); @@ -74,8 +57,8 @@ public class SpeciesComparatorTest { @Test public void testDifferent() { try { - SimpleMolecule species1 = createSimpleMolecule(); - SimpleMolecule species2 = createSimpleMolecule(); + CellDesignerSimpleMolecule species1 = createSimpleMolecule(); + CellDesignerSimpleMolecule species2 = createSimpleMolecule(); species1.setCharge(99); assertTrue(comparator.compare(species1, species2) != 0); @@ -138,7 +121,6 @@ public class SpeciesComparatorTest { 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); @@ -151,7 +133,7 @@ public class SpeciesComparatorTest { assertTrue(comparator.compare(species1, species2) != 0); assertTrue(comparator.compare(species2, species1) != 0); - assertTrue(comparator.compare(new Rna(), new Drug()) != 0); + assertTrue(comparator.compare(new CellDesignerRna(), new CellDesignerDrug()) != 0); } catch (Exception e) { e.printStackTrace(); @@ -159,8 +141,8 @@ public class SpeciesComparatorTest { } } - public SimpleMolecule createSimpleMolecule() { - SimpleMolecule result = new SimpleMolecule(); + public CellDesignerSimpleMolecule createSimpleMolecule() { + CellDesignerSimpleMolecule result = new CellDesignerSimpleMolecule(); result.setHomodimer(12); result.setElementId("id"); result.setName("id"); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SpeciesStateTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SpeciesStateTest.java index 882a0b0e68..b8814cdb37 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SpeciesStateTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SpeciesStateTest.java @@ -11,10 +11,12 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationResidueAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaRegionAlias; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.SpeciesState; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.Rna; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; +import lcsb.mapviewer.model.map.species.field.RnaRegion; public class SpeciesStateTest { @@ -28,7 +30,7 @@ public class SpeciesStateTest { @Test public void testGetters() { - List<ModificationResidue> modifications = new ArrayList<>(); + List<CellDesignerModificationResidue> modifications = new ArrayList<>(); SpeciesState state = new SpeciesState(); state.setModifications(modifications); assertEquals(modifications, state.getModifications()); @@ -48,16 +50,16 @@ public class SpeciesStateTest { @Test public void testConstructorFromRna() { - RnaAlias rna = new RnaAlias("1"); - rna.addRegion(new RnaRegionAlias()); + Rna rna = new Rna("1"); + rna.addRegion(new RnaRegion()); SpeciesState state = new SpeciesState(rna); assertEquals(1, state.getModifications().size()); } @Test public void testConstructorFromGene() { - GeneAlias gene = new GeneAlias("2"); - gene.addModificationResidue(new ModificationResidueAlias()); + Gene gene = new Gene("2"); + gene.addModificationResidue(new ModificationResidue()); SpeciesState state = new SpeciesState(gene); assertEquals(1, state.getModifications().size()); } @@ -65,8 +67,8 @@ public class SpeciesStateTest { @Test public void testAddModifResidue() { SpeciesState state = new SpeciesState(); - state.addModificationResidue(new ModificationResidue()); - ModificationResidue mr = new ModificationResidue(); + state.addModificationResidue(new CellDesignerModificationResidue()); + CellDesignerModificationResidue mr = new CellDesignerModificationResidue(); mr.setName("a"); state.addModificationResidue(mr); assertEquals(1, state.getModifications().size()); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SpeciesTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SpeciesTest.java index fbb1662a5b..14a1f22989 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SpeciesTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/SpeciesTest.java @@ -15,6 +15,7 @@ import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerTestFunctions; import lcsb.mapviewer.model.map.MiriamData; +import lcsb.mapviewer.model.map.species.GenericProtein; public class SpeciesTest extends CellDesignerTestFunctions { @@ -29,7 +30,7 @@ public class SpeciesTest extends CellDesignerTestFunctions { @Test public void testSerialization() { try { - SerializationUtils.serialize(new Species()); + SerializationUtils.serialize(new CellDesignerSpecies<GenericProtein>()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -39,7 +40,7 @@ public class SpeciesTest extends CellDesignerTestFunctions { @Test public void testGetters() { try { - Species species = new Species(); + CellDesignerSpecies<?> species = new CellDesignerSpecies<GenericProtein>(); String elementId = "51"; Integer initialAmount = 54; Integer initialConcentration = 58; @@ -77,7 +78,7 @@ public class SpeciesTest extends CellDesignerTestFunctions { public void testConstructor() { try { String id = "as_id"; - Species species = new Species(id); + CellDesignerSpecies<?> species = new CellDesignerSpecies<GenericProtein>(id); assertEquals(id, species.getElementId()); } catch (Exception e) { e.printStackTrace(); @@ -88,7 +89,7 @@ public class SpeciesTest extends CellDesignerTestFunctions { @Test public void testSetId() { try { - Species species = new Species(); + CellDesignerSpecies<?> species = new CellDesignerSpecies<GenericProtein>(); species.setElementId(""); species.setElementId("xx"); try { @@ -108,10 +109,10 @@ public class SpeciesTest extends CellDesignerTestFunctions { public void testUpdate1() { try { int warningsCount = getWarnings().size(); - Species species = new Species(); + CellDesignerSpecies<?> species = new CellDesignerSpecies<GenericProtein>(); species.setName("A"); species.setNotes("XXX"); - Species species2 = new Species(); + CellDesignerSpecies<?> species2 = new CellDesignerSpecies<GenericProtein>(); species2.setName("B"); species.update(species2); int warningsCount2 = getWarnings().size(); @@ -126,9 +127,9 @@ public class SpeciesTest extends CellDesignerTestFunctions { @Test public void testUpdate2() { try { - Species species = new Species(); + CellDesignerSpecies<?> species = new CellDesignerSpecies<GenericProtein>(); species.setNotes("XXX"); - Species species2 = new Species(); + CellDesignerSpecies<?> species2 = new CellDesignerSpecies<GenericProtein>(); species2.addMiriamData(new MiriamData()); species.update(species2); int warningsCount = getWarnings().size(); @@ -143,9 +144,9 @@ public class SpeciesTest extends CellDesignerTestFunctions { @Test public void testUpdate3() { try { - Species species = new Species(); + CellDesignerSpecies<?> species = new CellDesignerSpecies<GenericProtein>(); species.setNotes("XXX"); - Species species2 = new Species(); + CellDesignerSpecies<?> species2 = new CellDesignerSpecies<GenericProtein>(); species2.setNotes("xx"); species.update(species2); int warningsCount = getWarnings().size(); @@ -160,9 +161,9 @@ public class SpeciesTest extends CellDesignerTestFunctions { @Test public void testUpdate4() { try { - Species species = new Species(); + CellDesignerSpecies<?> species = new CellDesignerSpecies<GenericProtein>(); species.setNotes("XX"); - Species species2 = new Species(); + CellDesignerSpecies<?> species2 = new CellDesignerSpecies<GenericProtein>(); species2.setNotes("xxX"); species.update(species2); int warningsCount = getWarnings().size(); @@ -178,9 +179,9 @@ public class SpeciesTest extends CellDesignerTestFunctions { @Test public void testUpdate5() { try { - Species species = new Species(); + CellDesignerSpecies<?> species = new CellDesignerSpecies<GenericProtein>(); species.setNotes("XX"); - Species species2 = new Species(); + CellDesignerSpecies<?> species2 = new CellDesignerSpecies<GenericProtein>(); species2.setNotes("a as x"); species2.setHypothetical(true); species2.setSymbol("sym"); @@ -198,10 +199,10 @@ public class SpeciesTest extends CellDesignerTestFunctions { @Test public void testUpdate6() { try { - Species species = new Species(); + CellDesignerSpecies<?> species = new CellDesignerSpecies<GenericProtein>(); species.setSymbol("sym1"); species.setFullName("a_sym1"); - Species species2 = new Species(); + CellDesignerSpecies<?> species2 = new CellDesignerSpecies<GenericProtein>(); species2.setSymbol("sym2"); species2.setFullName("b_sym1"); species.update(species2); @@ -217,8 +218,8 @@ public class SpeciesTest extends CellDesignerTestFunctions { @Test public void testUpdate7() { try { - Species species = new Species(); - Species species2 = new Species(); + CellDesignerSpecies<?> species = new CellDesignerSpecies<GenericProtein>(); + CellDesignerSpecies<?> species2 = new CellDesignerSpecies<GenericProtein>(); species2.addSynonym("syn"); species2.addFormerSymbol("sym"); species.update(species2); @@ -234,7 +235,7 @@ public class SpeciesTest extends CellDesignerTestFunctions { @Test public void testSetInitialAmount() { try { - Species species = new Species(); + CellDesignerSpecies<?> species = new CellDesignerSpecies<GenericProtein>(); species.setInitialAmount("1"); assertEquals((Integer) 1, species.getInitialAmount()); try { @@ -255,7 +256,7 @@ public class SpeciesTest extends CellDesignerTestFunctions { @Test public void testSetCharge() { try { - Species species = new Species(); + CellDesignerSpecies<?> species = new CellDesignerSpecies<GenericProtein>(); species.setCharge("1"); assertEquals((Integer) 1, species.getCharge()); try { @@ -276,7 +277,7 @@ public class SpeciesTest extends CellDesignerTestFunctions { @Test public void testSetOnlySubstanceUnits() { try { - Species species = new Species(); + CellDesignerSpecies<?> species = new CellDesignerSpecies<GenericProtein>(); species.setOnlySubstanceUnits("true"); assertTrue(species.getOnlySubstanceUnits()); try { @@ -298,7 +299,7 @@ public class SpeciesTest extends CellDesignerTestFunctions { @Test public void testSetInitialConcentration() { try { - Species species = new Species(); + CellDesignerSpecies<?> species = new CellDesignerSpecies<GenericProtein>(); species.setInitialConcentration("1"); assertEquals((Integer) 1, species.getInitialConcentration()); try { 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 90ebc9489c..6f3882334d 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,8 +9,7 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; -import lcsb.mapviewer.converter.model.celldesigner.structure.TruncatedProtein; +import lcsb.mapviewer.model.map.species.TruncatedProtein; public class TruncatedProteinTest { @@ -25,17 +24,17 @@ public class TruncatedProteinTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new TruncatedProtein()); + SerializationUtils.serialize(new CellDesignerTruncatedProtein()); } catch (Exception e) { e.printStackTrace(); throw e; } } - + @Test public void testConstructor() { try { - TruncatedProtein species = new TruncatedProtein(new Species()); + CellDesignerTruncatedProtein species = new CellDesignerTruncatedProtein(new CellDesignerSpecies<TruncatedProtein>()); assertNotNull(species); } catch (Exception e) { e.printStackTrace(); @@ -46,7 +45,7 @@ public class TruncatedProteinTest { @Test public void testCopy1() { try { - TruncatedProtein species = new TruncatedProtein(new Species()).copy(); + CellDesignerTruncatedProtein species = new CellDesignerTruncatedProtein(new CellDesignerSpecies<TruncatedProtein>()).copy(); assertNotNull(species); } catch (Exception e) { e.printStackTrace(); @@ -57,7 +56,7 @@ public class TruncatedProteinTest { @Test public void testCopy2() { try { - new TruncatedProtein() { + new CellDesignerTruncatedProtein() { /** * diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/UnknownComparatorTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/UnknownComparatorTest.java index f09907eb61..6eb492e927 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/UnknownComparatorTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/UnknownComparatorTest.java @@ -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.Unknown; -import lcsb.mapviewer.converter.model.celldesigner.structure.UnknownComparator; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerUnknown; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerUnknownComparator; public class UnknownComparatorTest { - UnknownComparator comparator = new UnknownComparator(); + CellDesignerUnknownComparator comparator = new CellDesignerUnknownComparator(); @Before public void setUp() throws Exception { @@ -27,18 +27,14 @@ public class UnknownComparatorTest { @Test public void testEquals() { try { - Unknown aRna1 = createUnknown(); - Unknown aRna2 = createUnknown(); + CellDesignerUnknown aRna1 = createUnknown(); + CellDesignerUnknown aRna2 = createUnknown(); assertEquals(0, comparator.compare(aRna1, aRna1)); assertEquals(0, comparator.compare(aRna1, aRna2)); assertEquals(0, comparator.compare(aRna2, aRna1)); - aRna1.setElementId("AAA"); - assertEquals(0, comparator.compare(aRna1, aRna2)); - assertEquals(0, comparator.compare(aRna2, aRna1)); - } catch (Exception e) { e.printStackTrace(); fail("Unknowne exception occurred"); @@ -48,16 +44,16 @@ public class UnknownComparatorTest { @Test public void testDifferent() { try { - Unknown unknown2 = createUnknown(); + CellDesignerUnknown unknown2 = createUnknown(); assertTrue(comparator.compare(null, unknown2) != 0); assertTrue(comparator.compare(unknown2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - Unknown unknown = createUnknown(); + CellDesignerUnknown unknown = createUnknown(); unknown.setName("n"); assertTrue(comparator.compare(unknown, unknown2) != 0); - assertTrue(comparator.compare(unknown, new Unknown() { + assertTrue(comparator.compare(unknown, new CellDesignerUnknown() { private static final long serialVersionUID = 1L; }) != 0); @@ -67,15 +63,15 @@ public class UnknownComparatorTest { } } - public Unknown createUnknown() { - Unknown result = new Unknown(); + public CellDesignerUnknown createUnknown() { + CellDesignerUnknown result = new CellDesignerUnknown(); return result; } @Test public void testInvalid() { try { - class Tmp extends Unknown{ + class Tmp extends CellDesignerUnknown{ private static final long serialVersionUID = 1L; } Tmp object = new Tmp(); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/UnknownTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/UnknownTest.java index 24ac6f9abf..8ed1e0bc65 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/UnknownTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/UnknownTest.java @@ -9,8 +9,9 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.Species; -import lcsb.mapviewer.converter.model.celldesigner.structure.Unknown; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerUnknown; +import lcsb.mapviewer.model.map.species.Unknown; public class UnknownTest { @@ -25,7 +26,7 @@ public class UnknownTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new Unknown()); + SerializationUtils.serialize(new CellDesignerUnknown()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -35,7 +36,7 @@ public class UnknownTest { @Test public void testConstructor1() { try { - Unknown degraded = new Unknown(new Species()); + CellDesignerUnknown degraded = new CellDesignerUnknown(new CellDesignerSpecies<Unknown>()); assertNotNull(degraded); } catch (Exception e) { e.printStackTrace(); @@ -46,7 +47,7 @@ public class UnknownTest { @Test public void testGetters() { try { - Unknown degraded = new Unknown(new Species()); + CellDesignerUnknown degraded = new CellDesignerUnknown(new CellDesignerSpecies<Unknown>()); assertNotNull(degraded.getStringType()); } catch (Exception e) { e.printStackTrace(); @@ -57,7 +58,7 @@ public class UnknownTest { @Test public void testCopy() { try { - Unknown degraded = new Unknown().copy(); + CellDesignerUnknown degraded = new CellDesignerUnknown().copy(); assertNotNull(degraded); } catch (Exception e) { e.printStackTrace(); @@ -68,7 +69,7 @@ public class UnknownTest { @Test public void testInvalidCopy() { try { - new Unknown() { + new CellDesignerUnknown() { /** * diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ViewTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ViewTest.java index 9050c16045..818365ca41 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ViewTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/structure/ViewTest.java @@ -9,6 +9,8 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.View; + public class ViewTest { @AfterClass diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/types/ModifierTypeUtilsTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/types/ModifierTypeUtilsTest.java index c8e441ead6..47c055254a 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/types/ModifierTypeUtilsTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/types/ModifierTypeUtilsTest.java @@ -16,16 +16,16 @@ import org.junit.Test; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.converter.model.celldesigner.structure.Element; +import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerElement; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.reaction.AndOperator; import lcsb.mapviewer.model.map.reaction.Modifier; import lcsb.mapviewer.model.map.reaction.NodeOperator; import lcsb.mapviewer.model.map.reaction.Product; import lcsb.mapviewer.model.map.reaction.Reactant; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class ModifierTypeUtilsTest { @@ -218,7 +218,7 @@ public class ModifierTypeUtilsTest { } @SuppressWarnings("unused") - public InvalidModifier(SpeciesAlias alias, Element<?> element) { + public InvalidModifier(Species alias, CellDesignerElement<?> element) { throw new NotImplementedException(); } } @@ -235,7 +235,7 @@ public class ModifierTypeUtilsTest { // and check if we catch properly information about problematic // implementation - utils.createModifierForStringType(typeToModify.getStringName(), new GenericProteinAlias("id")); + utils.createModifierForStringType(typeToModify.getStringName(), new GenericProtein("id")); fail("Exceptione expected"); } catch (InvalidStateException e) { assertTrue(e.getMessage().contains("Problem with instantiation of Modifier class")); 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 5a6f1927fb..551f51b2af 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 @@ -29,21 +29,7 @@ import lcsb.mapviewer.common.comparator.DoubleComparator; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.converter.graphics.reaction.ReactionConverter; import lcsb.mapviewer.model.graphics.ArrowType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaAlias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.DegradedAlias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.IonAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationResidueAlias; -import lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; -import lcsb.mapviewer.model.map.layout.alias.TruncatedProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.UnknownAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.modifier.Catalysis; import lcsb.mapviewer.model.map.modifier.Inhibition; @@ -70,6 +56,20 @@ import lcsb.mapviewer.model.map.reaction.type.ReducedPhysicalStimulationReaction import lcsb.mapviewer.model.map.reaction.type.ReducedTriggerReaction; import lcsb.mapviewer.model.map.reaction.type.StateTransitionReaction; import lcsb.mapviewer.model.map.reaction.type.UnknownTransitionReaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.AntisenseRna; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Degraded; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.Ion; +import lcsb.mapviewer.model.map.species.Phenotype; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Rna; +import lcsb.mapviewer.model.map.species.SimpleMolecule; +import lcsb.mapviewer.model.map.species.Species; +import lcsb.mapviewer.model.map.species.TruncatedProtein; +import lcsb.mapviewer.model.map.species.Unknown; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; import lcsb.mapviewer.modelutils.map.ElementUtils; /** @@ -156,9 +156,9 @@ public class SbgnmlXmlExporter { map.setLanguage(Language.PD.getName()); Sbgn sbgnData = new Sbgn(); - List<SpeciesAlias> aliases = model.getSpeciesAliases(); + List<Species> aliases = model.getSpeciesAliases(); - for (SpeciesAlias a : aliases) { + for (Species a : aliases) { if (a.getComplexAlias() == null) { Glyph newGlyph = aliasToGlyph(a); map.getGlyph().add(newGlyph); @@ -194,7 +194,7 @@ public class SbgnmlXmlExporter { * alias with all parameters for the glyph * @return newly created glyph */ - private Glyph aliasToGlyph(Alias alias) { + private Glyph aliasToGlyph(Element alias) { Glyph newGlyph = new Glyph(); boolean idIsANumber = true; try { @@ -219,8 +219,8 @@ public class SbgnmlXmlExporter { if (GlyphClazz.fromClazz(newGlyph.getClazz()).equals(GlyphClazz.MACROMOLECULE) || GlyphClazz.fromClazz(newGlyph.getClazz()).equals(GlyphClazz.MACROMOLECULE_MULTIMER)) { - ProteinAlias protein = (ProteinAlias) alias; - for (ModificationResidueAlias mr : protein.getModificationResidues()) { + Protein protein = (Protein) alias; + for (ModificationResidue mr : protein.getModificationResidues()) { Glyph stateVariableGlyph = parseStateVariable(mr, newGlyph); stateVariableGlyph.setId(newGlyph.getId().concat("-").concat(stateVariableGlyph.getId())); newGlyph.getGlyph().add(stateVariableGlyph); @@ -232,9 +232,9 @@ public class SbgnmlXmlExporter { newGlyph.getGlyph().add(unitOfInformationGlyph); } - if (alias instanceof ComplexAlias) { - ComplexAlias complexAlias = (ComplexAlias) alias; - for (SpeciesAlias a : complexAlias.getAliases()) { + if (alias instanceof Complex) { + Complex complexAlias = (Complex) alias; + for (Species a : complexAlias.getAliases()) { Glyph childGlyph = aliasToGlyph(a); newGlyph.getGlyph().add(childGlyph); } @@ -315,9 +315,9 @@ public class SbgnmlXmlExporter { * element to extract GlyphCLazz from * @return GlyphClazz adequate for given alias */ - private GlyphClazz getGlyphClazzFromElement(Alias element) { - if (element instanceof ProteinAlias) { - ProteinAlias protein = (ProteinAlias) element; + private GlyphClazz getGlyphClazzFromElement(Element element) { + if (element instanceof Protein) { + Protein protein = (Protein) element; if (protein.getHomodimer() == 1) { return GlyphClazz.MACROMOLECULE; } else { @@ -325,8 +325,8 @@ public class SbgnmlXmlExporter { } } - if (element instanceof SimpleMoleculeAlias) { - SimpleMoleculeAlias simpleMolecule = (SimpleMoleculeAlias) element; + if (element instanceof SimpleMolecule) { + SimpleMolecule simpleMolecule = (SimpleMolecule) element; if (simpleMolecule.getHomodimer() == 1) { return GlyphClazz.SIMPLE_CHEMICAL; } else { @@ -334,8 +334,8 @@ public class SbgnmlXmlExporter { } } - if (element instanceof IonAlias) { - IonAlias ion = (IonAlias) element; + if (element instanceof Ion) { + Ion ion = (Ion) element; if (ion.getHomodimer() == 1) { return GlyphClazz.SIMPLE_CHEMICAL; } else { @@ -343,8 +343,8 @@ public class SbgnmlXmlExporter { } } - if (element instanceof GeneAlias) { - GeneAlias gene = (GeneAlias) element; + if (element instanceof Gene) { + Gene gene = (Gene) element; if (gene.getHomodimer() == 1) { return GlyphClazz.NUCLEIC_ACID_FEATURE; } else { @@ -352,8 +352,8 @@ public class SbgnmlXmlExporter { } } - if (element instanceof RnaAlias) { - RnaAlias rna = (RnaAlias) element; + if (element instanceof Rna) { + Rna rna = (Rna) element; if (rna.getHomodimer() == 1) { return GlyphClazz.NUCLEIC_ACID_FEATURE; } else { @@ -361,8 +361,8 @@ public class SbgnmlXmlExporter { } } - if (element instanceof AntisenseRnaAlias) { - AntisenseRnaAlias rna = (AntisenseRnaAlias) element; + if (element instanceof AntisenseRna) { + AntisenseRna rna = (AntisenseRna) element; if (rna.getHomodimer() == 1) { return GlyphClazz.NUCLEIC_ACID_FEATURE; } else { @@ -370,8 +370,8 @@ public class SbgnmlXmlExporter { } } - if (element instanceof ComplexAlias) { - ComplexAlias complexSpecies = (ComplexAlias) element; + if (element instanceof Complex) { + Complex complexSpecies = (Complex) element; if (complexSpecies.getHomodimer() == 1) { return GlyphClazz.COMPLEX; } else { @@ -379,18 +379,18 @@ public class SbgnmlXmlExporter { } } - if (element instanceof DegradedAlias) { + if (element instanceof Degraded) { return GlyphClazz.SOURCE_AND_SINK; } - if (element instanceof PhenotypeAlias) { + if (element instanceof Phenotype) { return GlyphClazz.PHENOTYPE; } - if (element instanceof CompartmentAlias) { + if (element instanceof Compartment) { return GlyphClazz.COMPARTMENT; } - if (element instanceof UnknownAlias) { + if (element instanceof Unknown) { return GlyphClazz.UNSPECIFIED_ENTITY; } @@ -405,22 +405,22 @@ public class SbgnmlXmlExporter { * element with the name * @return label for a glyph */ - private Label getGlyphLabelFromAlias(Alias element) { + private Label getGlyphLabelFromAlias(Element element) { Label label = new Label(); label.setText(element.getName()); return label; } /** - * Returns state variable glyph parsed from {@link ModificationResidueAlias}. + * Returns state variable glyph parsed from {@link ModificationResidue}. * * @param mr - * {@link ModificationResidueAlias} to be parsed + * {@link ModificationResidue} to be parsed * @param parentGlyph * parent glyph for the state variable * @return state variable glyph */ - private Glyph parseStateVariable(ModificationResidueAlias mr, Glyph parentGlyph) { + private Glyph parseStateVariable(ModificationResidue mr, Glyph parentGlyph) { Glyph glyph = new Glyph(); glyph.setId(mr.getIdModificationResidue()); glyph.setClazz(GlyphClazz.STATE_VARIABLE.getClazz()); @@ -484,27 +484,27 @@ public class SbgnmlXmlExporter { * @return glyph with unit of information extracted from the alias or null if * no unit of information was found */ - private Glyph getUnitOfInformationGlyph(Alias alias) { + private Glyph getUnitOfInformationGlyph(Element alias) { Glyph uoiGlyph = null; String uoiText = ""; - if (alias instanceof SpeciesAlias) { - SpeciesAlias species = (SpeciesAlias) alias; + if (alias instanceof Species) { + Species species = (Species) alias; int homodir = species.getHomodimer(); if (homodir > 1) { uoiText = "N:".concat(Integer.toString(homodir)); } } - if (alias instanceof TruncatedProteinAlias) { + if (alias instanceof TruncatedProtein) { if (!uoiText.equals("")) { uoiText = uoiText.concat("; "); } uoiText = uoiText.concat("ct:truncatedProtein"); } - if (alias instanceof SpeciesAlias) { - SpeciesAlias speciesAlias = (SpeciesAlias) alias; + if (alias instanceof Species) { + Species speciesAlias = (Species) alias; if ((speciesAlias.getAliasStateLabel() != null) && (speciesAlias.getAliasStatePrefix() != null)) { if (!uoiText.equals("")) { uoiText = uoiText.concat("; "); @@ -517,19 +517,19 @@ public class SbgnmlXmlExporter { } if (!uoiText.contains("ct:")) { - if (alias instanceof RnaAlias) { + if (alias instanceof Rna) { if (!uoiText.equals("")) { uoiText = uoiText.concat("; "); } uoiText = uoiText.concat("ct:RNA"); } - if (alias instanceof AntisenseRnaAlias) { + if (alias instanceof AntisenseRna) { if (!uoiText.equals("")) { uoiText = uoiText.concat("; "); } uoiText = uoiText.concat("ct:antisenseRNA"); } - if (alias instanceof GeneAlias) { + if (alias instanceof Gene) { if (!uoiText.equals("")) { uoiText = uoiText.concat("; "); } @@ -716,7 +716,7 @@ public class SbgnmlXmlExporter { throw new InvalidArgumentException(); } - if (reaction.getProducts().get(0).getAlias() instanceof PhenotypeAlias) { + if (reaction.getProducts().get(0).getAlias() instanceof Phenotype) { logger.warn("Found Phenotype being a reactant in process. That is discouraged"); } 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 30617c76de..521f433ccf 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 @@ -36,21 +36,8 @@ import lcsb.mapviewer.model.graphics.ArrowType; import lcsb.mapviewer.model.graphics.ArrowTypeData; import lcsb.mapviewer.model.graphics.LineType; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.DegradedAlias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationResidueAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; -import lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; -import lcsb.mapviewer.model.map.layout.alias.SquareCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.UnknownAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.compartment.SquareCompartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; import lcsb.mapviewer.model.map.modifier.Catalysis; @@ -73,6 +60,19 @@ import lcsb.mapviewer.model.map.reaction.type.ReducedPhysicalStimulationReaction import lcsb.mapviewer.model.map.reaction.type.ReducedTriggerReaction; import lcsb.mapviewer.model.map.reaction.type.StateTransitionReaction; import lcsb.mapviewer.model.map.reaction.type.UnknownTransitionReaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Degraded; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Phenotype; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Rna; +import lcsb.mapviewer.model.map.species.SimpleMolecule; +import lcsb.mapviewer.model.map.species.Species; +import lcsb.mapviewer.model.map.species.Unknown; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; +import lcsb.mapviewer.model.map.species.field.ModificationState; /** * This class is a parser for SBGN-ML files. @@ -352,7 +352,7 @@ public class SbgnmlXmlParser { * @throws Exception */ private void parseGlyph(Glyph g, Model model) { - SpeciesAlias newSpecies = null; + Species newSpecies = null; switch (GlyphClazz.fromClazz(g.getClazz())) { case AND: case NOT: @@ -369,35 +369,35 @@ public class SbgnmlXmlParser { parseComplex(g, null, false, model); break; case MACROMOLECULE: - newSpecies = new GenericProteinAlias(g.getId()); + newSpecies = new GenericProtein(g.getId()); parseSpecies(g, newSpecies, true, model); break; case MACROMOLECULE_MULTIMER: - newSpecies = new GenericProteinAlias(g.getId()); + newSpecies = new GenericProtein(g.getId()); parseSpecies(g, newSpecies, false, model); break; case NUCLEIC_ACID_FEATURE: if (isRNA(g)) { - newSpecies = new RnaAlias(g.getId()); + newSpecies = new Rna(g.getId()); } else { - newSpecies = new GeneAlias(g.getId()); + newSpecies = new Gene(g.getId()); } parseSpecies(g, newSpecies, true, model); break; case NUCLEIC_ACID_FEATURE_MULTIMER: if (isRNA(g)) { - newSpecies = new RnaAlias(g.getId()); + newSpecies = new Rna(g.getId()); } else { - newSpecies = new GeneAlias(g.getId()); + newSpecies = new Gene(g.getId()); } parseSpecies(g, newSpecies, false, model); break; case PERTURBING_AGENT: - newSpecies = new PhenotypeAlias(g.getId()); + newSpecies = new Phenotype(g.getId()); parseSpecies(g, newSpecies, true, model); break; case PHENOTYPE: - newSpecies = new PhenotypeAlias(g.getId()); + newSpecies = new Phenotype(g.getId()); parseSpecies(g, newSpecies, true, model); break; case ASSOCIATION: @@ -408,22 +408,22 @@ public class SbgnmlXmlParser { processes.add(new Process(g)); break; case SIMPLE_CHEMICAL: - newSpecies = new SimpleMoleculeAlias(g.getId()); + newSpecies = new SimpleMolecule(g.getId()); parseSpecies(g, newSpecies, true, model); break; case SIMPLE_CHEMICAL_MULTIMER: - newSpecies = new SimpleMoleculeAlias(g.getId()); + newSpecies = new SimpleMolecule(g.getId()); parseSpecies(g, newSpecies, false, model); break; case SOURCE_AND_SINK: - newSpecies = new DegradedAlias(g.getId()); + newSpecies = new Degraded(g.getId()); parseSpecies(g, newSpecies, true, model); break; case TAG: case SUBMAP: logger.warn("Submaps are not supported. Glyph: " + g.getId() + " has not been parsed."); case UNSPECIFIED_ENTITY: - newSpecies = new UnknownAlias(g.getId()); + newSpecies = new Unknown(g.getId()); parseSpecies(g, newSpecies, true, model); break; default: @@ -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 SpeciesAlias)) { + && (model.getAliasByAliasId(targetGlyph.getId()) instanceof Species)) { try { parsePhenotypeArc(a, model); } catch (InvalidArgumentException ex) { @@ -579,7 +579,7 @@ public class SbgnmlXmlParser { * @param model * model to be updated */ - private void parseSpecies(Glyph g, SpeciesAlias newSpecies, boolean isHomodimer, Model model) { + private void parseSpecies(Glyph g, Species newSpecies, boolean isHomodimer, Model model) { newSpecies.setModel(model); // If Glyph has label with a name, set it as Species name. If not, set // Id as name. @@ -613,11 +613,11 @@ public class SbgnmlXmlParser { } } else { String structuralState = child.getState().getValue(); - if (newSpecies instanceof ProteinAlias) { - ProteinAlias protein = (ProteinAlias) newSpecies; + if (newSpecies instanceof Protein) { + Protein protein = (Protein) newSpecies; protein.setStructuralState(structuralState); - } else if (newSpecies instanceof ComplexAlias) { - ComplexAlias complex = (ComplexAlias) newSpecies; + } else if (newSpecies instanceof Complex) { + Complex complex = (Complex) newSpecies; complex.setStructuralState(structuralState); } } @@ -637,7 +637,7 @@ public class SbgnmlXmlParser { * @param model * model to be updated */ - private void parseAlias(Glyph g, SpeciesAlias newAlias, Model model) { + private void parseAlias(Glyph g, Species newAlias, Model model) { newAlias.setHeight(new Double(g.getBbox().getH())); newAlias.setWidth(new Double(g.getBbox().getW())); newAlias.setX(new Double(g.getBbox().getX())); @@ -645,13 +645,13 @@ public class SbgnmlXmlParser { if (g.getCompartmentRef() != null) { Glyph compartmentGlyph = (Glyph) g.getCompartmentRef(); - CompartmentAlias compartmentAlias = model.getCompartmentAliasByCompartmentAliasId(compartmentGlyph.getId()); + Compartment compartmentAlias = model.getCompartmentAliasByCompartmentAliasId(compartmentGlyph.getId()); newAlias.setParent(compartmentAlias); newAlias.setCompartmentAlias(compartmentAlias); compartmentAlias.addAlias(newAlias); } else if (newAlias.getComplexAlias() == null) { // If the alias is in any compartment, assign it to that compartment - for (CompartmentAlias compartmentAlias : model.getCompartmentsAliases()) { + for (Compartment compartmentAlias : model.getCompartmentsAliases()) { boolean dx1 = compartmentAlias.getX() + compartmentAlias.getWidth() - newAlias.getX() >= 0; boolean dx2 = compartmentAlias.getX() - (newAlias.getX() + newAlias.getWidth()) <= 0; boolean dy1 = compartmentAlias.getY() + compartmentAlias.getHeight() - newAlias.getY() >= 0; @@ -739,12 +739,12 @@ public class SbgnmlXmlParser { * Exception is thrown if state variable is parsed for species other * than Protein */ - private void parseStateVariable(Glyph unitOfInformationGlyph, Glyph speciesGlyph, SpeciesAlias newSpecies) throws Exception { - if (!(newSpecies instanceof ProteinAlias)) { + private void parseStateVariable(Glyph unitOfInformationGlyph, Glyph speciesGlyph, Species newSpecies) throws Exception { + if (!(newSpecies instanceof Protein)) { throw new Exception("Only macromolecule elements can have state variables."); } - ProteinAlias protein = (ProteinAlias) newSpecies; - ModificationResidueAlias mr = new ModificationResidueAlias(); + Protein protein = (Protein) newSpecies; + ModificationResidue mr = new ModificationResidue(); mr.setSpecies(protein); mr.setIdModificationResidue(unitOfInformationGlyph.getId()); @@ -804,7 +804,7 @@ public class SbgnmlXmlParser { * @param alias * alias that the unit of information concerns */ - private void parseUnitOfInformation(Glyph unitOfInformationGlyph, SpeciesAlias alias) { + private void parseUnitOfInformation(Glyph unitOfInformationGlyph, Species alias) { String unitOfInformationText = unitOfInformationGlyph.getLabel().getText(); if (unitOfInformationText.contains(":") && !unitOfInformationText.startsWith("N:")) { String unitOfInformationPrefix = unitOfInformationText.substring(0, unitOfInformationText.indexOf(':')); @@ -829,49 +829,49 @@ public class SbgnmlXmlParser { * @param model * model to update with the parsed complex species */ - private void parseComplex(Glyph complexGlyph, ComplexAlias parentComplexSpecies, boolean isHomodimer, Model model) { - ComplexAlias complexSpecies = new ComplexAlias(complexGlyph.getId()); + private void parseComplex(Glyph complexGlyph, Complex parentComplexSpecies, boolean isHomodimer, Model model) { + Complex complexSpecies = new Complex(complexGlyph.getId()); if (parentComplexSpecies != null) { complexSpecies.setComplexAlias(parentComplexSpecies); } parseSpecies(complexGlyph, complexSpecies, isHomodimer, model); - ComplexAlias complexAlias = (ComplexAlias) model.getAliasByAliasId(complexGlyph.getId()); + Complex complexAlias = (Complex) model.getAliasByAliasId(complexGlyph.getId()); for (Glyph child : complexGlyph.getGlyph()) { - SpeciesAlias newSpecies; + Species newSpecies; switch (GlyphClazz.fromClazz(child.getClazz())) { case UNSPECIFIED_ENTITY: - newSpecies = new UnknownAlias(child.getId()); + newSpecies = new Unknown(child.getId()); newSpecies.setComplexAlias(complexSpecies); parseSpecies(child, newSpecies, true, model); break; case SIMPLE_CHEMICAL: - newSpecies = new SimpleMoleculeAlias(child.getId()); + newSpecies = new SimpleMolecule(child.getId()); newSpecies.setComplexAlias(complexSpecies); parseSpecies(child, newSpecies, true, model); break; case MACROMOLECULE: - newSpecies = new GenericProteinAlias(child.getId()); + newSpecies = new GenericProtein(child.getId()); newSpecies.setComplexAlias(complexSpecies); parseSpecies(child, newSpecies, true, model); break; case NUCLEIC_ACID_FEATURE: - newSpecies = new GeneAlias(child.getId()); + newSpecies = new Gene(child.getId()); newSpecies.setComplexAlias(complexSpecies); parseSpecies(child, newSpecies, true, model); break; case SIMPLE_CHEMICAL_MULTIMER: - newSpecies = new SimpleMoleculeAlias(child.getId()); + newSpecies = new SimpleMolecule(child.getId()); newSpecies.setComplexAlias(complexSpecies); parseSpecies(child, newSpecies, false, model); break; case MACROMOLECULE_MULTIMER: - newSpecies = new GenericProteinAlias(child.getId()); + newSpecies = new GenericProtein(child.getId()); newSpecies.setComplexAlias(complexSpecies); parseSpecies(child, newSpecies, false, model); break; case NUCLEIC_ACID_FEATURE_MULTIMER: - newSpecies = new GeneAlias(child.getId()); + newSpecies = new Gene(child.getId()); newSpecies.setComplexAlias(complexSpecies); parseSpecies(child, newSpecies, false, model); break; @@ -884,10 +884,10 @@ public class SbgnmlXmlParser { default: break; } - Alias newAlias = model.getAliasByAliasId(child.getId()); + Element newAlias = model.getAliasByAliasId(child.getId()); if (newAlias != null) { newAlias.setParent(complexAlias); - complexAlias.addAlias((SpeciesAlias) newAlias); + complexAlias.addAlias((Species) newAlias); } } } @@ -1265,7 +1265,7 @@ public class SbgnmlXmlParser { } if (a.getSource() instanceof Glyph) { Glyph sourceGlyph = (Glyph) a.getSource(); - SpeciesAlias modifierAlias = (SpeciesAlias) model.getAliasByAliasId(sourceGlyph.getId()); + Species modifierAlias = (Species) model.getAliasByAliasId(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(); - SpeciesAlias modifierAlias = (SpeciesAlias) model.getAliasByAliasId(sourceGlyph.getId()); + Species modifierAlias = (Species) model.getAliasByAliasId(sourceGlyph.getId()); modifier.setAlias(modifierAlias); List<Point2D> pointList = getLinePoints(logicArc); pointList.add(operatorCenterPoint); @@ -1485,7 +1485,7 @@ public class SbgnmlXmlParser { */ private void parseCompartment(Glyph g, Model model) { - CompartmentAlias compAlias = new SquareCompartmentAlias(g.getId()); + Compartment compAlias = new SquareCompartment(g.getId()); if (g.getLabel() != null) { compAlias.setName(g.getLabel().getText()); } 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 c67e4e2ff6..33a4974fe4 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 @@ -15,15 +15,15 @@ import java.util.Map; import lcsb.mapviewer.common.MimeType; import lcsb.mapviewer.converter.graphics.layer.LayerConverter; import lcsb.mapviewer.converter.graphics.reaction.ReactionConverter; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.compartment.PathwayCompartment; import lcsb.mapviewer.model.map.layout.ColorSchema; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ArtifitialCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.model.Model; 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.Species; import org.apache.log4j.Logger; @@ -164,7 +164,7 @@ public abstract class AbstractImageGenerator { /** * List of objects containging information about layouts visualized in the * javascript (on client side). Every object (map) represents data for - * single layout. In this map we have pairs between {@link Alias}/ + * single layout. In this map we have pairs between {@link Element}/ * {@link Reaction} and {@link ColorSchema} used to visualize the element. * */ @@ -442,11 +442,11 @@ public abstract class AbstractImageGenerator { /** * Adds layout data that is visualized on the client side. Layout data - * contains mapping between {@link Alias}/{@link Reaction} and + * contains mapping between {@link Element}/{@link Reaction} and * {@link ColorSchema} used for coloring specific element. * * @param map - * layout data containing mapping between {@link Alias}/ + * layout data containing mapping between {@link Element}/ * {@link Reaction} and {@link ColorSchema} used for coloring * specific element */ @@ -467,7 +467,7 @@ public abstract class AbstractImageGenerator { * object in layouts visualized in the javascript. * * @param object - * object ({@link Alias} or {@link Reaction}) for which we return + * object ({@link Element} or {@link Reaction}) for which we return * list of {@link ColorSchema} in different layouts * @return list with {@link ColorSchema} used to visualize the specific * object in layouts visualized in the javascript @@ -562,12 +562,12 @@ public abstract class AbstractImageGenerator { // or layers if they should be solid and hide complexity behind it // draw all aliases - for (Alias alias : params.getModel().getSortedAliases()) { + for (Element alias : params.getModel().getSortedAliases()) { // draw only aliases that don't have parents (aren't included in any // compartment/complexes) - if (alias.getParent() == null && alias instanceof SpeciesAlias) { + if (alias.getParent() == null && alias instanceof Species) { - drawAlias((SpeciesAlias) alias, params.getVisibleLayoutsForElement(alias)); + drawAlias((Species) alias, params.getVisibleLayoutsForElement(alias)); } } // draw all reactions @@ -575,7 +575,7 @@ public abstract class AbstractImageGenerator { drawReaction(reaction, params.getVisibleLayoutsForElement(reaction)); } // draw all compartments - for (CompartmentAlias ca : params.getModel().getSortedCompartmentsAliases()) { + for (Compartment ca : params.getModel().getSortedCompartmentsAliases()) { // draw only aliases that don't have parents (aren't included in any // compartment/complexes) if (ca.getParent() == null) { @@ -623,7 +623,7 @@ public abstract class AbstractImageGenerator { * @throws DrawingException * thrown when there was a problem with drawing compartment alias */ - protected void drawCompartmentAlias(final CompartmentAlias compAlias, final boolean nested, List<ColorSchema> visibleLayouts, Params params) + protected void drawCompartmentAlias(final Compartment compAlias, final boolean nested, List<ColorSchema> visibleLayouts, Params params) throws DrawingException { // If 'compAlias' has not the big enough visibility level then should not be // visible. @@ -653,7 +653,7 @@ public abstract class AbstractImageGenerator { // we draw compartment alias only when we have hierarchical view or it's // standard compartment (not the artifital pathway) - if (nested || !(compAlias instanceof ArtifitialCompartmentAlias)) { + if (nested || !(compAlias instanceof PathwayCompartment)) { try { converter.drawAlias(compAlias, graphics, compartmentParams, visibleLayouts); } catch (Exception e) { @@ -667,17 +667,17 @@ public abstract class AbstractImageGenerator { if (fill) { return; } - List<Alias> result = new ArrayList<Alias>(); + List<Element> result = new ArrayList<Element>(); result.addAll(compAlias.getAliases()); - Collections.sort(result, Alias.SIZE_COMPARATOR); + Collections.sort(result, Element.SIZE_COMPARATOR); // draw all children of this compartment - for (Alias alias : result) { + for (Element alias : result) { // if a child is a standard alias - if (alias instanceof SpeciesAlias) { - drawAlias((SpeciesAlias) alias, params.getVisibleLayoutsForElement(alias)); - } else if (alias instanceof CompartmentAlias) { - drawCompartmentAlias((CompartmentAlias) alias, nested, params.getVisibleLayoutsForElement(alias), params); + if (alias instanceof Species) { + drawAlias((Species) alias, params.getVisibleLayoutsForElement(alias)); + } else if (alias instanceof Compartment) { + drawCompartmentAlias((Compartment) alias, nested, params.getVisibleLayoutsForElement(alias), params); } else { // if a child is not a compartment or an alias then we have a // problem @@ -686,7 +686,7 @@ public abstract class AbstractImageGenerator { } if (!compAlias.containsIdenticalSpecies()) { - if (!(compAlias instanceof ArtifitialCompartmentAlias)) { + if (!(compAlias instanceof PathwayCompartment)) { converter.drawText(compAlias, graphics, compartmentParams); } } @@ -702,7 +702,7 @@ public abstract class AbstractImageGenerator { * @throws DrawingException * thrown when there was a problem with drawing an alias */ - protected void drawAlias(final SpeciesAlias alias, List<ColorSchema> visibleLayouts) throws DrawingException { + protected void drawAlias(final Species alias, List<ColorSchema> visibleLayouts) throws DrawingException { // The displaying of alias is indicated by values of VisibilityLevel. If // VisibilityLevel is big enough, then it is @@ -722,10 +722,10 @@ public abstract class AbstractImageGenerator { } boolean rescale = false; - if (alias instanceof ComplexAlias) { - if (((ComplexAlias) alias).getAliases().size() == 0) { + if (alias instanceof Complex) { + if (((Complex) alias).getAliases().size() == 0) { rescale = true; - } else if (((ComplexAlias) alias).getAliases().get(0).getVisibilityLevel() > level) { + } else if (((Complex) alias).getAliases().get(0).getVisibilityLevel() > level) { rescale = true; } } @@ -744,14 +744,14 @@ public abstract class AbstractImageGenerator { // if the alias is a complex alias then we may want to draw children // objects - if (alias instanceof ComplexAlias) { - ComplexAlias complex = (ComplexAlias) alias; + if (alias instanceof Complex) { + Complex complex = (Complex) alias; // before drawing children check if the view is not set to brief // mode if (!complex.getState().equalsIgnoreCase("brief")) { // depending on current zoom level, children are drawn or not if (complex.getTransparencyLevel() <= level) { - for (SpeciesAlias a : complex.getAliases()) { + for (Species a : complex.getAliases()) { drawAlias(a, visibleLayouts); } } 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 43255ebac4..a60ff0cd60 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 @@ -27,29 +27,29 @@ import lcsb.mapviewer.converter.graphics.species.RnaConverter; import lcsb.mapviewer.converter.graphics.species.SBGNNucleicAcidFeatureConverter; import lcsb.mapviewer.converter.graphics.species.SimpleMoleculeConverter; import lcsb.mapviewer.converter.graphics.species.UnknownConverter; +import lcsb.mapviewer.model.map.compartment.BottomSquareCompartment; +import lcsb.mapviewer.model.map.compartment.LeftSquareCompartment; +import lcsb.mapviewer.model.map.compartment.OvalCompartment; +import lcsb.mapviewer.model.map.compartment.PathwayCompartment; +import lcsb.mapviewer.model.map.compartment.RightSquareCompartment; +import lcsb.mapviewer.model.map.compartment.SquareCompartment; +import lcsb.mapviewer.model.map.compartment.TopSquareCompartment; import lcsb.mapviewer.model.map.layout.ColorSchema; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaAlias; -import lcsb.mapviewer.model.map.layout.alias.ArtifitialCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.BottomSquareCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.DegradedAlias; -import lcsb.mapviewer.model.map.layout.alias.DrugAlias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.IonAlias; -import lcsb.mapviewer.model.map.layout.alias.IonChannelProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.LeftSquareCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.OvalCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias; -import lcsb.mapviewer.model.map.layout.alias.ReceptorProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RightSquareCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; -import lcsb.mapviewer.model.map.layout.alias.SquareCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.TopSquareCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.TruncatedProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.UnknownAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.AntisenseRna; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Degraded; +import lcsb.mapviewer.model.map.species.Drug; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Ion; +import lcsb.mapviewer.model.map.species.IonChannelProtein; +import lcsb.mapviewer.model.map.species.Phenotype; +import lcsb.mapviewer.model.map.species.ReceptorProtein; +import lcsb.mapviewer.model.map.species.Rna; +import lcsb.mapviewer.model.map.species.SimpleMolecule; +import lcsb.mapviewer.model.map.species.TruncatedProtein; +import lcsb.mapviewer.model.map.species.Unknown; /** * This class is designed to convert any type of alias into a graphic glyph that @@ -60,7 +60,7 @@ import lcsb.mapviewer.model.map.layout.alias.UnknownAlias; * @author Piotr Gawron * */ -public class AliasConverter implements IAliasConverter<Alias> { +public class AliasConverter implements IAliasConverter<Element> { /** * Default class logger. */ @@ -77,35 +77,35 @@ public class AliasConverter implements IAliasConverter<Alias> { * in this map is a class of alias. Value is the converter that can process * this type of alias. */ - private static Map<Class<? extends Alias>, IAliasConverter<?>> aliasConverters = new HashMap<Class<? extends Alias>, IAliasConverter<?>>(); + private static Map<Class<? extends Element>, IAliasConverter<?>> aliasConverters = new HashMap<Class<? extends Element>, IAliasConverter<?>>(); static { // at the beginning lets add all implemented aliases // for element reference - addAliasConverter(GenericProteinAlias.class, new ProteinConverter()); - addAliasConverter(IonChannelProteinAlias.class, new ProteinConverter()); - addAliasConverter(ReceptorProteinAlias.class, new ProteinConverter()); - addAliasConverter(TruncatedProteinAlias.class, new ProteinConverter()); - addAliasConverter(DegradedAlias.class, new DegradedConverter()); - addAliasConverter(ComplexAlias.class, new ComplexConverter()); - addAliasConverter(SimpleMoleculeAlias.class, new SimpleMoleculeConverter()); - addAliasConverter(DrugAlias.class, new DrugConverter()); - addAliasConverter(IonAlias.class, new IonConverter()); - addAliasConverter(PhenotypeAlias.class, new PhenotypeConverter()); - addAliasConverter(RnaAlias.class, new RnaConverter()); - addAliasConverter(AntisenseRnaAlias.class, new AntisenseRnaConverter()); - addAliasConverter(GeneAlias.class, new GeneConverter()); - addAliasConverter(UnknownAlias.class, new UnknownConverter()); + addAliasConverter(GenericProtein.class, new ProteinConverter()); + addAliasConverter(IonChannelProtein.class, new ProteinConverter()); + addAliasConverter(ReceptorProtein.class, new ProteinConverter()); + addAliasConverter(TruncatedProtein.class, new ProteinConverter()); + addAliasConverter(Degraded.class, new DegradedConverter()); + addAliasConverter(Complex.class, new ComplexConverter()); + addAliasConverter(SimpleMolecule.class, new SimpleMoleculeConverter()); + addAliasConverter(Drug.class, new DrugConverter()); + addAliasConverter(Ion.class, new IonConverter()); + addAliasConverter(Phenotype.class, new PhenotypeConverter()); + addAliasConverter(Rna.class, new RnaConverter()); + addAliasConverter(AntisenseRna.class, new AntisenseRnaConverter()); + addAliasConverter(Gene.class, new GeneConverter()); + addAliasConverter(Unknown.class, new UnknownConverter()); // for compartment aliases - addAliasConverter(SquareCompartmentAlias.class, new SquareCompartmentConverter()); - addAliasConverter(OvalCompartmentAlias.class, new OvalCompartmentConverter()); - addAliasConverter(ArtifitialCompartmentAlias.class, new ArtifitialCompartmentConverter()); - addAliasConverter(BottomSquareCompartmentAlias.class, new BottomSquareCompartmentConverter()); - addAliasConverter(TopSquareCompartmentAlias.class, new TopSquareCompartmentConverter()); - addAliasConverter(LeftSquareCompartmentAlias.class, new LeftSquareCompartmentConverter()); - addAliasConverter(RightSquareCompartmentAlias.class, new RightSquareCompartmentConverter()); + addAliasConverter(SquareCompartment.class, new SquareCompartmentConverter()); + addAliasConverter(OvalCompartment.class, new OvalCompartmentConverter()); + addAliasConverter(PathwayCompartment.class, new ArtifitialCompartmentConverter()); + addAliasConverter(BottomSquareCompartment.class, new BottomSquareCompartmentConverter()); + addAliasConverter(TopSquareCompartment.class, new TopSquareCompartmentConverter()); + addAliasConverter(LeftSquareCompartment.class, new LeftSquareCompartmentConverter()); + addAliasConverter(RightSquareCompartment.class, new RightSquareCompartmentConverter()); } @@ -117,7 +117,7 @@ public class AliasConverter implements IAliasConverter<Alias> { * @param converter * converter that should be used for conversion of this alias */ - protected static void addAliasConverter(final Class<? extends Alias> clazz, final IAliasConverter<?> converter) { + protected static void addAliasConverter(final Class<? extends Element> clazz, final IAliasConverter<?> converter) { if (aliasConverters.get(clazz) != null) { logger.warn("Converter for " + clazz + " has been already added"); } @@ -133,7 +133,7 @@ public class AliasConverter implements IAliasConverter<Alias> { * @return converter that can be applied for the given alias; null if such * converter doesn't exist */ - private static IAliasConverter<? extends Alias> getConverterForAlias(final Alias alias) { + private static IAliasConverter<? extends Element> getConverterForAlias(final Element alias) { if (alias == null) { throw new InvalidArgumentException("alias cannot be null"); } @@ -161,10 +161,10 @@ public class AliasConverter implements IAliasConverter<Alias> { * @param sbgnFormat * boolean value indicating if SBGN display format should be used */ - public AliasConverter(final Alias alias, final boolean sbgnFormat) { + public AliasConverter(final Element alias, final boolean sbgnFormat) { // If alias is a nucleic acid feature to be displayed in SBGN - if (sbgnFormat && (alias instanceof AntisenseRnaAlias || alias instanceof RnaAlias || alias instanceof GeneAlias)) { + if (sbgnFormat && (alias instanceof AntisenseRna || alias instanceof Rna || alias instanceof Gene)) { aliasConverter = new SBGNNucleicAcidFeatureConverter(); } else { // If not, at the beginning try to find an appropriate converter @@ -183,25 +183,25 @@ public class AliasConverter implements IAliasConverter<Alias> { * @param alias * alias for which this converter will be used */ - public AliasConverter(final Alias alias) { + public AliasConverter(final Element alias) { this(alias, false); } @SuppressWarnings("unchecked") @Override - public void drawAlias(final Alias alias, final Graphics2D graphics, final ConverterParams params) { + public void drawAlias(final Element alias, final Graphics2D graphics, final ConverterParams params) { aliasConverter.drawAlias(alias, graphics, params); } @SuppressWarnings("unchecked") @Override - public void drawText(final Alias compAlias, final Graphics2D graphics, final ConverterParams params) throws DrawingException { + public void drawText(final Element compAlias, final Graphics2D graphics, final ConverterParams params) throws DrawingException { aliasConverter.drawText(compAlias, graphics, params); } @SuppressWarnings("unchecked") @Override - public void drawAlias(Alias alias, Graphics2D graphics, ConverterParams params, List<ColorSchema> visualizedLayoutsColorSchemas) { + public void drawAlias(Element alias, Graphics2D graphics, ConverterParams params, List<ColorSchema> visualizedLayoutsColorSchemas) { aliasConverter.drawAlias(alias, graphics, params, visualizedLayoutsColorSchemas); } } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/IAliasConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/IAliasConverter.java index bfb089af4f..d06ea04b21 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/IAliasConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/IAliasConverter.java @@ -4,18 +4,18 @@ import java.awt.Graphics2D; import java.util.List; import lcsb.mapviewer.model.map.layout.ColorSchema; -import lcsb.mapviewer.model.map.layout.alias.Alias; +import lcsb.mapviewer.model.map.species.Element; /** * This interface defines what operations should be possible to convert - * {@link Alias} into a graphics on Graphics2D object. + * {@link Element} into a graphics on Graphics2D object. * * @author Piotr Gawron * * @param <T> * class of alias to convert */ -public interface IAliasConverter<T extends Alias> { +public interface IAliasConverter<T extends Element> { /** * Alpha value (0..255) used for visualizing layout data that are normally * visualized in javascript. diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/ArtifitialCompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/ArtifitialCompartmentConverter.java index 021a918f00..17dd4f37e2 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/ArtifitialCompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/ArtifitialCompartmentConverter.java @@ -1,67 +1,67 @@ -package lcsb.mapviewer.converter.graphics.compartment; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.Shape; -import java.awt.Stroke; -import java.awt.geom.Point2D; -import java.awt.geom.Rectangle2D; - -import lcsb.mapviewer.converter.graphics.ConverterParams; -import lcsb.mapviewer.model.graphics.LineType; -import lcsb.mapviewer.model.map.layout.alias.ArtifitialCompartmentAlias; - -/** - * This class allows to draw ArtifitialCompartment on the Graphics2D class. - * - * @author Piotr Gawron - * - */ -public class ArtifitialCompartmentConverter extends CompartmentConverter<ArtifitialCompartmentAlias> { - /** - * Background color of drawn compartments. - */ - private Color backgroundColor = Color.LIGHT_GRAY; - - @Override - public void drawAlias(final ArtifitialCompartmentAlias alias, final Graphics2D graphics, final ConverterParams params) { - // keep the old values of colors and line - Color oldColor = graphics.getColor(); - Stroke oldStroke = graphics.getStroke(); - - Shape shape = new Rectangle2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight()); - - Color color = alias.getColor(); - - // fill the background - if (params.isFill()) { - graphics.setColor(backgroundColor); - } else { - Color bgAlphaColor = new Color(0, 0, 0, getAlphaLevel()); - graphics.setColor(bgAlphaColor); - } - graphics.fill(shape); - - // draw the border - graphics.setColor(color); - graphics.setStroke(LineType.SOLID_BOLD.getStroke()); - graphics.draw(shape); - - // restore old color and line type - graphics.setColor(oldColor); - graphics.setStroke(oldStroke); - - // draw description of the compartment - if (params.isFill()) { - Point2D tmpPoint = alias.getNamePoint(); - alias.setNamePoint(alias.getCenter()); - drawText(alias, graphics, params); - alias.setNamePoint(tmpPoint); - } else { - if (!alias.containsIdenticalSpecies()) { - drawText(alias, graphics, params); - } - } - } - -} +package lcsb.mapviewer.converter.graphics.compartment; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; + +import lcsb.mapviewer.converter.graphics.ConverterParams; +import lcsb.mapviewer.model.graphics.LineType; +import lcsb.mapviewer.model.map.compartment.PathwayCompartment; + +/** + * This class allows to draw ArtifitialCompartment on the Graphics2D class. + * + * @author Piotr Gawron + * + */ +public class ArtifitialCompartmentConverter extends CompartmentConverter<PathwayCompartment> { + /** + * Background color of drawn compartments. + */ + private Color backgroundColor = Color.LIGHT_GRAY; + + @Override + public void drawAlias(final PathwayCompartment alias, final Graphics2D graphics, final ConverterParams params) { + // keep the old values of colors and line + Color oldColor = graphics.getColor(); + Stroke oldStroke = graphics.getStroke(); + + Shape shape = new Rectangle2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight()); + + Color color = alias.getColor(); + + // fill the background + if (params.isFill()) { + graphics.setColor(backgroundColor); + } else { + Color bgAlphaColor = new Color(0, 0, 0, getAlphaLevel()); + graphics.setColor(bgAlphaColor); + } + graphics.fill(shape); + + // draw the border + graphics.setColor(color); + graphics.setStroke(LineType.SOLID_BOLD.getStroke()); + graphics.draw(shape); + + // restore old color and line type + graphics.setColor(oldColor); + graphics.setStroke(oldStroke); + + // draw description of the compartment + if (params.isFill()) { + Point2D tmpPoint = alias.getNamePoint(); + alias.setNamePoint(alias.getCenter()); + drawText(alias, graphics, params); + alias.setNamePoint(tmpPoint); + } else { + if (!alias.containsIdenticalSpecies()) { + drawText(alias, graphics, params); + } + } + } + +} diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/BottomSquareCompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/BottomSquareCompartmentConverter.java index e3108042dd..25d9cdd4f3 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/BottomSquareCompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/BottomSquareCompartmentConverter.java @@ -1,80 +1,80 @@ -package lcsb.mapviewer.converter.graphics.compartment; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.Shape; -import java.awt.Stroke; -import java.awt.geom.Area; -import java.awt.geom.Line2D; -import java.awt.geom.Point2D; -import java.awt.geom.Rectangle2D; - -import lcsb.mapviewer.converter.graphics.ConverterParams; -import lcsb.mapviewer.model.graphics.LineType; -import lcsb.mapviewer.model.map.layout.alias.BottomSquareCompartmentAlias; - -import org.apache.log4j.Logger; - -/** - * Class responsible for drawing BottomSquareCompartment on the Graphics2D. - * - * @author Piotr Gawron - * - */ -public class BottomSquareCompartmentConverter extends CompartmentConverter<BottomSquareCompartmentAlias> { - - /** - * Default class logger. - */ - @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(BottomSquareCompartmentConverter.class.getName()); - - @Override - public void drawAlias(final BottomSquareCompartmentAlias alias, final Graphics2D graphics, final ConverterParams params) { - // keep the old values of colors and line - Color oldColor = graphics.getColor(); - Stroke oldStroke = graphics.getStroke(); - - // create shape of the compartment - Shape s1 = new Line2D.Double(0, alias.getY(), alias.getWidth(), alias.getY()); - Shape s3 = new Line2D.Double(0, alias.getY() + alias.getThickness(), alias.getWidth(), alias.getY() + alias.getThickness()); - Area a1 = new Area(new Rectangle2D.Double(0.0, alias.getY(), alias.getWidth(), alias.getHeight())); - - Color c1 = alias.getColor(); - Color c2 = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), HIGH_ALPHA_LEVEL); - if (c1.equals(Color.WHITE)) { - c1 = Color.BLACK; - } - - // fill the background - if (params.isFill()) { - graphics.setColor(c1); - } else { - Color bgAlphaColor = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), getAlphaLevel()); - graphics.setColor(bgAlphaColor); - } - graphics.fill(s1); - - // create borders - graphics.setColor(c1); - graphics.setStroke(LineType.SOLID_BOLD.getStroke()); - graphics.draw(s1); - graphics.setStroke(LineType.SOLID.getStroke()); - graphics.draw(s3); - graphics.setColor(c2); - if (params.isFill()) { - graphics.fill(a1); - } - // restore color and line type - graphics.setColor(oldColor); - graphics.setStroke(oldStroke); - - // draw description - if (params.isFill()) { - Point2D tmpPoint = alias.getNamePoint(); - alias.setNamePoint(alias.getCenter()); - drawText(alias, graphics, params); - alias.setNamePoint(tmpPoint); - } - } -} +package lcsb.mapviewer.converter.graphics.compartment; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Area; +import java.awt.geom.Line2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; + +import lcsb.mapviewer.converter.graphics.ConverterParams; +import lcsb.mapviewer.model.graphics.LineType; +import lcsb.mapviewer.model.map.compartment.BottomSquareCompartment; + +import org.apache.log4j.Logger; + +/** + * Class responsible for drawing BottomSquareCompartment on the Graphics2D. + * + * @author Piotr Gawron + * + */ +public class BottomSquareCompartmentConverter extends CompartmentConverter<BottomSquareCompartment> { + + /** + * Default class logger. + */ + @SuppressWarnings("unused") + private static Logger logger = Logger.getLogger(BottomSquareCompartmentConverter.class.getName()); + + @Override + public void drawAlias(final BottomSquareCompartment alias, final Graphics2D graphics, final ConverterParams params) { + // keep the old values of colors and line + Color oldColor = graphics.getColor(); + Stroke oldStroke = graphics.getStroke(); + + // create shape of the compartment + Shape s1 = new Line2D.Double(0, alias.getY(), alias.getWidth(), alias.getY()); + Shape s3 = new Line2D.Double(0, alias.getY() + alias.getThickness(), alias.getWidth(), alias.getY() + alias.getThickness()); + Area a1 = new Area(new Rectangle2D.Double(0.0, alias.getY(), alias.getWidth(), alias.getHeight())); + + Color c1 = alias.getColor(); + Color c2 = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), HIGH_ALPHA_LEVEL); + if (c1.equals(Color.WHITE)) { + c1 = Color.BLACK; + } + + // fill the background + if (params.isFill()) { + graphics.setColor(c1); + } else { + Color bgAlphaColor = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), getAlphaLevel()); + graphics.setColor(bgAlphaColor); + } + graphics.fill(s1); + + // create borders + graphics.setColor(c1); + graphics.setStroke(LineType.SOLID_BOLD.getStroke()); + graphics.draw(s1); + graphics.setStroke(LineType.SOLID.getStroke()); + graphics.draw(s3); + graphics.setColor(c2); + if (params.isFill()) { + graphics.fill(a1); + } + // restore color and line type + graphics.setColor(oldColor); + graphics.setStroke(oldStroke); + + // draw description + if (params.isFill()) { + Point2D tmpPoint = alias.getNamePoint(); + alias.setNamePoint(alias.getCenter()); + drawText(alias, graphics, params); + alias.setNamePoint(tmpPoint); + } + } +} 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 ea1699fcb9..cf4088bb9b 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 @@ -17,8 +17,8 @@ import lcsb.mapviewer.converter.graphics.IAliasConverter; import lcsb.mapviewer.converter.graphics.geometry.FontFinder; import lcsb.mapviewer.converter.graphics.geometry.RectangleTooSmallException; import lcsb.mapviewer.converter.graphics.placefinder.PlaceFinder; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.layout.ColorSchema; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; /** * Abstract class responsible for common methods to draw compartmentAliases on @@ -30,7 +30,7 @@ import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; * class for which the comparator is created * */ -public abstract class CompartmentConverter<T extends CompartmentAlias> implements IAliasConverter<T> { +public abstract class CompartmentConverter<T extends Compartment> implements IAliasConverter<T> { /** * Default class logger. diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/LeftSquareCompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/LeftSquareCompartmentConverter.java index 146d977a7b..5d3f1a7fa5 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/LeftSquareCompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/LeftSquareCompartmentConverter.java @@ -1,80 +1,80 @@ -package lcsb.mapviewer.converter.graphics.compartment; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.Shape; -import java.awt.Stroke; -import java.awt.geom.Area; -import java.awt.geom.Line2D; -import java.awt.geom.Point2D; -import java.awt.geom.Rectangle2D; - -import lcsb.mapviewer.converter.graphics.ConverterParams; -import lcsb.mapviewer.model.graphics.LineType; -import lcsb.mapviewer.model.map.layout.alias.LeftSquareCompartmentAlias; - -import org.apache.log4j.Logger; - -/** - * Class responsible for drawing LeftSquareCompartment on the Graphics2D. - * - * @author Piotr Gawron - * - */ -public class LeftSquareCompartmentConverter extends CompartmentConverter<LeftSquareCompartmentAlias> { - /** - * Default class logger. - */ - @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(LeftSquareCompartmentConverter.class.getName()); - - @Override - public void drawAlias(final LeftSquareCompartmentAlias alias, final Graphics2D graphics, final ConverterParams params) { - // keep the old values of color and line type - Color oldColor = graphics.getColor(); - Stroke oldStroke = graphics.getStroke(); - - // create shape of the compartment - Shape s1 = new Line2D.Double(alias.getWidth(), alias.getHeight(), alias.getWidth(), 0); - Shape s3 = new Line2D.Double(alias.getWidth() - alias.getThickness(), 0, alias.getWidth() - alias.getThickness(), alias.getHeight()); - Area a1 = new Area(new Rectangle2D.Double(0.0, 0.0, alias.getWidth(), alias.getHeight())); - - Color c1 = alias.getColor(); - Color c2 = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), HIGH_ALPHA_LEVEL); - if (c1.equals(Color.WHITE)) { - c1 = Color.BLACK; - } - - // fill the background - if (params.isFill()) { - graphics.setColor(c1); - } else { - Color bgAlphaColor = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), getAlphaLevel()); - graphics.setColor(bgAlphaColor); - } - graphics.fill(s1); - - // create borders - graphics.setColor(c1); - graphics.setStroke(LineType.SOLID_BOLD.getStroke()); - graphics.draw(s1); - graphics.setStroke(LineType.SOLID.getStroke()); - graphics.draw(s3); - graphics.setColor(c2); - if (params.isFill()) { - graphics.fill(a1); - } - - // restore color and line type - graphics.setColor(oldColor); - graphics.setStroke(oldStroke); - - // draw description - if (params.isFill()) { - Point2D tmpPoint = alias.getNamePoint(); - alias.setNamePoint(alias.getCenter()); - drawText(alias, graphics, params); - alias.setNamePoint(tmpPoint); - } - } -} +package lcsb.mapviewer.converter.graphics.compartment; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Area; +import java.awt.geom.Line2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; + +import lcsb.mapviewer.converter.graphics.ConverterParams; +import lcsb.mapviewer.model.graphics.LineType; +import lcsb.mapviewer.model.map.compartment.LeftSquareCompartment; + +import org.apache.log4j.Logger; + +/** + * Class responsible for drawing LeftSquareCompartment on the Graphics2D. + * + * @author Piotr Gawron + * + */ +public class LeftSquareCompartmentConverter extends CompartmentConverter<LeftSquareCompartment> { + /** + * Default class logger. + */ + @SuppressWarnings("unused") + private static Logger logger = Logger.getLogger(LeftSquareCompartmentConverter.class.getName()); + + @Override + public void drawAlias(final LeftSquareCompartment alias, final Graphics2D graphics, final ConverterParams params) { + // keep the old values of color and line type + Color oldColor = graphics.getColor(); + Stroke oldStroke = graphics.getStroke(); + + // create shape of the compartment + Shape s1 = new Line2D.Double(alias.getWidth(), alias.getHeight(), alias.getWidth(), 0); + Shape s3 = new Line2D.Double(alias.getWidth() - alias.getThickness(), 0, alias.getWidth() - alias.getThickness(), alias.getHeight()); + Area a1 = new Area(new Rectangle2D.Double(0.0, 0.0, alias.getWidth(), alias.getHeight())); + + Color c1 = alias.getColor(); + Color c2 = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), HIGH_ALPHA_LEVEL); + if (c1.equals(Color.WHITE)) { + c1 = Color.BLACK; + } + + // fill the background + if (params.isFill()) { + graphics.setColor(c1); + } else { + Color bgAlphaColor = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), getAlphaLevel()); + graphics.setColor(bgAlphaColor); + } + graphics.fill(s1); + + // create borders + graphics.setColor(c1); + graphics.setStroke(LineType.SOLID_BOLD.getStroke()); + graphics.draw(s1); + graphics.setStroke(LineType.SOLID.getStroke()); + graphics.draw(s3); + graphics.setColor(c2); + if (params.isFill()) { + graphics.fill(a1); + } + + // restore color and line type + graphics.setColor(oldColor); + graphics.setStroke(oldStroke); + + // draw description + if (params.isFill()) { + Point2D tmpPoint = alias.getNamePoint(); + alias.setNamePoint(alias.getCenter()); + drawText(alias, graphics, params); + alias.setNamePoint(tmpPoint); + } + } +} diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/OvalCompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/OvalCompartmentConverter.java index 3ece516ee3..e13e233558 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/OvalCompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/OvalCompartmentConverter.java @@ -1,91 +1,91 @@ -package lcsb.mapviewer.converter.graphics.compartment; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.Shape; -import java.awt.Stroke; -import java.awt.geom.Area; -import java.awt.geom.Ellipse2D; -import java.awt.geom.Point2D; - -import lcsb.mapviewer.converter.graphics.ConverterParams; -import lcsb.mapviewer.model.graphics.LineType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.OvalCompartmentAlias; - -/** - * Class responsible for drawing OvalCompartment on the Graphics2D. - * - * @author Piotr Gawron - * - */ -public class OvalCompartmentConverter extends CompartmentConverter<OvalCompartmentAlias> { - - /** - * Returns shape representing alias. - * - * @param alias - * alias for which we are looking for a Shape - * @return Shape object that represents alias - */ - private Shape getShape(final Alias alias) { - return new Ellipse2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight()); - } - - @Override - public void drawAlias(final OvalCompartmentAlias alias, final Graphics2D graphics, final ConverterParams params) { - // keep the old values of color and line type - Color oldColor = graphics.getColor(); - Stroke oldStroke = graphics.getStroke(); - - // create shape of the compartment - Shape s1 = getShape(alias); - alias.increaseBorder(-alias.getThickness()); - Shape s3 = getShape(alias); - alias.increaseBorder(alias.getThickness()); - - Color c1 = alias.getColor(); - Color c2 = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), HIGH_ALPHA_LEVEL); - if (c1.equals(Color.WHITE)) { - c1 = Color.BLACK; - } - - Area a1 = new Area(s1); - a1.subtract(new Area(s3)); - - // fill the background - if (params.isFill()) { - graphics.setColor(c1); - } else { - Color bgAlphaColor = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), getAlphaLevel()); - graphics.setColor(bgAlphaColor); - } - graphics.fill(s1); - - // create borders - graphics.setColor(c1); - graphics.setStroke(LineType.SOLID_BOLD.getStroke()); - graphics.draw(s1); - graphics.setStroke(LineType.SOLID.getStroke()); - graphics.draw(s3); - graphics.setColor(c2); - graphics.fill(a1); - - // restore color and line type - graphics.setColor(oldColor); - graphics.setStroke(oldStroke); - - // draw description - if (params.isFill()) { - Point2D tmpPoint = alias.getNamePoint(); - alias.setNamePoint(alias.getCenter()); - drawText(alias, graphics, params); - alias.setNamePoint(tmpPoint); - } else { - if (!alias.containsIdenticalSpecies()) { - drawText(alias, graphics, params); - } - } - } - -} +package lcsb.mapviewer.converter.graphics.compartment; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Area; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Point2D; + +import lcsb.mapviewer.converter.graphics.ConverterParams; +import lcsb.mapviewer.model.graphics.LineType; +import lcsb.mapviewer.model.map.compartment.OvalCompartment; +import lcsb.mapviewer.model.map.species.Element; + +/** + * Class responsible for drawing OvalCompartment on the Graphics2D. + * + * @author Piotr Gawron + * + */ +public class OvalCompartmentConverter extends CompartmentConverter<OvalCompartment> { + + /** + * Returns shape representing alias. + * + * @param alias + * alias for which we are looking for a Shape + * @return Shape object that represents alias + */ + private Shape getShape(final Element alias) { + return new Ellipse2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight()); + } + + @Override + public void drawAlias(final OvalCompartment alias, final Graphics2D graphics, final ConverterParams params) { + // keep the old values of color and line type + Color oldColor = graphics.getColor(); + Stroke oldStroke = graphics.getStroke(); + + // create shape of the compartment + Shape s1 = getShape(alias); + alias.increaseBorder(-alias.getThickness()); + Shape s3 = getShape(alias); + alias.increaseBorder(alias.getThickness()); + + Color c1 = alias.getColor(); + Color c2 = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), HIGH_ALPHA_LEVEL); + if (c1.equals(Color.WHITE)) { + c1 = Color.BLACK; + } + + Area a1 = new Area(s1); + a1.subtract(new Area(s3)); + + // fill the background + if (params.isFill()) { + graphics.setColor(c1); + } else { + Color bgAlphaColor = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), getAlphaLevel()); + graphics.setColor(bgAlphaColor); + } + graphics.fill(s1); + + // create borders + graphics.setColor(c1); + graphics.setStroke(LineType.SOLID_BOLD.getStroke()); + graphics.draw(s1); + graphics.setStroke(LineType.SOLID.getStroke()); + graphics.draw(s3); + graphics.setColor(c2); + graphics.fill(a1); + + // restore color and line type + graphics.setColor(oldColor); + graphics.setStroke(oldStroke); + + // draw description + if (params.isFill()) { + Point2D tmpPoint = alias.getNamePoint(); + alias.setNamePoint(alias.getCenter()); + drawText(alias, graphics, params); + alias.setNamePoint(tmpPoint); + } else { + if (!alias.containsIdenticalSpecies()) { + drawText(alias, graphics, params); + } + } + } + +} diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/RightSquareCompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/RightSquareCompartmentConverter.java index 5c8237d3d6..5fa37bec8f 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/RightSquareCompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/RightSquareCompartmentConverter.java @@ -1,86 +1,86 @@ -package lcsb.mapviewer.converter.graphics.compartment; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.Shape; -import java.awt.Stroke; -import java.awt.geom.Area; -import java.awt.geom.Line2D; -import java.awt.geom.Point2D; -import java.awt.geom.Rectangle2D; - -import lcsb.mapviewer.converter.graphics.ConverterParams; -import lcsb.mapviewer.model.graphics.LineType; -import lcsb.mapviewer.model.map.layout.alias.RightSquareCompartmentAlias; - -import org.apache.log4j.Logger; - -/** - * Class responsible for drawing RightSquareCompartment on the Graphics2D. - * - * @author Piotr Gawron - * - */ -public class RightSquareCompartmentConverter extends CompartmentConverter<RightSquareCompartmentAlias> { - /** - * Default class logger. - */ - @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(RightSquareCompartmentConverter.class.getName()); - - @Override - public void drawAlias(final RightSquareCompartmentAlias alias, final Graphics2D graphics, final ConverterParams params) { - // keep the old values of color and line type - Color oldColor = graphics.getColor(); - Stroke oldStroke = graphics.getStroke(); - - // create shape of the compartment - Shape s1 = new Line2D.Double(alias.getX(), alias.getHeight(), alias.getX(), 0); - Shape s3 = new Line2D.Double(alias.getX() + alias.getThickness(), alias.getHeight(), alias.getX(), 0); - Area a1 = new Area(new Rectangle2D.Double(alias.getX(), 0.0, alias.getWidth(), alias.getHeight())); - - Color c1 = alias.getColor(); - Color c2 = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), HIGH_ALPHA_LEVEL); - if (c1.equals(Color.WHITE)) { - c1 = Color.BLACK; - } - - // fill the background - if (params.isFill()) { - graphics.setColor(c1); - } else { - Color bgAlphaColor = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), getAlphaLevel()); - graphics.setColor(bgAlphaColor); - } - graphics.fill(s1); - - // create borders - graphics.setColor(c1); - graphics.setStroke(LineType.SOLID_BOLD.getStroke()); - graphics.draw(s1); - graphics.setStroke(LineType.SOLID.getStroke()); - graphics.draw(s3); - graphics.setColor(c2); - if (params.isFill()) { - graphics.fill(a1); - } - // restore color and line type - graphics.setColor(oldColor); - graphics.setStroke(oldStroke); - - // three lines below are only temporary fix... - double x = alias.getNamePoint().getX() - alias.getX(); - double y = alias.getNamePoint().getY(); - alias.getNamePoint().setLocation(x, y); - - // draw description - if (params.isFill()) { - Point2D tmpPoint = alias.getNamePoint(); - alias.setNamePoint(alias.getCenter()); - drawText(alias, graphics, params); - alias.setNamePoint(tmpPoint); - } - x += alias.getX(); - alias.getNamePoint().setLocation(x, y); - } -} +package lcsb.mapviewer.converter.graphics.compartment; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Area; +import java.awt.geom.Line2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; + +import lcsb.mapviewer.converter.graphics.ConverterParams; +import lcsb.mapviewer.model.graphics.LineType; +import lcsb.mapviewer.model.map.compartment.RightSquareCompartment; + +import org.apache.log4j.Logger; + +/** + * Class responsible for drawing RightSquareCompartment on the Graphics2D. + * + * @author Piotr Gawron + * + */ +public class RightSquareCompartmentConverter extends CompartmentConverter<RightSquareCompartment> { + /** + * Default class logger. + */ + @SuppressWarnings("unused") + private static Logger logger = Logger.getLogger(RightSquareCompartmentConverter.class.getName()); + + @Override + public void drawAlias(final RightSquareCompartment alias, final Graphics2D graphics, final ConverterParams params) { + // keep the old values of color and line type + Color oldColor = graphics.getColor(); + Stroke oldStroke = graphics.getStroke(); + + // create shape of the compartment + Shape s1 = new Line2D.Double(alias.getX(), alias.getHeight(), alias.getX(), 0); + Shape s3 = new Line2D.Double(alias.getX() + alias.getThickness(), alias.getHeight(), alias.getX(), 0); + Area a1 = new Area(new Rectangle2D.Double(alias.getX(), 0.0, alias.getWidth(), alias.getHeight())); + + Color c1 = alias.getColor(); + Color c2 = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), HIGH_ALPHA_LEVEL); + if (c1.equals(Color.WHITE)) { + c1 = Color.BLACK; + } + + // fill the background + if (params.isFill()) { + graphics.setColor(c1); + } else { + Color bgAlphaColor = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), getAlphaLevel()); + graphics.setColor(bgAlphaColor); + } + graphics.fill(s1); + + // create borders + graphics.setColor(c1); + graphics.setStroke(LineType.SOLID_BOLD.getStroke()); + graphics.draw(s1); + graphics.setStroke(LineType.SOLID.getStroke()); + graphics.draw(s3); + graphics.setColor(c2); + if (params.isFill()) { + graphics.fill(a1); + } + // restore color and line type + graphics.setColor(oldColor); + graphics.setStroke(oldStroke); + + // three lines below are only temporary fix... + double x = alias.getNamePoint().getX() - alias.getX(); + double y = alias.getNamePoint().getY(); + alias.getNamePoint().setLocation(x, y); + + // draw description + if (params.isFill()) { + Point2D tmpPoint = alias.getNamePoint(); + alias.setNamePoint(alias.getCenter()); + drawText(alias, graphics, params); + alias.setNamePoint(tmpPoint); + } + x += alias.getX(); + alias.getNamePoint().setLocation(x, y); + } +} diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/SquareCompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/SquareCompartmentConverter.java index e379687c91..d07657464f 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/SquareCompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/SquareCompartmentConverter.java @@ -1,98 +1,98 @@ -package lcsb.mapviewer.converter.graphics.compartment; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.Shape; -import java.awt.Stroke; -import java.awt.geom.Area; -import java.awt.geom.Point2D; -import java.awt.geom.RoundRectangle2D; - -import lcsb.mapviewer.converter.graphics.ConverterParams; -import lcsb.mapviewer.model.graphics.LineType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SquareCompartmentAlias; - -import org.apache.log4j.Logger; - -/** - * Class responsible for drawing SquareCompartment on the Graphics2D. - * - * @author Piotr Gawron - * - */ -public class SquareCompartmentConverter extends CompartmentConverter<SquareCompartmentAlias> { - /** - * How big is the arc in the corner of rectangle that represents square - * compartment. - */ - private static final int RECTANGLE_CORNER_ARC_SIZE = 20; - /** - * Default class logger. - */ - @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(SquareCompartmentConverter.class.getName()); - - /** - * Returns shape representing alias. - * - * @param alias - * alias for which we are looking for a Shape - * @return Shape object that represents alias - */ - private Shape getShape(final Alias alias) { - return new RoundRectangle2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight(), RECTANGLE_CORNER_ARC_SIZE, RECTANGLE_CORNER_ARC_SIZE); - } - - @Override - public void drawAlias(final SquareCompartmentAlias alias, final Graphics2D graphics, final ConverterParams params) { - // keep the old values of color and line type - Color oldColor = graphics.getColor(); - Stroke oldStroke = graphics.getStroke(); - - // create shape of the compartment - Shape s1 = getShape(alias); - alias.increaseBorder(-alias.getThickness()); - Shape s3 = getShape(alias); - alias.increaseBorder(alias.getThickness()); - - Color c1 = alias.getColor(); - Color c2 = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), HIGH_ALPHA_LEVEL); - if (c1.equals(Color.WHITE)) { - c1 = Color.BLACK; - } - - Area a1 = new Area(s1); - a1.subtract(new Area(s3)); - - // fill the background - if (params.isFill()) { - graphics.setColor(c1); - } else { - Color bgAlphaColor = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), getAlphaLevel()); - graphics.setColor(bgAlphaColor); - } - graphics.fill(s1); - - // create borders - graphics.setColor(c1); - graphics.setStroke(LineType.SOLID_BOLD.getStroke()); - graphics.draw(s1); - graphics.setStroke(LineType.SOLID.getStroke()); - graphics.draw(s3); - graphics.setColor(c2); - graphics.fill(a1); - - // restore color and line type - graphics.setColor(oldColor); - graphics.setStroke(oldStroke); - - // draw description - if (params.isFill()) { - Point2D tmpPoint = alias.getNamePoint(); - alias.setNamePoint(alias.getCenter()); - drawText(alias, graphics, params); - alias.setNamePoint(tmpPoint); - } - } -} +package lcsb.mapviewer.converter.graphics.compartment; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Area; +import java.awt.geom.Point2D; +import java.awt.geom.RoundRectangle2D; + +import lcsb.mapviewer.converter.graphics.ConverterParams; +import lcsb.mapviewer.model.graphics.LineType; +import lcsb.mapviewer.model.map.compartment.SquareCompartment; +import lcsb.mapviewer.model.map.species.Element; + +import org.apache.log4j.Logger; + +/** + * Class responsible for drawing SquareCompartment on the Graphics2D. + * + * @author Piotr Gawron + * + */ +public class SquareCompartmentConverter extends CompartmentConverter<SquareCompartment> { + /** + * How big is the arc in the corner of rectangle that represents square + * compartment. + */ + private static final int RECTANGLE_CORNER_ARC_SIZE = 20; + /** + * Default class logger. + */ + @SuppressWarnings("unused") + private static Logger logger = Logger.getLogger(SquareCompartmentConverter.class.getName()); + + /** + * Returns shape representing alias. + * + * @param alias + * alias for which we are looking for a Shape + * @return Shape object that represents alias + */ + private Shape getShape(final Element alias) { + return new RoundRectangle2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight(), RECTANGLE_CORNER_ARC_SIZE, RECTANGLE_CORNER_ARC_SIZE); + } + + @Override + public void drawAlias(final SquareCompartment alias, final Graphics2D graphics, final ConverterParams params) { + // keep the old values of color and line type + Color oldColor = graphics.getColor(); + Stroke oldStroke = graphics.getStroke(); + + // create shape of the compartment + Shape s1 = getShape(alias); + alias.increaseBorder(-alias.getThickness()); + Shape s3 = getShape(alias); + alias.increaseBorder(alias.getThickness()); + + Color c1 = alias.getColor(); + Color c2 = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), HIGH_ALPHA_LEVEL); + if (c1.equals(Color.WHITE)) { + c1 = Color.BLACK; + } + + Area a1 = new Area(s1); + a1.subtract(new Area(s3)); + + // fill the background + if (params.isFill()) { + graphics.setColor(c1); + } else { + Color bgAlphaColor = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), getAlphaLevel()); + graphics.setColor(bgAlphaColor); + } + graphics.fill(s1); + + // create borders + graphics.setColor(c1); + graphics.setStroke(LineType.SOLID_BOLD.getStroke()); + graphics.draw(s1); + graphics.setStroke(LineType.SOLID.getStroke()); + graphics.draw(s3); + graphics.setColor(c2); + graphics.fill(a1); + + // restore color and line type + graphics.setColor(oldColor); + graphics.setStroke(oldStroke); + + // draw description + if (params.isFill()) { + Point2D tmpPoint = alias.getNamePoint(); + alias.setNamePoint(alias.getCenter()); + drawText(alias, graphics, params); + alias.setNamePoint(tmpPoint); + } + } +} diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/TopSquareCompartmentConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/TopSquareCompartmentConverter.java index e9bc9a55c7..afc5febcff 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/TopSquareCompartmentConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/TopSquareCompartmentConverter.java @@ -1,76 +1,76 @@ -package lcsb.mapviewer.converter.graphics.compartment; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.Shape; -import java.awt.Stroke; -import java.awt.geom.Area; -import java.awt.geom.Line2D; -import java.awt.geom.Point2D; -import java.awt.geom.Rectangle2D; - -import lcsb.mapviewer.converter.graphics.ConverterParams; -import lcsb.mapviewer.model.graphics.LineType; -import lcsb.mapviewer.model.map.layout.alias.TopSquareCompartmentAlias; - -import org.apache.log4j.Logger; - -/** - * Class responsible for drawing TopSquareCompartment on the Graphics2D. - * - * @author Piotr Gawron - * - */ -public class TopSquareCompartmentConverter extends CompartmentConverter<TopSquareCompartmentAlias> { - - /** - * Default class logger. - */ - @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(TopSquareCompartmentConverter.class.getName()); - - @Override - public void drawAlias(final TopSquareCompartmentAlias alias, final Graphics2D graphics, final ConverterParams params) { - Color oldColor = graphics.getColor(); - Stroke oldStroke = graphics.getStroke(); - - Shape s1 = new Line2D.Double(0, alias.getHeight(), alias.getWidth(), alias.getHeight()); - Shape s3 = new Line2D.Double(0, alias.getHeight() - alias.getThickness(), alias.getWidth(), alias.getHeight() - alias.getThickness()); - Area a1 = new Area(new Rectangle2D.Double(0.0, 0.0, alias.getWidth(), alias.getHeight())); - - Color c1 = alias.getColor(); - Color c2 = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), HIGH_ALPHA_LEVEL); - if (c1.equals(Color.WHITE)) { - c1 = Color.BLACK; - } - - if (params.isFill()) { - graphics.setColor(c1); - } else { - Color bgAlphaColor = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), getAlphaLevel()); - graphics.setColor(bgAlphaColor); - } - graphics.fill(s1); - - graphics.setColor(c1); - graphics.setStroke(LineType.SOLID_BOLD.getStroke()); - graphics.draw(s1); - graphics.setStroke(LineType.SOLID.getStroke()); - graphics.draw(s3); - graphics.setColor(c2); - if (params.isFill()) { - graphics.fill(a1); - } - - // restore color and line type - graphics.setColor(oldColor); - graphics.setStroke(oldStroke); - // draw description - if (params.isFill()) { - Point2D tmpPoint = alias.getNamePoint(); - alias.setNamePoint(alias.getCenter()); - drawText(alias, graphics, params); - alias.setNamePoint(tmpPoint); - } - } -} +package lcsb.mapviewer.converter.graphics.compartment; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Area; +import java.awt.geom.Line2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; + +import lcsb.mapviewer.converter.graphics.ConverterParams; +import lcsb.mapviewer.model.graphics.LineType; +import lcsb.mapviewer.model.map.compartment.TopSquareCompartment; + +import org.apache.log4j.Logger; + +/** + * Class responsible for drawing TopSquareCompartment on the Graphics2D. + * + * @author Piotr Gawron + * + */ +public class TopSquareCompartmentConverter extends CompartmentConverter<TopSquareCompartment> { + + /** + * Default class logger. + */ + @SuppressWarnings("unused") + private static Logger logger = Logger.getLogger(TopSquareCompartmentConverter.class.getName()); + + @Override + public void drawAlias(final TopSquareCompartment alias, final Graphics2D graphics, final ConverterParams params) { + Color oldColor = graphics.getColor(); + Stroke oldStroke = graphics.getStroke(); + + Shape s1 = new Line2D.Double(0, alias.getHeight(), alias.getWidth(), alias.getHeight()); + Shape s3 = new Line2D.Double(0, alias.getHeight() - alias.getThickness(), alias.getWidth(), alias.getHeight() - alias.getThickness()); + Area a1 = new Area(new Rectangle2D.Double(0.0, 0.0, alias.getWidth(), alias.getHeight())); + + Color c1 = alias.getColor(); + Color c2 = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), HIGH_ALPHA_LEVEL); + if (c1.equals(Color.WHITE)) { + c1 = Color.BLACK; + } + + if (params.isFill()) { + graphics.setColor(c1); + } else { + Color bgAlphaColor = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), getAlphaLevel()); + graphics.setColor(bgAlphaColor); + } + graphics.fill(s1); + + graphics.setColor(c1); + graphics.setStroke(LineType.SOLID_BOLD.getStroke()); + graphics.draw(s1); + graphics.setStroke(LineType.SOLID.getStroke()); + graphics.draw(s3); + graphics.setColor(c2); + if (params.isFill()) { + graphics.fill(a1); + } + + // restore color and line type + graphics.setColor(oldColor); + graphics.setStroke(oldStroke); + // draw description + if (params.isFill()) { + Point2D tmpPoint = alias.getNamePoint(); + alias.setNamePoint(alias.getCenter()); + drawText(alias, graphics, params); + alias.setNamePoint(tmpPoint); + } + } +} diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/package-info.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/package-info.java index ac04e1c815..238015b528 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/package-info.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/compartment/package-info.java @@ -1,7 +1,5 @@ -/** - * Provides classes that draws different implemention of - * {@link lcsb.mapviewer.db.model.map.layout.alias.CompartmentAlias - * CompartmentAlias} on the {@link java.awt.Graphics2D Graphics2D}. - */ -package lcsb.mapviewer.converter.graphics.compartment; - +/** + * Provides classes that draws different implemention of + * {@link Compartment} on the {@link Graphics2D}. + */ +package lcsb.mapviewer.converter.graphics.compartment; diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/placefinder/PlaceFinder.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/placefinder/PlaceFinder.java index 210333ea16..06b52123ff 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/placefinder/PlaceFinder.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/placefinder/PlaceFinder.java @@ -1,466 +1,466 @@ -package lcsb.mapviewer.converter.graphics.placefinder; - -import java.awt.geom.Rectangle2D; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.model.Model; - -import org.apache.log4j.Logger; - -/** - * This class allows to find free space where description should appear for the - * alias in hierarchical view. - * - * @author Piotr Gawron - * - */ -public class PlaceFinder { - - /** - * Represents small part of the map (enclosed by cuting lines) where something - * can be put. Contains borders (height, weight, location etc). Informatin if - * it can be used or no and range (magic field that describes how much to the - * bottom rectangle can be extended). - * - * @author Piotr Gawron - * - */ - private class Field { - /** - * Border of the field. - */ - private Rectangle2D border; - /** - * Can the field be used for something or is occupied? - */ - private boolean available = true; - /** - * How many fields to the bottom are free (how much could we extend empty - * rectangle. - */ - private int range = -1; - - /** - * @return the border - * @see #border - */ - Rectangle2D getBorder() { - return border; - } - - /** - * @param border - * the border to set - * @see #border - */ - void setBorder(Rectangle2D border) { - this.border = border; - } - - /** - * @return the available - * @see #available - */ - public boolean isAvailable() { - return available; - } - - /** - * @param available - * the available to set - * @see #available - */ - public void setAvailable(boolean available) { - this.available = available; - } - - /** - * @return the range - * @see #range - */ - public int getRange() { - return range; - } - - /** - * @param range - * the range to set - * @see #range - */ - public void setRange(int range) { - this.range = range; - } - } - - /** - * Default class logger. - */ - @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(PlaceFinder.class.getName()); - /** - * Whole surface is split into rectangular regions. The lines that cut the - * surface correspond to borders of aliases that overlap current alias. This - * matrix defines which of these regions can be used for description. - */ - private Field[][] matrix; - - /** - * List of {@link CompartmentAlias compartment aliases} that split surface - * into regions. - */ - private List<CompartmentAlias> aliases; - - /** - * Alias for which computation is done. - */ - private Alias mainAlias; - - /** - * Left boundary of the rectangle in which we want to fit our description. - */ - private double leftBound; - /** - * Right boundary of the rectangle in which we want to fit our description. - */ - private double rightBound; - /** - * Top boundary of the rectangle in which we want to fit our description. - */ - private double upBound; - /** - * Bottom boundary of the rectangle in which we want to fit our description. - */ - private double bottomBound; - - /** - * Model for which this {@link PlaceFinder} was created. - */ - private Model model; - - /** - * Map with aliases that should be considered when looking for a place to put - * text. - */ - private Map<Alias, List<CompartmentAlias>> otherAliases = new HashMap<Alias, List<CompartmentAlias>>(); - - /** - * Default constructor for place finder in a model. - * - * @param model - * model - * - */ - public PlaceFinder(Model model) { - this.model = model; - } - - /** - * Finds the biggest rectangle. - * - * @return the biggest rectangle - */ - private Rectangle2D findRectangle() { - Rectangle2D biggestRectangle = new Rectangle2D.Double(); - Rectangle2D temporaryRectangle = null; - for (int y = 0; y < getSizeY(); y++) { - for (int x = 0; x < getSizeX(); x++) { - temporaryRectangle = computeRectangleMaxArea(x, y); - double newArea = temporaryRectangle.getWidth() * temporaryRectangle.getHeight(); - double oldArea = biggestRectangle.getWidth() * biggestRectangle.getHeight(); - if (newArea > oldArea) { - biggestRectangle = temporaryRectangle; - } - } - } - - return biggestRectangle; - } - - /** - * Computes the biggest rectangle that starts in the region on the position - * [x,y]. - * - * @param x - * x index of the region - * @param y - * y index of the region - * @return the biggest rectangle that starts in the region on the given - * position - */ - private Rectangle2D computeRectangleMaxArea(int x, int y) { - Rectangle2D result = new Rectangle2D.Double(); - int possibleMaximumOfHeight = matrix[x][y].getRange(); - for (int k = x; k >= 0 && matrix[k][y].isAvailable(); k--) { - if (matrix[k][y].getRange() < possibleMaximumOfHeight) { - possibleMaximumOfHeight = matrix[k][y].getRange(); - } - Rectangle2D temporary = computeRectangle(x, y, k, possibleMaximumOfHeight); - double newArea = temporary.getWidth() * temporary.getHeight(); - double oldArea = result.getWidth() * result.getHeight(); - if (newArea > oldArea) { - result = temporary; - } - } - return result; - } - - /** - * Computes rectangle in region range [k..x][y..y+height]. - * - * @param x - * end x coordinate - * @param y - * start y coordinate - * @param k - * start x coordinate - * @param height - * height in y coordinate - * @return rectangle in region range - */ - private Rectangle2D computeRectangle(int x, int y, int k, int height) { - double resX = matrix[k][y].getBorder().getX(); - double resY = matrix[k][y].getBorder().getY(); - double resWidth = matrix[x][y + height - 1].getBorder().getX() - resX + matrix[x][y + height - 1].getBorder().getWidth(); - double resHeight = matrix[x][y + height - 1].getBorder().getY() - resY + matrix[x][y + height - 1].getBorder().getHeight(); - - return new Rectangle2D.Double(resX, resY, resWidth, resHeight); - } - - /** - * Computes how deep in y axis can regions be extended from starting x,y - * region. - */ - private void findRanges() { - for (int i = 0; i < getSizeX(); i++) { - for (int j = 0; j < getSizeY(); j++) { - if (!matrix[i][j].isAvailable()) { - int k = j; - int temporaryRange = 0; - while (k >= 0 && matrix[i][k].getRange() == -1) { - matrix[i][k--].setRange(temporaryRange++); - } - } - } - if (matrix[i][getSizeY() - 1].isAvailable()) { - int k = getSizeY() - 1; - int temporaryRange = 1; - while (k >= 0 && matrix[i][k].getRange() == -1) { - matrix[i][k--].setRange(temporaryRange++); - } - } - - } - } - - /** - * Disables regions for all aliases. - */ - private void fillMatrixWithAliases() { - for (Alias alias : aliases) { - if (alias != mainAlias) { - fillMatrixWithAlias(alias); - } - } - } - - /** - * Disable regions for given alias. - * - * @param alias - * alias that should disable regions - */ - private void fillMatrixWithAlias(Alias alias) { - Double a, b, c, d; - - a = alias.getX(); - b = alias.getX() + alias.getWidth(); - c = alias.getY() + alias.getHeight(); - d = alias.getY(); - - fillWithPoints(a, b, c, d); - } - - /** - * Disable regions between given coordinates. - * - * @param x - * starting x coordinate - * @param xw - * ending x coordinate - * @param yh - * ending y coordinate - * @param y - * starting y coordinate - */ - private void fillWithPoints(Double x, Double xw, Double yh, Double y) { - Integer widthStart = 0; - Integer widthEnd = matrix.length; - Integer heightStart = 0; - Integer heightEnd = matrix[0].length; - - for (int i = 0; i < matrix.length; i++) { - if (matrix[i][0].getBorder().getX() <= x) { - widthStart = i; - } - if (matrix[i][0].getBorder().getX() <= xw) { - widthEnd = i; - } - } - if (matrix[matrix.length - 1][0].getBorder().getX() + matrix[matrix.length - 1][0].getBorder().getWidth() <= xw) { - widthEnd = matrix.length; - } - for (int i = 0; i < matrix[0].length; i++) { - if (matrix[0][i].getBorder().getY() <= y) { - heightStart = i; - } - if (matrix[0][i].getBorder().getY() <= yh) { - heightEnd = i; - } - } - if (matrix[0][matrix[0].length - 1].getBorder().getY() + matrix[0][matrix[0].length - 1].getBorder().getHeight() <= yh) { - heightEnd = matrix[0].length; - } - - for (int i = widthStart; i < widthEnd; i++) { - for (int j = heightStart; j < heightEnd; j++) { - matrix[i][j].setAvailable(false); - } - } - } - - /** - * This method looks for a place to put description of the alias on the map. - * - * @param alias - * alias for which we try to determine text position - * @return bounds where text could be put - */ - public Rectangle2D getRetangle(CompartmentAlias alias) { - List<CompartmentAlias> list = otherAliases.get(alias); - if (list == null) { - list = new ArrayList<CompartmentAlias>(); - for (CompartmentAlias compAlias : model.getCompartmentsAliases()) { - if (compAlias.getVisibilityLevel() <= alias.getVisibilityLevel() && compAlias.getTransparencyLevel() > alias.getVisibilityLevel()) { - if (compAlias.cross(alias) && compAlias.getSize() <= alias.getSize()) { - list.add(compAlias); - } - } - } - otherAliases.put(alias, list); - } - - this.mainAlias = alias; - this.aliases = list; - - leftBound = alias.getX(); - rightBound = (alias.getX() + alias.getWidth()); - upBound = alias.getY(); - bottomBound = (alias.getY() + alias.getHeight()); - - createMatrix(); - - fillMatrixWithAliases(); - - findRanges(); // 2*O(n^2) - - return findRectangle(); - } - - /** - * Create empty matrix with fields. - * - * @see #matrix - */ - protected void createMatrix() { - Set<Double> xs = new TreeSet<Double>(); - Set<Double> ys = new TreeSet<Double>(); - List<Double> widths = new ArrayList<Double>(); - List<Double> xCoordsOfBegginingOfRectangle = new ArrayList<Double>(); - List<Double> heights = new ArrayList<Double>(); - List<Double> yCoordsOfBegginingOfRectangle = new ArrayList<Double>(); - - for (Alias alias : aliases) { - double x1 = alias.getX(); - double x2 = alias.getX() + alias.getWidth(); - double y1 = alias.getY(); - double y2 = alias.getY() + alias.getHeight(); - if (x1 >= leftBound && x1 <= rightBound) { - xs.add(x1); - } - if (x2 >= leftBound && x2 <= rightBound) { - xs.add(x2); - } - - if (y1 >= upBound && y1 <= bottomBound) { - ys.add(y1); - } - if (y2 >= upBound && y2 <= bottomBound) { - ys.add(y2); - } - } - Double previous = null; - for (Double width : xs) { - if (previous != null) { - widths.add(width - previous); - } - xCoordsOfBegginingOfRectangle.add(width); - previous = width; - } - previous = null; - for (Double height : ys) { - if (previous != null) { - heights.add(height - previous); - } - yCoordsOfBegginingOfRectangle.add(height); - previous = height; - } - - matrix = new Field[xs.size() - 1][ys.size() - 1]; - - for (int i = 0; i < getSizeX(); i++) { - for (int j = 0; j < getSizeY(); j++) { - Field field = new Field(); - xCoordsOfBegginingOfRectangle.get(i); - yCoordsOfBegginingOfRectangle.get(j); - widths.get(i); - heights.get(j); - field.setBorder(new Rectangle2D.Double(xCoordsOfBegginingOfRectangle.get(i), yCoordsOfBegginingOfRectangle.get(j), widths.get(i), heights.get(j))); - matrix[i][j] = field; - } - } - } - - /** - * - * @return {@link #model} - */ - public Model getModel() { - return model; - } - - /** - * Returns width of the {@link #matrix}. - * - * @return width of the {@link #matrix} - */ - private int getSizeX() { - return matrix.length; - } - - /** - * Returns height of the {@link #matrix}. - * - * @return height of the {@link #matrix} - */ - private int getSizeY() { - return matrix[0].length; - } - -} +package lcsb.mapviewer.converter.graphics.placefinder; + +import java.awt.geom.Rectangle2D; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; + +import org.apache.log4j.Logger; + +/** + * This class allows to find free space where description should appear for the + * alias in hierarchical view. + * + * @author Piotr Gawron + * + */ +public class PlaceFinder { + + /** + * Represents small part of the map (enclosed by cuting lines) where something + * can be put. Contains borders (height, weight, location etc). Informatin if + * it can be used or no and range (magic field that describes how much to the + * bottom rectangle can be extended). + * + * @author Piotr Gawron + * + */ + private class Field { + /** + * Border of the field. + */ + private Rectangle2D border; + /** + * Can the field be used for something or is occupied? + */ + private boolean available = true; + /** + * How many fields to the bottom are free (how much could we extend empty + * rectangle. + */ + private int range = -1; + + /** + * @return the border + * @see #border + */ + Rectangle2D getBorder() { + return border; + } + + /** + * @param border + * the border to set + * @see #border + */ + void setBorder(Rectangle2D border) { + this.border = border; + } + + /** + * @return the available + * @see #available + */ + public boolean isAvailable() { + return available; + } + + /** + * @param available + * the available to set + * @see #available + */ + public void setAvailable(boolean available) { + this.available = available; + } + + /** + * @return the range + * @see #range + */ + public int getRange() { + return range; + } + + /** + * @param range + * the range to set + * @see #range + */ + public void setRange(int range) { + this.range = range; + } + } + + /** + * Default class logger. + */ + @SuppressWarnings("unused") + private static Logger logger = Logger.getLogger(PlaceFinder.class.getName()); + /** + * Whole surface is split into rectangular regions. The lines that cut the + * surface correspond to borders of aliases that overlap current alias. This + * matrix defines which of these regions can be used for description. + */ + private Field[][] matrix; + + /** + * List of {@link Compartment compartment aliases} that split surface + * into regions. + */ + private List<Compartment> aliases; + + /** + * Alias for which computation is done. + */ + private Element mainAlias; + + /** + * Left boundary of the rectangle in which we want to fit our description. + */ + private double leftBound; + /** + * Right boundary of the rectangle in which we want to fit our description. + */ + private double rightBound; + /** + * Top boundary of the rectangle in which we want to fit our description. + */ + private double upBound; + /** + * Bottom boundary of the rectangle in which we want to fit our description. + */ + private double bottomBound; + + /** + * Model for which this {@link PlaceFinder} was created. + */ + private Model model; + + /** + * Map with aliases that should be considered when looking for a place to put + * text. + */ + private Map<Element, List<Compartment>> otherAliases = new HashMap<Element, List<Compartment>>(); + + /** + * Default constructor for place finder in a model. + * + * @param model + * model + * + */ + public PlaceFinder(Model model) { + this.model = model; + } + + /** + * Finds the biggest rectangle. + * + * @return the biggest rectangle + */ + private Rectangle2D findRectangle() { + Rectangle2D biggestRectangle = new Rectangle2D.Double(); + Rectangle2D temporaryRectangle = null; + for (int y = 0; y < getSizeY(); y++) { + for (int x = 0; x < getSizeX(); x++) { + temporaryRectangle = computeRectangleMaxArea(x, y); + double newArea = temporaryRectangle.getWidth() * temporaryRectangle.getHeight(); + double oldArea = biggestRectangle.getWidth() * biggestRectangle.getHeight(); + if (newArea > oldArea) { + biggestRectangle = temporaryRectangle; + } + } + } + + return biggestRectangle; + } + + /** + * Computes the biggest rectangle that starts in the region on the position + * [x,y]. + * + * @param x + * x index of the region + * @param y + * y index of the region + * @return the biggest rectangle that starts in the region on the given + * position + */ + private Rectangle2D computeRectangleMaxArea(int x, int y) { + Rectangle2D result = new Rectangle2D.Double(); + int possibleMaximumOfHeight = matrix[x][y].getRange(); + for (int k = x; k >= 0 && matrix[k][y].isAvailable(); k--) { + if (matrix[k][y].getRange() < possibleMaximumOfHeight) { + possibleMaximumOfHeight = matrix[k][y].getRange(); + } + Rectangle2D temporary = computeRectangle(x, y, k, possibleMaximumOfHeight); + double newArea = temporary.getWidth() * temporary.getHeight(); + double oldArea = result.getWidth() * result.getHeight(); + if (newArea > oldArea) { + result = temporary; + } + } + return result; + } + + /** + * Computes rectangle in region range [k..x][y..y+height]. + * + * @param x + * end x coordinate + * @param y + * start y coordinate + * @param k + * start x coordinate + * @param height + * height in y coordinate + * @return rectangle in region range + */ + private Rectangle2D computeRectangle(int x, int y, int k, int height) { + double resX = matrix[k][y].getBorder().getX(); + double resY = matrix[k][y].getBorder().getY(); + double resWidth = matrix[x][y + height - 1].getBorder().getX() - resX + matrix[x][y + height - 1].getBorder().getWidth(); + double resHeight = matrix[x][y + height - 1].getBorder().getY() - resY + matrix[x][y + height - 1].getBorder().getHeight(); + + return new Rectangle2D.Double(resX, resY, resWidth, resHeight); + } + + /** + * Computes how deep in y axis can regions be extended from starting x,y + * region. + */ + private void findRanges() { + for (int i = 0; i < getSizeX(); i++) { + for (int j = 0; j < getSizeY(); j++) { + if (!matrix[i][j].isAvailable()) { + int k = j; + int temporaryRange = 0; + while (k >= 0 && matrix[i][k].getRange() == -1) { + matrix[i][k--].setRange(temporaryRange++); + } + } + } + if (matrix[i][getSizeY() - 1].isAvailable()) { + int k = getSizeY() - 1; + int temporaryRange = 1; + while (k >= 0 && matrix[i][k].getRange() == -1) { + matrix[i][k--].setRange(temporaryRange++); + } + } + + } + } + + /** + * Disables regions for all aliases. + */ + private void fillMatrixWithAliases() { + for (Element alias : aliases) { + if (alias != mainAlias) { + fillMatrixWithAlias(alias); + } + } + } + + /** + * Disable regions for given alias. + * + * @param alias + * alias that should disable regions + */ + private void fillMatrixWithAlias(Element alias) { + Double a, b, c, d; + + a = alias.getX(); + b = alias.getX() + alias.getWidth(); + c = alias.getY() + alias.getHeight(); + d = alias.getY(); + + fillWithPoints(a, b, c, d); + } + + /** + * Disable regions between given coordinates. + * + * @param x + * starting x coordinate + * @param xw + * ending x coordinate + * @param yh + * ending y coordinate + * @param y + * starting y coordinate + */ + private void fillWithPoints(Double x, Double xw, Double yh, Double y) { + Integer widthStart = 0; + Integer widthEnd = matrix.length; + Integer heightStart = 0; + Integer heightEnd = matrix[0].length; + + for (int i = 0; i < matrix.length; i++) { + if (matrix[i][0].getBorder().getX() <= x) { + widthStart = i; + } + if (matrix[i][0].getBorder().getX() <= xw) { + widthEnd = i; + } + } + if (matrix[matrix.length - 1][0].getBorder().getX() + matrix[matrix.length - 1][0].getBorder().getWidth() <= xw) { + widthEnd = matrix.length; + } + for (int i = 0; i < matrix[0].length; i++) { + if (matrix[0][i].getBorder().getY() <= y) { + heightStart = i; + } + if (matrix[0][i].getBorder().getY() <= yh) { + heightEnd = i; + } + } + if (matrix[0][matrix[0].length - 1].getBorder().getY() + matrix[0][matrix[0].length - 1].getBorder().getHeight() <= yh) { + heightEnd = matrix[0].length; + } + + for (int i = widthStart; i < widthEnd; i++) { + for (int j = heightStart; j < heightEnd; j++) { + matrix[i][j].setAvailable(false); + } + } + } + + /** + * This method looks for a place to put description of the alias on the map. + * + * @param alias + * alias for which we try to determine text position + * @return bounds where text could be put + */ + public Rectangle2D getRetangle(Compartment alias) { + List<Compartment> list = otherAliases.get(alias); + if (list == null) { + list = new ArrayList<Compartment>(); + for (Compartment compAlias : model.getCompartmentsAliases()) { + if (compAlias.getVisibilityLevel() <= alias.getVisibilityLevel() && compAlias.getTransparencyLevel() > alias.getVisibilityLevel()) { + if (compAlias.cross(alias) && compAlias.getSize() <= alias.getSize()) { + list.add(compAlias); + } + } + } + otherAliases.put(alias, list); + } + + this.mainAlias = alias; + this.aliases = list; + + leftBound = alias.getX(); + rightBound = (alias.getX() + alias.getWidth()); + upBound = alias.getY(); + bottomBound = (alias.getY() + alias.getHeight()); + + createMatrix(); + + fillMatrixWithAliases(); + + findRanges(); // 2*O(n^2) + + return findRectangle(); + } + + /** + * Create empty matrix with fields. + * + * @see #matrix + */ + protected void createMatrix() { + Set<Double> xs = new TreeSet<Double>(); + Set<Double> ys = new TreeSet<Double>(); + List<Double> widths = new ArrayList<Double>(); + List<Double> xCoordsOfBegginingOfRectangle = new ArrayList<Double>(); + List<Double> heights = new ArrayList<Double>(); + List<Double> yCoordsOfBegginingOfRectangle = new ArrayList<Double>(); + + for (Element alias : aliases) { + double x1 = alias.getX(); + double x2 = alias.getX() + alias.getWidth(); + double y1 = alias.getY(); + double y2 = alias.getY() + alias.getHeight(); + if (x1 >= leftBound && x1 <= rightBound) { + xs.add(x1); + } + if (x2 >= leftBound && x2 <= rightBound) { + xs.add(x2); + } + + if (y1 >= upBound && y1 <= bottomBound) { + ys.add(y1); + } + if (y2 >= upBound && y2 <= bottomBound) { + ys.add(y2); + } + } + Double previous = null; + for (Double width : xs) { + if (previous != null) { + widths.add(width - previous); + } + xCoordsOfBegginingOfRectangle.add(width); + previous = width; + } + previous = null; + for (Double height : ys) { + if (previous != null) { + heights.add(height - previous); + } + yCoordsOfBegginingOfRectangle.add(height); + previous = height; + } + + matrix = new Field[xs.size() - 1][ys.size() - 1]; + + for (int i = 0; i < getSizeX(); i++) { + for (int j = 0; j < getSizeY(); j++) { + Field field = new Field(); + xCoordsOfBegginingOfRectangle.get(i); + yCoordsOfBegginingOfRectangle.get(j); + widths.get(i); + heights.get(j); + field.setBorder(new Rectangle2D.Double(xCoordsOfBegginingOfRectangle.get(i), yCoordsOfBegginingOfRectangle.get(j), widths.get(i), heights.get(j))); + matrix[i][j] = field; + } + } + } + + /** + * + * @return {@link #model} + */ + public Model getModel() { + return model; + } + + /** + * Returns width of the {@link #matrix}. + * + * @return width of the {@link #matrix} + */ + private int getSizeX() { + return matrix.length; + } + + /** + * Returns height of the {@link #matrix}. + * + * @return height of the {@link #matrix} + */ + private int getSizeY() { + return matrix[0].length; + } + +} diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/AntisenseRnaConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/AntisenseRnaConverter.java index ebfb0c2dcc..1bbb52b6c3 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/AntisenseRnaConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/AntisenseRnaConverter.java @@ -14,10 +14,10 @@ import java.awt.geom.Point2D; import org.apache.log4j.Logger; import lcsb.mapviewer.converter.graphics.ConverterParams; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaAlias; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaRegionAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.AntisenseRna; +import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion; +import lcsb.mapviewer.model.map.species.field.ModificationState; /** * This class defines methods used for drawing Antisense Rna SpeciesAlias on the @@ -27,7 +27,7 @@ import lcsb.mapviewer.model.map.layout.alias.ModificationState; * */ -public class AntisenseRnaConverter extends SpeciesConverter<AntisenseRnaAlias> { +public class AntisenseRnaConverter extends SpeciesConverter<AntisenseRna> { /** * Default class logger. */ @@ -35,7 +35,7 @@ public class AntisenseRnaConverter extends SpeciesConverter<AntisenseRnaAlias> { private static Logger logger = Logger.getLogger(AntisenseRnaConverter.class.getName()); @Override - public void drawAlias(final AntisenseRnaAlias alias, final Graphics2D graphics, final ConverterParams params) { + public void drawAlias(final AntisenseRna alias, final Graphics2D graphics, final ConverterParams params) { GeneralPath path = getAntisenseRnaPath(alias); Color c = graphics.getColor(); graphics.setColor(alias.getColor()); @@ -46,7 +46,7 @@ public class AntisenseRnaConverter extends SpeciesConverter<AntisenseRnaAlias> { graphics.draw(path); graphics.setStroke(stroke); - for (AntisenseRnaRegionAlias mr : alias.getRegions()) { + for (AntisenseRnaRegion mr : alias.getRegions()) { drawRegion(alias, mr, graphics, false, false); } @@ -60,7 +60,7 @@ public class AntisenseRnaConverter extends SpeciesConverter<AntisenseRnaAlias> { * alias for which we want to get border * @return border of the alias */ - private GeneralPath getAntisenseRnaPath(final Alias alias) { + private GeneralPath getAntisenseRnaPath(final Element alias) { // CHECKSTYLE:OFF GeneralPath path = new GeneralPath(Path2D.WIND_EVEN_ODD, 4); path.moveTo(alias.getX(), alias.getY()); @@ -73,7 +73,7 @@ public class AntisenseRnaConverter extends SpeciesConverter<AntisenseRnaAlias> { } @Override - public PathIterator getBoundPathIterator(final AntisenseRnaAlias alias) { + public PathIterator getBoundPathIterator(final AntisenseRna alias) { return getAntisenseRnaPath(alias).getPathIterator(new AffineTransform()); } @@ -91,7 +91,7 @@ public class AntisenseRnaConverter extends SpeciesConverter<AntisenseRnaAlias> { * @param drawDescription * flag determining if we want to draw description as well */ - private void drawRegion(final AntisenseRnaAlias alias, final AntisenseRnaRegionAlias mr, final Graphics2D graphics, final boolean drawEmptyRegion, + private void drawRegion(final AntisenseRna alias, final AntisenseRnaRegion mr, final Graphics2D graphics, final boolean drawEmptyRegion, final boolean drawDescription) { if ((!drawEmptyRegion) && (mr.getState() == null)) { return; diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/ComplexConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/ComplexConverter.java index 5cc49ba923..c9ac29e527 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/ComplexConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/ComplexConverter.java @@ -15,8 +15,8 @@ import lcsb.mapviewer.converter.graphics.ConverterParams; import lcsb.mapviewer.converter.graphics.geometry.FontFinder; import lcsb.mapviewer.converter.graphics.geometry.RectangleTooSmallException; import lcsb.mapviewer.model.graphics.LineType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Complex; /** * This class defines methods used for drawing ComplexAlias on the graphics2d @@ -25,7 +25,7 @@ import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; * @author Piotr Gawron * */ -public class ComplexConverter extends SpeciesConverter<ComplexAlias> { +public class ComplexConverter extends SpeciesConverter<Complex> { /** * How big is the triangle trimmed part of the complex. @@ -43,7 +43,7 @@ public class ComplexConverter extends SpeciesConverter<ComplexAlias> { private static Logger logger = Logger.getLogger(ComplexConverter.class.getName()); @Override - public void drawAlias(final ComplexAlias alias, final Graphics2D graphics, final ConverterParams params) { + public void drawAlias(final Complex alias, final Graphics2D graphics, final ConverterParams params) { if (alias.getState().equalsIgnoreCase("complexnoborder")) { return; } @@ -128,8 +128,8 @@ public class ComplexConverter extends SpeciesConverter<ComplexAlias> { } @Override - public void drawText(final ComplexAlias alias, final Graphics2D graphics, final ConverterParams params) { - if (((ComplexAlias) alias).getAliases().size() > 0) { + public void drawText(final Complex alias, final Graphics2D graphics, final ConverterParams params) { + if (((Complex) alias).getAliases().size() > 0) { if (alias.getTransparencyLevel() <= params.getLevel()) { super.drawText(alias, graphics, params); return; @@ -156,7 +156,7 @@ public class ComplexConverter extends SpeciesConverter<ComplexAlias> { * exact object for which we want to get a border * @return border of the alias */ - private GeneralPath getAliasPath(final Alias alias) { + private GeneralPath getAliasPath(final Element alias) { GeneralPath path = new GeneralPath(Path2D.WIND_EVEN_ODD); path.moveTo(alias.getX() + TRIMMED_CORNER_SIZE, alias.getY()); path.lineTo(alias.getX() + alias.getWidth() - TRIMMED_CORNER_SIZE, alias.getY()); @@ -171,7 +171,7 @@ public class ComplexConverter extends SpeciesConverter<ComplexAlias> { } @Override - public PathIterator getBoundPathIterator(final ComplexAlias alias) { + public PathIterator getBoundPathIterator(final Complex alias) { return getAliasPath(alias).getPathIterator(new AffineTransform()); } } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/DegradedConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/DegradedConverter.java index 30dd8db319..44c0b254b2 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/DegradedConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/DegradedConverter.java @@ -1,121 +1,121 @@ -package lcsb.mapviewer.converter.graphics.species; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.Stroke; -import java.awt.geom.Area; -import java.awt.geom.Ellipse2D; -import java.awt.geom.GeneralPath; -import java.awt.geom.Path2D; -import java.awt.geom.PathIterator; - -import lcsb.mapviewer.common.exception.InvalidStateException; -import lcsb.mapviewer.converter.graphics.ConverterParams; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; - -import org.apache.log4j.Logger; - -/** - * This class defines methods used for drawing Degraded SpeciesAlias on the - * graphics2d object. - * - * @author Piotr Gawron - * - */ -public class DegradedConverter extends SpeciesConverter<SpeciesAlias> { - /** - * Part of height of the line used to cross degraded circle that goes behind - * this circle. - */ - private static final int CROSS_LINE_EXTENDED_LENGTH = 7; - /** - * Default class logger. - */ - private static Logger logger = Logger.getLogger(DegradedConverter.class.getName()); - - @Override - public void drawAlias(final SpeciesAlias alias, final Graphics2D graphics, final ConverterParams params) { - double diameter = getDiameter(alias); - double x = getXCoord(alias, diameter); - double y = getYCoord(alias); - Area a1 = new Area(new Ellipse2D.Double(x, y, diameter, diameter)); - - double lineX1 = alias.getX() + alias.getWidth() / 2 + CROSS_LINE_EXTENDED_LENGTH; - double lineY1 = alias.getY(); - - double lineX2 = alias.getX() + alias.getWidth() / 2 - CROSS_LINE_EXTENDED_LENGTH; - double lineY2 = alias.getY() + diameter + 2 * CROSS_LINE_EXTENDED_LENGTH; - - GeneralPath path = new GeneralPath(Path2D.WIND_EVEN_ODD, 2); - path.moveTo(lineX1, lineY1); - path.lineTo(lineX1 + 1, lineY1); - path.lineTo(lineX2 + 1, lineY2); - path.lineTo(lineX2, lineY2); - path.closePath(); - - a1.exclusiveOr(new Area(path)); - Color c = graphics.getColor(); - graphics.setColor(alias.getColor()); - graphics.fill(a1); - graphics.setColor(c); - Stroke stroke = graphics.getStroke(); - graphics.setStroke(getBorderLine(alias)); - graphics.draw(a1); - graphics.setStroke(stroke); - drawText(alias, graphics, params); - } - - /** - * Returns transformed y coordinate for the degraded alias. - * - * @param alias - * object alias to to which we are looking for y coordinate - * @return y coordinate of the alias - */ - private double getYCoord(final Alias alias) { - double y = alias.getY() + CROSS_LINE_EXTENDED_LENGTH; - return y; - } - - /** - * Returns transformed x coordinate for the degraded alias. - * - * @param alias - * object alias to to which we are looking for x coordinate - * @param diameter - * diameter of cross line used in this alias - * @return x coordinate of the alias - */ - private double getXCoord(final Alias alias, final double diameter) { - double x = alias.getX() + (alias.getWidth() - diameter) / 2; - return x; - } - - /** - * Computes diameter of cross line for the degraded alias. - * - * @param alias - * object alias to to which we are looking for diameter. - * @return diameter of the cross line - */ - private double getDiameter(final Alias alias) { - double diameter = Math.min(alias.getWidth(), alias.getHeight()) - 2 * CROSS_LINE_EXTENDED_LENGTH; - if (diameter < 0) { - logger.warn("Diameter cannot be negative..."); - diameter = 0; - } - return diameter; - } - - @Override - public String getText(final SpeciesAlias alias) { - return ""; - } - - @Override - public PathIterator getBoundPathIterator(final SpeciesAlias alias) { - throw new InvalidStateException("This class doesn't have bound"); - } - -} +package lcsb.mapviewer.converter.graphics.species; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Stroke; +import java.awt.geom.Area; +import java.awt.geom.Ellipse2D; +import java.awt.geom.GeneralPath; +import java.awt.geom.Path2D; +import java.awt.geom.PathIterator; + +import lcsb.mapviewer.common.exception.InvalidStateException; +import lcsb.mapviewer.converter.graphics.ConverterParams; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; + +import org.apache.log4j.Logger; + +/** + * This class defines methods used for drawing Degraded SpeciesAlias on the + * graphics2d object. + * + * @author Piotr Gawron + * + */ +public class DegradedConverter extends SpeciesConverter<Species> { + /** + * Part of height of the line used to cross degraded circle that goes behind + * this circle. + */ + private static final int CROSS_LINE_EXTENDED_LENGTH = 7; + /** + * Default class logger. + */ + private static Logger logger = Logger.getLogger(DegradedConverter.class.getName()); + + @Override + public void drawAlias(final Species alias, final Graphics2D graphics, final ConverterParams params) { + double diameter = getDiameter(alias); + double x = getXCoord(alias, diameter); + double y = getYCoord(alias); + Area a1 = new Area(new Ellipse2D.Double(x, y, diameter, diameter)); + + double lineX1 = alias.getX() + alias.getWidth() / 2 + CROSS_LINE_EXTENDED_LENGTH; + double lineY1 = alias.getY(); + + double lineX2 = alias.getX() + alias.getWidth() / 2 - CROSS_LINE_EXTENDED_LENGTH; + double lineY2 = alias.getY() + diameter + 2 * CROSS_LINE_EXTENDED_LENGTH; + + GeneralPath path = new GeneralPath(Path2D.WIND_EVEN_ODD, 2); + path.moveTo(lineX1, lineY1); + path.lineTo(lineX1 + 1, lineY1); + path.lineTo(lineX2 + 1, lineY2); + path.lineTo(lineX2, lineY2); + path.closePath(); + + a1.exclusiveOr(new Area(path)); + Color c = graphics.getColor(); + graphics.setColor(alias.getColor()); + graphics.fill(a1); + graphics.setColor(c); + Stroke stroke = graphics.getStroke(); + graphics.setStroke(getBorderLine(alias)); + graphics.draw(a1); + graphics.setStroke(stroke); + drawText(alias, graphics, params); + } + + /** + * Returns transformed y coordinate for the degraded alias. + * + * @param alias + * object alias to to which we are looking for y coordinate + * @return y coordinate of the alias + */ + private double getYCoord(final Element alias) { + double y = alias.getY() + CROSS_LINE_EXTENDED_LENGTH; + return y; + } + + /** + * Returns transformed x coordinate for the degraded alias. + * + * @param alias + * object alias to to which we are looking for x coordinate + * @param diameter + * diameter of cross line used in this alias + * @return x coordinate of the alias + */ + private double getXCoord(final Element alias, final double diameter) { + double x = alias.getX() + (alias.getWidth() - diameter) / 2; + return x; + } + + /** + * Computes diameter of cross line for the degraded alias. + * + * @param alias + * object alias to to which we are looking for diameter. + * @return diameter of the cross line + */ + private double getDiameter(final Element alias) { + double diameter = Math.min(alias.getWidth(), alias.getHeight()) - 2 * CROSS_LINE_EXTENDED_LENGTH; + if (diameter < 0) { + logger.warn("Diameter cannot be negative..."); + diameter = 0; + } + return diameter; + } + + @Override + public String getText(final Species alias) { + return ""; + } + + @Override + public PathIterator getBoundPathIterator(final Species alias) { + throw new InvalidStateException("This class doesn't have bound"); + } + +} diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/DrugConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/DrugConverter.java index a186c8ea4d..f737787cac 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/DrugConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/DrugConverter.java @@ -1,106 +1,106 @@ -package lcsb.mapviewer.converter.graphics.species; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.Shape; -import java.awt.Stroke; -import java.awt.geom.AffineTransform; -import java.awt.geom.PathIterator; -import java.awt.geom.Point2D; -import java.awt.geom.RoundRectangle2D; -import java.util.ArrayList; - -import lcsb.mapviewer.converter.graphics.ConverterParams; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; - -import org.apache.log4j.Logger; - -/** - * This class defines methods used for drawing Drug SpeciesAlias on the - * graphics2d object. - * - * @author Piotr Gawron - * - */ -public class DrugConverter extends SpeciesConverter<SpeciesAlias> { - /** - * Distance between internal and external border of drug graphical - * representation. - */ - private static final int OFFSET_BETWEEN_BORDERS = 4; - /** - * How big should be the arc in rectangle for drug representation. - */ - private static final int RECTANGLE_CORNER_ARC_SIZE = 40; - /** - * Default class logger. - */ - @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(DrugConverter.class.getName()); - - /** - * Returns shape of the Drug . - * - * @param alias - * alias for which we are looking for a border - * @return Shape object defining given alias - */ - private Shape getDrugShape(final Alias alias) { - return new RoundRectangle2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight(), RECTANGLE_CORNER_ARC_SIZE, RECTANGLE_CORNER_ARC_SIZE); - } - - @Override - public void drawAlias(final SpeciesAlias alias, final Graphics2D graphics, final ConverterParams params) { - Shape a1 = getDrugShape(alias); - double offset = OFFSET_BETWEEN_BORDERS; - Shape a2 = new RoundRectangle2D.Double( - alias.getX() + offset, alias.getY() + offset, alias.getWidth() - 2 * offset, alias.getHeight() - 2 * offset, RECTANGLE_CORNER_ARC_SIZE, - RECTANGLE_CORNER_ARC_SIZE); - Color c = graphics.getColor(); - graphics.setColor(alias.getColor()); - graphics.fill(a1); - graphics.setColor(c); - Stroke stroke = graphics.getStroke(); - graphics.setStroke(getBorderLine(alias)); - graphics.draw(a1); - graphics.draw(a2); - graphics.setStroke(stroke); - drawText(alias, graphics, params); - } - - /** - * Returns shape of the Drug as a list of points. - * - * @param alias - * alias for which we are looking for a border - * @return list of points defining border of the given alias - */ - protected ArrayList<Point2D> getDrugPoints(final SpeciesAlias alias) { - ArrayList<Point2D> list = new ArrayList<Point2D>(); - - double x = alias.getX(); - double y = alias.getY(); - double width = alias.getWidth(); - double height = alias.getHeight(); - - // CHECKSTYLE:OFF - list.add(new Point2D.Double(x, y + height / 2)); - list.add(new Point2D.Double(x + width / 12, y)); - list.add(new Point2D.Double(x + width / 2, y)); - list.add(new Point2D.Double(x + width * 11 / 12, y)); - list.add(new Point2D.Double(x + width, y + height / 2)); - list.add(new Point2D.Double(x + width * 11 / 12, y + height)); - list.add(new Point2D.Double(x + width / 2, y + height)); - list.add(new Point2D.Double(x + width / 12, y + height)); - // CHECKSTYLE:ON - - return list; - } - - @Override - public PathIterator getBoundPathIterator(final SpeciesAlias alias) { - return getDrugShape(alias).getPathIterator(new AffineTransform()); - } - -} +package lcsb.mapviewer.converter.graphics.species; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.AffineTransform; +import java.awt.geom.PathIterator; +import java.awt.geom.Point2D; +import java.awt.geom.RoundRectangle2D; +import java.util.ArrayList; + +import lcsb.mapviewer.converter.graphics.ConverterParams; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; + +import org.apache.log4j.Logger; + +/** + * This class defines methods used for drawing Drug SpeciesAlias on the + * graphics2d object. + * + * @author Piotr Gawron + * + */ +public class DrugConverter extends SpeciesConverter<Species> { + /** + * Distance between internal and external border of drug graphical + * representation. + */ + private static final int OFFSET_BETWEEN_BORDERS = 4; + /** + * How big should be the arc in rectangle for drug representation. + */ + private static final int RECTANGLE_CORNER_ARC_SIZE = 40; + /** + * Default class logger. + */ + @SuppressWarnings("unused") + private static Logger logger = Logger.getLogger(DrugConverter.class.getName()); + + /** + * Returns shape of the Drug . + * + * @param alias + * alias for which we are looking for a border + * @return Shape object defining given alias + */ + private Shape getDrugShape(final Element alias) { + return new RoundRectangle2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight(), RECTANGLE_CORNER_ARC_SIZE, RECTANGLE_CORNER_ARC_SIZE); + } + + @Override + public void drawAlias(final Species alias, final Graphics2D graphics, final ConverterParams params) { + Shape a1 = getDrugShape(alias); + double offset = OFFSET_BETWEEN_BORDERS; + Shape a2 = new RoundRectangle2D.Double( + alias.getX() + offset, alias.getY() + offset, alias.getWidth() - 2 * offset, alias.getHeight() - 2 * offset, RECTANGLE_CORNER_ARC_SIZE, + RECTANGLE_CORNER_ARC_SIZE); + Color c = graphics.getColor(); + graphics.setColor(alias.getColor()); + graphics.fill(a1); + graphics.setColor(c); + Stroke stroke = graphics.getStroke(); + graphics.setStroke(getBorderLine(alias)); + graphics.draw(a1); + graphics.draw(a2); + graphics.setStroke(stroke); + drawText(alias, graphics, params); + } + + /** + * Returns shape of the Drug as a list of points. + * + * @param alias + * alias for which we are looking for a border + * @return list of points defining border of the given alias + */ + protected ArrayList<Point2D> getDrugPoints(final Species alias) { + ArrayList<Point2D> list = new ArrayList<Point2D>(); + + double x = alias.getX(); + double y = alias.getY(); + double width = alias.getWidth(); + double height = alias.getHeight(); + + // CHECKSTYLE:OFF + list.add(new Point2D.Double(x, y + height / 2)); + list.add(new Point2D.Double(x + width / 12, y)); + list.add(new Point2D.Double(x + width / 2, y)); + list.add(new Point2D.Double(x + width * 11 / 12, y)); + list.add(new Point2D.Double(x + width, y + height / 2)); + list.add(new Point2D.Double(x + width * 11 / 12, y + height)); + list.add(new Point2D.Double(x + width / 2, y + height)); + list.add(new Point2D.Double(x + width / 12, y + height)); + // CHECKSTYLE:ON + + return list; + } + + @Override + public PathIterator getBoundPathIterator(final Species alias) { + return getDrugShape(alias).getPathIterator(new AffineTransform()); + } + +} diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/GeneConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/GeneConverter.java index fecd7d7777..195dd99d7c 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/GeneConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/GeneConverter.java @@ -14,10 +14,10 @@ import java.awt.geom.Point2D; import org.apache.log4j.Logger; import lcsb.mapviewer.converter.graphics.ConverterParams; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationResidueAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; +import lcsb.mapviewer.model.map.species.field.ModificationState; /** * This class defines methods used for drawing Gene SpeciesAlias on the @@ -26,7 +26,7 @@ import lcsb.mapviewer.model.map.layout.alias.ModificationState; * @author Piotr Gawron * */ -public class GeneConverter extends SpeciesConverter<GeneAlias> { +public class GeneConverter extends SpeciesConverter<Gene> { /** * Default class logger. */ @@ -34,7 +34,7 @@ public class GeneConverter extends SpeciesConverter<GeneAlias> { private static Logger logger = Logger.getLogger(GeneConverter.class.getName()); @Override - public void drawAlias(final GeneAlias alias, final Graphics2D graphics, final ConverterParams params) { + public void drawAlias(final Gene alias, final Graphics2D graphics, final ConverterParams params) { Shape shape = getGeneShape(alias); Color c = graphics.getColor(); graphics.setColor(alias.getColor()); @@ -45,7 +45,7 @@ public class GeneConverter extends SpeciesConverter<GeneAlias> { graphics.draw(shape); graphics.setStroke(stroke); - for (ModificationResidueAlias mr : alias.getModificationResidues()) { + for (ModificationResidue mr : alias.getModificationResidues()) { drawModification(alias, mr, graphics, false, false); } @@ -70,7 +70,7 @@ public class GeneConverter extends SpeciesConverter<GeneAlias> { * flag that indicates if we should draw description of the * modification */ - private void drawModification(final GeneAlias alias, final ModificationResidueAlias mr, final Graphics2D graphics, final boolean drawEmptyModification, + private void drawModification(final Gene alias, final ModificationResidue mr, final Graphics2D graphics, final boolean drawEmptyModification, final boolean drawDescription) { if ((!drawEmptyModification) && (mr.getState() == null)) { return; @@ -118,14 +118,14 @@ public class GeneConverter extends SpeciesConverter<GeneAlias> { * alias for which we are looking for a Shape * @return Shape object that represents alias */ - private Shape getGeneShape(final Alias alias) { + private Shape getGeneShape(final Element alias) { Shape shape; shape = new Rectangle(alias.getX().intValue(), alias.getY().intValue(), alias.getWidth().intValue(), alias.getHeight().intValue()); return shape; } @Override - public PathIterator getBoundPathIterator(final GeneAlias alias) { + public PathIterator getBoundPathIterator(final Gene alias) { return getGeneShape(alias).getPathIterator(new AffineTransform()); } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/IonConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/IonConverter.java index 1b0dd1ac47..34f5a147c0 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/IonConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/IonConverter.java @@ -10,8 +10,8 @@ import java.awt.geom.Point2D; import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.converter.graphics.ConverterParams; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; import org.apache.log4j.Logger; @@ -23,14 +23,14 @@ import org.apache.log4j.Logger; * @author Piotr Gawron * */ -public class IonConverter extends SpeciesConverter<SpeciesAlias> { +public class IonConverter extends SpeciesConverter<Species> { /** * Default class logger. */ private static Logger logger = Logger.getLogger(IonConverter.class.getName()); @Override - public void drawAlias(final SpeciesAlias alias, final Graphics2D graphics, final ConverterParams params) { + public void drawAlias(final Species alias, final Graphics2D graphics, final ConverterParams params) { double diameter = getDiameter(alias); double x = getXCoord(alias, diameter); double y = getYCoord(alias); @@ -53,7 +53,7 @@ public class IonConverter extends SpeciesConverter<SpeciesAlias> { * object alias to to which we are looking for y coordinate * @return y coordinate of the alias */ - private double getYCoord(final Alias alias) { + private double getYCoord(final Element alias) { double y = alias.getY(); return y; } @@ -67,7 +67,7 @@ public class IonConverter extends SpeciesConverter<SpeciesAlias> { * diameter of circle representation of ion * @return x coordinate of the alias */ - private double getXCoord(final Alias alias, final double diameter) { + private double getXCoord(final Element alias, final double diameter) { double x = alias.getX() + (alias.getWidth() - diameter) / 2; return x; } @@ -79,7 +79,7 @@ public class IonConverter extends SpeciesConverter<SpeciesAlias> { * object alias to to which we are looking for diameter. * @return diameter of ion circle representation */ - private double getDiameter(final Alias alias) { + private double getDiameter(final Element alias) { double diameter = Math.min(alias.getWidth(), alias.getHeight()); if (diameter < 0) { logger.warn("Something is wrong. Size cannot be negative"); @@ -90,12 +90,12 @@ public class IonConverter extends SpeciesConverter<SpeciesAlias> { } @Override - public PathIterator getBoundPathIterator(final SpeciesAlias alias) { + public PathIterator getBoundPathIterator(final Species alias) { throw new InvalidStateException("This class doesn't have bound"); } @Override - public Point2D getPointCoordinatesOnBorder(final SpeciesAlias alias, final double angle) { + public Point2D getPointCoordinatesOnBorder(final Species alias, final double angle) { if (alias.getWidth() == 0 && alias.getHeight() == 0) { logger.warn("Looking for coordinates for the alias with 0 size"); return alias.getCenter(); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/PhenotypeConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/PhenotypeConverter.java index 217c3f630d..6dba03ff81 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/PhenotypeConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/PhenotypeConverter.java @@ -9,8 +9,8 @@ import java.awt.geom.Path2D; import java.awt.geom.PathIterator; import lcsb.mapviewer.converter.graphics.ConverterParams; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; import org.apache.log4j.Logger; @@ -22,7 +22,7 @@ import org.apache.log4j.Logger; * @author Piotr Gawron * */ -public class PhenotypeConverter extends SpeciesConverter<SpeciesAlias> { +public class PhenotypeConverter extends SpeciesConverter<Species> { /** * Default class logger. */ @@ -30,7 +30,7 @@ public class PhenotypeConverter extends SpeciesConverter<SpeciesAlias> { private static Logger logger = Logger.getLogger(PhenotypeConverter.class.getName()); @Override - public void drawAlias(final SpeciesAlias alias, final Graphics2D graphics, final ConverterParams params) { + public void drawAlias(final Species alias, final Graphics2D graphics, final ConverterParams params) { GeneralPath path = getPhenotypePath(alias); Color c = graphics.getColor(); @@ -51,7 +51,7 @@ public class PhenotypeConverter extends SpeciesConverter<SpeciesAlias> { * alias for which we are looking for a border * @return GeneralPath object defining border of the given alias */ - private GeneralPath getPhenotypePath(final Alias alias) { + private GeneralPath getPhenotypePath(final Element alias) { // CHECKSTYLE:OFF GeneralPath path = new GeneralPath(Path2D.WIND_EVEN_ODD, 6); path.moveTo(alias.getX() + alias.getWidth() / 6, alias.getY()); @@ -66,7 +66,7 @@ public class PhenotypeConverter extends SpeciesConverter<SpeciesAlias> { } @Override - public PathIterator getBoundPathIterator(final SpeciesAlias alias) { + public PathIterator getBoundPathIterator(final Species alias) { return getPhenotypePath(alias).getPathIterator(new AffineTransform()); } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/ProteinConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/ProteinConverter.java index 7816899e08..b3e3343d98 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/ProteinConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/ProteinConverter.java @@ -21,26 +21,25 @@ import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.converter.graphics.ConverterParams; import lcsb.mapviewer.model.graphics.LineType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.IonChannelProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationResidueAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ReceptorProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; -import lcsb.mapviewer.model.map.layout.alias.TruncatedProteinAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.IonChannelProtein; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.ReceptorProtein; +import lcsb.mapviewer.model.map.species.Species; +import lcsb.mapviewer.model.map.species.TruncatedProtein; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; +import lcsb.mapviewer.model.map.species.field.ModificationState; import lcsb.mapviewer.modelutils.map.ElementUtils; /** - * This class defines methods used for drawing SpeciesAlias of - * {@link lcsb.mapviewer.db.model.map.species.Protein Protein} on the + * This class defines methods used for drawing {@link Protein} on the * {@link Graphics2D} object. * * @author Piotr Gawron * */ -public class ProteinConverter extends SpeciesConverter<ProteinAlias> { +public class ProteinConverter extends SpeciesConverter<Protein> { /** * Width of the ion part in the open channel representation. */ @@ -59,7 +58,7 @@ public class ProteinConverter extends SpeciesConverter<ProteinAlias> { */ private static Logger logger = Logger.getLogger(ProteinConverter.class.getName()); - private ElementUtils eu = new ElementUtils(); + private ElementUtils eu = new ElementUtils(); /** * Returns shape of generic protein. @@ -68,12 +67,12 @@ public class ProteinConverter extends SpeciesConverter<ProteinAlias> { * alias for which we are looking for a border * @return Shape object defining given alias */ - private Shape getGenericShape(final Alias alias) { + private Shape getGenericShape(final Element alias) { return new RoundRectangle2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight(), RECTANGLE_CORNER_ARC_SIZE, RECTANGLE_CORNER_ARC_SIZE); } @Override - public void drawAlias(final ProteinAlias alias, final Graphics2D graphics, final ConverterParams params) { + public void drawAlias(final Protein alias, final Graphics2D graphics, final ConverterParams params) { // Local variable setting the SBGN visualization boolean sbgnFormat = params.isSbgnFormat(); @@ -112,12 +111,12 @@ public class ProteinConverter extends SpeciesConverter<ProteinAlias> { alias.setY(alias.getY() - SpeciesConverter.HOMODIMER_OFFSET); Shape shape = null; - if (alias instanceof GenericProteinAlias || sbgnFormat) { + if (alias instanceof GenericProtein || sbgnFormat) { shape = getGenericShape(alias); if (alias.getActivity() && !sbgnFormat) { drawActivityGenericProtein(alias, graphics); } - } else if (alias instanceof IonChannelProteinAlias) { + } else if (alias instanceof IonChannelProtein) { Area a1; if (!alias.getActivity()) { a1 = new Area( @@ -136,12 +135,12 @@ public class ProteinConverter extends SpeciesConverter<ProteinAlias> { RECTANGLE_CORNER_ARC_SIZE)); a1.add(a2); shape = a1; - } else if (alias instanceof TruncatedProteinAlias) { + } else if (alias instanceof TruncatedProtein) { shape = getTruncatedShape(alias); if (alias.getActivity()) { drawActivityTruncatedShape(alias, graphics); } - } else if (alias instanceof ReceptorProteinAlias) { + } else if (alias instanceof ReceptorProtein) { shape = getReceptorShape(alias); if (alias.getActivity()) { drawActivityReceptorProtein(alias, graphics); @@ -162,14 +161,14 @@ public class ProteinConverter extends SpeciesConverter<ProteinAlias> { // SBGN display mode - units of information and state variables are // printed on the top element only if (!sbgnFormat || (homodimerId == homodir - 1)) { - for (ModificationResidueAlias mr : alias.getModificationResidues()) { + for (ModificationResidue mr : alias.getModificationResidues()) { // SBGN display mode - print empty state variables drawModification(alias, mr, graphics, sbgnFormat, false); } if (sbgnFormat) { // SBGN display mode - ion channel's state is marked as a unit of // information - if (alias instanceof IonChannelProteinAlias) { + if (alias instanceof IonChannelProtein) { if (!unitOfInformationText.equals("")) { unitOfInformationText = unitOfInformationText.concat("; "); } @@ -205,14 +204,14 @@ public class ProteinConverter extends SpeciesConverter<ProteinAlias> { } /** - * Draws activity border of {@link GenericProtein} alias. + * Draws activity border of {@link GenericProtein}. * * @param alias - * {@link SpeciesAlias} that will be drawn + * {@link Species} that will be drawn * @param graphics * where we are drawing */ - private void drawActivityGenericProtein(final SpeciesAlias alias, final Graphics2D graphics) { + private void drawActivityGenericProtein(final Protein alias, final Graphics2D graphics) { int border = ACTIVITY_BORDER_DISTANCE; alias.increaseBorder(border); Shape shape2 = getGenericShape(alias); @@ -224,14 +223,14 @@ public class ProteinConverter extends SpeciesConverter<ProteinAlias> { } /** - * Draws activity border of {@link ReceptorProtein} alias. + * Draws activity border of {@link ReceptorProtein}. * * @param alias - * {@link SpeciesAlias} that will be drawn + * {@link Species} that will be drawn * @param graphics * where we are drawing */ - public void drawActivityReceptorProtein(final SpeciesAlias alias, final Graphics2D graphics) { + public void drawActivityReceptorProtein(final Protein alias, final Graphics2D graphics) { int border = ACTIVITY_BORDER_DISTANCE; alias.setX(alias.getX() - border); alias.setY(alias.getY() - border); @@ -249,14 +248,14 @@ public class ProteinConverter extends SpeciesConverter<ProteinAlias> { } /** - * Draws activity border of {@link TruncatedProtein} alias. + * Draws activity border of {@link TruncatedProtein}. * * @param alias - * {@link SpeciesAlias} that will be drawn + * {@link Species} that will be drawn * @param graphics * where we are drawing */ - public void drawActivityTruncatedShape(final SpeciesAlias alias, final Graphics2D graphics) { + public void drawActivityTruncatedShape(final Protein alias, final Graphics2D graphics) { int border = ACTIVITY_BORDER_DISTANCE; alias.setX(alias.getX() - border); alias.setY(alias.getY() - border); @@ -291,7 +290,7 @@ public class ProteinConverter extends SpeciesConverter<ProteinAlias> { * flag that indicates if we should draw description of the * modification */ - private void drawModification(final ProteinAlias alias, final ModificationResidueAlias mr, final Graphics2D graphics, final boolean drawEmptyModification, + private void drawModification(final Protein alias, final ModificationResidue mr, final Graphics2D graphics, final boolean drawEmptyModification, final boolean drawDescription) { if ((!drawEmptyModification) && (mr.getState() == null)) { return; @@ -356,7 +355,7 @@ public class ProteinConverter extends SpeciesConverter<ProteinAlias> { * alias for which we are looking for a border * @return Shape object defining given alias */ - protected Shape getReceptorShape(final Alias alias) { + protected Shape getReceptorShape(final Element alias) { Shape shape; GeneralPath path = new GeneralPath(Path2D.WIND_EVEN_ODD); ArrayList<Point2D> points = getReceptorPoints(alias); @@ -376,7 +375,7 @@ public class ProteinConverter extends SpeciesConverter<ProteinAlias> { * alias for which we are looking for a border * @return Shape object defining given alias */ - protected Shape getTruncatedShape(final Alias alias) { + protected Shape getTruncatedShape(final Element alias) { Shape shape; GeneralPath path = new GeneralPath(); // CHECKSTYLE:OFF @@ -405,7 +404,7 @@ public class ProteinConverter extends SpeciesConverter<ProteinAlias> { * alias for which we are looking for a border * @return list of points defining border of the given alias */ - private ArrayList<Point2D> getReceptorPoints(final Alias alias) { + private ArrayList<Point2D> getReceptorPoints(final Element alias) { double x = alias.getX(); double y = alias.getY(); double width = alias.getWidth(); @@ -427,14 +426,14 @@ public class ProteinConverter extends SpeciesConverter<ProteinAlias> { } @Override - public PathIterator getBoundPathIterator(final ProteinAlias alias) { - if (alias instanceof GenericProteinAlias) { + public PathIterator getBoundPathIterator(final Protein alias) { + if (alias instanceof GenericProtein) { return getGenericShape(alias).getPathIterator(new AffineTransform()); - } else if (alias instanceof ReceptorProteinAlias) { + } else if (alias instanceof ReceptorProtein) { return getReceptorShape(alias).getPathIterator(new AffineTransform()); - } else if (alias instanceof IonChannelProteinAlias) { + } else if (alias instanceof IonChannelProtein) { return getGenericShape(alias).getPathIterator(new AffineTransform()); - } else if (alias instanceof TruncatedProteinAlias) { + } else if (alias instanceof TruncatedProtein) { return getTruncatedShape(alias).getPathIterator(new AffineTransform()); } else { throw new InvalidArgumentException("Not implemented protein converter for type: " + alias.getClass()); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/RnaConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/RnaConverter.java index 0e0c06e2b3..67e92e517f 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/RnaConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/RnaConverter.java @@ -14,20 +14,19 @@ import java.awt.geom.Point2D; import org.apache.log4j.Logger; import lcsb.mapviewer.converter.graphics.ConverterParams; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaRegionAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Rna; +import lcsb.mapviewer.model.map.species.field.ModificationState; +import lcsb.mapviewer.model.map.species.field.RnaRegion; /** - * This class defines methods used for drawing SpeciesAlias of - * {@link lcsb.mapviewer.converter.model.celldesigner.structure.db.model.map.species.Rna - * Rna} on the {@link Graphics2D} object. + * This class defines methods used for drawing {@link Rna} on the + * {@link Graphics2D} object. * * @author Piotr Gawron * */ -public class RnaConverter extends SpeciesConverter<RnaAlias> { +public class RnaConverter extends SpeciesConverter<Rna> { /** * Default class logger. */ @@ -35,7 +34,7 @@ public class RnaConverter extends SpeciesConverter<RnaAlias> { private static Logger logger = Logger.getLogger(RnaConverter.class.getName()); @Override - public void drawAlias(final RnaAlias alias, final Graphics2D graphics, final ConverterParams params) { + public void drawAlias(final Rna alias, final Graphics2D graphics, final ConverterParams params) { GeneralPath path = getRnaPath(alias); Color c = graphics.getColor(); graphics.setColor(alias.getColor()); @@ -46,7 +45,7 @@ public class RnaConverter extends SpeciesConverter<RnaAlias> { graphics.draw(path); graphics.setStroke(stroke); - for (RnaRegionAlias mr : alias.getRegions()) { + for (RnaRegion mr : alias.getRegions()) { drawModification(alias, mr, graphics, false, false); } @@ -60,7 +59,7 @@ public class RnaConverter extends SpeciesConverter<RnaAlias> { * alias for which we are looking for a border * @return GeneralPath object defining border of the given alias */ - private GeneralPath getRnaPath(final Alias alias) { + private GeneralPath getRnaPath(final Element alias) { // CHECKSTYLE:OFF GeneralPath path = new GeneralPath(Path2D.WIND_EVEN_ODD, 4); path.moveTo(alias.getX() + alias.getWidth() / 4, alias.getY()); @@ -73,7 +72,7 @@ public class RnaConverter extends SpeciesConverter<RnaAlias> { } @Override - public PathIterator getBoundPathIterator(final RnaAlias alias) { + public PathIterator getBoundPathIterator(final Rna alias) { return getRnaPath(alias).getPathIterator(new AffineTransform()); } @@ -95,7 +94,7 @@ public class RnaConverter extends SpeciesConverter<RnaAlias> { * flag that indicates if we should draw description of the * modification */ - private void drawModification(final RnaAlias alias, final RnaRegionAlias mr, final Graphics2D graphics, final boolean drawEmptyModification, + private void drawModification(final Rna alias, final RnaRegion mr, final Graphics2D graphics, final boolean drawEmptyModification, final boolean drawDescription) { if ((!drawEmptyModification) && (mr.getState() == null)) { return; diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/SBGNNucleicAcidFeatureConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/SBGNNucleicAcidFeatureConverter.java index 25252c4945..599c7023d1 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/SBGNNucleicAcidFeatureConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/SBGNNucleicAcidFeatureConverter.java @@ -9,8 +9,8 @@ import java.awt.geom.GeneralPath; import java.awt.geom.PathIterator; import lcsb.mapviewer.converter.graphics.ConverterParams; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; /** * This class defines methods used for drawing SpeciesAlias of nucleic acid @@ -20,7 +20,7 @@ import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; * */ -public class SBGNNucleicAcidFeatureConverter extends SpeciesConverter<SpeciesAlias> { +public class SBGNNucleicAcidFeatureConverter extends SpeciesConverter<Species> { /** * How big should be the arc in rectangle for nucleic acid feature @@ -35,7 +35,7 @@ public class SBGNNucleicAcidFeatureConverter extends SpeciesConverter<SpeciesAli * alias for which the shape should be returned * @return shape of the SBGN Nucleic acid feature for given alias */ - private Shape getShape(final Alias alias) { + private Shape getShape(final Element alias) { GeneralPath bottomRoundedRectangle = new GeneralPath(GeneralPath.WIND_EVEN_ODD); double x = alias.getX(), y = alias.getY(), width = alias.getWidth(), height = alias.getHeight(); @@ -51,7 +51,7 @@ public class SBGNNucleicAcidFeatureConverter extends SpeciesConverter<SpeciesAli } @Override - public void drawAlias(SpeciesAlias alias, Graphics2D graphics, ConverterParams params) { + public void drawAlias(Species alias, Graphics2D graphics, ConverterParams params) { // Unit of information text - multimer cardinality String unitOfInformationText = null; if (alias.getAliasStatePrefix() != null && alias.getAliasStateLabel() != null) { @@ -113,7 +113,7 @@ public class SBGNNucleicAcidFeatureConverter extends SpeciesConverter<SpeciesAli } @Override - protected PathIterator getBoundPathIterator(SpeciesAlias alias) { + protected PathIterator getBoundPathIterator(Species alias) { return getShape(alias).getPathIterator(new AffineTransform()); } diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/SimpleMoleculeConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/SimpleMoleculeConverter.java index 35fed2b238..fd4c02aa19 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/SimpleMoleculeConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/SimpleMoleculeConverter.java @@ -12,24 +12,23 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.converter.graphics.ConverterParams; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; +import lcsb.mapviewer.model.map.species.SimpleMolecule; /** - * This class defines methods used for drawing SpeciesAlias of - * {@link lcsb.mapviewer.converter.model.celldesigner.structure.db.model.map.species.SimpleMolecule - * SimpleMolecule} on the {@link Graphics2D} object. + * This class defines methods used for drawing {@link SimpleMolecule} on + * the {@link Graphics2D} object. * * @author Piotr Gawron * */ -public class SimpleMoleculeConverter extends SpeciesConverter<SimpleMoleculeAlias> { +public class SimpleMoleculeConverter extends SpeciesConverter<SimpleMolecule> { /** * Default class logger. */ private static Logger logger = Logger.getLogger(SimpleMoleculeConverter.class.getName()); @Override - public void drawAlias(final SimpleMoleculeAlias alias, final Graphics2D graphics, final ConverterParams params) { + public void drawAlias(final SimpleMolecule alias, final Graphics2D graphics, final ConverterParams params) { int homodir; if (params.isSbgnFormat()) { // If the SBGN display mode is set, multimer is shown as two stacked @@ -93,12 +92,12 @@ public class SimpleMoleculeConverter extends SpeciesConverter<SimpleMoleculeAlia } @Override - public PathIterator getBoundPathIterator(final SimpleMoleculeAlias alias) { + public PathIterator getBoundPathIterator(final SimpleMolecule alias) { throw new InvalidStateException("This class doesn't provide boundPath"); } @Override - public Point2D getPointCoordinatesOnBorder(final SimpleMoleculeAlias alias, final double angle) { + public Point2D getPointCoordinatesOnBorder(final SimpleMolecule alias, final double angle) { if (alias.getWidth() == 0 && alias.getHeight() == 0) { logger.warn("Looking for coordinates on border of alias of size 0"); return alias.getCenter(); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/SpeciesConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/SpeciesConverter.java index 7e546fc818..6413599429 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/SpeciesConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/SpeciesConverter.java @@ -23,21 +23,21 @@ import lcsb.mapviewer.converter.graphics.ConverterParams; import lcsb.mapviewer.converter.graphics.IAliasConverter; import lcsb.mapviewer.model.graphics.LineType; import lcsb.mapviewer.model.map.layout.ColorSchema; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; /** - * This class defines basics used for drawing aliases of - * {@link lcsb.mapviewer.db.model.map.species.Species Species} (node in the - * graph representation) on the graphics2d object. + * This class defines basics used for drawing aliases of {@link Species} + * (node in the graph representation) on the graphics2d object. * * @param <T> * alias class that can be drawn with this converter * @author Piotr Gawron * */ -public abstract class SpeciesConverter<T extends Alias> implements IAliasConverter<T> { +public abstract class SpeciesConverter<T extends Species> implements IAliasConverter<T> { + /** * PI value. */ @@ -240,7 +240,7 @@ public abstract class SpeciesConverter<T extends Alias> implements IAliasConvert * alias for which we are looking for a border * @return Shape object defining given alias */ - protected Shape getDefaultAliasShape(final Alias alias) { + protected Shape getDefaultAliasShape(final Element alias) { Shape shape; shape = new Rectangle(alias.getX().intValue(), alias.getY().intValue(), alias.getWidth().intValue(), alias.getHeight().intValue()); return shape; @@ -255,7 +255,7 @@ public abstract class SpeciesConverter<T extends Alias> implements IAliasConvert * specific drawing parameters (like scale) * @return Font that should be used for drawing alias description */ - protected Font getFont(final Alias alias, ConverterParams params) { + protected Font getFont(final Element alias, ConverterParams params) { double fontSize = DEFAULT_SPECIES_FONT_SIZE; if (alias.getFontSize() != null) { fontSize = alias.getFontSize(); @@ -288,8 +288,8 @@ public abstract class SpeciesConverter<T extends Alias> implements IAliasConvert graphics.setFont(font); Point2D point = alias.getCenter(); - if (alias instanceof ComplexAlias) { - if (((ComplexAlias) alias).getAliases().size() > 0) { + if (alias instanceof Complex) { + if (((Complex) alias).getAliases().size() > 0) { if (alias.getTransparencyLevel() <= params.getLevel()) { point.setLocation(point.getX(), alias.getY() + alias.getHeight() - graphics.getFontMetrics().getAscent()); } @@ -392,15 +392,15 @@ public abstract class SpeciesConverter<T extends Alias> implements IAliasConvert * alias to be drawn * @return style of the line used to draw alias */ - protected Stroke getBorderLine(final SpeciesAlias alias) { + protected Stroke getBorderLine(final Species alias) { if (!alias.isHypothetical()) { - if (alias instanceof ComplexAlias) { + if (alias instanceof Complex) { return LineType.SOLID_BOLD.getStroke(); } else { return LineType.SOLID.getStroke(); } } else { - if (alias instanceof ComplexAlias) { + if (alias instanceof Complex) { return LineType.DASHED_BOLD.getStroke(); } else { return LineType.DASHED.getStroke(); diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/UnknownConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/UnknownConverter.java index 4337fe9367..7063ad399c 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/UnknownConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/species/UnknownConverter.java @@ -11,7 +11,7 @@ import java.awt.geom.Point2D; import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.converter.graphics.ConverterParams; import lcsb.mapviewer.model.graphics.LineType; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Species; import org.apache.log4j.Logger; @@ -23,14 +23,14 @@ import org.apache.log4j.Logger; * @author Piotr Gawron * */ -public class UnknownConverter extends SpeciesConverter<SpeciesAlias> { +public class UnknownConverter extends SpeciesConverter<Species> { /** * Default class logger. */ private static Logger logger = Logger.getLogger(UnknownConverter.class.getName()); @Override - public void drawAlias(final SpeciesAlias alias, final Graphics2D graphics, final ConverterParams params) { + public void drawAlias(final Species alias, final Graphics2D graphics, final ConverterParams params) { if (alias.getActivity()) { int border = ACTIVITY_BORDER_DISTANCE; alias.increaseBorder(border); @@ -51,12 +51,12 @@ public class UnknownConverter extends SpeciesConverter<SpeciesAlias> { } @Override - public PathIterator getBoundPathIterator(final SpeciesAlias alias) { + public PathIterator getBoundPathIterator(final Species alias) { throw new InvalidStateException("This class doesn't provide boundPath"); } @Override - public Point2D getPointCoordinatesOnBorder(final SpeciesAlias alias, final double angle) { + public Point2D getPointCoordinatesOnBorder(final Species alias, final double angle) { if (alias.getWidth() == 0 && alias.getHeight() == 0) { logger.warn("Looking for coordinates for unknown of 0 size"); return alias.getCenter(); diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java index fbc8c4b21d..02e0979c11 100644 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java @@ -1,36 +1,37 @@ -package lcsb.mapviewer.converter.graphics; - -import static org.junit.Assert.fail; -import lcsb.mapviewer.model.map.layout.alias.BottomSquareCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.LeftSquareCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.RightSquareCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.TopSquareCompartmentAlias; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class ConverterTest { - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void test() { - try { - new AliasConverter(new BottomSquareCompartmentAlias()); - new AliasConverter(new TopSquareCompartmentAlias()); - new AliasConverter(new LeftSquareCompartmentAlias()); - new AliasConverter(new RightSquareCompartmentAlias()); - }catch (Exception e) { - e.printStackTrace(); - fail("Unknown exception"); - } - } - -} +package lcsb.mapviewer.converter.graphics; + +import static org.junit.Assert.fail; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import lcsb.mapviewer.model.map.compartment.BottomSquareCompartment; +import lcsb.mapviewer.model.map.compartment.LeftSquareCompartment; +import lcsb.mapviewer.model.map.compartment.RightSquareCompartment; +import lcsb.mapviewer.model.map.compartment.TopSquareCompartment; + +public class ConverterTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void test() { + try { + new AliasConverter(new BottomSquareCompartment()); + new AliasConverter(new TopSquareCompartment()); + new AliasConverter(new LeftSquareCompartment()); + new AliasConverter(new RightSquareCompartment()); + }catch (Exception e) { + e.printStackTrace(); + fail("Unknown exception"); + } + } + +} diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/NormalImageGeneratorTest.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/NormalImageGeneratorTest.java index 59817921e0..96d8113bbb 100644 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/NormalImageGeneratorTest.java +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/NormalImageGeneratorTest.java @@ -18,14 +18,14 @@ import lcsb.mapviewer.converter.graphics.AbstractImageGenerator.Params; import lcsb.mapviewer.converter.graphics.compartment.ArtifitialCompartmentConverter; import lcsb.mapviewer.converter.graphics.species.ComplexConverter; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.ArtifitialCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.compartment.PathwayCompartment; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.layout.graphics.LayerText; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class NormalImageGeneratorTest { static Logger logger = Logger.getLogger(NormalImageGenerator.class); @@ -52,7 +52,7 @@ public class NormalImageGeneratorTest { class TmpComplexConverter extends ComplexConverter { @Override - public void drawText(ComplexAlias compAlias, Graphics2D graphics, ConverterParams params) { + public void drawText(Complex compAlias, Graphics2D graphics, ConverterParams params) { setScale(params.getScale()); setCentered(params.isTextCentered()); super.drawText(compAlias, graphics, params); @@ -64,7 +64,7 @@ public class NormalImageGeneratorTest { public void testComplexConversion() throws Exception { scale = null; try { - AliasConverter.addAliasConverter(ComplexAlias.class, new TmpComplexConverter()); + AliasConverter.addAliasConverter(Complex.class, new TmpComplexConverter()); Model model = createComplexModel(); new CreateHierarchyCommand(model, 2, 2).execute(); @@ -84,7 +84,7 @@ public class NormalImageGeneratorTest { model.setWidth(600); model.setHeight(600); - ComplexAlias alias = new ComplexAlias("1"); + Complex alias = new Complex("1"); alias.setName("a"); alias.setX(10); alias.setY(10); @@ -92,7 +92,7 @@ public class NormalImageGeneratorTest { alias.setHeight(50); model.addAlias(alias); - SpeciesAlias a2 = new GenericProteinAlias("2"); + Species a2 = new GenericProtein("2"); a2.setName("b"); a2.setX(10); a2.setY(100); @@ -105,7 +105,7 @@ public class NormalImageGeneratorTest { class TmpArtifitialConverter extends ArtifitialCompartmentConverter { @Override - public void drawText(ArtifitialCompartmentAlias compAlias, Graphics2D graphics, ConverterParams params) { + public void drawText(PathwayCompartment compAlias, Graphics2D graphics, ConverterParams params) { setScale(params.getScale()); setCentered(params.isTextCentered()); setArtifitialCalled(true); @@ -118,7 +118,7 @@ public class NormalImageGeneratorTest { public void testNestedCompartmentsConversion() throws Exception { scale = null; try { - AliasConverter.addAliasConverter(ArtifitialCompartmentAlias.class, new TmpArtifitialConverter()); + AliasConverter.addAliasConverter(PathwayCompartment.class, new TmpArtifitialConverter()); Model model = createCompartmentModel(); new CreateHierarchyCommand(model, 2, 2).execute(); new PngImageGenerator(new Params().scale(2).width(600).height(600).model(model).level(0).nested(true)); @@ -149,7 +149,7 @@ public class NormalImageGeneratorTest { layer.addLayerLine(new PolylineData(new Point2D.Double(0, 0), new Point2D.Double(100, 100))); - ComplexAlias alias = new ComplexAlias("1"); + Complex alias = new Complex("1"); alias.setName("a"); alias.setX(300); alias.setY(90); @@ -164,7 +164,7 @@ public class NormalImageGeneratorTest { public void testArtifitialInNonHierarchicalView() throws Exception { scale = null; try { - AliasConverter.addAliasConverter(ArtifitialCompartmentAlias.class, new TmpArtifitialConverter()); + AliasConverter.addAliasConverter(PathwayCompartment.class, new TmpArtifitialConverter()); setArtifitialCalled(false); Model model = createCompartmentModel(); diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/PdfImageGeneratorTest.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/PdfImageGeneratorTest.java index eeef94d0f5..a69271674f 100644 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/PdfImageGeneratorTest.java +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/PdfImageGeneratorTest.java @@ -15,11 +15,11 @@ import org.junit.Test; import lcsb.mapviewer.commands.CreateHierarchyCommand; import lcsb.mapviewer.converter.graphics.AbstractImageGenerator.Params; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.layout.graphics.LayerText; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.Complex; public class PdfImageGeneratorTest { @@ -88,7 +88,7 @@ public class PdfImageGeneratorTest { layer.addLayerLine(new PolylineData(new Point2D.Double(0, 0), new Point2D.Double(100, 100))); - ComplexAlias alias = new ComplexAlias("1"); + Complex alias = new Complex("1"); alias.setName("a"); alias.setX(300); alias.setY(90); 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 4acd4cebfd..d9d071ebc1 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 @@ -11,8 +11,8 @@ import org.apache.log4j.Logger; import org.junit.Test; import lcsb.mapviewer.common.exception.InvalidXmlSchemaException; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.SquareCompartmentAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.compartment.SquareCompartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; @@ -29,7 +29,7 @@ public class AllPlaceFinderTest { Model model = new ModelFullIndexed(null); model.addAlias(createCompartmentAlias(94.0, 70.0, 355.0, 173.0)); - for (CompartmentAlias alias : model.getCompartmentsAliases()) { + for (Compartment alias : model.getCompartmentsAliases()) { PlaceFinder pf = new PlaceFinder(model); actual = pf.getRetangle(alias).toString(); } @@ -47,7 +47,7 @@ public class AllPlaceFinderTest { model.addAlias(createCompartmentAlias(332.0, 66.0, 188.0, 255.0)); String expected = ""; - for (CompartmentAlias alias : model.getCompartmentsAliases()) { + for (Compartment alias : model.getCompartmentsAliases()) { PlaceFinder pf = new PlaceFinder(model); actual = pf.getRetangle(alias).toString(); Rectangle2D result = alias.getBorder(); @@ -59,9 +59,9 @@ public class AllPlaceFinderTest { @Test public void twoIntersectingCompartments() throws InvalidXmlSchemaException, IOException { Model model = new ModelFullIndexed(null); - CompartmentAlias alias = createCompartmentAlias(87.0, 56.0, 235.0, 219.0); + Compartment alias = createCompartmentAlias(87.0, 56.0, 235.0, 219.0); model.addAlias(alias); - CompartmentAlias alias2 = createCompartmentAlias(227.0, 17.0, 290.0, 317.0); + Compartment alias2 = createCompartmentAlias(227.0, 17.0, 290.0, 317.0); model.addAlias(alias2); PlaceFinder pf = new PlaceFinder(model); @@ -77,7 +77,7 @@ public class AllPlaceFinderTest { model.addAlias(createCompartmentAlias(45.0, 38.0, 174.0, 169.0)); model.addAlias(createCompartmentAlias(118.0, 85.0, 60.0, 68.0)); double actual = 0.0; - for (CompartmentAlias alias : model.getCompartmentsAliases()) { + for (Compartment alias : model.getCompartmentsAliases()) { PlaceFinder pf = new PlaceFinder(model); Rectangle2D rect = pf.getRetangle(alias); actual = rect.getWidth() * rect.getHeight(); @@ -93,7 +93,7 @@ public class AllPlaceFinderTest { model.addAlias(createCompartmentAlias(88.0, 70.0, 138.0, 112.0)); double actual = 0.0; Rectangle2D result = null; - for (CompartmentAlias alias : model.getCompartmentsAliases()) { + for (Compartment alias : model.getCompartmentsAliases()) { PlaceFinder pf = new PlaceFinder(model); Rectangle2D rect = pf.getRetangle(alias); actual += rect.getWidth() * rect.getHeight(); @@ -118,8 +118,8 @@ public class AllPlaceFinderTest { return tru; } - private CompartmentAlias createCompartmentAlias(double x, double y, double width, double height) { - CompartmentAlias result = new SquareCompartmentAlias(); + private Compartment createCompartmentAlias(double x, double y, double width, double height) { + Compartment result = new SquareCompartment(); result.setAliasId("" + id++); result.setX(x); result.setY(y); @@ -137,7 +137,7 @@ public class AllPlaceFinderTest { model.addAlias(createCompartmentAlias(4521.0, 0.0, 10000.0, 6000.0)); model.addAlias(createCompartmentAlias(4828.0, 0.0, 5172.0, 6000.0)); double actual = 0.0; - for (CompartmentAlias alias : model.getCompartmentsAliases()) { + for (Compartment alias : model.getCompartmentsAliases()) { PlaceFinder pf = new PlaceFinder(model); Rectangle2D rect = pf.getRetangle(alias); actual = rect.getWidth() * rect.getHeight(); diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/species/SpeciesConverterTest.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/species/SpeciesConverterTest.java index 1f93051927..64c6307dd4 100644 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/species/SpeciesConverterTest.java +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/species/SpeciesConverterTest.java @@ -17,8 +17,8 @@ import org.junit.Test; import lcsb.mapviewer.converter.graphics.ConverterParams; import lcsb.mapviewer.model.map.layout.ColorSchema; import lcsb.mapviewer.model.map.layout.GenericColorSchema; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Protein; public class SpeciesConverterTest { @@ -34,11 +34,11 @@ public class SpeciesConverterTest { public void testGetResidueCoords() throws Exception { try { final class Conv extends ProteinConverter { - public Point2D getCoordinate(ProteinAlias alias, double angle) { + public Point2D getCoordinate(Protein alias, double angle) { return super.getResidueCoordinates(alias, angle); } } - GenericProteinAlias alias = new GenericProteinAlias("id"); + GenericProtein alias = new GenericProtein("id"); alias.setX(135); alias.setY(194.0); alias.setWidth(130); @@ -68,12 +68,12 @@ public class SpeciesConverterTest { Graphics2D graphics = bi.createGraphics(); ProteinConverter rc = new ProteinConverter(); - GenericProteinAlias alias = createAlias(); + GenericProtein alias = createAlias(); rc.drawAlias(alias, graphics, new ConverterParams()); int val = bi.getRGB((int) alias.getCenterX(), (int) alias.getCenterY()); - GenericProteinAlias alias2 = createAlias(); + GenericProtein alias2 = createAlias(); bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB); graphics = bi.createGraphics(); @@ -101,12 +101,12 @@ public class SpeciesConverterTest { Graphics2D graphics = bi.createGraphics(); ProteinConverter rc = new ProteinConverter(); - GenericProteinAlias alias = createAlias(); + GenericProtein alias = createAlias(); rc.drawAlias(alias, graphics, new ConverterParams()); int val = bi.getRGB((int) alias.getCenterX(), (int) alias.getCenterY()); - GenericProteinAlias alias2 = createAlias(); + GenericProtein alias2 = createAlias(); bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB); graphics = bi.createGraphics(); @@ -142,12 +142,12 @@ public class SpeciesConverterTest { Graphics2D graphics = bi.createGraphics(); ProteinConverter rc = new ProteinConverter(); - GenericProteinAlias alias = createAlias(); + GenericProtein alias = createAlias(); rc.drawAlias(alias, graphics, new ConverterParams()); int val = bi.getRGB((int) alias.getCenterX(), (int) alias.getCenterY()); - GenericProteinAlias alias2 = createAlias(); + GenericProtein alias2 = createAlias(); bi = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB); graphics = bi.createGraphics(); @@ -176,8 +176,8 @@ public class SpeciesConverterTest { } } - private GenericProteinAlias createAlias() { - GenericProteinAlias alias = new GenericProteinAlias("id"); + private GenericProtein createAlias() { + GenericProtein alias = new GenericProtein("id"); alias.setName("NAME_OF_THE_ELEMENT"); alias.setX(10); alias.setY(20); diff --git a/converter/src/main/java/lcsb/mapviewer/converter/ComplexZipConverter.java b/converter/src/main/java/lcsb/mapviewer/converter/ComplexZipConverter.java index e004c14c8a..ab1c2c2f80 100644 --- a/converter/src/main/java/lcsb/mapviewer/converter/ComplexZipConverter.java +++ b/converter/src/main/java/lcsb/mapviewer/converter/ComplexZipConverter.java @@ -31,16 +31,16 @@ import lcsb.mapviewer.converter.zip.ZipEntryFile; import lcsb.mapviewer.model.cache.UploadedFileEntry; import lcsb.mapviewer.model.map.graph.DataMiningSet; import lcsb.mapviewer.model.map.layout.Layout; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.AliasSubmodelConnection; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelSubmodelConnection; 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.Complex; +import lcsb.mapviewer.model.map.species.Phenotype; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Species; /** * This class allows to create complex {@link Model} that contains submaps. It's @@ -211,26 +211,26 @@ public class ComplexZipConverter<T extends IConverter> { topModel .addCreationWarning("[SUBMODEL MAPPING] Reaction " + reaction.getIdReaction() + " in mapping file (" + mapping + ") contains modifiers. Skipped"); } else { - Alias fromAlias = reaction.getReactants().get(0).getAlias(); - Alias toAlias = reaction.getProducts().get(0).getAlias(); - if (!(fromAlias instanceof SpeciesAlias)) { + Element fromAlias = reaction.getReactants().get(0).getAlias(); + Element toAlias = reaction.getProducts().get(0).getAlias(); + if (!(fromAlias instanceof Species)) { topModel.addCreationWarning( "[SUBMODEL MAPPING] Reaction " + reaction.getIdReaction() + " in mapping file (" + mapping + ") contains doesn't start in species. Skipped"); - } else if (!(toAlias instanceof SpeciesAlias)) { + } else if (!(toAlias instanceof Species)) { topModel.addCreationWarning( "[SUBMODEL MAPPING] Reaction " + reaction.getIdReaction() + " in mapping file (" + mapping + ") contains doesn't end in species. Skipped"); } else { - ComplexAlias complexFrom = ((SpeciesAlias) fromAlias).getComplexAlias(); - ComplexAlias complexTo = ((SpeciesAlias) toAlias).getComplexAlias(); + Complex complexFrom = ((Species) fromAlias).getComplexAlias(); + Complex complexTo = ((Species) toAlias).getComplexAlias(); if (complexFrom == null) { topModel.addCreationWarning( "[SUBMODEL MAPPING] Reaction " + reaction.getIdReaction() + " in mapping file (" + mapping + ") contains doesn't start inside complex. Skipped"); - } else if (complexTo == null && (!(toAlias instanceof ComplexAlias))) { + } else if (complexTo == null && (!(toAlias instanceof Complex))) { topModel.addCreationWarning( "[SUBMODEL MAPPING] Reaction " + reaction.getIdReaction() + " in mapping file (" + mapping + ") contains doesn't end inside complex. Skipped"); } else { if (complexTo == null) { - complexTo = (ComplexAlias) toAlias; + complexTo = (Complex) toAlias; } String fromName = complexFrom.getName(); String toName = complexTo.getName(); @@ -241,18 +241,18 @@ 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"); } - Alias source = fromModel.getAliasByAliasId(fromAlias.getName()); + Element source = fromModel.getAliasByAliasId(fromAlias.getName()); if (source == null) { throw new InvalidArgumentException("Mapping file references to element with alias: " + fromAlias.getName() + ". But such element doesn't exist"); } - Alias dest = null; - if (!(toAlias instanceof ComplexAlias)) { + Element dest = null; + if (!(toAlias instanceof Complex)) { dest = fromModel.getAliasByAliasId(toAlias.getName()); } SubmodelType type = SubmodelType.UNKNOWN; - if (fromAlias instanceof ProteinAlias) { + if (fromAlias instanceof Protein) { type = SubmodelType.DOWNSTREAM_TARGETS; - } else if (fromAlias instanceof PhenotypeAlias) { + } else if (fromAlias instanceof Phenotype) { type = SubmodelType.PATHWAY; } AliasSubmodelConnection connection = new AliasSubmodelConnection(toModel, type); diff --git a/converter/src/test/java/lcsb/mapviewer/converter/ComplexZipConverterTest.java b/converter/src/test/java/lcsb/mapviewer/converter/ComplexZipConverterTest.java index f959a49748..84e13e4ee8 100644 --- a/converter/src/test/java/lcsb/mapviewer/converter/ComplexZipConverterTest.java +++ b/converter/src/test/java/lcsb/mapviewer/converter/ComplexZipConverterTest.java @@ -28,11 +28,6 @@ import lcsb.mapviewer.model.map.InconsistentModelException; import lcsb.mapviewer.model.map.OverviewImage; import lcsb.mapviewer.model.map.OverviewLink; import lcsb.mapviewer.model.map.OverviewModelLink; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; import lcsb.mapviewer.model.map.model.ModelSubmodelConnection; @@ -41,6 +36,11 @@ import lcsb.mapviewer.model.map.reaction.Product; import lcsb.mapviewer.model.map.reaction.Reactant; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.type.TransportReaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Phenotype; +import lcsb.mapviewer.model.map.species.Species; public class ComplexZipConverterTest { private static Logger logger = Logger.getLogger(ComplexZipConverterTest.class); @@ -59,43 +59,43 @@ public class ComplexZipConverterTest { public Model createModel(ConverterParams params) { Model result = new ModelFullIndexed(null); - SpeciesAlias sa1 = new GenericProteinAlias("sa1"); + Species sa1 = new GenericProtein("sa1"); result.addAlias(sa1); - SpeciesAlias sa2 = new GenericProteinAlias("sa2"); + Species sa2 = new GenericProtein("sa2"); result.addAlias(sa2); - SpeciesAlias sa3 = new GenericProteinAlias("sa3"); + Species sa3 = new GenericProtein("sa3"); result.addAlias(sa3); - SpeciesAlias sa4 = new PhenotypeAlias("sa4"); + Species sa4 = new Phenotype("sa4"); result.addAlias(sa4); - ComplexAlias ca1 = new ComplexAlias("ca1"); + Complex ca1 = new Complex("ca1"); ca1.setName("main"); result.addAlias(ca1); - SpeciesAlias sa5 = new GenericProteinAlias("sa5"); + Species sa5 = new GenericProtein("sa5"); sa5.setName("sa1"); result.addAlias(sa5); ca1.addAlias(sa5); - SpeciesAlias sa6 = new PhenotypeAlias("sa6"); + Species sa6 = new Phenotype("sa6"); sa6.setName("sa4"); result.addAlias(sa6); ca1.addAlias(sa6); - ComplexAlias ca2 = new ComplexAlias("ca2"); + Complex ca2 = new Complex("ca2"); ca2.setName("s1"); result.addAlias(ca2); - SpeciesAlias sa7 = new GenericProteinAlias("sa7"); + Species sa7 = new GenericProtein("sa7"); sa7.setName("sa1"); result.addAlias(sa7); ca2.addAlias(sa7); - ComplexAlias ca3 = new ComplexAlias("cs3"); + Complex ca3 = new Complex("cs3"); ca3.setName("s2"); result.addAlias(ca3); - ComplexAlias ca4 = new ComplexAlias("cs4"); + Complex ca4 = new Complex("cs4"); ca4.setName("s3"); result.addAlias(ca4); @@ -234,20 +234,20 @@ public class ComplexZipConverterTest { assertNotNull(s2Model); assertNotNull(s3Model); - Alias al1 = model.getAliasByAliasId("sa1"); + Element al1 = model.getAliasByAliasId("sa1"); assertNotNull(al1.getSubmodel()); assertEquals(SubmodelType.DOWNSTREAM_TARGETS, al1.getSubmodel().getType()); assertEquals(s1Model, al1.getSubmodel().getSubmodel().getModel()); - Alias al2 = model.getAliasByAliasId("sa2"); + Element al2 = model.getAliasByAliasId("sa2"); assertNull(al2.getSubmodel()); - Alias al4 = model.getAliasByAliasId("sa4"); + Element al4 = model.getAliasByAliasId("sa4"); assertNotNull(al4.getSubmodel()); assertEquals(SubmodelType.PATHWAY, al4.getSubmodel().getType()); assertEquals(s2Model, al4.getSubmodel().getSubmodel().getModel()); - Alias s1_al1 = s1Model.getAliasByAliasId("sa1"); + Element s1_al1 = s1Model.getAliasByAliasId("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); - Alias al1 = model.getAliasByAliasId("sa1"); + Element al1 = model.getAliasByAliasId("sa1"); assertNotNull(al1.getSubmodel()); assertEquals(SubmodelType.DOWNSTREAM_TARGETS, al1.getSubmodel().getType()); assertEquals(s1Model, al1.getSubmodel().getSubmodel().getModel()); - Alias al2 = model.getAliasByAliasId("sa2"); + Element al2 = model.getAliasByAliasId("sa2"); assertNull(al2.getSubmodel()); - Alias al4 = model.getAliasByAliasId("sa4"); + Element al4 = model.getAliasByAliasId("sa4"); assertNotNull(al4.getSubmodel()); assertEquals(SubmodelType.PATHWAY, al4.getSubmodel().getType()); assertEquals(s2Model, al4.getSubmodel().getSubmodel().getModel()); - Alias s1_al1 = s1Model.getAliasByAliasId("sa1"); + Element s1_al1 = s1Model.getAliasByAliasId("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/SelectedPoint.java b/editor/src/main/java/lcsb/mapviewer/editor/SelectedPoint.java index 17db3f35fd..28caa05a55 100644 --- a/editor/src/main/java/lcsb/mapviewer/editor/SelectedPoint.java +++ b/editor/src/main/java/lcsb/mapviewer/editor/SelectedPoint.java @@ -1,59 +1,59 @@ -package lcsb.mapviewer.editor; - -import java.awt.geom.Point2D; - -import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.reaction.Reaction; - -/** - * Class represeting selected {@link Point2D} on {@link Alias} or - * {@link Reaction}. - * - * @author Piotr Gawron - * - */ -public class SelectedPoint { - - /** - * Point that is selected. - */ - private Point2D point; - - /** - * Object where the point is located. - */ - private Object container; - - /** - * Default constructor. - * - * @param container - * {@link #container} - * @param point - * {@link #point} - */ - public SelectedPoint(Object container, Point2D point) { - if (!(container instanceof Alias) && !(container instanceof Reaction)) { - throw new InvalidArgumentException("Unknown container class: " + container); - } - this.container = container; - this.point = point; - } - - /** - * @return the point - * @see #point - */ - public Point2D getPoint() { - return point; - } - - /** - * @return the container - * @see #container - */ - public Object getContainer() { - return container; - } -} +package lcsb.mapviewer.editor; + +import java.awt.geom.Point2D; + +import lcsb.mapviewer.common.exception.InvalidArgumentException; +import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; + +/** + * Class represeting selected {@link Point2D} on {@link Element} or + * {@link Reaction}. + * + * @author Piotr Gawron + * + */ +public class SelectedPoint { + + /** + * Point that is selected. + */ + private Point2D point; + + /** + * Object where the point is located. + */ + private Object container; + + /** + * Default constructor. + * + * @param container + * {@link #container} + * @param point + * {@link #point} + */ + public SelectedPoint(Object container, Point2D point) { + if (!(container instanceof Element) && !(container instanceof Reaction)) { + throw new InvalidArgumentException("Unknown container class: " + container); + } + this.container = container; + this.point = point; + } + + /** + * @return the point + * @see #point + */ + public Point2D getPoint() { + return point; + } + + /** + * @return the container + * @see #container + */ + public Object getContainer() { + return container; + } +} diff --git a/editor/src/main/java/lcsb/mapviewer/editor/gui/ElementModifiedEvent.java b/editor/src/main/java/lcsb/mapviewer/editor/gui/ElementModifiedEvent.java index 43d05e0ef7..785a833d63 100644 --- a/editor/src/main/java/lcsb/mapviewer/editor/gui/ElementModifiedEvent.java +++ b/editor/src/main/java/lcsb/mapviewer/editor/gui/ElementModifiedEvent.java @@ -1,65 +1,65 @@ -package lcsb.mapviewer.editor.gui; - -import java.awt.event.ActionEvent; - -import lcsb.mapviewer.commands.ModelCommand; - -/** - * {@link ActionEvent} represeint event when - * {@link lcsb.mapviewer.model.map.layout.alias.Alias} or - * {@link lcsb.mapviewer.model.map.reaction.Reaction} changed. - * - * @author Piotr Gawron - * - * @param <T> - * - */ -public class ElementModifiedEvent<T> extends ActionEvent { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * Object that changed. - */ - private T element; - - /** - * {@link ModelCommand} used to change the {@link #element}. - */ - private ModelCommand command; - - /** - * Default constructor. - * - * @param source - * object that caused the event - * @param element - * {@link #element} - * @param command - * {@link #command} - */ - public ElementModifiedEvent(Object source, T element, ModelCommand command) { - super(source, 0, "Element modified"); - this.element = element; - this.command = command; - } - - /** - * @return the project - * @see #project - */ - public T getElement() { - return element; - } - - /** - * @return the command - * @see #command - */ - public ModelCommand getCommand() { - return command; - } -} +package lcsb.mapviewer.editor.gui; + +import java.awt.event.ActionEvent; + +import lcsb.mapviewer.commands.ModelCommand; + +/** + * {@link ActionEvent} represeint event when + * {@link lcsb.mapviewer.model.map.species.Element} or + * {@link lcsb.mapviewer.model.map.reaction.Reaction} changed. + * + * @author Piotr Gawron + * + * @param <T> + * + */ +public class ElementModifiedEvent<T> extends ActionEvent { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Object that changed. + */ + private T element; + + /** + * {@link ModelCommand} used to change the {@link #element}. + */ + private ModelCommand command; + + /** + * Default constructor. + * + * @param source + * object that caused the event + * @param element + * {@link #element} + * @param command + * {@link #command} + */ + public ElementModifiedEvent(Object source, T element, ModelCommand command) { + super(source, 0, "Element modified"); + this.element = element; + this.command = command; + } + + /** + * @return the project + * @see #project + */ + public T getElement() { + return element; + } + + /** + * @return the command + * @see #command + */ + public ModelCommand getCommand() { + return command; + } +} diff --git a/editor/src/main/java/lcsb/mapviewer/editor/gui/WindowContent.java b/editor/src/main/java/lcsb/mapviewer/editor/gui/WindowContent.java index 8218721e8d..6706e8e7b0 100644 --- a/editor/src/main/java/lcsb/mapviewer/editor/gui/WindowContent.java +++ b/editor/src/main/java/lcsb/mapviewer/editor/gui/WindowContent.java @@ -1,136 +1,136 @@ -package lcsb.mapviewer.editor.gui; - -import java.awt.BorderLayout; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.List; - -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTabbedPane; - -import lcsb.mapviewer.editor.OpenProjectEvent; -import lcsb.mapviewer.editor.OpenProjectListener; -import lcsb.mapviewer.editor.OpenedProject; -import lcsb.mapviewer.editor.Workspace; -import lcsb.mapviewer.editor.gui.canvas.MinervaCanvas; -import lcsb.mapviewer.editor.gui.detailstab.ElementDetailsPanel; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.reaction.Reaction; - -import org.apache.commons.io.FilenameUtils; -import org.apache.log4j.Logger; - -/** - * Panel representing content of the gui window. - * - * @author Piotr Gawron - * - */ -public class WindowContent extends JPanel { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * Default class logger. - */ - @SuppressWarnings("unused") - private final Logger logger = Logger.getLogger(WindowContent.class); - - /** - * Tabs with projects content. - */ - private JTabbedPane projectsTab; - - /** - * {@link JPanel} with detail information about selected element. - */ - private ElementDetailsPanel elementDetailsPanel; - - /** - * Currently selected tab on {@link #projectsTab}. - */ - private ProjectTab selectedTab; - - /** - * Workspace with all opened projects. - */ - private Workspace workspace; - - /** - * Default constructor. - * - * @param workspace - * {@link #workspace} - */ - public WindowContent(Workspace workspace) { - this.workspace = workspace; - this.setLayout(new BorderLayout(GuiStyle.GAP_BETWEEN_COMPONENTS, GuiStyle.GAP_BETWEEN_COMPONENTS)); - - projectsTab = new JTabbedPane(); - - this.add(projectsTab, BorderLayout.CENTER); - - elementDetailsPanel = new ElementDetailsPanel(); - - this.add(new JScrollPane(elementDetailsPanel), BorderLayout.EAST); - - projectsTab.addPropertyChangeListener(MinervaCanvas.SELECTED_ELEMENTS, new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - selectedTab = (ProjectTab) (evt.getSource()); - List<?> selectedElements = (List<?>) evt.getNewValue(); - if (selectedElements.size() == 1) { - elementDetailsPanel.setElement(selectedElements.get(0)); - } else { - elementDetailsPanel.setElement(null); - } - } - }); - - elementDetailsPanel.addAliasModifiedEventListener(new ElementModifiedEventListener<Alias>() { - @Override - public void actionPerformed(ElementModifiedEvent<Alias> e) { - if (e.getCommand().getAffectedRegion() != null) { - selectedTab.addInvalidRegion(e.getCommand().getAffectedRegion()); - selectedTab.repaint(); - } - } - }); - - elementDetailsPanel.addReactionModifiedEventListener(new ElementModifiedEventListener<Reaction>() { - @Override - public void actionPerformed(ElementModifiedEvent<Reaction> e) { - if (e.getCommand().getAffectedRegion() != null) { - selectedTab.addInvalidRegion(e.getCommand().getAffectedRegion()); - selectedTab.repaint(); - } - } - }); - - this.workspace.addProjectAddedListener(new OpenTabListener()); - } - - /** - * Listener used to open new tab. - * - * @author Piotr Gawron - * - */ - private class OpenTabListener implements OpenProjectListener { - - @Override - public void actionPerformed(OpenProjectEvent e) { - OpenedProject project = e.getProject(); - ProjectTab tab = new ProjectTab(project); - projectsTab.addTab(FilenameUtils.getName(project.getFileName()), tab); - for (PropertyChangeListener listener : projectsTab.getPropertyChangeListeners(MinervaCanvas.SELECTED_ELEMENTS)) { - tab.addPropertyChangeListener(MinervaCanvas.SELECTED_ELEMENTS, listener); - } - } - - } -} +package lcsb.mapviewer.editor.gui; + +import java.awt.BorderLayout; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.List; + +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; + +import lcsb.mapviewer.editor.OpenProjectEvent; +import lcsb.mapviewer.editor.OpenProjectListener; +import lcsb.mapviewer.editor.OpenedProject; +import lcsb.mapviewer.editor.Workspace; +import lcsb.mapviewer.editor.gui.canvas.MinervaCanvas; +import lcsb.mapviewer.editor.gui.detailstab.ElementDetailsPanel; +import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; + +import org.apache.commons.io.FilenameUtils; +import org.apache.log4j.Logger; + +/** + * Panel representing content of the gui window. + * + * @author Piotr Gawron + * + */ +public class WindowContent extends JPanel { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Default class logger. + */ + @SuppressWarnings("unused") + private final Logger logger = Logger.getLogger(WindowContent.class); + + /** + * Tabs with projects content. + */ + private JTabbedPane projectsTab; + + /** + * {@link JPanel} with detail information about selected element. + */ + private ElementDetailsPanel elementDetailsPanel; + + /** + * Currently selected tab on {@link #projectsTab}. + */ + private ProjectTab selectedTab; + + /** + * Workspace with all opened projects. + */ + private Workspace workspace; + + /** + * Default constructor. + * + * @param workspace + * {@link #workspace} + */ + public WindowContent(Workspace workspace) { + this.workspace = workspace; + this.setLayout(new BorderLayout(GuiStyle.GAP_BETWEEN_COMPONENTS, GuiStyle.GAP_BETWEEN_COMPONENTS)); + + projectsTab = new JTabbedPane(); + + this.add(projectsTab, BorderLayout.CENTER); + + elementDetailsPanel = new ElementDetailsPanel(); + + this.add(new JScrollPane(elementDetailsPanel), BorderLayout.EAST); + + projectsTab.addPropertyChangeListener(MinervaCanvas.SELECTED_ELEMENTS, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + selectedTab = (ProjectTab) (evt.getSource()); + List<?> selectedElements = (List<?>) evt.getNewValue(); + if (selectedElements.size() == 1) { + elementDetailsPanel.setElement(selectedElements.get(0)); + } else { + elementDetailsPanel.setElement(null); + } + } + }); + + elementDetailsPanel.addAliasModifiedEventListener(new ElementModifiedEventListener<Element>() { + @Override + public void actionPerformed(ElementModifiedEvent<Element> e) { + if (e.getCommand().getAffectedRegion() != null) { + selectedTab.addInvalidRegion(e.getCommand().getAffectedRegion()); + selectedTab.repaint(); + } + } + }); + + elementDetailsPanel.addReactionModifiedEventListener(new ElementModifiedEventListener<Reaction>() { + @Override + public void actionPerformed(ElementModifiedEvent<Reaction> e) { + if (e.getCommand().getAffectedRegion() != null) { + selectedTab.addInvalidRegion(e.getCommand().getAffectedRegion()); + selectedTab.repaint(); + } + } + }); + + this.workspace.addProjectAddedListener(new OpenTabListener()); + } + + /** + * Listener used to open new tab. + * + * @author Piotr Gawron + * + */ + private class OpenTabListener implements OpenProjectListener { + + @Override + public void actionPerformed(OpenProjectEvent e) { + OpenedProject project = e.getProject(); + ProjectTab tab = new ProjectTab(project); + projectsTab.addTab(FilenameUtils.getName(project.getFileName()), tab); + for (PropertyChangeListener listener : projectsTab.getPropertyChangeListeners(MinervaCanvas.SELECTED_ELEMENTS)) { + tab.addPropertyChangeListener(MinervaCanvas.SELECTED_ELEMENTS, listener); + } + } + + } +} diff --git a/editor/src/main/java/lcsb/mapviewer/editor/gui/canvas/CanvasSelectMouseListener.java b/editor/src/main/java/lcsb/mapviewer/editor/gui/canvas/CanvasSelectMouseListener.java index 369191c372..6df8bb3626 100644 --- a/editor/src/main/java/lcsb/mapviewer/editor/gui/canvas/CanvasSelectMouseListener.java +++ b/editor/src/main/java/lcsb/mapviewer/editor/gui/canvas/CanvasSelectMouseListener.java @@ -1,125 +1,125 @@ -package lcsb.mapviewer.editor.gui.canvas; - -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; -import lcsb.mapviewer.model.map.reaction.Reaction; - -import org.apache.log4j.Logger; - -/** - * {@link MouseListener} used when canvas is in select mode (allows to select - * element on the map). - * - * @author Piotr Gawron - * - */ -public class CanvasSelectMouseListener implements MouseListener { - - /** - * When clicking on the map and the click is not perfectly on the line this - * distance describe how far from the line click is still considered as - * clicking on the line. - */ - private static final double MAX_DISTANCE_TO_SELECTED_ELEMENT = 5; - - /** - * Default class logger. - */ - @SuppressWarnings("unused") - private Logger logger = Logger.getLogger(CanvasSelectMouseListener.class); - - /** - * Canvas where drawing is performed. - */ - private MinervaCanvas canvas; - - /** - * Default constructor. - * - * @param canvas - * {@link #canvas} - */ - public CanvasSelectMouseListener(MinervaCanvas canvas) { - this.canvas = canvas; - } - - @Override - public void mouseClicked(MouseEvent e) { - Point2D point = canvas.mouseCoordinatesToPoint2D(e.getPoint()); - - List<Object> result = new ArrayList<Object>(); - - Set<Alias> aliases = canvas.getModel().getAliases(); - for (Alias alias : aliases) { - if (alias instanceof SpeciesAlias) { - if (alias.contains(point)) { - result.add(alias); - } - } - } - double dist = MAX_DISTANCE_TO_SELECTED_ELEMENT; - if (result.size() == 0) { - Reaction r = null; - Set<Reaction> reactions = canvas.getModel().getReactions(); - for (Reaction reaction : reactions) { - double newDist = reaction.getDistanceFromPoint(point); - if (newDist < dist) { - r = reaction; - dist = reaction.getDistanceFromPoint(point); - } - } - if (r != null) { - canvas.setSelectedElement(r); - return; - } - } - - if (result.size() > 1) { - Alias alias = (Alias) result.get(0); - for (Object obj : result) { - if (((Alias) (obj)).getSize() < alias.getSize()) { - alias = (Alias) obj; - } - } - result.clear(); - result.add(alias); - } - if (result.size() == 0) { - canvas.setSelectedElement(null); - } else { - canvas.setSelectedElement(result.get(0)); - } - } - - @Override - public void mousePressed(MouseEvent e) { - // TODO Auto-generated method stub - - } - - @Override - public void mouseReleased(MouseEvent e) { - // TODO Auto-generated method stub - - } - - @Override - public void mouseEntered(MouseEvent e) { - // TODO Auto-generated method stub - - } - - @Override - public void mouseExited(MouseEvent e) { - // TODO Auto-generated method stub - - } - -} +package lcsb.mapviewer.editor.gui.canvas; + +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; + +import org.apache.log4j.Logger; + +/** + * {@link MouseListener} used when canvas is in select mode (allows to select + * element on the map). + * + * @author Piotr Gawron + * + */ +public class CanvasSelectMouseListener implements MouseListener { + + /** + * When clicking on the map and the click is not perfectly on the line this + * distance describe how far from the line click is still considered as + * clicking on the line. + */ + private static final double MAX_DISTANCE_TO_SELECTED_ELEMENT = 5; + + /** + * Default class logger. + */ + @SuppressWarnings("unused") + private Logger logger = Logger.getLogger(CanvasSelectMouseListener.class); + + /** + * Canvas where drawing is performed. + */ + private MinervaCanvas canvas; + + /** + * Default constructor. + * + * @param canvas + * {@link #canvas} + */ + public CanvasSelectMouseListener(MinervaCanvas canvas) { + this.canvas = canvas; + } + + @Override + public void mouseClicked(MouseEvent e) { + Point2D point = canvas.mouseCoordinatesToPoint2D(e.getPoint()); + + List<Object> result = new ArrayList<Object>(); + + Set<Element> aliases = canvas.getModel().getAliases(); + for (Element alias : aliases) { + if (alias instanceof Species) { + if (alias.contains(point)) { + result.add(alias); + } + } + } + double dist = MAX_DISTANCE_TO_SELECTED_ELEMENT; + if (result.size() == 0) { + Reaction r = null; + Set<Reaction> reactions = canvas.getModel().getReactions(); + for (Reaction reaction : reactions) { + double newDist = reaction.getDistanceFromPoint(point); + if (newDist < dist) { + r = reaction; + dist = reaction.getDistanceFromPoint(point); + } + } + if (r != null) { + canvas.setSelectedElement(r); + return; + } + } + + if (result.size() > 1) { + Element alias = (Element) result.get(0); + for (Object obj : result) { + if (((Element) (obj)).getSize() < alias.getSize()) { + alias = (Element) obj; + } + } + result.clear(); + result.add(alias); + } + if (result.size() == 0) { + canvas.setSelectedElement(null); + } else { + canvas.setSelectedElement(result.get(0)); + } + } + + @Override + public void mousePressed(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseReleased(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseEntered(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseExited(MouseEvent e) { + // TODO Auto-generated method stub + + } + +} diff --git a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeAbbreviationCommand.java b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeAbbreviationCommand.java index 3646c99919..291935c122 100644 --- a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeAbbreviationCommand.java +++ b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeAbbreviationCommand.java @@ -1,33 +1,33 @@ -package lcsb.mapviewer.editor.gui.detailstab; - -import javax.swing.JTextField; -import javax.swing.text.JTextComponent; - -import lcsb.mapviewer.commands.ModelCommand; -import lcsb.mapviewer.commands.properties.ChangeElementAbbreviationCommand; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.model.Model; - -/** - * Class that creates {@link ChangeElementAbbreviationCommand} object from gui input - * for given {@link Model} and {@link Alias}. - * - * @author Piotr Gawron - * - */ -public class CreateChangeAbbreviationCommand extends CreatePropertyChangeCommand { - /** - * Default constructor. - * - * @param field - * GUI input from which {@link ModelCommand} will be created - */ - CreateChangeAbbreviationCommand(JTextField field) { - super(field); - } - - @Override - public ModelCommand createCommand(Model model, Alias alias) { - return new ChangeElementAbbreviationCommand(model, alias, ((JTextComponent) getField()).getText()); - } -} +package lcsb.mapviewer.editor.gui.detailstab; + +import javax.swing.JTextField; +import javax.swing.text.JTextComponent; + +import lcsb.mapviewer.commands.ModelCommand; +import lcsb.mapviewer.commands.properties.ChangeElementAbbreviationCommand; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; + +/** + * Class that creates {@link ChangeElementAbbreviationCommand} object from gui input + * for given {@link Model} and {@link Element}. + * + * @author Piotr Gawron + * + */ +public class CreateChangeAbbreviationCommand extends CreatePropertyChangeCommand { + /** + * Default constructor. + * + * @param field + * GUI input from which {@link ModelCommand} will be created + */ + CreateChangeAbbreviationCommand(JTextField field) { + super(field); + } + + @Override + public ModelCommand createCommand(Model model, Element alias) { + return new ChangeElementAbbreviationCommand(model, alias, ((JTextComponent) getField()).getText()); + } +} diff --git a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeColorCommand.java b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeColorCommand.java index fd8c7e61c1..6a12d1680d 100644 --- a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeColorCommand.java +++ b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeColorCommand.java @@ -1,32 +1,32 @@ -package lcsb.mapviewer.editor.gui.detailstab; - -import javax.swing.JButton; - -import lcsb.mapviewer.commands.ModelCommand; -import lcsb.mapviewer.commands.properties.ChangeElementColorCommand; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.model.Model; - -/** - * Class that creates {@link ChangeElementColorCommand} object from gui input - * for given {@link Model} and {@link Alias}. - * - * @author Piotr Gawron - * - */ -public class CreateChangeColorCommand extends CreatePropertyChangeCommand { - /** - * Default constructor. - * - * @param button - * GUI buton where new color value will be defined - */ - CreateChangeColorCommand(JButton button) { - super(button); - } - - @Override - public ModelCommand createCommand(Model model, Alias alias) { - return new ChangeElementColorCommand(model, alias, getField().getBackground()); - } -} +package lcsb.mapviewer.editor.gui.detailstab; + +import javax.swing.JButton; + +import lcsb.mapviewer.commands.ModelCommand; +import lcsb.mapviewer.commands.properties.ChangeElementColorCommand; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; + +/** + * Class that creates {@link ChangeElementColorCommand} object from gui input + * for given {@link Model} and {@link Element}. + * + * @author Piotr Gawron + * + */ +public class CreateChangeColorCommand extends CreatePropertyChangeCommand { + /** + * Default constructor. + * + * @param button + * GUI buton where new color value will be defined + */ + CreateChangeColorCommand(JButton button) { + super(button); + } + + @Override + public ModelCommand createCommand(Model model, Element alias) { + return new ChangeElementColorCommand(model, alias, getField().getBackground()); + } +} diff --git a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeFontSizeCommand.java b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeFontSizeCommand.java index 7d0fb71785..2d1b649cc4 100644 --- a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeFontSizeCommand.java +++ b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeFontSizeCommand.java @@ -1,41 +1,41 @@ -package lcsb.mapviewer.editor.gui.detailstab; - -import javax.swing.JTextField; -import javax.swing.text.JTextComponent; - -import lcsb.mapviewer.commands.ModelCommand; -import lcsb.mapviewer.commands.properties.ChangeElementFontSizeCommand; -import lcsb.mapviewer.common.exception.InvalidStateException; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.model.Model; - -import org.apache.commons.lang3.math.NumberUtils; - -/** - * Class that creates {@link ChangeElementFontSizeCommand} object from gui input - * for given {@link Model} and {@link Alias}. - * - * @author Piotr Gawron - * - */ -public class CreateChangeFontSizeCommand extends CreatePropertyChangeCommand { - - /** - * Default constructor. - * - * @param field - * GUI input from which {@link ModelCommand} will be created - */ - protected CreateChangeFontSizeCommand(JTextField field) { - super(field); - } - - @Override - public ModelCommand createCommand(Model model, Alias alias) { - if (NumberUtils.isNumber(((JTextComponent) getField()).getText())) { - return new ChangeElementFontSizeCommand(model, alias, Double.valueOf(((JTextComponent) getField()).getText())); - } else { - throw new InvalidStateException("Input text is not a double value:" + ((JTextComponent) getField()).getText()); - } - } -} +package lcsb.mapviewer.editor.gui.detailstab; + +import javax.swing.JTextField; +import javax.swing.text.JTextComponent; + +import lcsb.mapviewer.commands.ModelCommand; +import lcsb.mapviewer.commands.properties.ChangeElementFontSizeCommand; +import lcsb.mapviewer.common.exception.InvalidStateException; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; + +import org.apache.commons.lang3.math.NumberUtils; + +/** + * Class that creates {@link ChangeElementFontSizeCommand} object from gui input + * for given {@link Model} and {@link Element}. + * + * @author Piotr Gawron + * + */ +public class CreateChangeFontSizeCommand extends CreatePropertyChangeCommand { + + /** + * Default constructor. + * + * @param field + * GUI input from which {@link ModelCommand} will be created + */ + protected CreateChangeFontSizeCommand(JTextField field) { + super(field); + } + + @Override + public ModelCommand createCommand(Model model, Element alias) { + if (NumberUtils.isNumber(((JTextComponent) getField()).getText())) { + return new ChangeElementFontSizeCommand(model, alias, Double.valueOf(((JTextComponent) getField()).getText())); + } else { + throw new InvalidStateException("Input text is not a double value:" + ((JTextComponent) getField()).getText()); + } + } +} diff --git a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeFormerSymbolCommand.java b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeFormerSymbolCommand.java index e5782b2e5a..ab410ec8c4 100644 --- a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeFormerSymbolCommand.java +++ b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeFormerSymbolCommand.java @@ -8,12 +8,12 @@ import lcsb.mapviewer.commands.ModelCommand; import lcsb.mapviewer.commands.properties.AddElementFormerSymbolsCommand; import lcsb.mapviewer.commands.properties.ChangeElementFormerSymbolCommand; import lcsb.mapviewer.commands.properties.RemoveElementFormerSymbolsCommand; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; /** - * Class that creates commands that modifies {@link Alias#formerSymbols} from - * gui input for given {@link Model} and {@link Alias}. + * Class that creates commands that modifies {@link Element#formerSymbols} from + * gui input for given {@link Model} and {@link Element}. * * @author Piotr Gawron * @@ -31,17 +31,17 @@ public class CreateChangeFormerSymbolCommand extends CreateListPropertyChangeCom } @Override - protected ModelCommand createRemoveCommand(Model model, Alias alias, List<String> values) { + protected ModelCommand createRemoveCommand(Model model, Element alias, List<String> values) { return new RemoveElementFormerSymbolsCommand(model, alias, values); } @Override - protected ModelCommand createChangeCommand(Model model, Alias alias, String newValue, String oldValue) { + protected ModelCommand createChangeCommand(Model model, Element alias, String newValue, String oldValue) { return new ChangeElementFormerSymbolCommand(model, alias, newValue, oldValue); } @Override - protected ModelCommand createAddCommand(Model model, Alias alias, List<String> newValues) { + protected ModelCommand createAddCommand(Model model, Element alias, List<String> newValues) { return new AddElementFormerSymbolsCommand(model, alias, newValues); } diff --git a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeFormulaCommand.java b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeFormulaCommand.java index 2e5236d45c..170886fd88 100644 --- a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeFormulaCommand.java +++ b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeFormulaCommand.java @@ -1,33 +1,33 @@ -package lcsb.mapviewer.editor.gui.detailstab; - -import javax.swing.JTextField; -import javax.swing.text.JTextComponent; - -import lcsb.mapviewer.commands.ModelCommand; -import lcsb.mapviewer.commands.properties.ChangeElementFormulaCommand; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.model.Model; - -/** - * Class that creates {@link ChangeElementFormulaCommand} object from gui input - * for given {@link Model} and {@link Alias}. - * - * @author Piotr Gawron - * - */ -public class CreateChangeFormulaCommand extends CreatePropertyChangeCommand { - /** - * Default constructor. - * - * @param field - * GUI input from which {@link ModelCommand} will be created - */ - CreateChangeFormulaCommand(JTextField field) { - super(field); - } - - @Override - public ModelCommand createCommand(Model model, Alias alias) { - return new ChangeElementFormulaCommand(model, alias, ((JTextComponent) getField()).getText()); - } -} +package lcsb.mapviewer.editor.gui.detailstab; + +import javax.swing.JTextField; +import javax.swing.text.JTextComponent; + +import lcsb.mapviewer.commands.ModelCommand; +import lcsb.mapviewer.commands.properties.ChangeElementFormulaCommand; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; + +/** + * Class that creates {@link ChangeElementFormulaCommand} object from gui input + * for given {@link Model} and {@link Element}. + * + * @author Piotr Gawron + * + */ +public class CreateChangeFormulaCommand extends CreatePropertyChangeCommand { + /** + * Default constructor. + * + * @param field + * GUI input from which {@link ModelCommand} will be created + */ + CreateChangeFormulaCommand(JTextField field) { + super(field); + } + + @Override + public ModelCommand createCommand(Model model, Element alias) { + return new ChangeElementFormulaCommand(model, alias, ((JTextComponent) getField()).getText()); + } +} diff --git a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeFullNameCommand.java b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeFullNameCommand.java index e77102ad6d..7001d5f093 100644 --- a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeFullNameCommand.java +++ b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeFullNameCommand.java @@ -1,33 +1,33 @@ -package lcsb.mapviewer.editor.gui.detailstab; - -import javax.swing.JTextField; -import javax.swing.text.JTextComponent; - -import lcsb.mapviewer.commands.ModelCommand; -import lcsb.mapviewer.commands.properties.ChangeElementFullNameCommand; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.model.Model; - -/** - * Class that creates {@link ChangeElementFullNameCommand} object from gui input - * for given {@link Model} and {@link Alias}. - * - * @author Piotr Gawron - * - */ -public class CreateChangeFullNameCommand extends CreatePropertyChangeCommand { - /** - * Default constructor. - * - * @param field - * GUI input from which {@link ModelCommand} will be created - */ - CreateChangeFullNameCommand(JTextField field) { - super(field); - } - - @Override - public ModelCommand createCommand(Model model, Alias alias) { - return new ChangeElementFullNameCommand(model, alias, ((JTextComponent) getField()).getText()); - } -} +package lcsb.mapviewer.editor.gui.detailstab; + +import javax.swing.JTextField; +import javax.swing.text.JTextComponent; + +import lcsb.mapviewer.commands.ModelCommand; +import lcsb.mapviewer.commands.properties.ChangeElementFullNameCommand; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; + +/** + * Class that creates {@link ChangeElementFullNameCommand} object from gui input + * for given {@link Model} and {@link Element}. + * + * @author Piotr Gawron + * + */ +public class CreateChangeFullNameCommand extends CreatePropertyChangeCommand { + /** + * Default constructor. + * + * @param field + * GUI input from which {@link ModelCommand} will be created + */ + CreateChangeFullNameCommand(JTextField field) { + super(field); + } + + @Override + public ModelCommand createCommand(Model model, Element alias) { + return new ChangeElementFullNameCommand(model, alias, ((JTextComponent) getField()).getText()); + } +} diff --git a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeMiriamDataCommand.java b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeMiriamDataCommand.java index 0aed10ffb5..8d6f4450eb 100644 --- a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeMiriamDataCommand.java +++ b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeMiriamDataCommand.java @@ -1,49 +1,49 @@ -package lcsb.mapviewer.editor.gui.detailstab; - -import java.util.List; - -import javax.swing.JList; - -import lcsb.mapviewer.commands.ModelCommand; -import lcsb.mapviewer.commands.properties.AddElementMiriamDataCommand; -import lcsb.mapviewer.commands.properties.ChangeElementMiriamDataCommand; -import lcsb.mapviewer.commands.properties.RemoveElementMiriamDataCommand; -import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.model.Model; - -/** - * Class that creates commands that modifies {@link MiriamData miriam - * annotationd} from gui input for given {@link Model} and {@link Alias}. - * - * @author Piotr Gawron - * - */ -public class CreateChangeMiriamDataCommand extends CreateListPropertyChangeCommand<MiriamData> { - - /** - * Default constructor. - * - * @param list - * GUI input from which {@link ModelCommand} will be created - */ - CreateChangeMiriamDataCommand(JList<MiriamData> list) { - super(list); - } - - @Override - protected ModelCommand createRemoveCommand(Model model, Alias alias, List<MiriamData> values) { - return new RemoveElementMiriamDataCommand(model, alias, values); - } - - @Override - protected ModelCommand createChangeCommand(Model model, Alias alias, MiriamData newValue, MiriamData oldValue) { - return new ChangeElementMiriamDataCommand(model, alias, newValue, oldValue); - } - - @Override - protected ModelCommand createAddCommand(Model model, Alias alias, List<MiriamData> newValues) { - return new AddElementMiriamDataCommand(model, alias, newValues); - } - -} +package lcsb.mapviewer.editor.gui.detailstab; + +import java.util.List; + +import javax.swing.JList; + +import lcsb.mapviewer.commands.ModelCommand; +import lcsb.mapviewer.commands.properties.AddElementMiriamDataCommand; +import lcsb.mapviewer.commands.properties.ChangeElementMiriamDataCommand; +import lcsb.mapviewer.commands.properties.RemoveElementMiriamDataCommand; +import lcsb.mapviewer.model.map.MiriamData; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; + +/** + * Class that creates commands that modifies {@link MiriamData miriam + * annotationd} from gui input for given {@link Model} and {@link Element}. + * + * @author Piotr Gawron + * + */ +public class CreateChangeMiriamDataCommand extends CreateListPropertyChangeCommand<MiriamData> { + + /** + * Default constructor. + * + * @param list + * GUI input from which {@link ModelCommand} will be created + */ + CreateChangeMiriamDataCommand(JList<MiriamData> list) { + super(list); + } + + @Override + protected ModelCommand createRemoveCommand(Model model, Element alias, List<MiriamData> values) { + return new RemoveElementMiriamDataCommand(model, alias, values); + } + + @Override + protected ModelCommand createChangeCommand(Model model, Element alias, MiriamData newValue, MiriamData oldValue) { + return new ChangeElementMiriamDataCommand(model, alias, newValue, oldValue); + } + + @Override + protected ModelCommand createAddCommand(Model model, Element alias, List<MiriamData> newValues) { + return new AddElementMiriamDataCommand(model, alias, newValues); + } + +} diff --git a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeNameCommand.java b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeNameCommand.java index 01be4fdd69..e9cfe5f198 100644 --- a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeNameCommand.java +++ b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeNameCommand.java @@ -5,11 +5,11 @@ import javax.swing.text.JTextComponent; import lcsb.mapviewer.commands.ModelCommand; import lcsb.mapviewer.commands.properties.ChangeElementNameCommand; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; /** - * Class with method executed when text property of {@link Alias} is changed. + * Class with method executed when text property of {@link Element} is changed. * */ public class CreateChangeNameCommand extends CreatePropertyChangeCommand { @@ -24,7 +24,7 @@ public class CreateChangeNameCommand extends CreatePropertyChangeCommand { } @Override - public ModelCommand createCommand(Model model, Alias alias) { + public ModelCommand createCommand(Model model, Element alias) { return new ChangeElementNameCommand(model, alias, ((JTextComponent) getField()).getText()); } } diff --git a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeNotesCommand.java b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeNotesCommand.java index 7e9856d6b8..ee860545fd 100644 --- a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeNotesCommand.java +++ b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeNotesCommand.java @@ -1,32 +1,32 @@ -package lcsb.mapviewer.editor.gui.detailstab; - -import javax.swing.text.JTextComponent; - -import lcsb.mapviewer.commands.ModelCommand; -import lcsb.mapviewer.commands.properties.ChangeElementNotesCommand; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.model.Model; - -/** - * Class that creates {@link ChangeElementNotesCommand} object from gui input - * for given {@link Model} and {@link Alias}. - * - * @author Piotr Gawron - * - */ -public class CreateChangeNotesCommand extends CreatePropertyChangeCommand { - /** - * Default constructor. - * - * @param field - * GUI input from which {@link ModelCommand} will be created - */ - CreateChangeNotesCommand(JTextComponent field) { - super(field); - } - - @Override - public ModelCommand createCommand(Model model, Alias alias) { - return new ChangeElementNotesCommand(model, alias, ((JTextComponent) getField()).getText()); - } -} +package lcsb.mapviewer.editor.gui.detailstab; + +import javax.swing.text.JTextComponent; + +import lcsb.mapviewer.commands.ModelCommand; +import lcsb.mapviewer.commands.properties.ChangeElementNotesCommand; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; + +/** + * Class that creates {@link ChangeElementNotesCommand} object from gui input + * for given {@link Model} and {@link Element}. + * + * @author Piotr Gawron + * + */ +public class CreateChangeNotesCommand extends CreatePropertyChangeCommand { + /** + * Default constructor. + * + * @param field + * GUI input from which {@link ModelCommand} will be created + */ + CreateChangeNotesCommand(JTextComponent field) { + super(field); + } + + @Override + public ModelCommand createCommand(Model model, Element alias) { + return new ChangeElementNotesCommand(model, alias, ((JTextComponent) getField()).getText()); + } +} diff --git a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeSymbolCommand.java b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeSymbolCommand.java index 67c3ea52b1..7976a9e3ee 100644 --- a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeSymbolCommand.java +++ b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeSymbolCommand.java @@ -1,33 +1,33 @@ -package lcsb.mapviewer.editor.gui.detailstab; - -import javax.swing.JTextField; -import javax.swing.text.JTextComponent; - -import lcsb.mapviewer.commands.ModelCommand; -import lcsb.mapviewer.commands.properties.ChangeElementSymbolCommand; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.model.Model; - -/** - * Class that creates {@link ChangeElementSymbolCommand} object from gui input - * for given {@link Model} and {@link Alias}. - * - * @author Piotr Gawron - * - */ -public class CreateChangeSymbolCommand extends CreatePropertyChangeCommand { - /** - * Default constructor. - * - * @param field - * GUI input from which {@link ModelCommand} will be created - */ - CreateChangeSymbolCommand(JTextField field) { - super(field); - } - - @Override - public ModelCommand createCommand(Model model, Alias alias) { - return new ChangeElementSymbolCommand(model, alias, ((JTextComponent) getField()).getText()); - } -} +package lcsb.mapviewer.editor.gui.detailstab; + +import javax.swing.JTextField; +import javax.swing.text.JTextComponent; + +import lcsb.mapviewer.commands.ModelCommand; +import lcsb.mapviewer.commands.properties.ChangeElementSymbolCommand; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; + +/** + * Class that creates {@link ChangeElementSymbolCommand} object from gui input + * for given {@link Model} and {@link Element}. + * + * @author Piotr Gawron + * + */ +public class CreateChangeSymbolCommand extends CreatePropertyChangeCommand { + /** + * Default constructor. + * + * @param field + * GUI input from which {@link ModelCommand} will be created + */ + CreateChangeSymbolCommand(JTextField field) { + super(field); + } + + @Override + public ModelCommand createCommand(Model model, Element alias) { + return new ChangeElementSymbolCommand(model, alias, ((JTextComponent) getField()).getText()); + } +} diff --git a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeSynonymCommand.java b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeSynonymCommand.java index c3cdeb8b8b..0055be2f32 100644 --- a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeSynonymCommand.java +++ b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateChangeSynonymCommand.java @@ -8,12 +8,12 @@ import lcsb.mapviewer.commands.ModelCommand; import lcsb.mapviewer.commands.properties.AddElementSynonymsCommand; import lcsb.mapviewer.commands.properties.ChangeElementSynonymCommand; import lcsb.mapviewer.commands.properties.RemoveElementSynonymsCommand; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; /** - * Class that creates commands that modifies {@link Alias#synonyms} from gui - * input for given {@link Model} and {@link Alias}. + * Class that creates commands that modifies {@link Element#synonyms} from gui + * input for given {@link Model} and {@link Element}. * * @author Piotr Gawron * @@ -31,17 +31,17 @@ public class CreateChangeSynonymCommand extends CreateListPropertyChangeCommand< } @Override - protected ModelCommand createRemoveCommand(Model model, Alias alias, List<String> values) { + protected ModelCommand createRemoveCommand(Model model, Element alias, List<String> values) { return new RemoveElementSynonymsCommand(model, alias, values); } @Override - protected ModelCommand createChangeCommand(Model model, Alias alias, String newValue, String oldValue) { + protected ModelCommand createChangeCommand(Model model, Element alias, String newValue, String oldValue) { return new ChangeElementSynonymCommand(model, alias, newValue, oldValue); } @Override - protected ModelCommand createAddCommand(Model model, Alias alias, List<String> newValues) { + protected ModelCommand createAddCommand(Model model, Element alias, List<String> newValues) { return new AddElementSynonymsCommand(model, alias, newValues); } diff --git a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateListPropertyChangeCommand.java b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateListPropertyChangeCommand.java index 1a51039ea3..817a54d8a6 100644 --- a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateListPropertyChangeCommand.java +++ b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreateListPropertyChangeCommand.java @@ -1,94 +1,94 @@ -package lcsb.mapviewer.editor.gui.detailstab; - -import java.util.List; - -import javax.swing.JList; - -import lcsb.mapviewer.commands.ModelCommand; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.model.Model; - -/** - * Abstract class that creates {@link ModelCommand commands} to - * add/remove/modify positions on {@link Alias} property that is a list. - * - * @author Piotr Gawron - * - * @param <T> - * type of the property element - */ -public abstract class CreateListPropertyChangeCommand<T> { - - /** - * List where elements are stored. - */ - private JList<T> field; - - /** - * Default constructor. - * - * @param field - * GUI input from which {@link ModelCommand} will be created - */ - CreateListPropertyChangeCommand(JList<T> field) { - this.field = field; - } - - /** - * Creates command that should add element to the property list. - * - * @param model - * model where element is located - * @param alias - * {@link Alias} that should be modified - * @param newValues - * new values that should be added - * @return {@link ModelCommand} that will add new values - */ - protected abstract ModelCommand createAddCommand(Model model, Alias alias, List<T> newValues); - - /** - * Creates command that should remove elements from the property list. - * - * @param model - * model where element is located - * @param alias - * {@link Alias} that should be modified - * @param values - * values that should be removed - * @return {@link ModelCommand} that will add new values - */ - protected abstract ModelCommand createRemoveCommand(Model model, Alias alias, List<T> values); - - /** - * Creates command that should modify position on property list. - * - * @param model - * model where element is located - * @param alias - * {@link Alias} that should be modified - * @param newValue - * new value of the property element - * @param oldValue - * old value of the property element - * @return {@link ModelCommand} that will add new values - */ - protected abstract ModelCommand createChangeCommand(Model model, Alias alias, T newValue, T oldValue); - - /** - * @return the field - * @see #field - */ - protected JList<T> getField() { - return field; - } - - /** - * @param field - * the field to set - * @see #field - */ - protected void setField(JList<T> field) { - this.field = field; - } -} +package lcsb.mapviewer.editor.gui.detailstab; + +import java.util.List; + +import javax.swing.JList; + +import lcsb.mapviewer.commands.ModelCommand; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; + +/** + * Abstract class that creates {@link ModelCommand commands} to + * add/remove/modify positions on {@link Element} property that is a list. + * + * @author Piotr Gawron + * + * @param <T> + * type of the property element + */ +public abstract class CreateListPropertyChangeCommand<T> { + + /** + * List where elements are stored. + */ + private JList<T> field; + + /** + * Default constructor. + * + * @param field + * GUI input from which {@link ModelCommand} will be created + */ + CreateListPropertyChangeCommand(JList<T> field) { + this.field = field; + } + + /** + * Creates command that should add element to the property list. + * + * @param model + * model where element is located + * @param alias + * {@link Element} that should be modified + * @param newValues + * new values that should be added + * @return {@link ModelCommand} that will add new values + */ + protected abstract ModelCommand createAddCommand(Model model, Element alias, List<T> newValues); + + /** + * Creates command that should remove elements from the property list. + * + * @param model + * model where element is located + * @param alias + * {@link Element} that should be modified + * @param values + * values that should be removed + * @return {@link ModelCommand} that will add new values + */ + protected abstract ModelCommand createRemoveCommand(Model model, Element alias, List<T> values); + + /** + * Creates command that should modify position on property list. + * + * @param model + * model where element is located + * @param alias + * {@link Element} that should be modified + * @param newValue + * new value of the property element + * @param oldValue + * old value of the property element + * @return {@link ModelCommand} that will add new values + */ + protected abstract ModelCommand createChangeCommand(Model model, Element alias, T newValue, T oldValue); + + /** + * @return the field + * @see #field + */ + protected JList<T> getField() { + return field; + } + + /** + * @param field + * the field to set + * @see #field + */ + protected void setField(JList<T> field) { + this.field = field; + } +} diff --git a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreatePropertyChangeCommand.java b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreatePropertyChangeCommand.java index b5f18d58ad..7f866fe951 100644 --- a/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreatePropertyChangeCommand.java +++ b/editor/src/main/java/lcsb/mapviewer/editor/gui/detailstab/CreatePropertyChangeCommand.java @@ -1,60 +1,60 @@ -package lcsb.mapviewer.editor.gui.detailstab; - -import javax.swing.JComponent; - -import lcsb.mapviewer.commands.ModelCommand; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.model.Model; - -/** - * Abstract class that creates {@link ModelCommand commands} to remove property - * of {@link Alias}. - * - * @author Piotr Gawron - * - */ -public abstract class CreatePropertyChangeCommand { - - /** - * GUI component that stores the data. - */ - private JComponent field; - - /** - * Default constructor. - * - * @param field - * GUI input from which {@link ModelCommand} will be created - */ - CreatePropertyChangeCommand(JComponent field) { - this.field = field; - } - - /** - * Method that creates a command to modify {@link Alias} property. - * - * @param model - * {@link Model} where alias is stored - * @param alias - * {@link Alias} to modify - * @return {@link ModelCommand} that will modify alias - */ - protected abstract ModelCommand createCommand(Model model, Alias alias); - - /** - * @return the field - * @see #field - */ - protected JComponent getField() { - return field; - } - - /** - * @param field - * the field to set - * @see #field - */ - protected void setField(JComponent field) { - this.field = field; - } -} +package lcsb.mapviewer.editor.gui.detailstab; + +import javax.swing.JComponent; + +import lcsb.mapviewer.commands.ModelCommand; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; + +/** + * Abstract class that creates {@link ModelCommand commands} to remove property + * of {@link Element}. + * + * @author Piotr Gawron + * + */ +public abstract class CreatePropertyChangeCommand { + + /** + * GUI component that stores the data. + */ + private JComponent field; + + /** + * Default constructor. + * + * @param field + * GUI input from which {@link ModelCommand} will be created + */ + CreatePropertyChangeCommand(JComponent field) { + this.field = field; + } + + /** + * Method that creates a command to modify {@link Element} property. + * + * @param model + * {@link Model} where alias is stored + * @param alias + * {@link Element} to modify + * @return {@link ModelCommand} that will modify alias + */ + protected abstract ModelCommand createCommand(Model model, Element alias); + + /** + * @return the field + * @see #field + */ + protected JComponent getField() { + return field; + } + + /** + * @param field + * the field to set + * @see #field + */ + protected void setField(JComponent field) { + this.field = field; + } +} 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 a54e06996c..0cf93582a1 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 @@ -42,14 +42,14 @@ import lcsb.mapviewer.editor.gui.objectedit.MiriamDataDialog; import lcsb.mapviewer.editor.gui.objectedit.ObjectEditDialog; import lcsb.mapviewer.editor.gui.objectedit.StringEditDialog; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Complex; /** - * {@link JPanel} with detail information about selected {@link Alias} or + * {@link JPanel} with detail information about selected {@link Element} or * {@link Reaction}. * * @author Piotr Gawron @@ -74,12 +74,12 @@ public class ElementDetailsPanel extends JPanel { private final Logger logger = Logger.getLogger(ElementDetailsPanel.class); /** - * Label for {@link Alias#name} parameter. + * Label for {@link Element#name} parameter. */ private JLabel nameLabel; /** - * Label for {@link Alias#getElementId()} parameter. + * Label for {@link Element#getElementId()} parameter. */ private JLabel idLabel; @@ -89,67 +89,67 @@ public class ElementDetailsPanel extends JPanel { private JLabel complexLabel; /** - * Label for {@link Alias#compartmentAlias} parameter. + * Label for {@link Element#compartmentAlias} parameter. */ private JLabel compartmentLabel; /** - * Label for {@link Alias#fontSize} parameter. + * Label for {@link Element#fontSize} parameter. */ private JLabel fontSizeLabel; /** - * Label for {@link Alias#color} parameter. + * Label for {@link Element#color} parameter. */ private JLabel colorLabel; /** - * Label for {@link Alias#notes} parameter. + * Label for {@link Element#notes} parameter. */ private JLabel notesLabel; /** - * Label for {@link Alias#symbol} parameter. + * Label for {@link Element#symbol} parameter. */ private JLabel symbolLabel; /** - * Label for {@link Alias#fullName} parameter. + * Label for {@link Element#fullName} parameter. */ private JLabel fullNameLabel; /** - * Label for {@link Alias#abbreviation} parameter. + * Label for {@link Element#abbreviation} parameter. */ private JLabel abbreviationLabel; /** - * Label for {@link Alias#formula} parameter. + * Label for {@link Element#formula} parameter. */ private JLabel formulaLabel; /** - * Label for {@link Alias#synonyms} parameter. + * Label for {@link Element#synonyms} parameter. */ private JLabel synonymsLabel; /** - * Label for {@link Alias#formerSymbols} parameter. + * Label for {@link Element#formerSymbols} parameter. */ private JLabel formerSymbolsLabel; /** - * Label for {@link Alias#symbol} parameter. + * Label for {@link Element#symbol} parameter. */ private JLabel miriamDataLabel; /** - * {@link JTextField} for {@link Alias#name} parameter. + * {@link JTextField} for {@link Element#name} parameter. */ private JTextField nameText; /** - * {@link JTextField} for {@link Alias#name} parameter. + * {@link JTextField} for {@link Element#name} parameter. */ private JTextField idText; @@ -159,91 +159,91 @@ public class ElementDetailsPanel extends JPanel { private JTextField complexText; /** - * {@link JTextField} for {@link Alias#compartmentAlias} parameter. + * {@link JTextField} for {@link Element#compartmentAlias} parameter. */ private JTextField compartmentText; /** - * {@link JTextField} for {@link Alias#fontSize} parameter. + * {@link JTextField} for {@link Element#fontSize} parameter. */ private JTextField fontSizeText; /** - * {@link JTextField} for {@link Alias#color} parameter. + * {@link JTextField} for {@link Element#color} parameter. */ private JButton colorButton; /** - * {@link JTextField} for {@link Alias#notes} parameter. + * {@link JTextField} for {@link Element#notes} parameter. */ private JTextArea notesText; /** - * {@link JTextField} for {@link Alias#symbol} parameter. + * {@link JTextField} for {@link Element#symbol} parameter. */ private JTextField symbolText; /** - * {@link JTextField} for {@link Alias#fullName} parameter. + * {@link JTextField} for {@link Element#fullName} parameter. */ private JTextField fullNameText; /** - * {@link JTextField} for {@link Alias#abbreviation} parameter. + * {@link JTextField} for {@link Element#abbreviation} parameter. */ private JTextField abbreviationText; /** - * {@link JTextField} for {@link Alias#formula} parameter. + * {@link JTextField} for {@link Element#formula} parameter. */ private JTextField formulaText; /** - * {@link JList} for {@link Alias#synonyms} parameter. + * {@link JList} for {@link Element#synonyms} parameter. */ private JList<String> synonymsList; /** - * {@link JList} for {@link Alias#formerSymbols} parameter. + * {@link JList} for {@link Element#formerSymbols} parameter. */ private JList<String> formerSymbolsList; /** - * {@link JList} for {@link Alias#miriamData} parameter. + * {@link JList} for {@link Element#miriamData} parameter. */ private JList<MiriamData> miriamDataList; /** - * List of synonyms in {@link Alias#synonyms}. + * List of synonyms in {@link Element#synonyms}. * * @see {@link #synonymsList} */ private DefaultListModel<String> synonymsListModel = new DefaultListModel<>(); /** - * List of synonyms in {@link Alias#formerSymbols}. + * List of synonyms in {@link Element#formerSymbols}. * * @see {@link #formerSymbolsList} */ private DefaultListModel<String> formerSymbolsListModel = new DefaultListModel<>(); /** - * List of synonyms in {@link Alias#miriamData}. + * List of synonyms in {@link Element#miriamData}. * * @see {@link #miriamDataList} */ private DefaultListModel<MiriamData> miriamDataListModel = new DefaultListModel<>(); /** - * {@link Alias} or {@link Reaction} that is currently selected. + * {@link Element} or {@link Reaction} that is currently selected. */ private Object element; /** * List of listeners that should be thrown when some properties of selected - * {@link Alias} is changed. + * {@link Element} is changed. */ - private List<ElementModifiedEventListener<Alias>> aliasListeners = new ArrayList<>(); + private List<ElementModifiedEventListener<Element>> aliasListeners = new ArrayList<>(); /** * List of listeners that should be thrown when some properties of selected @@ -365,7 +365,7 @@ public class ElementDetailsPanel extends JPanel { T s = e.getElement(); List<T> values = new ArrayList<>(); values.add(s); - ModelCommand modelCommand = createCommandObject.createAddCommand(getModel(), (Alias) element, values); + ModelCommand modelCommand = createCommandObject.createAddCommand(getModel(), (Element) element, values); processCommand(modelCommand); ((DefaultListModel<T>) list.getModel()).addElement(s); } @@ -385,7 +385,7 @@ public class ElementDetailsPanel extends JPanel { @Override public void actionPerformed(ElementModifiedEvent<T> e) throws CommandExecutionException { T s = e.getElement(); - ModelCommand modelCommand = createCommandObject.createChangeCommand(getModel(), (Alias) element, s, list.getSelectedValue()); + ModelCommand modelCommand = createCommandObject.createChangeCommand(getModel(), (Element) element, s, list.getSelectedValue()); processCommand(modelCommand); ((DefaultListModel<T>) list.getModel()).set(list.getSelectedIndices()[0], s); } @@ -404,7 +404,7 @@ public class ElementDetailsPanel extends JPanel { for (T string : list.getSelectedValuesList()) { elements.add(string); } - ModelCommand modelCommand = createCommandObject.createRemoveCommand(getModel(), (Alias) element, elements); + ModelCommand modelCommand = createCommandObject.createRemoveCommand(getModel(), (Element) element, elements); try { processCommand(modelCommand); for (T string : elements) { @@ -439,7 +439,7 @@ public class ElementDetailsPanel extends JPanel { Color newColor = JColorChooser.showDialog(ElementDetailsPanel.this, "Choose Color", colorButton.getBackground()); if (newColor != null) { colorButton.setBackground(newColor); - ModelCommand modelCommand = createCommandObject.createCommand(getModel(), (Alias) element); + ModelCommand modelCommand = createCommandObject.createCommand(getModel(), (Element) element); try { processCommand(modelCommand); } catch (CommandExecutionException exception) { @@ -464,9 +464,9 @@ public class ElementDetailsPanel extends JPanel { public void processCommand(ModelCommand modelCommand) throws CommandExecutionException { modelCommand.execute(); if (modelCommand != null) { - if (element instanceof Alias) { - ElementModifiedEvent<Alias> event = new ElementModifiedEvent<Alias>(this, (Alias) element, modelCommand); - for (ElementModifiedEventListener<Alias> listener : aliasListeners) { + if (element instanceof Element) { + ElementModifiedEvent<Element> event = new ElementModifiedEvent<Element>(this, (Element) element, modelCommand); + for (ElementModifiedEventListener<Element> listener : aliasListeners) { listener.actionPerformed(event); } } else if (element instanceof Reaction) { @@ -498,7 +498,7 @@ public class ElementDetailsPanel extends JPanel { public void focusLost(FocusEvent e) { if (!updatingData && element != null) { - ModelCommand modelCommand = createCommandObject.createCommand(getModel(), (Alias) element); + ModelCommand modelCommand = createCommandObject.createCommand(getModel(), (Element) element); try { processCommand(modelCommand); } catch (CommandExecutionException exception) { @@ -512,7 +512,7 @@ public class ElementDetailsPanel extends JPanel { @Override public void actionPerformed(ActionEvent e) { if (!updatingData && element != null) { - ModelCommand modelCommand = createCommandObject.createCommand(getModel(), (Alias) element); + ModelCommand modelCommand = createCommandObject.createCommand(getModel(), (Element) element); try { processCommand(modelCommand); } catch (CommandExecutionException exception) { @@ -547,8 +547,8 @@ public class ElementDetailsPanel extends JPanel { updatingData = true; removeAll(); try { - if (object instanceof Alias) { - createAliasPanel((Alias) object); + if (object instanceof Element) { + createAliasPanel((Element) object); } else if (object instanceof Reaction) { createReactionPanel((Reaction) object); } else if (object != null) { @@ -577,9 +577,9 @@ public class ElementDetailsPanel extends JPanel { * Creates property details panel for alias. * * @param alias - * {@link Alias} for which panel will be created + * {@link Element} for which panel will be created */ - private void createAliasPanel(Alias alias) { + private void createAliasPanel(Element alias) { int row = 0; add(nameLabel, createLayoutConstraints(0, row)); add(nameText, createLayoutConstraints(1, row)); @@ -593,7 +593,7 @@ public class ElementDetailsPanel extends JPanel { add(complexLabel, createLayoutConstraints(0, row)); add(complexText, createLayoutConstraints(1, row)); - if (alias.getParent() instanceof ComplexAlias) { + if (alias.getParent() instanceof Complex) { complexText.setText(alias.getParent().getAliasId()); } else { complexText.setText("N/A"); @@ -602,7 +602,7 @@ public class ElementDetailsPanel extends JPanel { add(compartmentLabel, createLayoutConstraints(0, row)); add(compartmentText, createLayoutConstraints(1, row)); - if (alias.getCompartmentAlias() instanceof CompartmentAlias) { + if (alias.getCompartmentAlias() instanceof Compartment) { compartmentText.setText(alias.getCompartmentAlias().getAliasId()); } else { compartmentText.setText("N/A"); @@ -728,7 +728,7 @@ public class ElementDetailsPanel extends JPanel { * @param e * {@link ElementModifiedEventListener listener} to add */ - public void addAliasModifiedEventListener(ElementModifiedEventListener<Alias> e) { + public void addAliasModifiedEventListener(ElementModifiedEventListener<Element> e) { aliasListeners.add(e); } @@ -749,8 +749,8 @@ public class ElementDetailsPanel extends JPanel { * @return {@link Model} where edited element is located */ private Model getModel() { - if (element instanceof Alias) { - return ((Alias) element).getModel(); + if (element instanceof Element) { + return ((Element) element).getModel(); } else if (element instanceof Reaction) { return ((Reaction) element).getModel(); } else if (element != null) { 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 30dd8b7d2d..bdc922d6a7 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/ColorModelCommand.java @@ -15,17 +15,17 @@ import lcsb.mapviewer.model.graphics.ArrowTypeData; 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.ColorSchema; import lcsb.mapviewer.model.map.layout.InvalidColorSchemaException; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelSubmodelConnection; import lcsb.mapviewer.model.map.reaction.AbstractNode; import lcsb.mapviewer.model.map.reaction.Product; import lcsb.mapviewer.model.map.reaction.Reactant; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; /** * This {@link ModelCommand} colors a model (nodes and reactions) according to @@ -142,8 +142,8 @@ public class ColorModelCommand extends ModelCommand { * @throws InvalidColorSchemaException * thrown when alias was already colored by other schema */ - private void applyColor(Alias alias, ColorSchema schema) throws InvalidColorSchemaException { - if (alias instanceof SpeciesAlias) { + private void applyColor(Element alias, ColorSchema schema) throws InvalidColorSchemaException { + if (alias instanceof Species) { if (!alias.getColor().equals(Color.WHITE)) { throw new InvalidColorSchemaException("At least two rows try to set color to element: " + alias.getName()); } @@ -163,8 +163,8 @@ public class ColorModelCommand extends ModelCommand { * @return <code>true</code> if coloring schema should be used for alias, * <code>false</code> otherwise */ - protected boolean match(Alias alias, ColorSchema schema) { - if (alias instanceof SpeciesAlias) { + protected boolean match(Element alias, ColorSchema schema) { + if (alias instanceof Species) { if (schema.getName() != null) { if (!alias.getName().equalsIgnoreCase(schema.getName())) { return false; @@ -193,7 +193,7 @@ public class ColorModelCommand extends ModelCommand { if (schema.getCompartments().size() > 0) { boolean found = false; - for (CompartmentAlias cAlias : alias.getModelData().getModel().getCompartmentsAliases()) { + for (Compartment cAlias : alias.getModelData().getModel().getCompartmentsAliases()) { for (String compartmentName : schema.getCompartments()) { if (cAlias.getName().equalsIgnoreCase(compartmentName)) { if (cAlias.cross(alias)) { @@ -226,7 +226,7 @@ public class ColorModelCommand extends ModelCommand { List<ColorSchema> result = new ArrayList<ColorSchema>(); for (ColorSchema schema : schemas) { boolean found = false; - for (Alias alias : getModel().getAliases()) { + for (Element alias : getModel().getAliases()) { if (match(alias, schema)) { found = true; } @@ -244,11 +244,11 @@ public class ColorModelCommand extends ModelCommand { } /** - * Returns list of elements ({@link Reaction reactions} and {@link Alias + * Returns list of elements ({@link Reaction reactions} and {@link Element * aliases}) that are modified by the coloring command. * * @return {@link Map}, where key corresponds to modified {@link Reaction} or - * {@link Alias} and value is a {@link ColorSchema} that should be + * {@link Element} and value is a {@link ColorSchema} that should be * used for coloring * @throws InvalidColorSchemaException * thrown when more than one {@link ColorSchema} match an element @@ -261,7 +261,7 @@ public class ColorModelCommand extends ModelCommand { models.addAll(getModel().getSubmodels()); for (Model model2 : models) { for (ColorSchema schema : schemas) { - for (Alias alias : model2.getAliases()) { + 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."); @@ -306,7 +306,7 @@ public class ColorModelCommand extends ModelCommand { */ private void colorModel(Model result, boolean top) throws InvalidColorSchemaException { - for (Alias alias : result.getAliases()) { + for (Element alias : result.getAliases()) { alias.setColor(Color.WHITE); } for (Reaction reaction : result.getReactions()) { @@ -316,7 +316,7 @@ public class ColorModelCommand extends ModelCommand { } for (ColorSchema schema : schemas) { - for (Alias alias : result.getAliases()) { + for (Element alias : result.getAliases()) { if (match(alias, schema)) { schema.setMatches(schema.getMatches() + 1); applyColor(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 e45e2262bb..f9613dda3f 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/CopyCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/CopyCommand.java @@ -10,12 +10,9 @@ import lcsb.mapviewer.common.exception.InvalidClassException; import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.model.graphics.PolylineData; import lcsb.mapviewer.model.map.OverviewImage; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.graph.DataMiningSet; import lcsb.mapviewer.model.map.layout.Layout; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.model.AliasSubmodelConnection; import lcsb.mapviewer.model.map.model.Model; @@ -26,6 +23,9 @@ import lcsb.mapviewer.model.map.reaction.AbstractNode; import lcsb.mapviewer.model.map.reaction.NodeOperator; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.ReactionNode; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Species; /** * Command that creates a new instance of the model with the same data. @@ -137,7 +137,7 @@ public class CopyCommand extends NewModelCommand { } } } - for (Alias alias : modelCopy.getAliases()) { + for (Element alias : modelCopy.getAliases()) { // if alias has connection to submodel if (alias.getSubmodel() != null) { AliasSubmodelConnection connection = alias.getSubmodel(); @@ -174,20 +174,20 @@ public class CopyCommand extends NewModelCommand { result.setSbgnFormat(model.isSbgnFormat()); - for (Alias alias : model.getAliases()) { - if (alias instanceof CompartmentAlias) { - CompartmentAlias copy = ((CompartmentAlias) alias).copy(); + for (Element alias : model.getAliases()) { + if (alias instanceof Compartment) { + Compartment copy = ((Compartment) alias).copy(); copy.getAliases().clear(); result.addAlias(copy); } } - for (Alias alias : model.getAliases()) { - if (alias instanceof SpeciesAlias) { - SpeciesAlias copy = ((SpeciesAlias) alias).copy(); - CompartmentAlias ca = copy.getCompartmentAlias(); - Alias parent = copy.getParent(); + for (Element alias : model.getAliases()) { + if (alias instanceof Species) { + Species copy = ((Species) alias).copy(); + Compartment ca = copy.getCompartmentAlias(); + Element parent = copy.getParent(); copy.setCompartmentAlias(null); copy.setParent(null); @@ -200,12 +200,12 @@ public class CopyCommand extends NewModelCommand { ca = result.getCompartmentAliasByCompartmentAliasId(ca.getAliasId()); copy.setCompartmentAlias(ca); } - if (parent instanceof CompartmentAlias) { - ca = (CompartmentAlias) parent; + if (parent instanceof Compartment) { + ca = (Compartment) parent; ca = result.getCompartmentAliasByCompartmentAliasId(ca.getAliasId()); copy.setParent(ca); } - } else if (alias instanceof CompartmentAlias) { + } else if (alias instanceof Compartment) { // we already added compartment alias continue; } else { @@ -227,7 +227,7 @@ public class CopyCommand extends NewModelCommand { } result.setProject(model.getProject()); - for (Alias alias : result.getAliases()) { + for (Element alias : result.getAliases()) { updateAliasReferences(alias, result, model); } for (Reaction reaction : result.getReactions()) { @@ -364,32 +364,32 @@ public class CopyCommand extends NewModelCommand { * @param originalModel * original model from which alias copy was created */ - private void updateAliasReferences(Alias alias, Model model, Model originalModel) { - if (alias instanceof CompartmentAlias) { - CompartmentAlias compartmentAlias = (CompartmentAlias) alias; - CompartmentAlias original = originalModel.getCompartmentAliasByCompartmentAliasId(alias.getAliasId()); - for (Alias a : original.getAliases()) { + 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())); } } - if (alias instanceof ComplexAlias) { - ComplexAlias ca = (ComplexAlias) alias; + if (alias instanceof Complex) { + Complex ca = (Complex) alias; for (int i = 0; i < ca.getAliases().size(); i++) { - SpeciesAlias newAlias = (SpeciesAlias) model.getAliasByAliasId(ca.getAliases().get(i).getAliasId()); + Species newAlias = (Species) model.getAliasByAliasId(ca.getAliases().get(i).getAliasId()); ca.getAliases().set(i, newAlias); } } - if (alias instanceof SpeciesAlias) { - SpeciesAlias originalAlias = (SpeciesAlias) originalModel.getAliasByAliasId(alias.getAliasId()); - SpeciesAlias sa = (SpeciesAlias) alias; + if (alias instanceof Species) { + Species originalAlias = (Species) originalModel.getAliasByAliasId(alias.getAliasId()); + Species sa = (Species) alias; if (sa.getComplexAlias() != null) { - sa.setComplexAlias((ComplexAlias) model.getAliasByAliasId(sa.getComplexAlias().getAliasId())); + sa.setComplexAlias((Complex) model.getAliasByAliasId(sa.getComplexAlias().getAliasId())); } if (originalAlias.getParent() != null) { - Alias parent = null; + Element parent = null; parent = model.getAliasByAliasId(originalAlias.getParent().getAliasId()); sa.setParent(parent); } 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 b81b40470e..897797cda6 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/CreateHierarchyCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/CreateHierarchyCommand.java @@ -11,15 +11,15 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ArtifitialCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.compartment.PathwayCompartment; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.layout.graphics.LayerRect; import lcsb.mapviewer.model.map.layout.graphics.LayerText; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Species; /** * This {@link ModelCommand command} class allows to transform model into @@ -85,12 +85,12 @@ public class CreateHierarchyCommand extends ModelCommand { throw new InvalidStateException("To execute command, the command must be in CREATED or UNDONE state. " + getStatus() + " found."); } Model model = getModel(); - List<SpeciesAlias> compacts = new ArrayList<>(); - for (Alias alias : model.getAliases()) { - if (alias instanceof ComplexAlias) { - if (((ComplexAlias) alias).getState().contains("brief")) { - compacts.add((SpeciesAlias) alias); - compacts.addAll(((ComplexAlias) alias).getAliases()); + List<Species> compacts = new ArrayList<>(); + for (Element alias : model.getAliases()) { + if (alias instanceof Complex) { + if (((Complex) alias).getState().contains("brief")) { + compacts.add((Species) alias); + compacts.addAll(((Complex) alias).getAliases()); } } } @@ -101,7 +101,7 @@ public class CreateHierarchyCommand extends ModelCommand { orderConcludingComplex(); orderConcludingCompartments(); - List<Alias> sortedAliases = model.getAliasesSortedBySize(); + List<Element> sortedAliases = model.getAliasesSortedBySize(); setParentingAndChildreningOfNonComplexChildrens(sortedAliases); model.getAliases().addAll(compacts); sortedAliases = model.getAliasesSortedBySize(); @@ -120,21 +120,21 @@ public class CreateHierarchyCommand extends ModelCommand { * Cleans hierarchical information from the model. */ protected void clean() { - for (Alias alias : getModel().getAliases()) { + for (Element alias : getModel().getAliases()) { alias.setParent(null); - if (alias instanceof ComplexAlias) { - ((ComplexAlias) alias).getAliases().clear(); + if (alias instanceof Complex) { + ((Complex) alias).getAliases().clear(); } } - Set<ArtifitialCompartmentAlias> toRemove = new HashSet<>(); - for (CompartmentAlias alias : getModel().getCompartmentsAliases()) { + Set<PathwayCompartment> toRemove = new HashSet<>(); + for (Compartment alias : getModel().getCompartmentsAliases()) { alias.setParent(null); alias.getAliases().clear(); - if (alias instanceof ArtifitialCompartmentAlias) { - toRemove.add((ArtifitialCompartmentAlias) alias); + if (alias instanceof PathwayCompartment) { + toRemove.add((PathwayCompartment) alias); } } - for (ArtifitialCompartmentAlias alias : toRemove) { + for (PathwayCompartment alias : toRemove) { getModel().removeAlias(alias); } } @@ -148,7 +148,7 @@ public class CreateHierarchyCommand extends ModelCommand { int id = 0; for (Layer layer : model.getLayers()) { for (LayerRect rect : layer.getRectangles()) { - ArtifitialCompartmentAlias alias = new ArtifitialCompartmentAlias("art" + (id++)); + PathwayCompartment alias = new PathwayCompartment("art" + (id++)); alias.setX(rect.getX()); alias.setY(rect.getY()); alias.setWidth(rect.getWidth()); @@ -160,7 +160,7 @@ public class CreateHierarchyCommand extends ModelCommand { model.addAlias(alias); } for (LayerText text : layer.getTexts()) { - ArtifitialCompartmentAlias alias = new ArtifitialCompartmentAlias("art" + (id++)); + PathwayCompartment alias = new PathwayCompartment("art" + (id++)); alias.setX(text.getX()); alias.setY(text.getY()); alias.setWidth(text.getWidth()); @@ -190,16 +190,16 @@ public class CreateHierarchyCommand extends ModelCommand { private void orderConcludingComplex() { orderingComplexesInCompartments(); orderingComplexesInComplexes(); - List<Alias> list = new ArrayList<Alias>(); - for (Alias alias : getModel().getAliases()) { - if (alias instanceof ComplexAlias) { - for (SpeciesAlias specAlias : ((ComplexAlias) alias).getAliases()) { + List<Element> list = new ArrayList<Element>(); + for (Element alias : getModel().getAliases()) { + if (alias instanceof Complex) { + for (Species specAlias : ((Complex) alias).getAliases()) { if (list.contains(specAlias)) { throw new InvalidStateException("Some aliases are in few Complexes"); } } - if (alias instanceof CompartmentAlias) { - for (Alias specAlias : ((CompartmentAlias) alias).getAliases()) { + if (alias instanceof Compartment) { + for (Element specAlias : ((Compartment) alias).getAliases()) { if (list.contains(specAlias)) { throw new InvalidStateException("Some aliases are in few Structures"); } @@ -207,7 +207,7 @@ public class CreateHierarchyCommand extends ModelCommand { } } } - for (Alias alias : getModel().getAliases()) { + for (Element alias : getModel().getAliases()) { if (alias.getParent() != null) { throw new InvalidStateException("WTF"); } @@ -219,11 +219,11 @@ public class CreateHierarchyCommand extends ModelCommand { * Checks if hierarchical structure of compartments is valid. */ private void orderConcludingCompartments() { - for (CompartmentAlias compartment1 : getModel().getCompartmentsAliases()) { - for (CompartmentAlias compartment2 : getModel().getCompartmentsAliases()) { + for (Compartment compartment1 : getModel().getCompartmentsAliases()) { + for (Compartment compartment2 : getModel().getCompartmentsAliases()) { if (!compartment1.equals(compartment2)) { if (compartment1.contains(compartment2)) { - Set<Alias> duplicates = compartment2.getAliases(); + Set<Element> duplicates = compartment2.getAliases(); compartment1.getAliases().removeAll(duplicates); } } @@ -239,15 +239,15 @@ public class CreateHierarchyCommand extends ModelCommand { * @param maxZoomFactor * max scale used on the map */ - private void preSettingOfVisibilityLevel(List<Alias> sortedAliases, double maxZoomFactor) { - for (Alias alias : sortedAliases) { + private void preSettingOfVisibilityLevel(List<Element> sortedAliases, double maxZoomFactor) { + for (Element alias : sortedAliases) { double rate = computeRate(alias, Configuration.MIN_VISIBLE_OBJECT_SIZE); int logValue = (int) ((int) Math.ceil(Math.log(rate)) / LOG_4); if (alias.getParent() == null) { logValue = 0; } if (logValue >= zoomLevels) { - if (alias.getParent() instanceof ComplexAlias) { + if (alias.getParent() instanceof Complex) { logValue = zoomLevels - 1; } else { logValue = zoomLevels; @@ -263,11 +263,11 @@ public class CreateHierarchyCommand extends ModelCommand { * @param compartment * comaprtment alias */ - private void settingTransparencyLevelForCompartment(CompartmentAlias compartment) { + private void settingTransparencyLevelForCompartment(Compartment compartment) { 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 (Alias child : compartment.getAliases()) { + for (Element child : compartment.getAliases()) { maxVisibilityLevel = Math.min(maxVisibilityLevel, child.getVisibilityLevel()); } if (maxVisibilityLevel >= zoomLevels) { @@ -277,7 +277,7 @@ public class CreateHierarchyCommand extends ModelCommand { maxVisibilityLevel = 1; } compartment.setTransparencyLevel(maxVisibilityLevel); - for (Alias child : compartment.getAliases()) { + for (Element child : compartment.getAliases()) { child.setVisibilityLevel(compartment.getTransparencyLevel()); } } @@ -288,11 +288,11 @@ public class CreateHierarchyCommand extends ModelCommand { * @param complex * complex alias */ - private void settingTransparencyLevelForComplex(ComplexAlias complex) { + private void settingTransparencyLevelForComplex(Complex complex) { int maxVisibilityLevel = Integer.MAX_VALUE; double rate = computeRate(complex, Configuration.MAX_VISIBLE_OBJECT_SIZE); maxVisibilityLevel = (int) ((int) Math.ceil(Math.log(rate)) / LOG_4); - for (Alias child : complex.getAliases()) { + for (Element child : complex.getAliases()) { maxVisibilityLevel = Math.min(maxVisibilityLevel, child.getVisibilityLevel()); } if (maxVisibilityLevel >= zoomLevels) { @@ -302,7 +302,7 @@ public class CreateHierarchyCommand extends ModelCommand { maxVisibilityLevel = 1; } complex.setTransparencyLevel(maxVisibilityLevel); - for (Alias child : complex.getAliases()) { + for (Element child : complex.getAliases()) { child.setVisibilityLevel(complex.getTransparencyLevel()); } } @@ -313,12 +313,12 @@ public class CreateHierarchyCommand extends ModelCommand { * @param sortedAliases * list of aliases */ - private void settingOfTransparencyLevel(List<Alias> sortedAliases) { - for (Alias alias : sortedAliases) { - if (alias instanceof CompartmentAlias) { - settingTransparencyLevelForCompartment((CompartmentAlias) alias); - } else if (alias instanceof ComplexAlias) { - settingTransparencyLevelForComplex((ComplexAlias) alias); + private void settingOfTransparencyLevel(List<Element> sortedAliases) { + for (Element alias : sortedAliases) { + if (alias instanceof Compartment) { + settingTransparencyLevelForCompartment((Compartment) alias); + } else if (alias instanceof Complex) { + settingTransparencyLevelForComplex((Complex) alias); } else { alias.setTransparencyLevel(0); } @@ -331,16 +331,16 @@ public class CreateHierarchyCommand extends ModelCommand { * @param sortedAliases * list of aliases */ - private void setChildrening(List<Alias> sortedAliases) { - for (Alias compartment : sortedAliases) { - if (compartment instanceof CompartmentAlias) { - Set<Alias> removable = new HashSet<Alias>(); - for (Alias alias : ((CompartmentAlias) compartment).getAliases()) { + private void setChildrening(List<Element> sortedAliases) { + for (Element compartment : sortedAliases) { + if (compartment instanceof Compartment) { + Set<Element> removable = new HashSet<Element>(); + for (Element alias : ((Compartment) compartment).getAliases()) { if (alias.getParent() != compartment) { removable.add(alias); } } - ((CompartmentAlias) compartment).getAliases().removeAll(removable); + ((Compartment) compartment).getAliases().removeAll(removable); } } } @@ -351,20 +351,20 @@ public class CreateHierarchyCommand extends ModelCommand { * @param sortedAliases * list of aliases */ - private void setParentingOfNonComplexChildrens(List<Alias> sortedAliases) { - for (Alias alias : getModel().getAliases()) { + private void setParentingOfNonComplexChildrens(List<Element> sortedAliases) { + for (Element alias : getModel().getAliases()) { if (alias.getParent() == null) { - for (Alias complex : sortedAliases) { - if (complex instanceof ComplexAlias) { - if (((ComplexAlias) complex).getAliases().contains(alias)) { + for (Element complex : sortedAliases) { + if (complex instanceof Complex) { + if (((Complex) complex).getAliases().contains(alias)) { alias.setParent(complex); } } } if (alias.getParent() == null) { - for (Alias compartment : sortedAliases) { - if (compartment instanceof CompartmentAlias) { - if (((CompartmentAlias) compartment).getAliases().contains(alias)) { + for (Element compartment : sortedAliases) { + if (compartment instanceof Compartment) { + if (((Compartment) compartment).getAliases().contains(alias)) { alias.setParent(compartment); } } @@ -380,7 +380,7 @@ public class CreateHierarchyCommand extends ModelCommand { * @param sortedAliases * list of aliases */ - private void setParentingAndChildreningOfNonComplexChildrens(List<Alias> sortedAliases) { + private void setParentingAndChildreningOfNonComplexChildrens(List<Element> sortedAliases) { setParentingOfNonComplexChildrens(sortedAliases); setChildrening(sortedAliases); } @@ -389,14 +389,14 @@ public class CreateHierarchyCommand extends ModelCommand { * Assign aliases to compartments. */ private void assignToCompartments() { - for (CompartmentAlias alias : getModel().getCompartmentsAliases()) { - for (CompartmentAlias alias2 : getModel().getCompartmentsAliases()) { + for (Compartment alias : getModel().getCompartmentsAliases()) { + for (Compartment alias2 : getModel().getCompartmentsAliases()) { if (alias.contains(alias2)) { alias.addAlias(alias2); } } - for (Alias alias2 : getModel().getAliases()) { - if (!(alias2 instanceof CompartmentAlias)) { + for (Element alias2 : getModel().getAliases()) { + if (!(alias2 instanceof Compartment)) { if (alias.contains(alias2)) { alias.addAlias(alias2); } @@ -409,11 +409,11 @@ public class CreateHierarchyCommand extends ModelCommand { * Assign aliases to complexes. */ private void assignToComplexes() { - for (Alias alias : getModel().getAliases()) { - if (alias instanceof ComplexAlias) { - for (Alias alias2 : getModel().getAliases()) { + for (Element alias : getModel().getAliases()) { + if (alias instanceof Complex) { + for (Element alias2 : getModel().getAliases()) { if (alias.contains(alias2) && !alias.equals(alias2)) { - ((ComplexAlias) alias).getAliases().add((SpeciesAlias) alias2); + ((Complex) alias).getAliases().add((Species) alias2); } } } @@ -424,14 +424,14 @@ public class CreateHierarchyCommand extends ModelCommand { * Remove subchildren from complexes. */ private void orderingComplexesInComplexes() { - for (Alias complex1 : getModel().getAliases()) { - if (complex1 instanceof ComplexAlias) { - for (Alias complex2 : getModel().getAliases()) { - if (complex2 instanceof ComplexAlias) { + for (Element complex1 : getModel().getAliases()) { + if (complex1 instanceof Complex) { + for (Element complex2 : getModel().getAliases()) { + if (complex2 instanceof Complex) { if (!complex1.equals(complex2)) { if (complex1.contains(complex2)) { - List<SpeciesAlias> duplicates = ((ComplexAlias) complex2).getAliases(); - ((ComplexAlias) complex1).getAliases().removeAll(duplicates); + List<Species> duplicates = ((Complex) complex2).getAliases(); + ((Complex) complex1).getAliases().removeAll(duplicates); } } } @@ -444,10 +444,10 @@ public class CreateHierarchyCommand extends ModelCommand { * Remove subchildren from compartments by complexes. */ private void orderingComplexesInCompartments() { - for (CompartmentAlias compartment : getModel().getCompartmentsAliases()) { - for (Alias complex : getModel().getAliases()) { - if (complex instanceof ComplexAlias) { - List<SpeciesAlias> duplicates = ((ComplexAlias) complex).getAliases(); + for (Compartment compartment : getModel().getCompartmentsAliases()) { + for (Element complex : getModel().getAliases()) { + if (complex instanceof Complex) { + List<Species> duplicates = ((Complex) complex).getAliases(); compartment.getAliases().removeAll(duplicates); } } @@ -458,11 +458,11 @@ public class CreateHierarchyCommand extends ModelCommand { * Sets proper parents after creating hierarchical structure. */ private void parentingInComplexes() { - for (Alias complex : getModel().getAliases()) { - if (complex instanceof ComplexAlias) { - for (Alias child : ((ComplexAlias) complex).getAliases()) { - if (child instanceof ComplexAlias) { - if (((ComplexAlias) child).getAliases().contains(complex)) { + for (Element complex : getModel().getAliases()) { + if (complex instanceof Complex) { + for (Element child : ((Complex) complex).getAliases()) { + if (child instanceof Complex) { + if (((Complex) child).getAliases().contains(complex)) { if (complex.getParent() != null) { throw new InvalidStateException( child.getName() + " has parent " + child.getParent().getName() + " and now again try to add new parent " + complex.getName()); @@ -486,7 +486,7 @@ public class CreateHierarchyCommand extends ModelCommand { * @return ratio between the minimal object that should be visible, and alias * visible on the top level */ - private double computeRate(Alias alias, double limit) { + private double computeRate(Element alias, double limit) { double length = alias.getWidth() / maxZoomFactor; double height = alias.getHeight() / maxZoomFactor; double size = length * height; diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/ModelCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/ModelCommand.java index d6f392dea1..aefcf90fff 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/ModelCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/ModelCommand.java @@ -5,10 +5,10 @@ import java.awt.geom.Rectangle2D; import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.reaction.AbstractNode; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; /** * Abstract class representing operation on the model. There are following steps @@ -201,7 +201,7 @@ public abstract class ModelCommand { * @param alias * alias to be included in affected region */ - protected void includeInAffectedRegion(Alias alias) { + protected void includeInAffectedRegion(Element alias) { if (affectedRegion == null) { affectedRegion = new Rectangle2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight()); } else { diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/MoveCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/MoveCommand.java index 36fef91e25..41c480ae8d 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/MoveCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/MoveCommand.java @@ -1,76 +1,76 @@ -package lcsb.mapviewer.commands; - -import java.awt.geom.Point2D; - -import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.model.Model; -import lcsb.mapviewer.model.map.reaction.AbstractNode; -import lcsb.mapviewer.model.map.reaction.Reaction; - -/** - * Command which moves model by dx, dy coordinates. - * - * @author Piotr Gawron - * - */ -public class MoveCommand extends ModelCommand { - - /** - * Delta x. - */ - private double dx; - /** - * Delta y. - */ - private double dy; - - /** - * Default constructor. - * - * @param model - * model to move - * @param dx - * delta x - * @param dy - * delat y - */ - public MoveCommand(Model model, double dx, double dy) { - super(model); - this.dx = dx; - this.dy = dy; - } - - @Override - protected void undoImplementation() { - throw new NotImplementedException(); - } - - @Override - protected void redoImplementation() { - throw new NotImplementedException(); - } - - @Override - protected void executeImplementation() { - - Model model = getModel(); - - for (Alias alias : model.getAliases()) { - alias.setX(alias.getX() + dx); - alias.setY(alias.getY() + dy); - if (alias instanceof CompartmentAlias) { - ((CompartmentAlias) alias).setNamePoint(((CompartmentAlias) alias).getNamePoint().getX() + dx, ((CompartmentAlias) alias).getNamePoint().getY() + dy); - } - } - for (Reaction reaction : model.getReactions()) { - for (AbstractNode node : reaction.getNodes()) { - for (Point2D point : node.getLine().getPoints()) { - point.setLocation(point.getX() + dx, point.getY() + dy); - } - } - } - } - -} +package lcsb.mapviewer.commands; + +import java.awt.geom.Point2D; + +import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.reaction.AbstractNode; +import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; + +/** + * Command which moves model by dx, dy coordinates. + * + * @author Piotr Gawron + * + */ +public class MoveCommand extends ModelCommand { + + /** + * Delta x. + */ + private double dx; + /** + * Delta y. + */ + private double dy; + + /** + * Default constructor. + * + * @param model + * model to move + * @param dx + * delta x + * @param dy + * delat y + */ + public MoveCommand(Model model, double dx, double dy) { + super(model); + this.dx = dx; + this.dy = dy; + } + + @Override + protected void undoImplementation() { + throw new NotImplementedException(); + } + + @Override + protected void redoImplementation() { + throw new NotImplementedException(); + } + + @Override + protected void executeImplementation() { + + Model model = getModel(); + + for (Element alias : model.getAliases()) { + alias.setX(alias.getX() + dx); + alias.setY(alias.getY() + dy); + if (alias instanceof Compartment) { + ((Compartment) alias).setNamePoint(((Compartment) alias).getNamePoint().getX() + dx, ((Compartment) alias).getNamePoint().getY() + dy); + } + } + for (Reaction reaction : model.getReactions()) { + for (AbstractNode node : reaction.getNodes()) { + for (Point2D point : node.getLine().getPoints()) { + point.setLocation(point.getX() + dx, point.getY() + dy); + } + } + } + } + +} diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/MoveElementsCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/MoveElementsCommand.java index 059e1ad47f..aade207264 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/MoveElementsCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/MoveElementsCommand.java @@ -1,181 +1,181 @@ -package lcsb.mapviewer.commands; - -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.common.exception.InvalidStateException; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.model.Model; -import lcsb.mapviewer.model.map.reaction.Modifier; -import lcsb.mapviewer.model.map.reaction.NodeOperator; -import lcsb.mapviewer.model.map.reaction.Product; -import lcsb.mapviewer.model.map.reaction.Reactant; -import lcsb.mapviewer.model.map.reaction.Reaction; -import lcsb.mapviewer.model.map.reaction.ReactionNode; - -import org.apache.log4j.Logger; - -/** - * Command which moves elements in model by dx, dy coordinates. - * - * @author Piotr Gawron - * - */ -public class MoveElementsCommand extends ModelCommand { - - /** - * Default class logger. - */ - private final Logger logger = Logger.getLogger(MoveElementsCommand.class); - - /** - * Delta x. - */ - private double dx; - - /** - * Delta y. - */ - private double dy; - - /** - * List of objects to move. - */ - private List<Object> objectsToMove = new ArrayList<>(); - - /** - * Default constructor. - * - * @param model - * model to move - * @param elements - * elements that should be moved - * @param dx - * delta x - * @param dy - * delat y - */ - public MoveElementsCommand(Model model, List<Object> elements, double dx, double dy) { - super(model); - this.dx = dx; - this.dy = dy; - for (Object object : elements) { - if (object instanceof Alias) { - if (((Alias) object).getModel() != model) { - throw new InvalidArgumentException("Object doesnt belong to specified model: " + object); - } - } else if (object instanceof Reaction) { - if (((Reaction) object).getModel() != model) { - throw new InvalidArgumentException("Object doesnt belong to specified model: " + object); - } - } else { - throw new InvalidArgumentException("Cannot move element: " + object); - } - } - objectsToMove = elements; - } - - @Override - protected void undoImplementation() { - dx = -dx; - dy = -dy; - executeImplementation(); - dx = -dx; - dy = -dy; - setStatus(ModelCommandStatus.UNDONE); - } - - @Override - protected void redoImplementation() { - executeImplementation(); - setStatus(ModelCommandStatus.EXECUTED); - } - - @Override - protected void executeImplementation() { - Set<Alias> aliases = new HashSet<>(); - - for (Object object : objectsToMove) { - if (object instanceof Alias) { - Alias alias = (Alias) object; - - includeInAffectedRegion(alias); - - alias.setX(alias.getX() + dx); - alias.setY(alias.getY() + dy); - if (alias instanceof CompartmentAlias) { - ((CompartmentAlias) alias) - .setNamePoint(((CompartmentAlias) alias).getNamePoint().getX() + dx, ((CompartmentAlias) alias).getNamePoint().getY() + dy); - } - - includeInAffectedRegion(alias); - - aliases.add(alias); - } else if (object instanceof Reaction) { - Reaction reaction = (Reaction) object; - for (Reactant node : reaction.getReactants()) { - for (int i = 1; i < node.getLine().getPoints().size(); i++) { - Point2D point = node.getLine().getPoints().get(i); - logger.debug("Moving point: " + point); - point.setLocation(point.getX() + dx, point.getY() + dy); - } - } - for (Product node : reaction.getProducts()) { - for (int i = 0; i < node.getLine().getPoints().size() - 1; i++) { - Point2D point = node.getLine().getPoints().get(i); - point.setLocation(point.getX() + dx, point.getY() + dy); - } - } - for (Modifier node : reaction.getModifiers()) { - for (int i = 1; i < node.getLine().getPoints().size(); i++) { - Point2D point = node.getLine().getPoints().get(i); - point.setLocation(point.getX() + dx, point.getY() + dy); - } - } - for (NodeOperator node : reaction.getOperators()) { - for (int i = 0; i < node.getLine().getPoints().size(); i++) { - Point2D point = node.getLine().getPoints().get(i); - point.setLocation(point.getX() + dx, point.getY() + dy); - } - } - includeInAffectedRegion(reaction); - } else { - throw new InvalidStateException("Unknown class type: " + object); - } - } - if (aliases.size() > 0) { - // TODO this must be improved, we cannot do full search on every move - for (Reaction reaction : getModel().getReactions()) { - for (ReactionNode node : reaction.getReactionNodes()) { - if (aliases.contains(node.getAlias())) { - if (node instanceof Reactant) { - Point2D point = node.getLine().getBeginPoint(); - point.setLocation(point.getX() + dx, point.getY() + dy); - - // we don't have to include point that we change as it's already - // on the border of the element - includeInAffectedRegion(node.getLine().getPoints().get(1)); - } else if (node instanceof Modifier) { - Point2D point = node.getLine().getBeginPoint(); - point.setLocation(point.getX() + dx, point.getY() + dy); - // we don't have to include point that we change as it's already - // on the border of the element - includeInAffectedRegion(node.getLine().getPoints().get(1)); - } else if (node instanceof Product) { - Point2D point = node.getLine().getEndPoint(); - point.setLocation(point.getX() + dx, point.getY() + dy); - // we don't have to include point that we change as it's already - // on the border of the element - includeInAffectedRegion(node.getLine().getPoints().get(node.getLine().getPoints().size() - 1)); - } - } - } - } - } - } -} +package lcsb.mapviewer.commands; + +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import lcsb.mapviewer.common.exception.InvalidArgumentException; +import lcsb.mapviewer.common.exception.InvalidStateException; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.reaction.Modifier; +import lcsb.mapviewer.model.map.reaction.NodeOperator; +import lcsb.mapviewer.model.map.reaction.Product; +import lcsb.mapviewer.model.map.reaction.Reactant; +import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.reaction.ReactionNode; +import lcsb.mapviewer.model.map.species.Element; + +import org.apache.log4j.Logger; + +/** + * Command which moves elements in model by dx, dy coordinates. + * + * @author Piotr Gawron + * + */ +public class MoveElementsCommand extends ModelCommand { + + /** + * Default class logger. + */ + private final Logger logger = Logger.getLogger(MoveElementsCommand.class); + + /** + * Delta x. + */ + private double dx; + + /** + * Delta y. + */ + private double dy; + + /** + * List of objects to move. + */ + private List<Object> objectsToMove = new ArrayList<>(); + + /** + * Default constructor. + * + * @param model + * model to move + * @param elements + * elements that should be moved + * @param dx + * delta x + * @param dy + * delat y + */ + public MoveElementsCommand(Model model, List<Object> elements, double dx, double dy) { + super(model); + this.dx = dx; + this.dy = dy; + for (Object object : elements) { + if (object instanceof Element) { + if (((Element) object).getModel() != model) { + throw new InvalidArgumentException("Object doesnt belong to specified model: " + object); + } + } else if (object instanceof Reaction) { + if (((Reaction) object).getModel() != model) { + throw new InvalidArgumentException("Object doesnt belong to specified model: " + object); + } + } else { + throw new InvalidArgumentException("Cannot move element: " + object); + } + } + objectsToMove = elements; + } + + @Override + protected void undoImplementation() { + dx = -dx; + dy = -dy; + executeImplementation(); + dx = -dx; + dy = -dy; + setStatus(ModelCommandStatus.UNDONE); + } + + @Override + protected void redoImplementation() { + executeImplementation(); + setStatus(ModelCommandStatus.EXECUTED); + } + + @Override + protected void executeImplementation() { + Set<Element> aliases = new HashSet<>(); + + for (Object object : objectsToMove) { + if (object instanceof Element) { + Element alias = (Element) object; + + includeInAffectedRegion(alias); + + alias.setX(alias.getX() + dx); + alias.setY(alias.getY() + dy); + if (alias instanceof Compartment) { + ((Compartment) alias) + .setNamePoint(((Compartment) alias).getNamePoint().getX() + dx, ((Compartment) alias).getNamePoint().getY() + dy); + } + + includeInAffectedRegion(alias); + + aliases.add(alias); + } else if (object instanceof Reaction) { + Reaction reaction = (Reaction) object; + for (Reactant node : reaction.getReactants()) { + for (int i = 1; i < node.getLine().getPoints().size(); i++) { + Point2D point = node.getLine().getPoints().get(i); + logger.debug("Moving point: " + point); + point.setLocation(point.getX() + dx, point.getY() + dy); + } + } + for (Product node : reaction.getProducts()) { + for (int i = 0; i < node.getLine().getPoints().size() - 1; i++) { + Point2D point = node.getLine().getPoints().get(i); + point.setLocation(point.getX() + dx, point.getY() + dy); + } + } + for (Modifier node : reaction.getModifiers()) { + for (int i = 1; i < node.getLine().getPoints().size(); i++) { + Point2D point = node.getLine().getPoints().get(i); + point.setLocation(point.getX() + dx, point.getY() + dy); + } + } + for (NodeOperator node : reaction.getOperators()) { + for (int i = 0; i < node.getLine().getPoints().size(); i++) { + Point2D point = node.getLine().getPoints().get(i); + point.setLocation(point.getX() + dx, point.getY() + dy); + } + } + includeInAffectedRegion(reaction); + } else { + throw new InvalidStateException("Unknown class type: " + object); + } + } + if (aliases.size() > 0) { + // TODO this must be improved, we cannot do full search on every move + for (Reaction reaction : getModel().getReactions()) { + for (ReactionNode node : reaction.getReactionNodes()) { + if (aliases.contains(node.getAlias())) { + if (node instanceof Reactant) { + Point2D point = node.getLine().getBeginPoint(); + point.setLocation(point.getX() + dx, point.getY() + dy); + + // we don't have to include point that we change as it's already + // on the border of the element + includeInAffectedRegion(node.getLine().getPoints().get(1)); + } else if (node instanceof Modifier) { + Point2D point = node.getLine().getBeginPoint(); + point.setLocation(point.getX() + dx, point.getY() + dy); + // we don't have to include point that we change as it's already + // on the border of the element + includeInAffectedRegion(node.getLine().getPoints().get(1)); + } else if (node instanceof Product) { + Point2D point = node.getLine().getEndPoint(); + point.setLocation(point.getX() + dx, point.getY() + dy); + // we don't have to include point that we change as it's already + // on the border of the element + includeInAffectedRegion(node.getLine().getPoints().get(node.getLine().getPoints().size() - 1)); + } + } + } + } + } + } +} diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/SubModelCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/SubModelCommand.java index d77b2eb551..64302e7f96 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/SubModelCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/SubModelCommand.java @@ -6,15 +6,15 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.layout.graphics.LayerText; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.reaction.AbstractNode; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.ReactionNode; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Species; /** * Creates a new instance of the model with data limited to region described by @@ -49,25 +49,25 @@ public class SubModelCommand extends NewModelCommand { CopyCommand copy = new CopyCommand(getModel()); Model result = copy.execute(); - Set<Alias> aliasNotToRemove = new HashSet<Alias>(); + Set<Element> aliasNotToRemove = new HashSet<Element>(); - for (Alias alias : result.getAliases()) { + for (Element alias : result.getAliases()) { if (polygon.intersects(alias.getBorder())) { aliasNotToRemove.add(alias); } } boolean added = false; do { - Set<Alias> iterativeAliasNotToRemove = new HashSet<>(); - for (Alias alias : aliasNotToRemove) { - Alias parent = alias.getParent(); + Set<Element> iterativeAliasNotToRemove = new HashSet<>(); + for (Element alias : aliasNotToRemove) { + Element parent = alias.getParent(); if (parent != null) { if (!aliasNotToRemove.contains(parent)) { iterativeAliasNotToRemove.add(parent); } } - if (alias instanceof SpeciesAlias) { - parent = ((SpeciesAlias) alias).getComplexAlias(); + if (alias instanceof Species) { + parent = ((Species) alias).getComplexAlias(); if (parent != null) { if (!aliasNotToRemove.contains(parent)) { iterativeAliasNotToRemove.add(parent); @@ -80,27 +80,27 @@ public class SubModelCommand extends NewModelCommand { aliasNotToRemove.addAll(iterativeAliasNotToRemove); } while (added); - List<Alias> aliasToRemove = new ArrayList<Alias>(); - for (Alias alias : result.getAliases()) { + List<Element> aliasToRemove = new ArrayList<Element>(); + for (Element alias : result.getAliases()) { if (!(polygon.intersects(alias.getBorder()))) { boolean remove = true; - if (alias instanceof SpeciesAlias) { - remove = ((SpeciesAlias) alias).getComplexAlias() == null; + if (alias instanceof Species) { + remove = ((Species) alias).getComplexAlias() == null; } if (aliasNotToRemove.contains(alias)) { remove = false; } if (remove) { aliasToRemove.add(alias); - if (alias instanceof ComplexAlias) { - List<SpeciesAlias> aliases = ((ComplexAlias) alias).getAllChildrenAliases(); + if (alias instanceof Complex) { + List<Species> aliases = ((Complex) alias).getAllChildrenAliases(); aliasToRemove.addAll(aliases); } } } } - for (Alias alias : aliasToRemove) { + for (Element alias : aliasToRemove) { result.removeAlias(alias); } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/AddElementFormerSymbolsCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/AddElementFormerSymbolsCommand.java index c993a480be..f4bb75b0a1 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/AddElementFormerSymbolsCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/AddElementFormerSymbolsCommand.java @@ -5,12 +5,12 @@ import java.util.List; import org.apache.log4j.Logger; import lcsb.mapviewer.commands.CommandExecutionException; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; /** * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that changes former - * sybmols of the {@link Alias element}. + * sybmols of the {@link Element element}. * * @author Piotr Gawron * @@ -31,9 +31,9 @@ public class AddElementFormerSymbolsCommand extends AddElementPropertyListEntryC * @param alias * {@link ChangeElementPropertyCommand#alias} * @param values - * new {@link Alias#synonym} values to be added + * new {@link Element#synonym} values to be added */ - public AddElementFormerSymbolsCommand(Model model, Alias alias, List<String> values) { + public AddElementFormerSymbolsCommand(Model model, Element alias, List<String> values) { super(model, alias, values); } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/AddElementMiriamDataCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/AddElementMiriamDataCommand.java index e1127df55b..d2ab757f64 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/AddElementMiriamDataCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/AddElementMiriamDataCommand.java @@ -6,12 +6,12 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.commands.CommandExecutionException; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; /** * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that changes - * {@link MiriamData annotations} of the {@link Alias Element} . + * {@link MiriamData annotations} of the {@link Element Element} . * * @author Piotr Gawron * @@ -34,7 +34,7 @@ public class AddElementMiriamDataCommand extends AddElementPropertyListEntryComm * @param values * new annotation values to be added */ - public AddElementMiriamDataCommand(Model model, Alias alias, List<MiriamData> values) { + public AddElementMiriamDataCommand(Model model, Element alias, List<MiriamData> values) { super(model, alias, values); } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/AddElementPropertyListEntryCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/AddElementPropertyListEntryCommand.java index e43cf8d236..2a390f6e6b 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/AddElementPropertyListEntryCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/AddElementPropertyListEntryCommand.java @@ -5,12 +5,12 @@ import java.util.List; import lcsb.mapviewer.commands.CommandExecutionException; import lcsb.mapviewer.commands.ModelCommand; import lcsb.mapviewer.commands.ModelCommandStatus; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; /** * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that add entries - * into a property of the {@link Alias Element} that is list. + * into a property of the {@link Element Element} that is list. * * @param <T> * class of property to edit @@ -26,9 +26,9 @@ public abstract class AddElementPropertyListEntryCommand<T> extends ModelCommand private List<T> newValues; /** - * {@link Alias} for which we will change the property. + * {@link Element} for which we will change the property. */ - private Alias alias; + private Element alias; /** * Default constructor. @@ -43,7 +43,7 @@ public abstract class AddElementPropertyListEntryCommand<T> extends ModelCommand * new values of the element property that will be added * */ - public AddElementPropertyListEntryCommand(Model model, Alias alias, List<T> newValues) { + public AddElementPropertyListEntryCommand(Model model, Element alias, List<T> newValues) { super(model); this.alias = alias; this.newValues = newValues; @@ -59,7 +59,7 @@ public abstract class AddElementPropertyListEntryCommand<T> extends ModelCommand * @return the alias * @see #alias */ - protected Alias getAlias() { + protected Element getAlias() { return alias; } @@ -68,7 +68,7 @@ public abstract class AddElementPropertyListEntryCommand<T> extends ModelCommand * the alias to set * @see #alias */ - protected void setAlias(Alias alias) { + protected void setAlias(Element alias) { this.alias = alias; } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/AddElementSynonymsCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/AddElementSynonymsCommand.java index 34cc030dd9..6c4587b949 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/AddElementSynonymsCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/AddElementSynonymsCommand.java @@ -5,12 +5,12 @@ import java.util.List; import org.apache.log4j.Logger; import lcsb.mapviewer.commands.CommandExecutionException; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; /** * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that changes - * synonyms of the {@link Alias Element}. + * synonyms of the {@link Element Element}. * * @author Piotr Gawron * @@ -31,9 +31,9 @@ public class AddElementSynonymsCommand extends AddElementPropertyListEntryComman * @param alias * {@link ChangeElementPropertyCommand#alias} * @param values - * new {@link Alias#synonym} values to be added + * new {@link Element#synonym} values to be added */ - public AddElementSynonymsCommand(Model model, Alias alias, List<String> values) { + public AddElementSynonymsCommand(Model model, Element alias, List<String> values) { super(model, alias, values); } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementAbbreviationCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementAbbreviationCommand.java index f244eaf7fa..f0db3c5b9d 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementAbbreviationCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementAbbreviationCommand.java @@ -1,13 +1,13 @@ package lcsb.mapviewer.commands.properties; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; import org.apache.log4j.Logger; /** * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that changes name - * of the element connected to {@link Alias}. + * of the element connected to {@link Element}. * * @author Piotr Gawron * @@ -30,7 +30,7 @@ public class ChangeElementAbbreviationCommand extends ChangeElementPropertyComma * @param newName * new name of the elemnt */ - public ChangeElementAbbreviationCommand(Model model, Alias alias, String newName) { + public ChangeElementAbbreviationCommand(Model model, Element alias, String newName) { super(model, alias, newName); } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementColorCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementColorCommand.java index 49cd2f981e..334ddb8961 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementColorCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementColorCommand.java @@ -1,49 +1,49 @@ -package lcsb.mapviewer.commands.properties; - -import java.awt.Color; - -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.model.Model; - -import org.apache.log4j.Logger; - -/** - * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that - * {@link Alias#color}. - * - * @author Piotr Gawron - * - */ -public class ChangeElementColorCommand extends ChangeElementPropertyCommand<Color> { - - /** - * Default class logger. - */ - @SuppressWarnings("unused") - private final Logger logger = Logger.getLogger(ChangeElementColorCommand.class); - - /** - * Default constructor. - * - * @param model - * {@link lcsb.mapviewer.commands.ModelCommand#model} - * @param alias - * {@link ChangeElementPropertyCommand#alias} - * @param newName - * new {@link Alias#color} value - */ - public ChangeElementColorCommand(Model model, Alias alias, Color newName) { - super(model, alias, newName); - } - - @Override - protected void executeImplementation() { - - includeInAffectedRegion(getAlias()); - - setOldValue(getAlias().getColor()); - getAlias().setColor((Color) getNewValue()); - - includeInAffectedRegion(getAlias()); - } -} +package lcsb.mapviewer.commands.properties; + +import java.awt.Color; + +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; + +import org.apache.log4j.Logger; + +/** + * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that + * {@link Element#color}. + * + * @author Piotr Gawron + * + */ +public class ChangeElementColorCommand extends ChangeElementPropertyCommand<Color> { + + /** + * Default class logger. + */ + @SuppressWarnings("unused") + private final Logger logger = Logger.getLogger(ChangeElementColorCommand.class); + + /** + * Default constructor. + * + * @param model + * {@link lcsb.mapviewer.commands.ModelCommand#model} + * @param alias + * {@link ChangeElementPropertyCommand#alias} + * @param newName + * new {@link Element#color} value + */ + public ChangeElementColorCommand(Model model, Element alias, Color newName) { + super(model, alias, newName); + } + + @Override + protected void executeImplementation() { + + includeInAffectedRegion(getAlias()); + + setOldValue(getAlias().getColor()); + getAlias().setColor((Color) getNewValue()); + + includeInAffectedRegion(getAlias()); + } +} diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementFontSizeCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementFontSizeCommand.java index cd99b1914c..bd8a4fbcc7 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementFontSizeCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementFontSizeCommand.java @@ -1,51 +1,51 @@ -package lcsb.mapviewer.commands.properties; - -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.model.Model; - -import org.apache.log4j.Logger; - -/** - * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that changes - * {@link Alias#fontSize}. - * - * @author Piotr Gawron - * - */ -public class ChangeElementFontSizeCommand extends ChangeElementPropertyCommand<Double> { - - /** - * Default class logger. - */ - @SuppressWarnings("unused") - private final Logger logger = Logger.getLogger(ChangeElementFontSizeCommand.class); - - /** - * Default constructor. - * - * @param model - * {@link lcsb.mapviewer.commands.ModelCommand#model} - * @param alias - * {@link ChangeElementPropertyCommand#alias} - * @param newName - * new {@link Alias#fontSize} value - */ - public ChangeElementFontSizeCommand(Model model, Alias alias, Double newName) { - super(model, alias, newName); - } - - @Override - protected void executeImplementation() { - - // abbreviation is not visualized, so we don't need to report any - // visualization changes - // includeInAffectedRegion(getAlias()); - - setOldValue(getAlias().getFontSize()); - getAlias().setFontSize((Double) getNewValue()); - - // abbreviation is not visualized, so we don't need to report any - // visualization changes - // includeInAffectedRegion(getAlias()); - } -} +package lcsb.mapviewer.commands.properties; + +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; + +import org.apache.log4j.Logger; + +/** + * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that changes + * {@link Element#fontSize}. + * + * @author Piotr Gawron + * + */ +public class ChangeElementFontSizeCommand extends ChangeElementPropertyCommand<Double> { + + /** + * Default class logger. + */ + @SuppressWarnings("unused") + private final Logger logger = Logger.getLogger(ChangeElementFontSizeCommand.class); + + /** + * Default constructor. + * + * @param model + * {@link lcsb.mapviewer.commands.ModelCommand#model} + * @param alias + * {@link ChangeElementPropertyCommand#alias} + * @param newName + * new {@link Element#fontSize} value + */ + public ChangeElementFontSizeCommand(Model model, Element alias, Double newName) { + super(model, alias, newName); + } + + @Override + protected void executeImplementation() { + + // abbreviation is not visualized, so we don't need to report any + // visualization changes + // includeInAffectedRegion(getAlias()); + + setOldValue(getAlias().getFontSize()); + getAlias().setFontSize((Double) getNewValue()); + + // abbreviation is not visualized, so we don't need to report any + // visualization changes + // includeInAffectedRegion(getAlias()); + } +} diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementFormerSymbolCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementFormerSymbolCommand.java index c4a7bdc963..fc5adb281f 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementFormerSymbolCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementFormerSymbolCommand.java @@ -3,12 +3,12 @@ package lcsb.mapviewer.commands.properties; import org.apache.log4j.Logger; import lcsb.mapviewer.commands.CommandExecutionException; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; /** * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that changes former - * symbol of the {@link Alias Element}. + * symbol of the {@link Element Element}. * * @author Piotr Gawron * @@ -29,11 +29,11 @@ public class ChangeElementFormerSymbolCommand extends ChangeElementPropertyListE * @param alias * {@link ChangeElementPropertyCommand#alias} * @param newValue - * new {@link Alias#synonym} value + * new {@link Element#synonym} value * @param oldValue - * old {@link Alias#synonym} value + * old {@link Element#synonym} value */ - public ChangeElementFormerSymbolCommand(Model model, Alias alias, String newValue, String oldValue) { + public ChangeElementFormerSymbolCommand(Model model, Element alias, String newValue, String oldValue) { super(model, alias, newValue, oldValue); } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementFormulaCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementFormulaCommand.java index 59331221d2..5f3dc88d6f 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementFormulaCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementFormulaCommand.java @@ -2,12 +2,12 @@ package lcsb.mapviewer.commands.properties; import org.apache.log4j.Logger; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; /** * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that changes - * formula of the element connected to {@link Alias}. + * formula of the element connected to {@link Element}. * * @author Piotr Gawron * @@ -28,9 +28,9 @@ public class ChangeElementFormulaCommand extends ChangeElementPropertyCommand<St * @param alias * {@link ChangeElementPropertyCommand#alias} * @param newName - * new {@link Alias#formula} value + * new {@link Element#formula} value */ - public ChangeElementFormulaCommand(Model model, Alias alias, String newName) { + public ChangeElementFormulaCommand(Model model, Element alias, String newName) { super(model, alias, newName); } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementFullNameCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementFullNameCommand.java index 3acb3950d6..db9f6841c0 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementFullNameCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementFullNameCommand.java @@ -1,13 +1,13 @@ package lcsb.mapviewer.commands.properties; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; import org.apache.log4j.Logger; /** * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that changes full - * name of the element connected to {@link Alias}. + * name of the element connected to {@link Element}. * * @author Piotr Gawron * @@ -28,9 +28,9 @@ public class ChangeElementFullNameCommand extends ChangeElementPropertyCommand<S * @param alias * {@link ChangeElementPropertyCommand#alias} * @param newName - * new {@link Alias#fullName} value + * new {@link Element#fullName} value */ - public ChangeElementFullNameCommand(Model model, Alias alias, String newName) { + public ChangeElementFullNameCommand(Model model, Element alias, String newName) { super(model, alias, newName); } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementMiriamDataCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementMiriamDataCommand.java index 3fba13b864..34db575c45 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementMiriamDataCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementMiriamDataCommand.java @@ -4,12 +4,12 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.commands.CommandExecutionException; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; /** * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that changes - * annotations of the {@link Alias Element}. + * annotations of the {@link Element Element}. * * @author Piotr Gawron * @@ -34,7 +34,7 @@ public class ChangeElementMiriamDataCommand extends ChangeElementPropertyListEnt * @param oldValue * old annotation value */ - public ChangeElementMiriamDataCommand(Model model, Alias alias, MiriamData newValue, MiriamData oldValue) { + public ChangeElementMiriamDataCommand(Model model, Element alias, MiriamData newValue, MiriamData oldValue) { super(model, alias, newValue, oldValue); } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementNameCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementNameCommand.java index 425540c44c..82bfff0c28 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementNameCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementNameCommand.java @@ -1,13 +1,13 @@ package lcsb.mapviewer.commands.properties; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; import org.apache.log4j.Logger; /** * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that changes name - * of the element connected to {@link Alias}. + * of the element connected to {@link Element}. * * @author Piotr Gawron * @@ -30,7 +30,7 @@ public class ChangeElementNameCommand extends ChangeElementPropertyCommand<Strin * @param newName * new name of the elemnt */ - public ChangeElementNameCommand(Model model, Alias alias, String newName) { + public ChangeElementNameCommand(Model model, Element alias, String newName) { super(model, alias, newName); } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementNotesCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementNotesCommand.java index 9fb347d855..8e4be7669b 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementNotesCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementNotesCommand.java @@ -1,13 +1,13 @@ package lcsb.mapviewer.commands.properties; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; import org.apache.log4j.Logger; /** * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that changes notes - * of the element connected to {@link Alias}. + * of the element connected to {@link Element}. * * @author Piotr Gawron * @@ -28,9 +28,9 @@ public class ChangeElementNotesCommand extends ChangeElementPropertyCommand<Stri * @param alias * {@link ChangeElementPropertyCommand#alias} * @param newName - * new {@link Alias#notes} value + * new {@link Element#notes} value */ - public ChangeElementNotesCommand(Model model, Alias alias, String newName) { + public ChangeElementNotesCommand(Model model, Element alias, String newName) { super(model, alias, newName); } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementPropertyCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementPropertyCommand.java index 27377a08c2..fa157fb75e 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementPropertyCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementPropertyCommand.java @@ -1,120 +1,120 @@ -package lcsb.mapviewer.commands.properties; - -import lcsb.mapviewer.commands.CommandExecutionException; -import lcsb.mapviewer.commands.ModelCommand; -import lcsb.mapviewer.commands.ModelCommandStatus; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.model.Model; - -/** - * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that changes single - * property of the element connected to {@link Alias}. - * - * @param <T> - * class of property to edit - * - * @author Piotr Gawron - * - */ -public abstract class ChangeElementPropertyCommand<T> extends ModelCommand { - - /** - * New element property value. - */ - private T newValue; - - /** - * Old element property value. - */ - private T oldValue; - - /** - * {@link Alias} for which we will change the property. - */ - private Alias alias; - - /** - * Default constructor. - * - * @param model - * model to move - * - * @param alias - * alias to be changed - * - * @param newValue - * new value of the element property - */ - public ChangeElementPropertyCommand(Model model, Alias alias, T newValue) { - super(model); - this.alias = alias; - this.newValue = newValue; - } - - @Override - protected void undoImplementation() throws CommandExecutionException { - T tmp = newValue; - newValue = oldValue; - executeImplementation(); - newValue = tmp; - oldValue = null; - setStatus(ModelCommandStatus.UNDONE); - } - - @Override - protected void redoImplementation() throws CommandExecutionException { - executeImplementation(); - setStatus(ModelCommandStatus.EXECUTED); - } - - /** - * @return the alias - * @see #alias - */ - protected Alias getAlias() { - return alias; - } - - /** - * @param alias - * the alias to set - * @see #alias - */ - protected void setAlias(Alias alias) { - this.alias = alias; - } - - /** - * @return the oldValue - * @see #oldValue - */ - protected Object getOldValue() { - return oldValue; - } - - /** - * @param oldValue - * the oldValue to set - * @see #oldValue - */ - protected void setOldValue(T oldValue) { - this.oldValue = oldValue; - } - - /** - * @return the newValue - * @see #newValue - */ - protected Object getNewValue() { - return newValue; - } - - /** - * @param newValue - * the newValue to set - * @see #newValue - */ - protected void setNewValue(T newValue) { - this.newValue = newValue; - } -} +package lcsb.mapviewer.commands.properties; + +import lcsb.mapviewer.commands.CommandExecutionException; +import lcsb.mapviewer.commands.ModelCommand; +import lcsb.mapviewer.commands.ModelCommandStatus; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; + +/** + * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that changes single + * property of the element connected to {@link Element}. + * + * @param <T> + * class of property to edit + * + * @author Piotr Gawron + * + */ +public abstract class ChangeElementPropertyCommand<T> extends ModelCommand { + + /** + * New element property value. + */ + private T newValue; + + /** + * Old element property value. + */ + private T oldValue; + + /** + * {@link Element} for which we will change the property. + */ + private Element alias; + + /** + * Default constructor. + * + * @param model + * model to move + * + * @param alias + * alias to be changed + * + * @param newValue + * new value of the element property + */ + public ChangeElementPropertyCommand(Model model, Element alias, T newValue) { + super(model); + this.alias = alias; + this.newValue = newValue; + } + + @Override + protected void undoImplementation() throws CommandExecutionException { + T tmp = newValue; + newValue = oldValue; + executeImplementation(); + newValue = tmp; + oldValue = null; + setStatus(ModelCommandStatus.UNDONE); + } + + @Override + protected void redoImplementation() throws CommandExecutionException { + executeImplementation(); + setStatus(ModelCommandStatus.EXECUTED); + } + + /** + * @return the alias + * @see #alias + */ + protected Element getAlias() { + return alias; + } + + /** + * @param alias + * the alias to set + * @see #alias + */ + protected void setAlias(Element alias) { + this.alias = alias; + } + + /** + * @return the oldValue + * @see #oldValue + */ + protected Object getOldValue() { + return oldValue; + } + + /** + * @param oldValue + * the oldValue to set + * @see #oldValue + */ + protected void setOldValue(T oldValue) { + this.oldValue = oldValue; + } + + /** + * @return the newValue + * @see #newValue + */ + protected Object getNewValue() { + return newValue; + } + + /** + * @param newValue + * the newValue to set + * @see #newValue + */ + protected void setNewValue(T newValue) { + this.newValue = newValue; + } +} diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementPropertyListEntryCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementPropertyListEntryCommand.java index 4e37d44700..00218400a4 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementPropertyListEntryCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementPropertyListEntryCommand.java @@ -3,12 +3,12 @@ package lcsb.mapviewer.commands.properties; import lcsb.mapviewer.commands.CommandExecutionException; import lcsb.mapviewer.commands.ModelCommand; import lcsb.mapviewer.commands.ModelCommandStatus; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; /** * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that changes single - * entry in a property of the {@link Alias Element} + * entry in a property of the {@link Element Element} * that is list. * * @param <T> @@ -30,9 +30,9 @@ public abstract class ChangeElementPropertyListEntryCommand<T> extends ModelComm private T oldValue; /** - * {@link Alias} for which we will change the property. + * {@link Element} for which we will change the property. */ - private Alias alias; + private Element alias; /** * Default constructor. @@ -49,7 +49,7 @@ public abstract class ChangeElementPropertyListEntryCommand<T> extends ModelComm * @param oldValue * old value of the element property */ - public ChangeElementPropertyListEntryCommand(Model model, Alias alias, T newValue, T oldValue) { + public ChangeElementPropertyListEntryCommand(Model model, Element alias, T newValue, T oldValue) { super(model); this.alias = alias; this.oldValue = oldValue; @@ -78,7 +78,7 @@ public abstract class ChangeElementPropertyListEntryCommand<T> extends ModelComm * @return the alias * @see #alias */ - protected Alias getAlias() { + protected Element getAlias() { return alias; } @@ -87,7 +87,7 @@ public abstract class ChangeElementPropertyListEntryCommand<T> extends ModelComm * the alias to set * @see #alias */ - protected void setAlias(Alias alias) { + protected void setAlias(Element alias) { this.alias = alias; } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementSymbolCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementSymbolCommand.java index be89028cf0..20fb9cc8df 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementSymbolCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementSymbolCommand.java @@ -1,13 +1,13 @@ package lcsb.mapviewer.commands.properties; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; import org.apache.log4j.Logger; /** * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that changes symbol - * of the element connected to {@link Alias}. + * of the element connected to {@link Element}. * * @author Piotr Gawron * @@ -28,9 +28,9 @@ public class ChangeElementSymbolCommand extends ChangeElementPropertyCommand<Str * @param alias * {@link ChangeElementPropertyCommand#alias} * @param newName - * new {@link Alias#symbol} value + * new {@link Element#symbol} value */ - public ChangeElementSymbolCommand(Model model, Alias alias, String newName) { + public ChangeElementSymbolCommand(Model model, Element alias, String newName) { super(model, alias, newName); } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementSynonymCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementSynonymCommand.java index 4e6d78706b..9f669ca8c4 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementSynonymCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/ChangeElementSynonymCommand.java @@ -3,12 +3,12 @@ package lcsb.mapviewer.commands.properties; import org.apache.log4j.Logger; import lcsb.mapviewer.commands.CommandExecutionException; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; /** * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that changes - * synonym of the {@link Alias Element}. + * synonym of the {@link Element Element}. * * @author Piotr Gawron * @@ -29,11 +29,11 @@ public class ChangeElementSynonymCommand extends ChangeElementPropertyListEntryC * @param alias * {@link ChangeElementPropertyCommand#alias} * @param newValue - * new {@link Alias#synonym} value + * new {@link Element#synonym} value * @param oldValue - * old {@link Alias#synonym} value + * old {@link Element#synonym} value */ - public ChangeElementSynonymCommand(Model model, Alias alias, String newValue, String oldValue) { + public ChangeElementSynonymCommand(Model model, Element alias, String newValue, String oldValue) { super(model, alias, newValue, oldValue); } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/RemoveElementFormerSymbolsCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/RemoveElementFormerSymbolsCommand.java index ec6fbcd069..9f21a2c821 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/RemoveElementFormerSymbolsCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/RemoveElementFormerSymbolsCommand.java @@ -5,12 +5,12 @@ import java.util.List; import org.apache.log4j.Logger; import lcsb.mapviewer.commands.CommandExecutionException; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; /** * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that removes former - * symbols from {@link Alias Element}. + * symbols from {@link Element Element}. * * @author Piotr Gawron * @@ -31,9 +31,9 @@ public class RemoveElementFormerSymbolsCommand extends RemoveElementPropertyList * @param alias * {@link ChangeElementPropertyCommand#alias} * @param values - * {@link Alias#synonym} values to be removed + * {@link Element#synonym} values to be removed */ - public RemoveElementFormerSymbolsCommand(Model model, Alias alias, List<String> values) { + public RemoveElementFormerSymbolsCommand(Model model, Element alias, List<String> values) { super(model, alias, values); } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/RemoveElementMiriamDataCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/RemoveElementMiriamDataCommand.java index 6a6a0538f2..d7d6f7f9e7 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/RemoveElementMiriamDataCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/RemoveElementMiriamDataCommand.java @@ -6,12 +6,12 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.commands.CommandExecutionException; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; /** * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that removes - * annotations from {@link Alias Element}. + * annotations from {@link Element Element}. * * @author Piotr Gawron * @@ -32,9 +32,9 @@ public class RemoveElementMiriamDataCommand extends RemoveElementPropertyListEnt * @param alias * {@link ChangeElementPropertyCommand#alias} * @param values - * {@link Alias#synonym} values to be removed + * {@link Element#synonym} values to be removed */ - public RemoveElementMiriamDataCommand(Model model, Alias alias, List<MiriamData> values) { + public RemoveElementMiriamDataCommand(Model model, Element alias, List<MiriamData> values) { super(model, alias, values); } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/RemoveElementPropertyListEntryCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/RemoveElementPropertyListEntryCommand.java index 760a01bfd7..9e883c7777 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/RemoveElementPropertyListEntryCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/RemoveElementPropertyListEntryCommand.java @@ -5,12 +5,12 @@ import java.util.List; import lcsb.mapviewer.commands.CommandExecutionException; import lcsb.mapviewer.commands.ModelCommand; import lcsb.mapviewer.commands.ModelCommandStatus; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; /** * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that removes - * entries from a property of the {@link Alias + * entries from a property of the {@link Element * Element} that is list. * * @param <T> @@ -27,9 +27,9 @@ public abstract class RemoveElementPropertyListEntryCommand<T> extends ModelComm private List<T> values; /** - * {@link Alias} for which we will change the property. + * {@link Element} for which we will change the property. */ - private Alias alias; + private Element alias; /** * Default constructor. @@ -43,7 +43,7 @@ public abstract class RemoveElementPropertyListEntryCommand<T> extends ModelComm * @param values * values of the element property to remove */ - public RemoveElementPropertyListEntryCommand(Model model, Alias alias, List<T> values) { + public RemoveElementPropertyListEntryCommand(Model model, Element alias, List<T> values) { super(model); this.alias = alias; this.values = values; @@ -59,7 +59,7 @@ public abstract class RemoveElementPropertyListEntryCommand<T> extends ModelComm * @return the alias * @see #alias */ - protected Alias getAlias() { + protected Element getAlias() { return alias; } @@ -68,7 +68,7 @@ public abstract class RemoveElementPropertyListEntryCommand<T> extends ModelComm * the alias to set * @see #alias */ - protected void setAlias(Alias alias) { + protected void setAlias(Element alias) { this.alias = alias; } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/RemoveElementSynonymsCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/RemoveElementSynonymsCommand.java index 6849ce3646..fe8a7bbe3d 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/RemoveElementSynonymsCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/RemoveElementSynonymsCommand.java @@ -5,12 +5,12 @@ import java.util.List; import org.apache.log4j.Logger; import lcsb.mapviewer.commands.CommandExecutionException; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; /** * {@link lcsb.mapviewer.commands.ModelCommand ModelCommand} that removes - * synonym from {@link Alias Element}. + * synonym from {@link Element Element}. * * @author Piotr Gawron * @@ -31,9 +31,9 @@ public class RemoveElementSynonymsCommand extends RemoveElementPropertyListEntry * @param alias * {@link ChangeElementPropertyCommand#alias} * @param values - * {@link Alias#synonym} values to be removed + * {@link Element#synonym} values to be removed */ - public RemoveElementSynonymsCommand(Model model, Alias alias, List<String> values) { + public RemoveElementSynonymsCommand(Model model, Element alias, List<String> values) { super(model, alias, values); } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/properties/package-info.java b/model-command/src/main/java/lcsb/mapviewer/commands/properties/package-info.java index 3ab919c1fd..4d500fc4a0 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/properties/package-info.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/properties/package-info.java @@ -1,8 +1,8 @@ -/** - * This package contains {@link lcsb.mapviewer.commands.ModelCommand commands} - * that change properies of {@link java.lang.reflect.AnnotatedElement elements } - * or {@link lcsb.mapviewer.model.map.layout.alias.Alias aliases}. - * - */ -package lcsb.mapviewer.commands.properties; - +/** + * This package contains {@link lcsb.mapviewer.commands.ModelCommand commands} + * that change properies of {@link java.lang.reflect.AnnotatedElement elements } + * or {@link lcsb.mapviewer.model.map.species.Element aliases}. + * + */ +package lcsb.mapviewer.commands.properties; + 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 9e42751289..b56126bae3 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/ColorModelCommandTest.java @@ -19,14 +19,14 @@ import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.layout.ColorSchema; import lcsb.mapviewer.model.map.layout.GenericColorSchema; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelComparator; import lcsb.mapviewer.model.map.model.ModelFullIndexed; import lcsb.mapviewer.model.map.model.ModelSubmodelConnection; 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.GenericProtein; public class ColorModelCommandTest extends CommandTestFunctions { Logger logger = Logger.getLogger(ColorModelCommandTest.class); @@ -248,7 +248,7 @@ public class ColorModelCommandTest extends CommandTestFunctions { Map<Object, ColorSchema> map = factory.getModifiedElements(); assertEquals(2, map.size()); for (Map.Entry<Object, ColorSchema> entry : map.entrySet()) { - assertTrue(entry.getKey() instanceof Alias); + assertTrue(entry.getKey() instanceof Element); } } catch (Exception e) { e.printStackTrace(); @@ -313,7 +313,7 @@ public class ColorModelCommandTest extends CommandTestFunctions { colorSchema.setName(null); colorSchema.setReactionIdentifier("1"); - GenericProteinAlias alias = new GenericProteinAlias("id"); + GenericProtein alias = new GenericProtein("id"); alias.setName("test"); List<ColorSchema> schemas = new ArrayList<>(); diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/CommandTestFunctions.java b/model-command/src/test/java/lcsb/mapviewer/commands/CommandTestFunctions.java index 41c2a99100..685dc44f7c 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/CommandTestFunctions.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/CommandTestFunctions.java @@ -9,10 +9,10 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.converter.ConverterParams; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.GenericProtein; public abstract class CommandTestFunctions { public double EPSILON = 1e-6; @@ -43,7 +43,7 @@ public abstract class CommandTestFunctions { protected Model createSimpleModel() { Model model = new ModelFullIndexed(null); - GenericProteinAlias alias = new GenericProteinAlias("alias_id"); + GenericProtein alias = new GenericProtein("alias_id"); alias.setNotes(null); List<String> list = new ArrayList<>(); list.add("synonym"); @@ -52,7 +52,7 @@ public abstract class CommandTestFunctions { list2.add("f_symbol"); alias.setFormerSymbols(list2); - ComplexAlias complexAlias = new ComplexAlias("complex_alias_id"); + Complex complexAlias = new Complex("complex_alias_id"); model.addAlias(complexAlias); complexAlias.addAlias(alias); 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 5ef2240545..0789519d9c 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/CopyCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/CopyCommandTest.java @@ -16,9 +16,6 @@ import lcsb.mapviewer.converter.ConverterParams; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser; import lcsb.mapviewer.model.map.OverviewImage; import lcsb.mapviewer.model.map.OverviewModelLink; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.model.AliasSubmodelConnection; import lcsb.mapviewer.model.map.model.Model; @@ -27,6 +24,9 @@ import lcsb.mapviewer.model.map.model.ModelFullIndexed; import lcsb.mapviewer.model.map.model.ModelSubmodelConnection; 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.Complex; +import lcsb.mapviewer.model.map.species.GenericProtein; public class CopyCommandTest extends CommandTestFunctions { @@ -58,7 +58,7 @@ public class CopyCommandTest extends CommandTestFunctions { try { Model model = new ModelFullIndexed(null); - GenericProteinAlias protein = new GenericProteinAlias("A"); + GenericProtein protein = new GenericProtein("A"); protein.setNotes(null); model.addAlias(protein); @@ -79,14 +79,14 @@ public class CopyCommandTest extends CommandTestFunctions { try { Model model = new ModelFullIndexed(null); - ComplexAlias complexAlias = new ComplexAlias("id2"); - GenericProteinAlias protein = new GenericProteinAlias("A"); + Complex complexAlias = new Complex("id2"); + GenericProtein protein = new GenericProtein("A"); protein.setNotes(null); complexAlias.addAlias(protein); model.addAlias(protein); model.addAlias(complexAlias); - GenericProteinAlias alias = new GenericProteinAlias("B"); + GenericProtein alias = new GenericProtein("B"); alias.setNotes(null); complexAlias.addAlias(alias); @@ -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")); - Alias alias = model2.getAliasByAliasId("a_id"); + Element alias = model2.getAliasByAliasId("a_id"); alias.setSubmodel(new AliasSubmodelConnection(model3, SubmodelType.DOWNSTREAM_TARGETS, "name c")); Model copy = new CopyCommand(model2).execute(); @@ -279,7 +279,7 @@ public class CopyCommandTest extends CommandTestFunctions { Model model = new ModelFullIndexed(null); model.setNotes("Some description"); - GenericProteinAlias alias = new GenericProteinAlias("a_id"); + GenericProtein alias = new GenericProtein("a_id"); alias.setName("ad"); model.addAlias(alias); 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 a1d503c6ec..f6f07bd0f3 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/CreateHierarchyCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/CreateHierarchyCommandTest.java @@ -20,11 +20,11 @@ import org.junit.Test; import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.converter.ConverterParams; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ArtifitialCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.compartment.PathwayCompartment; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Complex; public class CreateHierarchyCommandTest extends CommandTestFunctions { Logger logger = Logger.getLogger(CreateHierarchyCommandTest.class); @@ -44,17 +44,17 @@ public class CreateHierarchyCommandTest extends CommandTestFunctions { new CreateHierarchyCommand(model, 8, 80).execute(); - Alias alias = model.getAliasByAliasId("sa5033"); + Element alias = model.getAliasByAliasId("sa5033"); - Set<Alias> parents = new HashSet<Alias>(); - while (alias.getParent() instanceof ComplexAlias) { + Set<Element> parents = new HashSet<Element>(); + while (alias.getParent() instanceof Complex) { assertFalse("Cyclic nesting", parents.contains(alias.getParent())); alias = alias.getParent(); parents.add(alias); } Set<Integer> levels = new HashSet<Integer>(); - for (Alias a : model.getAliases()) { + for (Element a : model.getAliases()) { levels.add(a.getVisibilityLevel()); } assertTrue(levels.size() > 2); @@ -88,8 +88,8 @@ public class CreateHierarchyCommandTest extends CommandTestFunctions { new CreateHierarchyCommand(model, 2, 2).execute(); boolean artifitial = false; - for (CompartmentAlias a : model.getCompartmentsAliases()) { - if (a instanceof ArtifitialCompartmentAlias) { + for (Compartment a : model.getCompartmentsAliases()) { + if (a instanceof PathwayCompartment) { artifitial = true; } } @@ -134,7 +134,7 @@ public class CreateHierarchyCommandTest extends CommandTestFunctions { new CreateHierarchyCommand(model, levels, zoomFactor).execute(); - for (Alias alias : model.getAliases()) { + 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); } @@ -156,7 +156,7 @@ public class CreateHierarchyCommandTest extends CommandTestFunctions { new CreateHierarchyCommand(model, levels, zoomFactor).execute(); - for (Alias alias : model.getAliases()) { + for (Element alias : model.getAliases()) { assertTrue( "Alias " + alias.getAliasId() + " 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); - Alias alias = model.getAliasByAliasId("sa1"); + Element alias = model.getAliasByAliasId("sa1"); Object parent1 = alias.getParent(); new CreateHierarchyCommand(model, 3, 16).execute(); Object parent2 = alias.getParent(); @@ -210,13 +210,13 @@ public class CreateHierarchyCommandTest extends CommandTestFunctions { CreateHierarchyCommand command = new CreateHierarchyCommand(model, 2, 2); command.clean(); - for (Alias alias : model.getAliases()) { + for (Element alias : model.getAliases()) { assertNull(alias.getParent()); - if (alias instanceof ComplexAlias) { - assertTrue(((ComplexAlias) alias).getAliases().isEmpty()); + if (alias instanceof Complex) { + assertTrue(((Complex) alias).getAliases().isEmpty()); } } - for (CompartmentAlias alias : model.getCompartmentsAliases()) { + for (Compartment alias : model.getCompartmentsAliases()) { assertNull(alias.getParent()); assertTrue(alias.getAliases().isEmpty()); } @@ -239,8 +239,8 @@ public class CreateHierarchyCommandTest extends CommandTestFunctions { CreateHierarchyCommand command = new CreateHierarchyCommand(model, zoomLevels, zoomFactor); command.execute(); - for (Alias alias : model.getAliases()) { - Alias parentAlias = alias.getParent(); + for (Element alias : model.getAliases()) { + Element parentAlias = alias.getParent(); if (parentAlias != null) { assertTrue(alias.getVisibilityLevel() >= parentAlias.getVisibilityLevel()); } 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 6f3ff0ec3e..51eeefd2e5 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/MoveElementsCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/MoveElementsCommandTest.java @@ -16,10 +16,10 @@ import org.junit.Test; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelComparator; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; public class MoveElementsCommandTest extends CommandTestFunctions { @@ -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); - Alias alias = model.getAliasByAliasId("sa2"); - Alias alias2 = model.getAliasByAliasId("sa1"); + Element alias = model.getAliasByAliasId("sa2"); + Element alias2 = model.getAliasByAliasId("sa1"); double anotherAliasX = alias2.getX(); double anotherAliasY = alias2.getY(); @@ -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); - Alias alias = model.getAliasByAliasId("sa1"); - Alias alias2 = model.getAliasByAliasId("sa2"); + Element alias = model.getAliasByAliasId("sa1"); + Element alias2 = model.getAliasByAliasId("sa2"); double anotherAliasX = alias2.getX(); double anotherAliasY = alias2.getY(); Reaction reaction = model.getReactionByReactionId("re1"); @@ -155,7 +155,7 @@ public class MoveElementsCommandTest extends CommandTestFunctions { public void testMoveReaction() throws Exception { try { Model model = getModelForFile("testFiles/spliting_test_Case.xml", false); - Alias alias2 = model.getAliasByAliasId("sa1"); + Element alias2 = model.getAliasByAliasId("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); - Alias alias = model.getAliasByAliasId("sa2"); + Element alias = model.getAliasByAliasId("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); - Alias alias = model.getAliasByAliasId("sa2"); + Element alias = model.getAliasByAliasId("sa2"); List<Object> list = new ArrayList<>(); list.add(alias); 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 45b4cea777..e5c9676f36 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 @@ -2,9 +2,9 @@ package lcsb.mapviewer.commands.properties; import static org.junit.Assert.*; import lcsb.mapviewer.commands.CommandTestFunctions; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelComparator; +import lcsb.mapviewer.model.map.species.Element; import org.junit.After; import org.junit.Before; @@ -28,7 +28,7 @@ public class ChangeElementAbbreviationCommandTest extends CommandTestFunctions{ @Test public void testChangeAliasAbbreviation() throws Exception { try { - Alias alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getAliasByAliasId("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(); - Alias alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getAliasByAliasId("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 a11bc6a187..421f6c5964 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 @@ -1,78 +1,78 @@ -package lcsb.mapviewer.commands.properties; - -import static org.junit.Assert.*; - -import java.awt.Color; - -import lcsb.mapviewer.commands.CommandTestFunctions; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.model.Model; -import lcsb.mapviewer.model.map.model.ModelComparator; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class ChangeElementColorCommandTest extends CommandTestFunctions { - - Model model; - - ModelComparator modelComparator = new ModelComparator(); - - @Before - public void setUp() throws Exception { - model = createSimpleModel(); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testChangeAliasColor() throws Exception { - try { - Alias alias = model.getAliasByAliasId("alias_id"); - ChangeElementColorCommand command = new ChangeElementColorCommand(model, alias, Color.PINK); - assertFalse(alias.getColor().equals(Color.PINK)); - command.execute(); - assertTrue(alias.getColor().equals(Color.PINK)); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testUndo() throws Exception { - try { - Model model2 = createSimpleModel(); - Alias alias = model.getAliasByAliasId("alias_id"); - - // models should be equal before move - assertEquals(0, modelComparator.compare(model, model2)); - - ChangeElementColorCommand command = new ChangeElementColorCommand(model, alias, Color.PINK); - command.execute(); - - // after move models should be different - assertTrue(0 != modelComparator.compare(model, model2)); - - // undo command - command.undo(); - - // after undo they should be the same again - assertEquals(0, modelComparator.compare(model, model2)); - - command.redo(); - - // after redo they should be different again - assertTrue(0 != modelComparator.compare(model, model2)); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - -} +package lcsb.mapviewer.commands.properties; + +import static org.junit.Assert.*; + +import java.awt.Color; + +import lcsb.mapviewer.commands.CommandTestFunctions; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.model.ModelComparator; +import lcsb.mapviewer.model.map.species.Element; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class ChangeElementColorCommandTest extends CommandTestFunctions { + + Model model; + + ModelComparator modelComparator = new ModelComparator(); + + @Before + public void setUp() throws Exception { + model = createSimpleModel(); + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testChangeAliasColor() throws Exception { + try { + Element alias = model.getAliasByAliasId("alias_id"); + ChangeElementColorCommand command = new ChangeElementColorCommand(model, alias, Color.PINK); + assertFalse(alias.getColor().equals(Color.PINK)); + command.execute(); + assertTrue(alias.getColor().equals(Color.PINK)); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testUndo() throws Exception { + try { + Model model2 = createSimpleModel(); + Element alias = model.getAliasByAliasId("alias_id"); + + // models should be equal before move + assertEquals(0, modelComparator.compare(model, model2)); + + ChangeElementColorCommand command = new ChangeElementColorCommand(model, alias, Color.PINK); + command.execute(); + + // after move models should be different + assertTrue(0 != modelComparator.compare(model, model2)); + + // undo command + command.undo(); + + // after undo they should be the same again + assertEquals(0, modelComparator.compare(model, model2)); + + command.redo(); + + // after redo they should be different again + assertTrue(0 != modelComparator.compare(model, model2)); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + +} 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 1f62417e3a..df14ff8a59 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 @@ -1,75 +1,75 @@ -package lcsb.mapviewer.commands.properties; - -import static org.junit.Assert.*; -import lcsb.mapviewer.commands.CommandTestFunctions; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.model.Model; -import lcsb.mapviewer.model.map.model.ModelComparator; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class ChangeElementFontSizeCommandTest extends CommandTestFunctions{ - - Model model; - - ModelComparator modelComparator= new ModelComparator(); - - @Before - public void setUp() throws Exception { - model = createSimpleModel(); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testChangeAliasFontSize() throws Exception { - try { - Alias alias = model.getAliasByAliasId("alias_id"); - ChangeElementFontSizeCommand command = new ChangeElementFontSizeCommand(model, alias, 15.0); - assertFalse(alias.getFontSize().equals(15.0)); - command.execute(); - assertTrue(alias.getFontSize().equals(15.0)); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testUndo() throws Exception { - try { - Model model2 = createSimpleModel(); - Alias alias = model.getAliasByAliasId("alias_id"); - - // models should be equal before move - assertEquals(0, modelComparator.compare(model, model2)); - - ChangeElementFontSizeCommand command = new ChangeElementFontSizeCommand(model, alias, 15.0); - command.execute(); - - // after move models should be different - assertTrue(0 != modelComparator.compare(model, model2)); - - // undo command - command.undo(); - - // after undo they should be the same again - assertEquals(0, modelComparator.compare(model, model2)); - - command.redo(); - - // after redo they should be different again - assertTrue(0 != modelComparator.compare(model, model2)); - - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - -} +package lcsb.mapviewer.commands.properties; + +import static org.junit.Assert.*; +import lcsb.mapviewer.commands.CommandTestFunctions; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.model.ModelComparator; +import lcsb.mapviewer.model.map.species.Element; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class ChangeElementFontSizeCommandTest extends CommandTestFunctions{ + + Model model; + + ModelComparator modelComparator= new ModelComparator(); + + @Before + public void setUp() throws Exception { + model = createSimpleModel(); + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testChangeAliasFontSize() throws Exception { + try { + Element alias = model.getAliasByAliasId("alias_id"); + ChangeElementFontSizeCommand command = new ChangeElementFontSizeCommand(model, alias, 15.0); + assertFalse(alias.getFontSize().equals(15.0)); + command.execute(); + assertTrue(alias.getFontSize().equals(15.0)); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testUndo() throws Exception { + try { + Model model2 = createSimpleModel(); + Element alias = model.getAliasByAliasId("alias_id"); + + // models should be equal before move + assertEquals(0, modelComparator.compare(model, model2)); + + ChangeElementFontSizeCommand command = new ChangeElementFontSizeCommand(model, alias, 15.0); + command.execute(); + + // after move models should be different + assertTrue(0 != modelComparator.compare(model, model2)); + + // undo command + command.undo(); + + // after undo they should be the same again + assertEquals(0, modelComparator.compare(model, model2)); + + command.redo(); + + // after redo they should be different again + assertTrue(0 != modelComparator.compare(model, model2)); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + +} 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 56f698e93c..73272e8c96 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 @@ -2,9 +2,9 @@ package lcsb.mapviewer.commands.properties; import static org.junit.Assert.*; import lcsb.mapviewer.commands.CommandTestFunctions; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelComparator; +import lcsb.mapviewer.model.map.species.Element; import org.junit.After; import org.junit.Before; @@ -29,7 +29,7 @@ public class ChangeElementFormerSymbolCommandTest extends CommandTestFunctions { @Test public void testChangeToTheSame() throws Exception { try { - Alias alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getAliasByAliasId("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 7051cdfe96..165351ea16 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 @@ -2,9 +2,9 @@ package lcsb.mapviewer.commands.properties; import static org.junit.Assert.*; import lcsb.mapviewer.commands.CommandTestFunctions; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelComparator; +import lcsb.mapviewer.model.map.species.Element; import org.junit.After; import org.junit.Before; @@ -28,7 +28,7 @@ public class ChangeElementFormulaCommandTest extends CommandTestFunctions{ @Test public void testChangeAliasFormula() throws Exception { try { - Alias alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getAliasByAliasId("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(); - Alias alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getAliasByAliasId("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 1108ebd2b1..1f87e26d86 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 @@ -2,9 +2,9 @@ package lcsb.mapviewer.commands.properties; import static org.junit.Assert.*; import lcsb.mapviewer.commands.CommandTestFunctions; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelComparator; +import lcsb.mapviewer.model.map.species.Element; import org.junit.After; import org.junit.Before; @@ -28,7 +28,7 @@ public class ChangeElementFullNameCommandTest extends CommandTestFunctions{ @Test public void testChangeAliasFullName() throws Exception { try { - Alias alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getAliasByAliasId("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(); - Alias alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getAliasByAliasId("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 b9586e8418..89a69905b9 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 @@ -5,8 +5,8 @@ import lcsb.mapviewer.commands.CommandExecutionException; import lcsb.mapviewer.commands.CommandTestFunctions; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; import org.junit.After; import org.junit.Before; @@ -28,7 +28,7 @@ public class ChangeElementMiriamDataCommandTest extends CommandTestFunctions { @Test public void testWithoutChange() throws Exception { try { - Alias alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getAliasByAliasId("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 { - Alias alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getAliasByAliasId("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 { - Alias alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getAliasByAliasId("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 53e28c6ba8..4f1512b344 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 @@ -4,9 +4,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import lcsb.mapviewer.commands.CommandTestFunctions; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelComparator; +import lcsb.mapviewer.model.map.species.Element; import org.junit.After; import org.junit.Before; @@ -30,7 +30,7 @@ public class ChangeElementNameCommandTest extends CommandTestFunctions { @Test public void testChangeAliasName() throws Exception { try { - Alias alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getAliasByAliasId("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(); - Alias alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getAliasByAliasId("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 d4e8a3005d..1dc3eb230d 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 @@ -2,9 +2,9 @@ package lcsb.mapviewer.commands.properties; import static org.junit.Assert.*; import lcsb.mapviewer.commands.CommandTestFunctions; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelComparator; +import lcsb.mapviewer.model.map.species.Element; import org.junit.After; import org.junit.Before; @@ -28,7 +28,7 @@ public class ChangeElementNotesCommandTest extends CommandTestFunctions{ @Test public void testChangeAliasNotes() throws Exception { try { - Alias alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getAliasByAliasId("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(); - Alias alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getAliasByAliasId("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 369eed4129..cae8426700 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 @@ -2,9 +2,9 @@ package lcsb.mapviewer.commands.properties; import static org.junit.Assert.*; import lcsb.mapviewer.commands.CommandTestFunctions; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelComparator; +import lcsb.mapviewer.model.map.species.Element; import org.junit.After; import org.junit.Before; @@ -28,7 +28,7 @@ public class ChangeElementSymbolCommandTest extends CommandTestFunctions{ @Test public void testChangeAliasSymbol() throws Exception { try { - Alias alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getAliasByAliasId("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(); - Alias alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getAliasByAliasId("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 679fe1dc47..90c858494a 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 @@ -2,9 +2,9 @@ package lcsb.mapviewer.commands.properties; import static org.junit.Assert.*; import lcsb.mapviewer.commands.CommandTestFunctions; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelComparator; +import lcsb.mapviewer.model.map.species.Element; import org.junit.After; import org.junit.Before; @@ -28,7 +28,7 @@ public class ChangeElementSynonymCommandTest extends CommandTestFunctions { @Test public void testChangeAliasSynonym() throws Exception { try { - Alias alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getAliasByAliasId("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 { - Alias alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getAliasByAliasId("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(); - Alias alias = model.getAliasByAliasId("alias_id"); + Element alias = model.getAliasByAliasId("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 875ba57f53..7b65e7e495 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/MiriamType.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/MiriamType.java @@ -4,15 +4,15 @@ import java.util.ArrayList; import java.util.List; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.layout.alias.ChemicalAlias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.DrugAlias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Chemical; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Drug; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.Phenotype; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Rna; /** * Type of known miriam annotation. @@ -44,8 +44,8 @@ public enum MiriamType { CHEBI("Chebi", // "http://www.ebi.ac.uk/chebi/", // new String[] { "urn:miriam:obo.chebi", "urn:miriam:chebi" }, // - new Class<?>[] { ChemicalAlias.class, DrugAlias.class, }, "MIR:00000002", // - new Class<?>[] { ChemicalAlias.class }), // + new Class<?>[] { Chemical.class, Drug.class, }, "MIR:00000002", // + new Class<?>[] { Chemical.class }), // /** * ChemSpider database: @@ -62,7 +62,7 @@ public enum MiriamType { CHEMBL_COMPOUND("ChEMBL", // "https://www.ebi.ac.uk/chembldb/", // new String[] { "urn:miriam:chembl.compound" }, // - new Class<?>[] { DrugAlias.class }, "MIR:00000084"), // + new Class<?>[] { Drug.class }, "MIR:00000084"), // /** * Target in chembl database: https://www.ebi.ac.uk/chembldb/. @@ -70,7 +70,7 @@ public enum MiriamType { CHEMBL_TARGET("ChEMBL target", // "https://www.ebi.ac.uk/chembldb/", // new String[] { "urn:miriam:chembl.target" }, // - new Class<?>[] { ProteinAlias.class, ComplexAlias.class }, "MIR:00000085"), // + new Class<?>[] { Protein.class, Complex.class }, "MIR:00000085"), // /** * Drugbank database: http://www.drugbank.ca/. @@ -78,7 +78,7 @@ public enum MiriamType { DRUGBANK("DrugBank", // "http://www.drugbank.ca/", // new String[] { "urn:miriam:drugbank" }, // - new Class<?>[] { DrugAlias.class }, "MIR:00000102"), // + new Class<?>[] { Drug.class }, "MIR:00000102"), // /** * Drugbank tagrets: http://www.drugbank.ca/targets. */ @@ -93,7 +93,7 @@ public enum MiriamType { EC("Enzyme Nomenclature", // "http://www.enzyme-database.org/", // new String[] { "urn:miriam:ec-code" }, // - new Class<?>[] { ProteinAlias.class, ComplexAlias.class }, "MIR:00000004"), // + new Class<?>[] { Protein.class, Complex.class }, "MIR:00000004"), // /** * Ensembl: www.ensembl.org. @@ -101,7 +101,7 @@ public enum MiriamType { ENSEMBL("Ensembl", // "www.ensembl.org", // new String[] { "urn:miriam:ensembl" }, // - new Class<?>[] { ProteinAlias.class, GeneAlias.class, RnaAlias.class }, "MIR:00000003"), // + new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000003"), // /** * Ensembl Plants: http://plants.ensembl.org/. @@ -117,7 +117,7 @@ public enum MiriamType { ENTREZ("Entrez Gene", // "http://www.ncbi.nlm.nih.gov/gene", // new String[] { "urn:miriam:ncbigene", "urn:miriam:entrez.gene" }, // - new Class<?>[] { ProteinAlias.class, GeneAlias.class, RnaAlias.class }, "MIR:00000069"), // + new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000069"), // /** * Gene Ontology: http://amigo.geneontology.org/amigo. @@ -125,7 +125,7 @@ public enum MiriamType { GO("Gene Ontology", // "http://amigo.geneontology.org/amigo", // new String[] { "urn:miriam:obo.go", "urn:miriam:go" }, // - new Class<?>[] { PhenotypeAlias.class, CompartmentAlias.class, ComplexAlias.class }, "MIR:00000022"), // + new Class<?>[] { Phenotype.class, Compartment.class, Complex.class }, "MIR:00000022"), // /** * HGNC: http://www.genenames.org. @@ -133,8 +133,8 @@ public enum MiriamType { HGNC("HGNC", // "http://www.genenames.org", // new String[] { "urn:miriam:hgnc" }, // - new Class<?>[] { ProteinAlias.class, GeneAlias.class, RnaAlias.class }, "MIR:00000080", // - new Class<?>[] { ProteinAlias.class, GeneAlias.class, RnaAlias.class }), // + new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000080", // + new Class<?>[] { Protein.class, Gene.class, Rna.class }), // /** * HGNC symbol: http://www.genenames.org. @@ -142,8 +142,8 @@ public enum MiriamType { HGNC_SYMBOL("HGNC Symbol", // "http://www.genenames.org", // new String[] { "urn:miriam:hgnc.symbol" }, // - new Class<?>[] { ProteinAlias.class, GeneAlias.class, RnaAlias.class }, "MIR:00000362", // - new Class<?>[] { ProteinAlias.class, GeneAlias.class, RnaAlias.class }), // + new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000362", // + new Class<?>[] { Protein.class, Gene.class, Rna.class }), // /** * HMDB: http://www.hmdb.ca/. @@ -151,7 +151,7 @@ public enum MiriamType { HMDB("HMDB", // "http://www.hmdb.ca/", // "urn:miriam:hmdb", // - new Class<?>[] { ChemicalAlias.class, DrugAlias.class, }, "MIR:00000051"), // + new Class<?>[] { Chemical.class, Drug.class, }, "MIR:00000051"), // /** * InterPro: http://www.ebi.ac.uk/interpro/. @@ -159,7 +159,7 @@ public enum MiriamType { INTERPRO("InterPro", // "http://www.ebi.ac.uk/interpro/", // new String[] { "urn:miriam:interpro" }, // - new Class<?>[] { ProteinAlias.class, ComplexAlias.class }, "MIR:00000011"), // + new Class<?>[] { Protein.class, Complex.class }, "MIR:00000011"), // /** * KEGG Compound: http://www.genome.jp/kegg/ligand.html. @@ -167,7 +167,7 @@ public enum MiriamType { KEGG_COMPOUND("Kegg Compound", // "http://www.genome.jp/kegg/ligand.html", // "urn:miriam:kegg.compound", // - new Class<?>[] { ChemicalAlias.class }, "MIR:00000013"), // + new Class<?>[] { Chemical.class }, "MIR:00000013"), // /** * KEGG Genes: http://www.genome.jp/kegg/genes.html. @@ -175,7 +175,7 @@ public enum MiriamType { KEGG_GENES("Kegg Genes", // "http://www.genome.jp/kegg/genes.html", // new String[] { "urn:miriam:kegg.genes", "urn:miriam:kegg.genes:hsa" }, // - new Class<?>[] { ProteinAlias.class, GeneAlias.class, RnaAlias.class }, "MIR:00000070"), // + new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000070"), // /** * KEGG Orthology: http://www.genome.jp/kegg/ko.html. @@ -207,7 +207,7 @@ public enum MiriamType { MESH_2012("MeSH 2012", // "http://www.nlm.nih.gov/mesh/", // new String[] { "urn:miriam:mesh.2012", "urn:miriam:mesh" }, // - new Class<?>[] { PhenotypeAlias.class, CompartmentAlias.class, ComplexAlias.class }, "MIR:00000270"), // + new Class<?>[] { Phenotype.class, Compartment.class, Complex.class }, "MIR:00000270"), // /** * miRBase Sequence: http://www.mirbase.org/. @@ -239,7 +239,7 @@ public enum MiriamType { MGD("Mouse Genome Database", // "http://www.informatics.jax.org/", // new String[] { "urn:miriam:mgd" }, // - new Class<?>[] { ProteinAlias.class, GeneAlias.class, RnaAlias.class }, "MIR:00000037"), // + new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000037"), // /** * Online Mendelian Inheritance in Man: http://omim.org/. @@ -247,7 +247,7 @@ public enum MiriamType { OMIM("Online Mendelian Inheritance in Man", // "http://omim.org/", // new String[] { "urn:miriam:omim" }, // - new Class<?>[] { PhenotypeAlias.class }, "MIR:00000016"), // + new Class<?>[] { Phenotype.class }, "MIR:00000016"), // /** * PANTHER Family: http://www.pantherdb.org/. @@ -255,7 +255,7 @@ public enum MiriamType { PANTHER("PANTHER Family", // "http://www.pantherdb.org/", // new String[] { "urn:miriam:panther.family", "urn:miriam:panther" }, // - new Class<?>[] { ProteinAlias.class, GeneAlias.class, RnaAlias.class }, "MIR:00000060"), // + new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000060"), // /** * Protein Family Database: http://pfam.xfam.org/. @@ -279,8 +279,8 @@ public enum MiriamType { PUBCHEM("PubChem-compound", // "http://pubchem.ncbi.nlm.nih.gov/", // new String[] { "urn:miriam:pubchem.compound" }, // - new Class<?>[] { ChemicalAlias.class }, "MIR:00000034", // - new Class<?>[] { ChemicalAlias.class }), // + new Class<?>[] { Chemical.class }, "MIR:00000034", // + new Class<?>[] { Chemical.class }), // /** * PubChem-substance: http://pubchem.ncbi.nlm.nih.gov/. @@ -288,8 +288,8 @@ public enum MiriamType { PUBCHEM_SUBSTANCE("PubChem-substance", // "http://pubchem.ncbi.nlm.nih.gov/", // new String[] { "urn:miriam:pubchem.substance" }, // - new Class<?>[] { ChemicalAlias.class }, "MIR:00000033", // - new Class<?>[] { ChemicalAlias.class }), // + new Class<?>[] { Chemical.class }, "MIR:00000033", // + new Class<?>[] { Chemical.class }), // /** * PubMed: http://www.ncbi.nlm.nih.gov/PubMed/. @@ -314,7 +314,7 @@ public enum MiriamType { REFSEQ("RefSeq", // "http://www.ncbi.nlm.nih.gov/projects/RefSeq/", // "urn:miriam:refseq", // - new Class<?>[] { ProteinAlias.class, GeneAlias.class, RnaAlias.class }, "MIR:00000039"), + new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000039"), /** * SGD: http://www.yeastgenome.org/. @@ -365,7 +365,7 @@ public enum MiriamType { UNIPROT("Uniprot", // "http://www.uniprot.org/", // "urn:miriam:uniprot", // - new Class<?>[] { ProteinAlias.class, GeneAlias.class, RnaAlias.class }, "MIR:00000005"), + new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000005"), /** * UniProt Isoform: http://www.uniprot.org/. @@ -373,7 +373,7 @@ public enum MiriamType { UNIPROT_ISOFORM("UniProt Isoform", // "http://www.uniprot.org/", // "urn:miriam:uniprot.isoform", // - new Class<?>[] { ProteinAlias.class }, "MIR:00000388"), + new Class<?>[] { Protein.class }, "MIR:00000388"), /** * Unknown reference type... diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/SearchIndex.java b/model/src/main/java/lcsb/mapviewer/model/map/SearchIndex.java similarity index 88% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/SearchIndex.java rename to model/src/main/java/lcsb/mapviewer/model/map/SearchIndex.java index be0bb52b10..584885c4f3 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/SearchIndex.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/SearchIndex.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map; import java.io.Serializable; @@ -13,6 +13,7 @@ import javax.persistence.Table; import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.species.Element; /** * This class defines single search index for the element. Every element can @@ -35,7 +36,7 @@ public class SearchIndex implements Serializable { * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(Alias.class); + private static Logger logger = Logger.getLogger(Element.class); /** * Database identifier. @@ -49,7 +50,7 @@ public class SearchIndex implements Serializable { * Element to which index is assigned. */ @ManyToOne - private Alias source; + private Element source; /** * Data of the index. @@ -137,7 +138,7 @@ public class SearchIndex implements Serializable { * @return the source * @see #source */ - public Alias getSource() { + public Element getSource() { return source; } @@ -146,7 +147,7 @@ public class SearchIndex implements Serializable { * the source to set * @see #source */ - public void setSource(Alias source) { + public void setSource(Element source) { this.source = source; } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/BottomSquareCompartmentAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/compartment/BottomSquareCompartment.java similarity index 70% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/BottomSquareCompartmentAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/compartment/BottomSquareCompartment.java index 1632028116..581dc4f308 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/BottomSquareCompartmentAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/compartment/BottomSquareCompartment.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.compartment; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; @@ -15,7 +15,7 @@ import lcsb.mapviewer.model.map.model.Model; */ @Entity @DiscriminatorValue("Bottom square Compartment Alias") -public class BottomSquareCompartmentAlias extends CompartmentAlias { +public class BottomSquareCompartment extends Compartment { /** * @@ -31,7 +31,7 @@ public class BottomSquareCompartmentAlias extends CompartmentAlias { * @param model * model object to which the alias will be assigned */ - public BottomSquareCompartmentAlias(CompartmentAlias originalAlias, Model model) { + public BottomSquareCompartment(Compartment originalAlias, Model model) { super(originalAlias); setX(0.0); setWidth(model.getWidth() * 2); @@ -46,21 +46,21 @@ public class BottomSquareCompartmentAlias extends CompartmentAlias { * @param originalAlias * orignal alias where the data was kept */ - public BottomSquareCompartmentAlias(CompartmentAlias originalAlias) { + public BottomSquareCompartment(Compartment originalAlias) { super(originalAlias); } /** * Default constructor. */ - public BottomSquareCompartmentAlias() { + public BottomSquareCompartment() { super(); } @Override - public BottomSquareCompartmentAlias copy() { - if (this.getClass() == BottomSquareCompartmentAlias.class) { - return new BottomSquareCompartmentAlias(this); + public BottomSquareCompartment copy() { + if (this.getClass() == BottomSquareCompartment.class) { + return new BottomSquareCompartment(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/CompartmentAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/compartment/Compartment.java similarity index 83% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/CompartmentAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/compartment/Compartment.java index 209ed260ac..019d17705b 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/CompartmentAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/compartment/Compartment.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.compartment; import java.awt.Color; import java.awt.geom.Point2D; @@ -18,6 +18,9 @@ import org.hibernate.annotations.Type; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; /** * This class defines alias for compartment in the model. @@ -27,7 +30,7 @@ import lcsb.mapviewer.common.exception.NotImplementedException; */ @Entity @DiscriminatorValue("Compartment Alias") -public class CompartmentAlias extends Alias { +public class Compartment extends Element { /** * */ @@ -56,7 +59,7 @@ public class CompartmentAlias extends Alias { /** * Default class logger. */ - private static Logger logger = Logger.getLogger(CompartmentAlias.class.getName()); + private static Logger logger = Logger.getLogger(Compartment.class.getName()); /** * Thickness of the compartment border. @@ -83,7 +86,7 @@ public class CompartmentAlias extends Alias { */ @Cascade({ CascadeType.ALL }) @OneToMany(fetch = FetchType.EAGER, mappedBy = "compartmentAlias") - private Set<Alias> aliases = new HashSet<>(); + private Set<Element> aliases = new HashSet<>(); /** * Constructor that creates an alias which is initialized by the data from the @@ -92,13 +95,13 @@ public class CompartmentAlias extends Alias { * @param original * object from which this object is initialized */ - public CompartmentAlias(CompartmentAlias original) { + public Compartment(Compartment original) { super(original); namePoint.setLocation(original.getNamePoint()); thickness = original.thickness; outerWidth = original.outerWidth; innerWidth = original.innerWidth; - for (Alias alias : original.aliases) { + for (Element alias : original.aliases) { addAlias(alias.copy()); } } @@ -106,7 +109,7 @@ public class CompartmentAlias extends Alias { /** * Default constructor. */ - CompartmentAlias() { + Compartment() { super(); namePoint = new Point2D.Double(0, 0); thickness = DEFAULT_COMPARTMENT_THICKNESS; @@ -115,7 +118,7 @@ public class CompartmentAlias extends Alias { setColor(DEFAULT_COLOR); } - public CompartmentAlias(String aliasId) { + public Compartment(String aliasId) { setAliasId(aliasId); } @@ -165,8 +168,8 @@ public class CompartmentAlias extends Alias { * @param aliasToAdd * alias that should be added */ - public void addAlias(Alias aliasToAdd) { - for (Alias alias : aliases) { + public void addAlias(Element aliasToAdd) { + for (Element alias : aliases) { if (alias.getAliasId().equals(aliasToAdd.getAliasId())) { if (alias.equals(aliasToAdd)) { return; @@ -185,12 +188,12 @@ public class CompartmentAlias extends Alias { * * @return list of all aliases in the compartment alias */ - public Set<Alias> getAllSubAliases() { - Set<Alias> result = new HashSet<Alias>(); + public Set<Element> getAllSubAliases() { + Set<Element> result = new HashSet<Element>(); result.addAll(getAliases()); - for (Alias abstractAlias : getAliases()) { - if (abstractAlias instanceof CompartmentAlias) { - result.addAll(((CompartmentAlias) abstractAlias).getAllSubAliases()); + for (Element abstractAlias : getAliases()) { + if (abstractAlias instanceof Compartment) { + result.addAll(((Compartment) abstractAlias).getAllSubAliases()); } } @@ -207,11 +210,11 @@ public class CompartmentAlias extends Alias { * @return true if the alias2 cross this compartment alias, <code>false</code> * otherwise */ - public boolean cross(Alias alias2) { - Set<Alias> parents = new HashSet<Alias>(); + public boolean cross(Element alias2) { + Set<Element> parents = new HashSet<Element>(); // in case of elements in complexes we have to check if the top level // complex cross alias - while (alias2.getParent() != null && alias2.getParent() instanceof ComplexAlias) { + 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()); @@ -239,8 +242,8 @@ public class CompartmentAlias extends Alias { * compartment, <code>false</code> otherwise */ public boolean containsIdenticalSpecies() { - for (Alias innerAlias : aliases) { - if (innerAlias instanceof SpeciesAlias) { + for (Element innerAlias : aliases) { + if (innerAlias instanceof Species) { String name = innerAlias.getName(); if (name.equalsIgnoreCase(getName())) { return true; @@ -255,9 +258,9 @@ public class CompartmentAlias extends Alias { * * @return copy of the object */ - public CompartmentAlias copy() { - if (this.getClass() == CompartmentAlias.class) { - return new CompartmentAlias(this); + public Compartment copy() { + if (this.getClass() == Compartment.class) { + return new Compartment(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } @@ -269,7 +272,7 @@ public class CompartmentAlias extends Alias { * @param alias * object to be removed */ - public void removeAlias(Alias alias) { + public void removeAlias(Element alias) { aliases.remove(alias); if (alias.getCompartmentAlias() != null) { if (alias.getCompartmentAlias() == this) { @@ -296,7 +299,7 @@ public class CompartmentAlias extends Alias { * @param aliases * the aliases to set */ - public void setAliases(Set<Alias> aliases) { + public void setAliases(Set<Element> aliases) { this.aliases = aliases; } @@ -372,7 +375,7 @@ public class CompartmentAlias extends Alias { * @return the aliases * @see #aliases */ - public Set<Alias> getAliases() { + public Set<Element> getAliases() { return aliases; } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/CompartmentAliasComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/compartment/CompartmentComparator.java similarity index 78% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/CompartmentAliasComparator.java rename to model/src/main/java/lcsb/mapviewer/model/map/compartment/CompartmentComparator.java index fc7b054678..2a1769a671 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/CompartmentAliasComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/compartment/CompartmentComparator.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.compartment; import java.util.Comparator; import java.util.HashMap; @@ -11,20 +11,22 @@ import lcsb.mapviewer.common.comparator.DoubleComparator; import lcsb.mapviewer.common.comparator.IntegerComparator; import lcsb.mapviewer.common.comparator.PointComparator; import lcsb.mapviewer.common.exception.InvalidArgumentException; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.ElementComparator; /** * This class implements comparator interface for CompartmentAlias. * * @author Piotr Gawron * - * @see CompartmentAlias + * @see Compartment * */ -public class CompartmentAliasComparator implements Comparator<CompartmentAlias> { +public class CompartmentComparator implements Comparator<Compartment> { /** * Default class logger. */ - private Logger logger = Logger.getLogger(CompartmentAliasComparator.class); + private Logger logger = Logger.getLogger(CompartmentComparator.class); /** * Epsilon value used for comparison of doubles. @@ -37,19 +39,19 @@ public class CompartmentAliasComparator implements Comparator<CompartmentAlias> * @param epsilon * {@link #epsilon} */ - public CompartmentAliasComparator(double epsilon) { + public CompartmentComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public CompartmentAliasComparator() { + public CompartmentComparator() { this(Configuration.EPSILON); } @Override - public int compare(CompartmentAlias arg0, CompartmentAlias arg1) { + public int compare(Compartment arg0, Compartment arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -78,8 +80,8 @@ public class CompartmentAliasComparator implements Comparator<CompartmentAlias> * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(CompartmentAlias arg0, CompartmentAlias arg1) { - AliasComparator aliasComparator = new AliasComparator(epsilon); + private int internalCompare(Compartment arg0, Compartment arg1) { + ElementComparator aliasComparator = new ElementComparator(epsilon); int result = aliasComparator.internalCompare(arg0, arg1); if (result != 0) { return result; @@ -114,25 +116,25 @@ public class CompartmentAliasComparator implements Comparator<CompartmentAlias> return integerComparator.compare(arg0.getAliases().size(), arg1.getAliases().size()); } - Map<String, Alias> map1 = new HashMap<>(); - Map<String, Alias> map2 = new HashMap<>(); + Map<String, Element> map1 = new HashMap<>(); + Map<String, Element> map2 = new HashMap<>(); - for (Alias alias : arg0.getAliases()) { + for (Element alias : arg0.getAliases()) { if (map1.get(alias.getAliasId()) != null) { throw new InvalidArgumentException("Few aliases with the same id: " + alias.getAliasId()); } map1.put(alias.getAliasId(), alias); } - for (Alias alias : arg1.getAliases()) { + for (Element alias : arg1.getAliases()) { if (map2.get(alias.getAliasId()) != null) { throw new InvalidArgumentException("Few aliases with the same id: " + alias.getAliasId()); } map2.put(alias.getAliasId(), alias); } - for (Alias alias : arg0.getAliases()) { - Alias alias2 = map2.get(alias.getAliasId()); + for (Element alias : arg0.getAliases()) { + Element alias2 = map2.get(alias.getAliasId()); int status = aliasComparator.compare(alias, alias2); if (status != 0) { logger.debug("Couldn't match alias: " + alias.getAliasId() + ", " + alias2); diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/LeftSquareCompartmentAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/compartment/LeftSquareCompartment.java similarity index 70% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/LeftSquareCompartmentAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/compartment/LeftSquareCompartment.java index 9a912253a3..8df301320b 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/LeftSquareCompartmentAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/compartment/LeftSquareCompartment.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.compartment; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; @@ -16,7 +16,7 @@ import lcsb.mapviewer.model.map.model.Model; */ @Entity @DiscriminatorValue("Left square Compartment Alias") -public class LeftSquareCompartmentAlias extends CompartmentAlias { +public class LeftSquareCompartment extends Compartment { /** * @@ -26,7 +26,7 @@ public class LeftSquareCompartmentAlias extends CompartmentAlias { /** * Default constructor. */ - public LeftSquareCompartmentAlias() { + public LeftSquareCompartment() { super(); } @@ -40,7 +40,7 @@ public class LeftSquareCompartmentAlias extends CompartmentAlias { * model object to which the alias will be assigned */ - public LeftSquareCompartmentAlias(CompartmentAlias originalAlias, Model model) { + public LeftSquareCompartment(Compartment originalAlias, Model model) { super(originalAlias); setX(0.0); setWidth(model.getWidth() * 2); @@ -55,14 +55,14 @@ public class LeftSquareCompartmentAlias extends CompartmentAlias { * @param originalAlias * orignal alias where the data was kept */ - public LeftSquareCompartmentAlias(LeftSquareCompartmentAlias originalAlias) { + public LeftSquareCompartment(LeftSquareCompartment originalAlias) { super(originalAlias); } @Override - public LeftSquareCompartmentAlias copy() { - if (this.getClass() == LeftSquareCompartmentAlias.class) { - return new LeftSquareCompartmentAlias(this); + public LeftSquareCompartment copy() { + if (this.getClass() == LeftSquareCompartment.class) { + return new LeftSquareCompartment(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/OvalCompartmentAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/compartment/OvalCompartment.java similarity index 67% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/OvalCompartmentAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/compartment/OvalCompartment.java index 4325ceb5fe..23194155a7 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/OvalCompartmentAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/compartment/OvalCompartment.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.compartment; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; @@ -13,7 +13,7 @@ import lcsb.mapviewer.common.exception.NotImplementedException; */ @Entity @DiscriminatorValue("Oval Compartment Alias") -public class OvalCompartmentAlias extends CompartmentAlias { +public class OvalCompartment extends Compartment { /** * @@ -23,7 +23,7 @@ public class OvalCompartmentAlias extends CompartmentAlias { /** * Default constructor. */ - public OvalCompartmentAlias() { + public OvalCompartment() { super(); } @@ -34,14 +34,14 @@ public class OvalCompartmentAlias extends CompartmentAlias { * @param originalAlias * orignal alias where the data was kept */ - public OvalCompartmentAlias(CompartmentAlias originalAlias) { + public OvalCompartment(Compartment originalAlias) { super(originalAlias); } @Override - public OvalCompartmentAlias copy() { - if (this.getClass() == OvalCompartmentAlias.class) { - return new OvalCompartmentAlias(this); + public OvalCompartment copy() { + if (this.getClass() == OvalCompartment.class) { + return new OvalCompartment(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ArtifitialCompartmentAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/compartment/PathwayCompartment.java similarity index 61% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ArtifitialCompartmentAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/compartment/PathwayCompartment.java index 35860cf34a..eec7511320 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ArtifitialCompartmentAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/compartment/PathwayCompartment.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.compartment; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; @@ -13,7 +13,7 @@ import lcsb.mapviewer.common.exception.NotImplementedException; */ @Entity @DiscriminatorValue("Artifitial Compartment Alias") -public class ArtifitialCompartmentAlias extends CompartmentAlias { +public class PathwayCompartment extends Compartment { /** * @@ -23,11 +23,11 @@ public class ArtifitialCompartmentAlias extends CompartmentAlias { /** * Default constructor. */ - public ArtifitialCompartmentAlias() { + public PathwayCompartment() { super(); } - public ArtifitialCompartmentAlias(String aliasId) { + public PathwayCompartment(String aliasId) { super(); setAliasId(aliasId); } @@ -38,14 +38,14 @@ public class ArtifitialCompartmentAlias extends CompartmentAlias { * @param original * data for initialization */ - public ArtifitialCompartmentAlias(ArtifitialCompartmentAlias original) { + public PathwayCompartment(PathwayCompartment original) { super(original); } @Override - public ArtifitialCompartmentAlias copy() { - if (this.getClass() == ArtifitialCompartmentAlias.class) { - return new ArtifitialCompartmentAlias(this); + public PathwayCompartment copy() { + if (this.getClass() == PathwayCompartment.class) { + return new PathwayCompartment(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/RightSquareCompartmentAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/compartment/RightSquareCompartment.java similarity index 75% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/RightSquareCompartmentAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/compartment/RightSquareCompartment.java index 5a8fb6b29f..8dd6a3f653 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/RightSquareCompartmentAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/compartment/RightSquareCompartment.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.compartment; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; @@ -17,7 +17,7 @@ import lcsb.mapviewer.model.map.model.Model; */ @Entity @DiscriminatorValue("Right square Compartment Alias") -public class RightSquareCompartmentAlias extends CompartmentAlias { +public class RightSquareCompartment extends Compartment { /** * */ @@ -27,12 +27,12 @@ public class RightSquareCompartmentAlias extends CompartmentAlias { * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(RightSquareCompartmentAlias.class); + private static Logger logger = Logger.getLogger(RightSquareCompartment.class); /** * Default constructor. */ - public RightSquareCompartmentAlias() { + public RightSquareCompartment() { super(); } @@ -45,7 +45,7 @@ public class RightSquareCompartmentAlias extends CompartmentAlias { * @param model * model object to which the alias will be assigned */ - public RightSquareCompartmentAlias(CompartmentAlias originalAlias, Model model) { + public RightSquareCompartment(Compartment originalAlias, Model model) { super(originalAlias); setX(0.0); setWidth(model.getWidth() * 2); @@ -76,14 +76,14 @@ public class RightSquareCompartmentAlias extends CompartmentAlias { * @param originalAlias * orignal alias where the data was kept */ - public RightSquareCompartmentAlias(RightSquareCompartmentAlias originalAlias) { + public RightSquareCompartment(RightSquareCompartment originalAlias) { super(originalAlias); } @Override - public RightSquareCompartmentAlias copy() { - if (this.getClass() == RightSquareCompartmentAlias.class) { - return new RightSquareCompartmentAlias(this); + public RightSquareCompartment copy() { + if (this.getClass() == RightSquareCompartment.class) { + return new RightSquareCompartment(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/SquareCompartmentAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/compartment/SquareCompartment.java similarity index 64% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/SquareCompartmentAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/compartment/SquareCompartment.java index 6746edf321..d87ba0c760 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/SquareCompartmentAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/compartment/SquareCompartment.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.compartment; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; @@ -13,7 +13,7 @@ import lcsb.mapviewer.common.exception.NotImplementedException; */ @Entity @DiscriminatorValue("Square Compartment Alias") -public class SquareCompartmentAlias extends CompartmentAlias { +public class SquareCompartment extends Compartment { /** * @@ -23,7 +23,7 @@ public class SquareCompartmentAlias extends CompartmentAlias { /** * Default constructor. */ - public SquareCompartmentAlias() { + public SquareCompartment() { super(); } @@ -34,19 +34,19 @@ public class SquareCompartmentAlias extends CompartmentAlias { * @param originalAlias * orignal alias where the data was kept */ - public SquareCompartmentAlias(CompartmentAlias originalAlias) { + public SquareCompartment(Compartment originalAlias) { super(originalAlias); } - public SquareCompartmentAlias(String aliasId) { + public SquareCompartment(String aliasId) { super(); setAliasId(aliasId); } @Override - public SquareCompartmentAlias copy() { - if (this.getClass() == SquareCompartmentAlias.class) { - return new SquareCompartmentAlias(this); + public SquareCompartment copy() { + if (this.getClass() == SquareCompartment.class) { + return new SquareCompartment(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/TopSquareCompartmentAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/compartment/TopSquareCompartment.java similarity index 71% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/TopSquareCompartmentAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/compartment/TopSquareCompartment.java index e73ed77efb..f45c36766a 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/TopSquareCompartmentAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/compartment/TopSquareCompartment.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.compartment; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; @@ -16,7 +16,7 @@ import lcsb.mapviewer.model.map.model.Model; @Entity @DiscriminatorValue("Top square Compartment Alias") -public class TopSquareCompartmentAlias extends CompartmentAlias { +public class TopSquareCompartment extends Compartment { /** * @@ -26,7 +26,7 @@ public class TopSquareCompartmentAlias extends CompartmentAlias { /** * Default constructor. */ - public TopSquareCompartmentAlias() { + public TopSquareCompartment() { super(); } @@ -39,7 +39,7 @@ public class TopSquareCompartmentAlias extends CompartmentAlias { * @param model * model object to which the alias will be assigned */ - public TopSquareCompartmentAlias(CompartmentAlias originalAlias, Model model) { + public TopSquareCompartment(Compartment originalAlias, Model model) { super(originalAlias); setX(0.0); setWidth(model.getWidth() * 2); @@ -54,14 +54,14 @@ public class TopSquareCompartmentAlias extends CompartmentAlias { * @param originalAlias * orignal alias where the data was kept */ - public TopSquareCompartmentAlias(TopSquareCompartmentAlias originalAlias) { + public TopSquareCompartment(TopSquareCompartment originalAlias) { super(originalAlias); } @Override - public TopSquareCompartmentAlias copy() { - if (this.getClass() == TopSquareCompartmentAlias.class) { - return new TopSquareCompartmentAlias(this); + public TopSquareCompartment copy() { + if (this.getClass() == TopSquareCompartment.class) { + return new TopSquareCompartment(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/graph/DataMining.java b/model/src/main/java/lcsb/mapviewer/model/map/graph/DataMining.java index 752fab4ae5..e3d988837b 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/graph/DataMining.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/graph/DataMining.java @@ -20,7 +20,7 @@ import org.hibernate.annotations.CascadeType; import org.hibernate.annotations.IndexColumn; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.Alias; +import lcsb.mapviewer.model.map.species.Element; /** * Entity representing data mining entry. @@ -49,7 +49,7 @@ public class DataMining implements Serializable { * For which element this entry was created. */ @ManyToOne(optional = false) - private Alias element; + private Element element; /** * List of the suggested connection. @@ -163,7 +163,7 @@ public class DataMining implements Serializable { * @return the element * @see #element */ - public Alias getElement() { + public Element getElement() { return element; } @@ -172,7 +172,7 @@ public class DataMining implements Serializable { * the element to set * @see #element */ - public void setElement(Alias element) { + public void setElement(Element element) { this.element = element; } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/BlockDiagram.java b/model/src/main/java/lcsb/mapviewer/model/map/layout/BlockDiagram.java similarity index 82% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/BlockDiagram.java rename to model/src/main/java/lcsb/mapviewer/model/map/layout/BlockDiagram.java index aea48af67b..c2190b9333 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/BlockDiagram.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/layout/BlockDiagram.java @@ -1,19 +1,19 @@ -package lcsb.mapviewer.model.map.layout.alias; - -import java.io.Serializable; - - -/** - * This model element is used by cell designer but don't know how... We ignore it - * - * @author Piotr Gawron - * - */ -public abstract class BlockDiagram implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 1L; - -} +package lcsb.mapviewer.model.map.layout; + +import java.io.Serializable; + + +/** + * This model element is used by cell designer but don't know how... We ignore it + * + * @author Piotr Gawron + * + */ +public abstract class BlockDiagram implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 1L; + +} diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/ColorSchema.java b/model/src/main/java/lcsb/mapviewer/model/map/layout/ColorSchema.java index 0493975e9a..89840fce67 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/ColorSchema.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/layout/ColorSchema.java @@ -8,7 +8,7 @@ import java.util.List; import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; +import lcsb.mapviewer.model.map.species.Element; /** * Entry of coloring schema used for changing colors in the map. It allows to @@ -58,7 +58,7 @@ public abstract class ColorSchema implements Serializable { private static final int MAX_SINGLE_COLOR_VALUE_IN_RGB_FORMAT = 255; /** - * Name of the {@link lcsb.mapviewer.db.model.map.Element Element}. If null + * Name of the {@link Element Element}. If null * then this field will be skiped. */ private String name = null; @@ -86,7 +86,7 @@ public abstract class ColorSchema implements Serializable { /** * What types of element should be identified by this entry. */ - private List<Class<? extends Alias>> types = new ArrayList<>(); + private List<Class<? extends Element>> types = new ArrayList<>(); /** * Value (-1..1 range) that is assigned to filtered elements (it will be @@ -167,8 +167,8 @@ public abstract class ColorSchema implements Serializable { * @param types2 * list of classes to add */ - public void addTypes(List<Class<? extends Alias>> types2) { - for (Class<? extends Alias> clazz : types2) { + public void addTypes(List<Class<? extends Element>> types2) { + for (Class<? extends Element> clazz : types2) { addType(clazz); } } @@ -303,7 +303,7 @@ public abstract class ColorSchema implements Serializable { * @return the types * @see #types */ - public List<Class<? extends Alias>> getTypes() { + public List<Class<? extends Element>> getTypes() { return types; } @@ -312,7 +312,7 @@ public abstract class ColorSchema implements Serializable { * the types to set * @see #types */ - public void setTypes(List<Class<? extends Alias>> types) { + public void setTypes(List<Class<? extends Element>> types) { this.types = types; } @@ -479,7 +479,7 @@ public abstract class ColorSchema implements Serializable { * @param clazz * class to add */ - public void addType(Class<? extends Alias> clazz) { + public void addType(Class<? extends Element> clazz) { this.types.add(clazz); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/AliasGroup.java b/model/src/main/java/lcsb/mapviewer/model/map/layout/ElementGroup.java similarity index 70% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/AliasGroup.java rename to model/src/main/java/lcsb/mapviewer/model/map/layout/ElementGroup.java index 6adc865c07..9a010c87e6 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/AliasGroup.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/layout/ElementGroup.java @@ -1,75 +1,77 @@ -package lcsb.mapviewer.model.map.layout.alias; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -/** - * This model element is used by cell designer but we ignore it. Maybe it will - * be usefull in the future. - * - * @author Piotr Gawron - * - */ -public class AliasGroup implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * String identifier of the group. - */ - private String idGroup; - - /** - * List of aliases in the group. - */ - private List<Alias> aliases = new ArrayList<Alias>(); - - /** - * @return the idGroup - * @see #idGroup - */ - public String getIdGroup() { - return idGroup; - } - - /** - * @param idGroup - * the idGroup to set - * @see #idGroup - */ - public void setIdGroup(String idGroup) { - this.idGroup = idGroup; - } - - /** - * @return the aliases - * @see #aliases - */ - public List<Alias> getAliases() { - return aliases; - } - - /** - * @param aliases - * the aliases to set - * @see #aliases - */ - public void setAliases(List<Alias> aliases) { - this.aliases = aliases; - } - - /** - * Add alias to the group. - * - * @param alias - * object to add to the group - */ - public void addAlias(Alias alias) { - aliases.add(alias); - } - -} +package lcsb.mapviewer.model.map.layout; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import lcsb.mapviewer.model.map.species.Element; + +/** + * This model element is used by cell designer but we ignore it. Maybe it will + * be usefull in the future. + * + * @author Piotr Gawron + * + */ +public class ElementGroup implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * String identifier of the group. + */ + private String idGroup; + + /** + * List of aliases in the group. + */ + private List<Element> aliases = new ArrayList<Element>(); + + /** + * @return the idGroup + * @see #idGroup + */ + public String getIdGroup() { + return idGroup; + } + + /** + * @param idGroup + * the idGroup to set + * @see #idGroup + */ + public void setIdGroup(String idGroup) { + this.idGroup = idGroup; + } + + /** + * @return the aliases + * @see #aliases + */ + public List<Element> getAliases() { + return aliases; + } + + /** + * @param aliases + * the aliases to set + * @see #aliases + */ + public void setAliases(List<Element> aliases) { + this.aliases = aliases; + } + + /** + * Add alias to the group. + * + * @param alias + * object to add to the group + */ + public void addAlias(Element alias) { + aliases.add(alias); + } + +} diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/DegradedAliasComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/DegradedAliasComparator.java deleted file mode 100644 index a13c4e4340..0000000000 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/DegradedAliasComparator.java +++ /dev/null @@ -1,83 +0,0 @@ -package lcsb.mapviewer.model.map.layout.alias; - -import java.util.Comparator; - -import org.apache.log4j.Logger; - -import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.common.exception.NotImplementedException; - -public class DegradedAliasComparator implements Comparator<DegradedAlias> { - - /** - * Default class logger. - */ - @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(DegradedAliasComparator.class); - - /** - * Epsilon value used for comparison of doubles. - */ - private double epsilon; - - /** - * Constructor that requires {@link #epsilon} parameter. - * - * @param epsilon - * {@link #epsilon} - */ - public DegradedAliasComparator(double epsilon) { - this.epsilon = epsilon; - } - - /** - * Default constructor. - */ - public DegradedAliasComparator() { - this(Configuration.EPSILON); - } - - @Override - public int compare(DegradedAlias arg0, DegradedAlias 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(DegradedAlias.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 DegradedAlias - * class in inheritence tree. By the design it calls also comparator of the - * upper (SpeciesAlias) 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(DegradedAlias arg0, DegradedAlias arg1) { - SpeciesAliasComparator speciesAliasComparator = new SpeciesAliasComparator(epsilon); - int result = speciesAliasComparator.internalCompare(arg0, arg1); - if (result != 0) { - return result; - } - return 0; - } -} diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/IonAliasComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/IonAliasComparator.java deleted file mode 100644 index 0372ac214f..0000000000 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/IonAliasComparator.java +++ /dev/null @@ -1,83 +0,0 @@ -package lcsb.mapviewer.model.map.layout.alias; - -import java.util.Comparator; - -import org.apache.log4j.Logger; - -import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.common.exception.NotImplementedException; - -public class IonAliasComparator implements Comparator<IonAlias> { - - /** - * Default class logger. - */ - @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(IonAliasComparator.class); - - /** - * Epsilon value used for comparison of doubles. - */ - private double epsilon; - - /** - * Constructor that requires {@link #epsilon} parameter. - * - * @param epsilon - * {@link #epsilon} - */ - public IonAliasComparator(double epsilon) { - this.epsilon = epsilon; - } - - /** - * Default constructor. - */ - public IonAliasComparator() { - this(Configuration.EPSILON); - } - - @Override - public int compare(IonAlias arg0, IonAlias 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(IonAlias.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 IonAlias} - * class in inheritence tree. By the design it calls also comparator of the - * upper {@link ChemicalAlias} 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(IonAlias arg0, IonAlias arg1) { - ChemicalAliasComparator speciesAliasComparator = new ChemicalAliasComparator(epsilon); - int result = speciesAliasComparator.internalCompare(arg0, arg1); - if (result != 0) { - return result; - } - return 0; - } -} diff --git a/model/src/main/java/lcsb/mapviewer/model/map/model/AliasSubmodelConnection.java b/model/src/main/java/lcsb/mapviewer/model/map/model/AliasSubmodelConnection.java index d328f9153f..bad3304df1 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/model/AliasSubmodelConnection.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/model/AliasSubmodelConnection.java @@ -7,7 +7,7 @@ import javax.persistence.Entity; import javax.persistence.ManyToOne; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.Alias; +import lcsb.mapviewer.model.map.species.Element; /** * This class defines connection between alias and submap (submodel). This means @@ -29,14 +29,14 @@ public class AliasSubmodelConnection extends SubmodelConnection implements Seria * From which alias this connection start. */ @ManyToOne - private Alias fromAlias; + private Element fromAlias; /** * This object defines reference element in submodel that represents central * (or identical) object in reference submodel. */ @ManyToOne - private Alias toAlias; + private Element toAlias; /** * Default constructor that initialize some fields. @@ -99,7 +99,7 @@ public class AliasSubmodelConnection extends SubmodelConnection implements Seria * @return the fromAlias * @see #fromAlias */ - public Alias getFromAlias() { + public Element getFromAlias() { return fromAlias; } @@ -108,7 +108,7 @@ public class AliasSubmodelConnection extends SubmodelConnection implements Seria * the fromAlias to set * @see #fromAlias */ - public void setFromAlias(Alias fromAlias) { + public void setFromAlias(Element fromAlias) { this.fromAlias = fromAlias; } @@ -116,7 +116,7 @@ public class AliasSubmodelConnection extends SubmodelConnection implements Seria * @return the toAlias * @see #toAlias */ - public Alias getToAlias() { + public Element getToAlias() { return toAlias; } @@ -125,7 +125,7 @@ public class AliasSubmodelConnection extends SubmodelConnection implements Seria * the toAlias to set * @see #toAlias */ - public void setToAlias(Alias toAlias) { + public void setToAlias(Element toAlias) { this.toAlias = toAlias; } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/model/AliasSubmodelConnectionComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/model/AliasSubmodelConnectionComparator.java index dd0ac692bf..5db1a1da5b 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/model/AliasSubmodelConnectionComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/model/AliasSubmodelConnectionComparator.java @@ -1,112 +1,112 @@ -package lcsb.mapviewer.model.map.model; - -import java.util.Comparator; - -import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.AliasComparator; - -import org.apache.log4j.Logger; - -/** - * This class implements comparator interface for {@link AliasSubmodelConnection}. - * - * @author Piotr Gawron - * - */ -public class AliasSubmodelConnectionComparator implements Comparator<AliasSubmodelConnection> { - /** - * Default class logger. - */ - private static Logger logger = Logger.getLogger(AliasSubmodelConnectionComparator.class); - - /** - * Epsilon value used for comparison of doubles. - */ - private double epsilon; - - /** - * Constructor that requires {@link #epsilon} parameter. - * - * @param epsilon - * {@link #epsilon} - */ - public AliasSubmodelConnectionComparator(double epsilon) { - this.epsilon = epsilon; - } - - /** - * Default constructor. - */ - public AliasSubmodelConnectionComparator() { - this(Configuration.EPSILON); - } - - @Override - public int compare(AliasSubmodelConnection arg0, AliasSubmodelConnection 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 { - logger.debug("class different: " + arg0.getClass() + ", " + arg1.getClass()); - return -1; - } - } - - /** - * This method compares only the fields that are defined in - * {@link AliasSubmodelConnection} class in inheritence tree. It also calls - * the {@link SubmodelConnectionComparator} for the super class ( - * {@link SubmodelConnection}). - * - * @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(AliasSubmodelConnection arg0, AliasSubmodelConnection arg1) { - SubmodelConnectionComparator superComparator = new SubmodelConnectionComparator(epsilon); - - int result = superComparator.internalCompare(arg0, arg1); - if (result != 0) { - return result; - } - AliasComparator aliasComparator = new AliasComparator(epsilon); - Alias alias1 = arg0.getFromAlias(); - Alias alias2 = arg1.getFromAlias(); - arg0.setFromAlias(null); - arg1.setFromAlias(null); - int status = aliasComparator.compare(alias1, alias2); - arg0.setFromAlias(alias1); - arg1.setFromAlias(alias2); - if (status != 0) { - logger.debug("from alias different: " + arg0.getFromAlias() + ", " + arg1.getFromAlias()); - return status; - } - alias1 = arg0.getToAlias(); - alias2 = arg1.getToAlias(); - arg0.setToAlias(null); - arg1.setToAlias(null); - status = aliasComparator.compare(alias1, alias2); - arg0.setToAlias(alias1); - arg1.setToAlias(alias2); - if (status != 0) { - logger.debug("to alias different: " + arg0.getToAlias() + ", " + arg1.getToAlias()); - return status; - } - - return 0; - } - -} +package lcsb.mapviewer.model.map.model; + +import java.util.Comparator; + +import lcsb.mapviewer.common.Configuration; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.ElementComparator; + +import org.apache.log4j.Logger; + +/** + * This class implements comparator interface for {@link AliasSubmodelConnection}. + * + * @author Piotr Gawron + * + */ +public class AliasSubmodelConnectionComparator implements Comparator<AliasSubmodelConnection> { + /** + * Default class logger. + */ + private static Logger logger = Logger.getLogger(AliasSubmodelConnectionComparator.class); + + /** + * Epsilon value used for comparison of doubles. + */ + private double epsilon; + + /** + * Constructor that requires {@link #epsilon} parameter. + * + * @param epsilon + * {@link #epsilon} + */ + public AliasSubmodelConnectionComparator(double epsilon) { + this.epsilon = epsilon; + } + + /** + * Default constructor. + */ + public AliasSubmodelConnectionComparator() { + this(Configuration.EPSILON); + } + + @Override + public int compare(AliasSubmodelConnection arg0, AliasSubmodelConnection 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 { + logger.debug("class different: " + arg0.getClass() + ", " + arg1.getClass()); + return -1; + } + } + + /** + * This method compares only the fields that are defined in + * {@link AliasSubmodelConnection} class in inheritence tree. It also calls + * the {@link SubmodelConnectionComparator} for the super class ( + * {@link SubmodelConnection}). + * + * @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(AliasSubmodelConnection arg0, AliasSubmodelConnection arg1) { + SubmodelConnectionComparator superComparator = new SubmodelConnectionComparator(epsilon); + + int result = superComparator.internalCompare(arg0, arg1); + if (result != 0) { + return result; + } + ElementComparator aliasComparator = new ElementComparator(epsilon); + Element alias1 = arg0.getFromAlias(); + Element alias2 = arg1.getFromAlias(); + arg0.setFromAlias(null); + arg1.setFromAlias(null); + int status = aliasComparator.compare(alias1, alias2); + arg0.setFromAlias(alias1); + arg1.setFromAlias(alias2); + if (status != 0) { + logger.debug("from alias different: " + arg0.getFromAlias() + ", " + arg1.getFromAlias()); + return status; + } + alias1 = arg0.getToAlias(); + alias2 = arg1.getToAlias(); + arg0.setToAlias(null); + arg1.setToAlias(null); + status = aliasComparator.compare(alias1, alias2); + arg0.setToAlias(alias1); + arg1.setToAlias(alias2); + if (status != 0) { + logger.debug("to alias different: " + arg0.getToAlias() + ", " + arg1.getToAlias()); + return status; + } + + return 0; + } + +} 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 f26bed4f32..25d9a36416 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 @@ -12,16 +12,16 @@ import lcsb.mapviewer.model.Project; import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.OverviewImage; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.graph.DataMiningSet; +import lcsb.mapviewer.model.map.layout.BlockDiagram; +import lcsb.mapviewer.model.map.layout.ElementGroup; import lcsb.mapviewer.model.map.layout.Layout; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.AliasGroup; -import lcsb.mapviewer.model.map.layout.alias.BlockDiagram; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; 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.Species; /** * This interface defines functionality that the model container class should @@ -52,7 +52,7 @@ public interface Model { * @param alias * alias to add */ - void addAlias(Alias alias); + void addAlias(Element alias); /** * Returns map model version. @@ -118,16 +118,16 @@ public interface Model { * * @return set of all alisaes */ - Set<Alias> getAliases(); + Set<Element> getAliases(); /** - * Returns alias with the given alias identfier ({@link Alias#aliasId}). + * Returns alias with the given alias identfier ({@link Element#aliasId}). * * @param idAlias * alias identifier * @return alias with the given id */ - <T extends Alias> T getAliasByAliasId(String idAlias); + <T extends Element> T getAliasByAliasId(String idAlias); /** * Adds reaction to the model. @@ -148,16 +148,16 @@ public interface Model { * Returns compartment alias with the given alias id. * * @param id - * compartment alias identifier ({@link Alias#aliasId}) + * compartment alias identifier ({@link Element#aliasId}) * @return compartment alias with the given compartment alias id */ - CompartmentAlias getCompartmentAliasByCompartmentAliasId(String id); + Compartment getCompartmentAliasByCompartmentAliasId(String id); /** * @return list of compartment aliases */ - List<CompartmentAlias> getCompartmentsAliases(); + List<Compartment> getCompartmentsAliases(); /** * Adds layer to the model. @@ -179,7 +179,7 @@ public interface Model { * @param aliases * list of aliases */ - void addAliases(List<? extends Alias> aliases); + void addAliases(List<? extends Element> aliases); /** * Sets new short description of the model. @@ -213,12 +213,12 @@ public interface Model { void addLayers(Collection<Layer> layers); /** - * Adds {@link AliasGroup} to the model. + * Adds {@link ElementGroup} to the model. * * @param aliasGroup * object to add */ - void addAliasGroup(AliasGroup aliasGroup); + void addAliasGroup(ElementGroup aliasGroup); /** * Adds {@link BlockDiagram} to the model. @@ -317,7 +317,7 @@ public interface Model { * @param alias * alias to remove */ - void removeAlias(Alias alias); + void removeAlias(Element alias); /** * Returns list of reactions sorted by reaction id. @@ -331,23 +331,23 @@ public interface Model { * * @return list of aliases sorted by the size */ - List<Alias> getSortedAliases(); + List<Element> getSortedAliases(); /** * Returns collection of species aliases (excluding complexes). * * @return collection of species aliases */ - Collection<SpeciesAlias> getNotComplexSpeciesAliases(); + Collection<Species> getNotComplexSpeciesAliases(); - List<SpeciesAlias> getSpeciesAliases(); + List<Species> getSpeciesAliases(); /** * Returns collection of complex aliases. * * @return collection of complex aliases */ - Collection<ComplexAlias> getComplexAliases(); + Collection<Complex> getComplexAliases(); /** * Adds reactions to model. @@ -366,7 +366,7 @@ public interface Model { */ Set<AnnotatedObject> getElementsByAnnotation(MiriamData miriamData); - List<Alias> getAliasByName(String name); + List<Element> getAliasByName(String name); /** * @@ -420,10 +420,10 @@ public interface Model { * Returns alias for given database identifier. * * @param dbId - * alias database identifier ({@link Alias#id}) + * alias database identifier ({@link Element#id}) * @return alias for a given id */ - Alias getAliasByDbId(Integer dbId); + Element getAliasByDbId(Integer dbId); /** * Returns reaction for given database identifier. @@ -439,14 +439,14 @@ public interface Model { * * @return list of aliases sorted by size */ - List<CompartmentAlias> getSortedCompartmentsAliases(); + List<Compartment> getSortedCompartmentsAliases(); /** * Returns list of aliases sorted by the size. * * @return list of aliases sorted by the size */ - List<Alias> getAliasesSortedBySize(); + List<Element> getAliasesSortedBySize(); /** * @@ -466,7 +466,7 @@ public interface Model { * @param aliases * new {@link ModelData#aliases} collection */ - void setAliases(Set<Alias> aliases); + void setAliases(Set<Element> aliases); /** * @return the modelData @@ -657,7 +657,7 @@ public interface Model { /** * Return list od all {@link AnnotatedObject} in the map. This includes all - * {@link Reaction reactions} and {@link Alias elements}. + * {@link Reaction reactions} and {@link Element elements}. * * @return list od all {@link AnnotatedObject} in the map */ 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 7eba1e40b5..eea5155dd2 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 @@ -19,12 +19,12 @@ import lcsb.mapviewer.model.map.OverviewImageComparator; import lcsb.mapviewer.model.map.graph.DataMiningSetComparator; import lcsb.mapviewer.model.map.layout.Layout; import lcsb.mapviewer.model.map.layout.LayoutComparator; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.AliasComparator; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.layout.graphics.LayerComparator; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.ReactionComparator; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.ElementComparator; /** * Comparator for {@link Model} class. @@ -344,26 +344,26 @@ public class ModelComparator implements Comparator<Model> { * @return if sets are equal then returns 0. If they are different then -1/1 * is returned. */ - private int compareAliases(Set<Alias> aliases, Set<Alias> aliases2) { - AliasComparator aliasComparator = new AliasComparator(epsilon); + private int compareAliases(Set<Element> aliases, Set<Element> aliases2) { + ElementComparator aliasComparator = new ElementComparator(epsilon); - Map<String, Alias> map1 = new HashMap<String, Alias>(); - Map<String, Alias> map2 = new HashMap<String, Alias>(); + Map<String, Element> map1 = new HashMap<String, Element>(); + Map<String, Element> map2 = new HashMap<String, Element>(); if (aliases.size() != aliases2.size()) { logger.debug("Number of aliases different: " + aliases.size() + ", " + aliases2.size()); return ((Integer) aliases.size()).compareTo(aliases2.size()); } - for (Alias alias : aliases) { + for (Element alias : aliases) { map1.put(alias.getAliasId(), alias); } - for (Alias alias : aliases2) { + for (Element alias : aliases2) { map2.put(alias.getAliasId(), alias); } - for (Alias alias : aliases) { + for (Element alias : aliases) { int status = aliasComparator.compare(alias, map2.get(alias.getAliasId())); if (status != 0) { logger.debug("Alias doesn't have a match: " + alias.getAliasId() + ", " + map2.get(alias.getAliasId())); @@ -371,7 +371,7 @@ public class ModelComparator implements Comparator<Model> { } } - for (Alias alias : aliases2) { + for (Element alias : aliases2) { int status = aliasComparator.compare(alias, map1.get(alias.getAliasId())); if (status != 0) { logger.debug("Alias doesn't have a match: " + alias.getAliasId() + ", " + map2.get(alias.getAliasId())); 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 6041b05312..b6b0124492 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 @@ -29,12 +29,12 @@ import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.Project; import lcsb.mapviewer.model.map.OverviewImage; import lcsb.mapviewer.model.map.graph.DataMiningSet; +import lcsb.mapviewer.model.map.layout.BlockDiagram; +import lcsb.mapviewer.model.map.layout.ElementGroup; import lcsb.mapviewer.model.map.layout.Layout; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.AliasGroup; -import lcsb.mapviewer.model.map.layout.alias.BlockDiagram; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; /** * Representation of the model data. It contains all information about single @@ -69,11 +69,11 @@ public class ModelData implements Serializable { /** * Set of all aliases in the map. * - * @see Alias + * @see Element */ @Cascade({ CascadeType.ALL }) @OneToMany(mappedBy = "model", orphanRemoval = true) - private Set<Alias> aliases = new HashSet<Alias>(); + private Set<Element> aliases = new HashSet<Element>(); /** * Set of all layers in the map. @@ -235,7 +235,7 @@ public class ModelData implements Serializable { * @param al * alias to add */ - public void addAlias(Alias al) { + public void addAlias(Element al) { al.setModelData(this); aliases.add(al); } @@ -263,13 +263,13 @@ public class ModelData implements Serializable { } /** - * Adds collection of {@link Alias aliases} to model data. + * Adds collection of {@link Element aliases} to model data. * * @param aliases * aliases to add */ - public void addAliases(List<? extends Alias> aliases) { - for (Alias alias : aliases) { + public void addAliases(List<? extends Element> aliases) { + for (Element alias : aliases) { addAlias(alias); } } @@ -296,7 +296,7 @@ public class ModelData implements Serializable { * @param aliases * new {@link #aliases} collection */ - public void setAliases(Set<Alias> aliases) { + public void setAliases(Set<Element> aliases) { this.aliases = aliases; } @@ -426,12 +426,12 @@ public class ModelData implements Serializable { } /** - * Adds {@link AliasGroup} to the model data. + * Adds {@link ElementGroup} to the model data. * * @param aliasGroup * object to add */ - public void addAliasGroup(AliasGroup aliasGroup) { + public void addAliasGroup(ElementGroup aliasGroup) { // for now we ignore this information } @@ -451,7 +451,7 @@ public class ModelData implements Serializable { * @param alias * alias to remove */ - public void removeAlias(Alias alias) { + public void removeAlias(Element alias) { if (alias == null) { throw new InvalidArgumentException("Cannot remove null"); } @@ -637,7 +637,7 @@ public class ModelData implements Serializable { * @return the aliases * @see #aliases */ - public Set<Alias> getAliases() { + public Set<Element> getAliases() { return aliases; } 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 f94a26e612..fbace68fe2 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 @@ -21,16 +21,16 @@ import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.OverviewImage; import lcsb.mapviewer.model.map.OverviewImageLink; import lcsb.mapviewer.model.map.OverviewLink; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.graph.DataMiningSet; +import lcsb.mapviewer.model.map.layout.BlockDiagram; +import lcsb.mapviewer.model.map.layout.ElementGroup; import lcsb.mapviewer.model.map.layout.Layout; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.AliasGroup; -import lcsb.mapviewer.model.map.layout.alias.BlockDiagram; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; 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.Species; /** * This class implemets {@link Model} interface. It's is very simple @@ -48,15 +48,15 @@ public class ModelFullIndexed implements Model { private static Logger logger = Logger.getLogger(ModelFullIndexed.class); /** - * Object that map {@link Alias#aliasId alias identifier} into {@link Alias}. + * Object that map {@link Element#aliasId alias identifier} into {@link Element}. */ - private Map<String, Alias> aliasByAliasId = new HashMap<String, Alias>(); + private Map<String, Element> aliasByAliasId = new HashMap<String, Element>(); /** - * Object that map {@link Alias#id alias database identifier} into - * {@link Alias}. + * Object that map {@link Element#id alias database identifier} into + * {@link Element}. */ - private Map<Integer, Alias> aliasByDbId = new HashMap<Integer, Alias>(); + private Map<Integer, Element> aliasByDbId = new HashMap<Integer, Element>(); /** * Object that map {@link Reaction#idReaction reaction identifier} into @@ -86,7 +86,7 @@ public class ModelFullIndexed implements Model { this.modelData = new ModelData(); } else { this.modelData = model; - for (Alias alias : model.getAliases()) { + for (Element alias : model.getAliases()) { aliasByAliasId.put(alias.getAliasId(), alias); aliasByDbId.put(alias.getId(), alias); } @@ -114,29 +114,29 @@ public class ModelFullIndexed implements Model { } @Override - public void addAlias(Alias alias) { - if (alias instanceof SpeciesAlias) { - addSpeciesAlias((SpeciesAlias) alias); - } else if (alias instanceof CompartmentAlias) { - addCompartmentAlias((CompartmentAlias) alias); + public void addAlias(Element alias) { + if (alias instanceof Species) { + addSpeciesAlias((Species) alias); + } else if (alias instanceof Compartment) { + addCompartmentAlias((Compartment) alias); } else { throw new InvalidArgumentException("Unknown type of alias: " + alias); } } /** - * Adds {@link SpeciesAlias} to the model. + * Adds {@link Species} to the model. * * @param al * alias to add */ - private void addSpeciesAlias(SpeciesAlias al) { + private void addSpeciesAlias(Species al) { if (al.getAliasId() == null || al.getAliasId().isEmpty()) { throw new InvalidArgumentException("Alias identifier cannot be empty"); } modelData.addAlias(al); - Alias alias2 = aliasByAliasId.get(al.getAliasId()); + Element alias2 = aliasByAliasId.get(al.getAliasId()); if (alias2 == null) { aliasByAliasId.put(al.getAliasId(), al); aliasByDbId.put(al.getId(), al); @@ -186,13 +186,14 @@ public class ModelFullIndexed implements Model { } @Override - public Set<Alias> getAliases() { + public Set<Element> getAliases() { return modelData.getAliases(); } + @SuppressWarnings("unchecked") @Override - public Alias getAliasByAliasId(String idAlias) { - return aliasByAliasId.get(idAlias); + public <T extends Element> T getAliasByAliasId(String idAlias) { + return (T) aliasByAliasId.get(idAlias); } @Override @@ -213,9 +214,9 @@ public class ModelFullIndexed implements Model { * @param al * alias to add */ - private void addCompartmentAlias(CompartmentAlias al) { + private void addCompartmentAlias(Compartment al) { modelData.addAlias(al); - Alias alias2 = aliasByAliasId.get(al.getAliasId()); + Element alias2 = aliasByAliasId.get(al.getAliasId()); if (alias2 == null) { aliasByAliasId.put(al.getAliasId(), al); aliasByDbId.put(al.getId(), al); @@ -225,16 +226,16 @@ public class ModelFullIndexed implements Model { } @Override - public CompartmentAlias getCompartmentAliasByCompartmentAliasId(String id) { - return (CompartmentAlias) aliasByAliasId.get(id); + public Compartment getCompartmentAliasByCompartmentAliasId(String id) { + return (Compartment) aliasByAliasId.get(id); } @Override - public List<CompartmentAlias> getCompartmentsAliases() { - List<CompartmentAlias> result = new ArrayList<CompartmentAlias>(); - for (Alias alias : modelData.getAliases()) { - if (alias instanceof CompartmentAlias) { - result.add((CompartmentAlias) alias); + public List<Compartment> getCompartmentsAliases() { + List<Compartment> result = new ArrayList<Compartment>(); + for (Element alias : modelData.getAliases()) { + if (alias instanceof Compartment) { + result.add((Compartment) alias); } } return result; @@ -251,8 +252,8 @@ public class ModelFullIndexed implements Model { } @Override - public void addAliases(List<? extends Alias> aliases) { - for (Alias alias : aliases) { + public void addAliases(List<? extends Element> aliases) { + for (Element alias : aliases) { addAlias(alias); } } @@ -271,7 +272,7 @@ public class ModelFullIndexed implements Model { } @Override - public void setAliases(Set<Alias> aliases) { + public void setAliases(Set<Element> aliases) { this.modelData.setAliases(aliases); } @@ -291,17 +292,17 @@ public class ModelFullIndexed implements Model { } @Override - public List<Alias> getAliasesSortedBySize() { - List<Alias> sortedAliases = new ArrayList<Alias>(); + public List<Element> getAliasesSortedBySize() { + List<Element> sortedAliases = new ArrayList<Element>(); sortedAliases.addAll(getAliases()); - Collections.sort(sortedAliases, Alias.SIZE_COMPARATOR); + Collections.sort(sortedAliases, Element.SIZE_COMPARATOR); return sortedAliases; } @Override - public List<CompartmentAlias> getSortedCompartmentsAliases() { - List<CompartmentAlias> result = getCompartmentsAliases(); - Collections.sort(result, Alias.SIZE_COMPARATOR); + public List<Compartment> getSortedCompartmentsAliases() { + List<Compartment> result = getCompartmentsAliases(); + Collections.sort(result, Element.SIZE_COMPARATOR); return result; } @@ -311,7 +312,7 @@ public class ModelFullIndexed implements Model { } @Override - public Alias getAliasByDbId(Integer dbId) { + public Element getAliasByDbId(Integer dbId) { return aliasByDbId.get(dbId); } @@ -353,7 +354,7 @@ public class ModelFullIndexed implements Model { @Override public Set<AnnotatedObject> getElementsByAnnotation(MiriamData miriamData) { Set<AnnotatedObject> result = new HashSet<AnnotatedObject>(); - for (Alias alias : getAliases()) { + for (Element alias : getAliases()) { for (MiriamData md : alias.getMiriamData()) { if (md.equals(miriamData)) { result.add(alias); @@ -380,22 +381,22 @@ public class ModelFullIndexed implements Model { } @Override - public Collection<ComplexAlias> getComplexAliases() { - List<ComplexAlias> result = new ArrayList<ComplexAlias>(); - for (Alias alias : modelData.getAliases()) { - if (alias instanceof ComplexAlias) { - result.add((ComplexAlias) alias); + public Collection<Complex> getComplexAliases() { + List<Complex> result = new ArrayList<Complex>(); + for (Element alias : modelData.getAliases()) { + if (alias instanceof Complex) { + result.add((Complex) alias); } } return result; } @Override - public Collection<SpeciesAlias> getNotComplexSpeciesAliases() { - List<SpeciesAlias> result = new ArrayList<SpeciesAlias>(); - for (Alias alias : modelData.getAliases()) { - if (alias instanceof SpeciesAlias && !(alias instanceof ComplexAlias)) { - result.add((SpeciesAlias) alias); + public Collection<Species> getNotComplexSpeciesAliases() { + List<Species> result = new ArrayList<Species>(); + for (Element alias : modelData.getAliases()) { + if (alias instanceof Species && !(alias instanceof Complex)) { + result.add((Species) alias); } } return result; @@ -409,10 +410,10 @@ public class ModelFullIndexed implements Model { } @Override - public List<Alias> getSortedAliases() { - List<Alias> result = new ArrayList<Alias>(); + public List<Element> getSortedAliases() { + List<Element> result = new ArrayList<Element>(); result.addAll(getAliases()); - Collections.sort(result, Alias.SIZE_COMPARATOR); + Collections.sort(result, Element.SIZE_COMPARATOR); return result; } @@ -435,7 +436,7 @@ public class ModelFullIndexed implements Model { } @Override - public void addAliasGroup(AliasGroup aliasGroup) { + public void addAliasGroup(ElementGroup aliasGroup) { modelData.addAliasGroup(aliasGroup); } @@ -445,32 +446,32 @@ public class ModelFullIndexed implements Model { } @Override - public void removeAlias(Alias alias) { + public void removeAlias(Element alias) { modelData.removeAlias(alias); aliasByAliasId.remove(alias.getAliasId()); aliasByDbId.remove(alias.getId()); if (alias.getParent() != null) { - if (alias.getParent() instanceof CompartmentAlias) { - CompartmentAlias ca = (CompartmentAlias) alias.getParent(); + if (alias.getParent() instanceof Compartment) { + Compartment ca = (Compartment) alias.getParent(); ca.removeAlias(alias); - } else if (alias.getParent() instanceof ComplexAlias) { - ComplexAlias ca = (ComplexAlias) alias.getParent(); - ca.removeAlias((SpeciesAlias) alias); + } else if (alias.getParent() instanceof Complex) { + Complex ca = (Complex) alias.getParent(); + ca.removeAlias((Species) alias); } else { throw new InvalidArgumentException("Unknown type of alias parent: " + alias.getParent().getClass().getName()); } } if (alias.getCompartmentAlias() != null) { - CompartmentAlias ca = alias.getCompartmentAlias(); + Compartment ca = alias.getCompartmentAlias(); ca.removeAlias(alias); } - if (alias instanceof SpeciesAlias) { - SpeciesAlias al = (SpeciesAlias) alias; + if (alias instanceof Species) { + Species al = (Species) alias; if (al.getComplexAlias() != null) { - ComplexAlias ca = ((SpeciesAlias) alias).getComplexAlias(); + Complex ca = ((Species) alias).getComplexAlias(); ca.removeAlias(al); } } @@ -757,9 +758,9 @@ public class ModelFullIndexed implements Model { } @Override - public List<Alias> getAliasByName(String name) { - List<Alias> result = new ArrayList<>(); - for (Alias element : getAliases()) { + public List<Element> getAliasByName(String name) { + List<Element> result = new ArrayList<>(); + for (Element element : getAliases()) { if (element.getName().equalsIgnoreCase(name)) { result.add(element); } @@ -768,11 +769,11 @@ public class ModelFullIndexed implements Model { } @Override - public List<SpeciesAlias> getSpeciesAliases() { - List<SpeciesAlias> result = new ArrayList<SpeciesAlias>(); - for (Alias alias : modelData.getAliases()) { - if (alias instanceof SpeciesAlias) { - result.add((SpeciesAlias) alias); + public List<Species> getSpeciesAliases() { + List<Species> result = new ArrayList<Species>(); + for (Element alias : modelData.getAliases()) { + if (alias instanceof Species) { + result.add((Species) alias); } } return result; diff --git a/model/src/main/java/lcsb/mapviewer/model/map/modifier/Catalysis.java b/model/src/main/java/lcsb/mapviewer/model/map/modifier/Catalysis.java index 616e6fa843..5d7b8bd08c 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/modifier/Catalysis.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/modifier/Catalysis.java @@ -4,8 +4,8 @@ import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.reaction.Modifier; +import lcsb.mapviewer.model.map.species.Species; /** * This class defines catalysis modifier in the reaction. @@ -35,7 +35,7 @@ public class Catalysis extends Modifier { * @param alias * alias object to which this modifiar is assigned */ - public Catalysis(SpeciesAlias alias) { + public Catalysis(Species alias) { super(alias); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/modifier/Inhibition.java b/model/src/main/java/lcsb/mapviewer/model/map/modifier/Inhibition.java index d6e36305cc..e38d9682b1 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/modifier/Inhibition.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/modifier/Inhibition.java @@ -4,8 +4,8 @@ import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.reaction.Modifier; +import lcsb.mapviewer.model.map.species.Species; /** * This class defines inhibition modifier in the reaction. @@ -35,7 +35,7 @@ public class Inhibition extends Modifier { * @param alias * alias object to which this modifiar is assigned */ - public Inhibition(SpeciesAlias alias) { + public Inhibition(Species alias) { super(alias); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/modifier/Modulation.java b/model/src/main/java/lcsb/mapviewer/model/map/modifier/Modulation.java index 7a5d19d33a..5c9c4001eb 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/modifier/Modulation.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/modifier/Modulation.java @@ -4,8 +4,8 @@ import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.reaction.Modifier; +import lcsb.mapviewer.model.map.species.Species; /** * This class defines modulation modifier in the reaction. @@ -35,7 +35,7 @@ public class Modulation extends Modifier { * @param alias * alias object to which this modifiar is assigned */ - public Modulation(SpeciesAlias alias) { + public Modulation(Species alias) { super(alias); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/modifier/PhysicalStimulation.java b/model/src/main/java/lcsb/mapviewer/model/map/modifier/PhysicalStimulation.java index 187bc27cb0..24458c841f 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/modifier/PhysicalStimulation.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/modifier/PhysicalStimulation.java @@ -4,8 +4,8 @@ import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.reaction.Modifier; +import lcsb.mapviewer.model.map.species.Species; /** * This class defines physical stimulation modifier in the reaction. @@ -36,7 +36,7 @@ public class PhysicalStimulation extends Modifier { * @param alias * alias object to which this modifiar is assigned */ - public PhysicalStimulation(SpeciesAlias alias) { + public PhysicalStimulation(Species alias) { super(alias); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/modifier/Trigger.java b/model/src/main/java/lcsb/mapviewer/model/map/modifier/Trigger.java index 877a6d7147..f90175e634 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/modifier/Trigger.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/modifier/Trigger.java @@ -4,8 +4,8 @@ import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.reaction.Modifier; +import lcsb.mapviewer.model.map.species.Species; /** * This class defines trigger modifier in the reaction. @@ -35,7 +35,7 @@ public class Trigger extends Modifier { * @param alias * alias object to which this modifiar is assigned */ - public Trigger(SpeciesAlias alias) { + public Trigger(Species alias) { super(alias); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/modifier/UnknownCatalysis.java b/model/src/main/java/lcsb/mapviewer/model/map/modifier/UnknownCatalysis.java index 3e2b0d8fb4..cf6f506ea3 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/modifier/UnknownCatalysis.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/modifier/UnknownCatalysis.java @@ -4,8 +4,8 @@ import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.reaction.Modifier; +import lcsb.mapviewer.model.map.species.Species; /** * This class defines unknown catalysis modifier in the reaction. @@ -36,7 +36,7 @@ public class UnknownCatalysis extends Modifier { * @param alias * alias object to which this modifiar is assigned */ - public UnknownCatalysis(SpeciesAlias alias) { + public UnknownCatalysis(Species alias) { super(alias); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/modifier/UnknownInhibition.java b/model/src/main/java/lcsb/mapviewer/model/map/modifier/UnknownInhibition.java index 511ebf6877..7bfde19c0c 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/modifier/UnknownInhibition.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/modifier/UnknownInhibition.java @@ -4,8 +4,8 @@ import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.reaction.Modifier; +import lcsb.mapviewer.model.map.species.Species; /** * This class defines unknown inhibition modifier in the reaction. @@ -36,7 +36,7 @@ public class UnknownInhibition extends Modifier { * @param alias * alias object to which this modifiar is assigned */ - public UnknownInhibition(SpeciesAlias alias) { + public UnknownInhibition(Species alias) { super(alias); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/reaction/Modifier.java b/model/src/main/java/lcsb/mapviewer/model/map/reaction/Modifier.java index f61570b290..cda54b65e2 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/reaction/Modifier.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/reaction/Modifier.java @@ -4,7 +4,7 @@ import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Species; /** * Represents modifier (ie. catalyst) in the {@link Reaction}. It is an @@ -30,7 +30,7 @@ public class Modifier extends ReactionNode { } /** - * Constructor that creates modifier for given {@link SpeciesAlias}. These + * Constructor that creates modifier for given {@link Species}. These * elements reference to the objects in the * {@link lcsb.mapviewer.model.map.model.db.model.map.Model Model} that * represents this modifier. @@ -38,7 +38,7 @@ public class Modifier extends ReactionNode { * @param alias * alias that represent this modifier */ - public Modifier(SpeciesAlias alias) { + public Modifier(Species alias) { super(alias); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/reaction/Product.java b/model/src/main/java/lcsb/mapviewer/model/map/reaction/Product.java index 2e7c9dbbd1..9fa4bd9850 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/reaction/Product.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/reaction/Product.java @@ -4,7 +4,7 @@ import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Species; /** * Represents product of the reaction (in the reaction). @@ -29,7 +29,7 @@ public class Product extends ReactionNode { } /** - * Constructor that creates product for given {@link SpeciesAlias}. These + * Constructor that creates product for given {@link Species}. These * elements reference to the objects in the * {@link lcsb.mapviewer.model.map.model.db.model.map.Model Model} that * represents this product. @@ -37,7 +37,7 @@ public class Product extends ReactionNode { * @param alias * alias that represent this product */ - public Product(SpeciesAlias alias) { + public Product(Species alias) { super(alias); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/reaction/Reactant.java b/model/src/main/java/lcsb/mapviewer/model/map/reaction/Reactant.java index f553d769f5..1fbd827ef7 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/reaction/Reactant.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/reaction/Reactant.java @@ -4,7 +4,7 @@ import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Species; /** * Represents reactant of the reaction. @@ -29,7 +29,7 @@ public class Reactant extends ReactionNode { } /** - * Constructor that creates reactant for a given {@link SpeciesAlias}. These + * Constructor that creates reactant for a given {@link Species}. These * elements reference to the objects in the * {@link lcsb.mapviewer.model.map.model.db.model.map.Model Model} that * represents this reactant. @@ -37,7 +37,7 @@ public class Reactant extends ReactionNode { * @param alias * alias that represent this reactant */ - public Reactant(SpeciesAlias alias) { + public Reactant(Species alias) { super(alias); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/reaction/Reaction.java b/model/src/main/java/lcsb/mapviewer/model/map/reaction/Reaction.java index 16fa2d5e4c..8b89218bf3 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/reaction/Reaction.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/reaction/Reaction.java @@ -40,12 +40,12 @@ import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.common.geometry.LineTransformation; import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelData; import lcsb.mapviewer.model.map.reaction.type.ReactionRect; import lcsb.mapviewer.model.map.reaction.type.TwoProductReactionInterface; import lcsb.mapviewer.model.map.reaction.type.TwoReactantReactionInterface; +import lcsb.mapviewer.model.map.species.Element; /** * This class describes reaction in the {@link Model}. Every reaction consists @@ -521,7 +521,7 @@ public class Reaction implements AnnotatedObject { * @return <code>true</code> if element is part of the reaction, * <code>false</code> otherwise */ - public boolean containsElement(Alias alias) { + public boolean containsElement(Element alias) { for (ReactionNode node : getReactionNodes()) { if (node.getAlias().equals(alias)) { return true; diff --git a/model/src/main/java/lcsb/mapviewer/model/map/reaction/ReactionNode.java b/model/src/main/java/lcsb/mapviewer/model/map/reaction/ReactionNode.java index 23643d2030..6ed59c1df0 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/reaction/ReactionNode.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/reaction/ReactionNode.java @@ -4,7 +4,7 @@ import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.ManyToOne; -import lcsb.mapviewer.model.map.layout.alias.Alias; +import lcsb.mapviewer.model.map.species.Element; /** * One of two known types of nodes in the {@link Reaction}. It defines input or @@ -34,7 +34,7 @@ public abstract class ReactionNode extends AbstractNode { * {@link SpecisAlias} that represents this node in the model. */ @ManyToOne - private Alias alias; + private Element alias; /** * Default constructor. @@ -59,9 +59,9 @@ public abstract class ReactionNode extends AbstractNode { * . * * @param alias - * {@link Alias} to which this node refer to + * {@link Element} to which this node refer to */ - public ReactionNode(Alias alias) { + public ReactionNode(Element alias) { this.alias = alias; } @@ -69,7 +69,7 @@ public abstract class ReactionNode extends AbstractNode { * @return the alias * @see #alias */ - public Alias getAlias() { + public Element getAlias() { return alias; } @@ -78,7 +78,7 @@ public abstract class ReactionNode extends AbstractNode { * the alias to set * @see #alias */ - public void setAlias(Alias alias) { + public void setAlias(Element alias) { this.alias = alias; } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/reaction/ReactionNodeComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/reaction/ReactionNodeComparator.java index 1efc5fba81..0e2d008e73 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/reaction/ReactionNodeComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/reaction/ReactionNodeComparator.java @@ -5,7 +5,7 @@ import java.util.Comparator; import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.model.map.layout.alias.AliasComparator; +import lcsb.mapviewer.model.map.species.ElementComparator; /** * This class implements comparator interface for {@link ReactionNode}. It also @@ -77,7 +77,7 @@ public class ReactionNodeComparator implements Comparator<ReactionNode> { */ private int internalCompare(ReactionNode arg0, ReactionNode arg1) { AbstractNodeComparator anComparator = new AbstractNodeComparator(epsilon); - AliasComparator aliasComparator = new AliasComparator(epsilon); + ElementComparator aliasComparator = new ElementComparator(epsilon); int result = anComparator.internalCompare(arg0, arg1); if (result != 0) { diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/AntisenseRnaAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRna.java similarity index 59% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/AntisenseRnaAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRna.java index 3f918eac7b..6910928f81 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/AntisenseRnaAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRna.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.ArrayList; import java.util.List; @@ -13,10 +13,11 @@ import org.hibernate.annotations.LazyCollection; import org.hibernate.annotations.LazyCollectionOption; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion; @Entity @DiscriminatorValue("ANTISENSE_RNA_ALIAS") -public class AntisenseRnaAlias extends SpeciesAlias { +public class AntisenseRna extends Species { /** * @@ -26,31 +27,31 @@ public class AntisenseRnaAlias extends SpeciesAlias { @Cascade({ CascadeType.ALL }) @OneToMany(mappedBy = "species") @LazyCollection(LazyCollectionOption.FALSE) - private List<AntisenseRnaRegionAlias> regions = new ArrayList<>(); + private List<AntisenseRnaRegion> regions = new ArrayList<>(); - AntisenseRnaAlias() { + AntisenseRna() { } - public AntisenseRnaAlias(AntisenseRnaAlias original) { + public AntisenseRna(AntisenseRna original) { super(original); - for (AntisenseRnaRegionAlias region : original.getRegions()) { - addRegion(new AntisenseRnaRegionAlias(region)); + for (AntisenseRnaRegion region : original.getRegions()) { + addRegion(new AntisenseRnaRegion(region)); } } - public void addRegion(AntisenseRnaRegionAlias antisenseRnaRegionAlias) { + public void addRegion(AntisenseRnaRegion antisenseRnaRegionAlias) { regions.add(antisenseRnaRegionAlias); antisenseRnaRegionAlias.setSpecies(this); } - public AntisenseRnaAlias(String aliasId) { + public AntisenseRna(String aliasId) { setAliasId(aliasId); } @Override - public AntisenseRnaAlias copy() { - if (this.getClass() == AntisenseRnaAlias.class) { - return new AntisenseRnaAlias(this); + public AntisenseRna copy() { + if (this.getClass() == AntisenseRna.class) { + return new AntisenseRna(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } @@ -60,7 +61,7 @@ public class AntisenseRnaAlias extends SpeciesAlias { * @return the regions * @see #regions */ - public List<AntisenseRnaRegionAlias> getRegions() { + public List<AntisenseRnaRegion> getRegions() { return regions; } @@ -69,7 +70,7 @@ public class AntisenseRnaAlias extends SpeciesAlias { * the regions to set * @see #regions */ - public void setRegions(List<AntisenseRnaRegionAlias> regions) { + public void setRegions(List<AntisenseRnaRegion> regions) { this.regions = regions; } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/AntisenseRnaAliasComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparator.java similarity index 68% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/AntisenseRnaAliasComparator.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparator.java index 5cdf02b8f7..3929ee6149 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/AntisenseRnaAliasComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparator.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.Comparator; @@ -7,13 +7,13 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; -public class AntisenseRnaAliasComparator implements Comparator<AntisenseRnaAlias> { +public class AntisenseRnaComparator implements Comparator<AntisenseRna> { /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(AntisenseRnaAliasComparator.class); + private static Logger logger = Logger.getLogger(AntisenseRnaComparator.class); /** * Epsilon value used for comparison of doubles. @@ -26,19 +26,19 @@ public class AntisenseRnaAliasComparator implements Comparator<AntisenseRnaAlias * @param epsilon * {@link #epsilon} */ - public AntisenseRnaAliasComparator(double epsilon) { + public AntisenseRnaComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public AntisenseRnaAliasComparator() { + public AntisenseRnaComparator() { this(Configuration.EPSILON); } @Override - public int compare(AntisenseRnaAlias arg0, AntisenseRnaAlias arg1) { + public int compare(AntisenseRna arg0, AntisenseRna arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -50,7 +50,7 @@ public class AntisenseRnaAliasComparator implements Comparator<AntisenseRnaAlias } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(AntisenseRnaAlias.class)) { + if (arg0.getClass().equals(AntisenseRna.class)) { return internalCompare(arg0, arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); @@ -72,8 +72,8 @@ public class AntisenseRnaAliasComparator implements Comparator<AntisenseRnaAlias * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(AntisenseRnaAlias arg0, AntisenseRnaAlias arg1) { - SpeciesAliasComparator speciesAliasComparator = new SpeciesAliasComparator(epsilon); + private int internalCompare(AntisenseRna arg0, AntisenseRna arg1) { + SpeciesComparator speciesAliasComparator = new SpeciesComparator(epsilon); int result = speciesAliasComparator.internalCompare(arg0, arg1); if (result != 0) { return result; diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ChemicalAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Chemical.java similarity index 86% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ChemicalAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/Chemical.java index b9a0c730c2..72703817ac 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ChemicalAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Chemical.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import javax.persistence.Column; import javax.persistence.DiscriminatorValue; @@ -6,7 +6,7 @@ import javax.persistence.Entity; @Entity @DiscriminatorValue("CHEMICAL_ALIAS") -public abstract class ChemicalAlias extends SpeciesAlias { +public abstract class Chemical extends Species { /** * @@ -37,10 +37,10 @@ public abstract class ChemicalAlias extends SpeciesAlias { private String inChIKey; - ChemicalAlias() { + Chemical() { } - public ChemicalAlias(ChemicalAlias original) { + public Chemical(Chemical original) { super(original); smiles = original.getSmiles(); inChI = original.getInChI(); diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ChemicalAliasComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/ChemicalComparator.java similarity index 59% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ChemicalAliasComparator.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/ChemicalComparator.java index 469e355951..4b9cba9976 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ChemicalAliasComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/ChemicalComparator.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.Comparator; @@ -7,21 +7,21 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; -public class ChemicalAliasComparator implements Comparator<ChemicalAlias> { +public class ChemicalComparator implements Comparator<Chemical> { /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(ChemicalAliasComparator.class); + private static Logger logger = Logger.getLogger(ChemicalComparator.class); /** * Epsilon value used for comparison of doubles. */ private double epsilon; - private IonAliasComparator ionAliasComparator; - private SimpleMoleculeAliasComparator simpleMoleculeAliasComparator; + private IonComparator ionAliasComparator; + private SimpleMoleculeComparator simpleMoleculeAliasComparator; /** * Constructor that requires {@link #epsilon} parameter. @@ -29,21 +29,21 @@ public class ChemicalAliasComparator implements Comparator<ChemicalAlias> { * @param epsilon * {@link #epsilon} */ - public ChemicalAliasComparator(double epsilon) { + public ChemicalComparator(double epsilon) { this.epsilon = epsilon; - ionAliasComparator = new IonAliasComparator(epsilon); - simpleMoleculeAliasComparator = new SimpleMoleculeAliasComparator(epsilon); + ionAliasComparator = new IonComparator(epsilon); + simpleMoleculeAliasComparator = new SimpleMoleculeComparator(epsilon); } /** * Default constructor. */ - public ChemicalAliasComparator() { + public ChemicalComparator() { this(Configuration.EPSILON); } @Override - public int compare(ChemicalAlias arg0, ChemicalAlias arg1) { + public int compare(Chemical arg0, Chemical arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -55,12 +55,12 @@ public class ChemicalAliasComparator implements Comparator<ChemicalAlias> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(ChemicalAlias.class)) { + if (arg0.getClass().equals(Chemical.class)) { return internalCompare(arg0, arg1); - } else if (arg0.getClass().equals(IonAlias.class)) { - return ionAliasComparator.compare((IonAlias) arg0, (IonAlias) arg1); - } else if (arg0.getClass().equals(SimpleMoleculeAlias.class)) { - return simpleMoleculeAliasComparator.compare((SimpleMoleculeAlias) arg0, (SimpleMoleculeAlias) arg1); + } else if (arg0.getClass().equals(Ion.class)) { + return ionAliasComparator.compare((Ion) arg0, (Ion) arg1); + } else if (arg0.getClass().equals(SimpleMolecule.class)) { + return simpleMoleculeAliasComparator.compare((SimpleMolecule) arg0, (SimpleMolecule) arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); } @@ -81,8 +81,8 @@ public class ChemicalAliasComparator implements Comparator<ChemicalAlias> { * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - int internalCompare(ChemicalAlias arg0, ChemicalAlias arg1) { - SpeciesAliasComparator speciesAliasComparator = new SpeciesAliasComparator(epsilon); + int internalCompare(Chemical arg0, Chemical arg1) { + SpeciesComparator speciesAliasComparator = new SpeciesComparator(epsilon); int result = speciesAliasComparator.internalCompare(arg0, arg1); if (result != 0) { return result; diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ComplexAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Complex.java similarity index 70% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ComplexAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/Complex.java index 74437c1dfd..0a1fffc9bd 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ComplexAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Complex.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.ArrayList; import java.util.HashSet; @@ -24,7 +24,7 @@ import lcsb.mapviewer.common.exception.NotImplementedException; */ @Entity @DiscriminatorValue("Complex Species Alias") -public class ComplexAlias extends SpeciesAlias { +public class Complex extends Species { /** * @@ -34,7 +34,7 @@ public class ComplexAlias extends SpeciesAlias { /** * Default class logger. */ - private static Logger logger = Logger.getLogger(ComplexAlias.class); + private static Logger logger = Logger.getLogger(Complex.class); /** * List of aliases that are in this complex alias (only aliases that lies @@ -42,7 +42,7 @@ public class ComplexAlias extends SpeciesAlias { */ @Cascade({ CascadeType.ALL }) @OneToMany(fetch = FetchType.EAGER, mappedBy = "complexAlias") - private List<SpeciesAlias> aliases = new ArrayList<>(); + private List<Species> aliases = new ArrayList<>(); /** * State of the complex species. @@ -52,7 +52,7 @@ public class ComplexAlias extends SpeciesAlias { /** * Default constructor. */ - ComplexAlias() { + Complex() { super(); } @@ -63,10 +63,10 @@ public class ComplexAlias extends SpeciesAlias { * @param original * original alias used for initialization */ - public ComplexAlias(ComplexAlias original) { + public Complex(Complex original) { super(original); - for (SpeciesAlias alias : original.getAliases()) { + for (Species alias : original.getAliases()) { addAlias(alias.copy()); } this.structuralState = original.getStructuralState(); @@ -78,7 +78,7 @@ public class ComplexAlias extends SpeciesAlias { * @param aliasId * identifier of the alias */ - public ComplexAlias(String aliasId) { + public Complex(String aliasId) { super(aliasId); } @@ -88,9 +88,9 @@ public class ComplexAlias extends SpeciesAlias { * @param alias * object to add */ - public void addAlias(SpeciesAlias alias) { + public void addAlias(Species alias) { boolean contains = false; - for (SpeciesAlias alias2 : aliases) { + for (Species alias2 : aliases) { if (alias.getAliasId().equals(alias2.getAliasId())) { contains = true; } @@ -107,7 +107,7 @@ public class ComplexAlias extends SpeciesAlias { * * @return list of aliases insied complexAlias. */ - public List<SpeciesAlias> getAliases() { + public List<Species> getAliases() { return aliases; } @@ -117,21 +117,21 @@ public class ComplexAlias extends SpeciesAlias { * * @return list of all aliases insied complex alias. */ - public List<SpeciesAlias> getAllChildrenAliases() { - List<SpeciesAlias> result = new ArrayList<SpeciesAlias>(); + public List<Species> getAllChildrenAliases() { + List<Species> result = new ArrayList<Species>(); result.addAll(aliases); - for (SpeciesAlias speciesAlias : aliases) { - if (speciesAlias instanceof ComplexAlias) { - result.addAll(((ComplexAlias) speciesAlias).getAllChildrenAliases()); + for (Species speciesAlias : aliases) { + if (speciesAlias instanceof Complex) { + result.addAll(((Complex) speciesAlias).getAllChildrenAliases()); } } return result; } @Override - public ComplexAlias copy() { - if (this.getClass() == ComplexAlias.class) { - return new ComplexAlias(this); + public Complex copy() { + if (this.getClass() == Complex.class) { + return new Complex(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } @@ -144,7 +144,7 @@ public class ComplexAlias extends SpeciesAlias { * @param alias * object to remove */ - public void removeAlias(SpeciesAlias alias) { + public void removeAlias(Species alias) { aliases.remove(alias); if (alias.getComplexAlias() != null) { if (alias.getComplexAlias() == this) { @@ -172,11 +172,11 @@ public class ComplexAlias extends SpeciesAlias { this.structuralState = structuralState; } - public Set<SpeciesAlias> getAllSimpleChildren() { - Set<SpeciesAlias> result = new HashSet<>(); - for (SpeciesAlias element : getAliases()) { - if (element instanceof ComplexAlias) { - result.addAll(((ComplexAlias) element).getAllSimpleChildren()); + public Set<Species> getAllSimpleChildren() { + Set<Species> result = new HashSet<>(); + for (Species element : getAliases()) { + if (element instanceof Complex) { + result.addAll(((Complex) element).getAllSimpleChildren()); } else { result.add(element); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ComplexAliasComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/ComplexComparator.java similarity index 71% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ComplexAliasComparator.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/ComplexComparator.java index b34faa1276..844f08650a 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ComplexAliasComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/ComplexComparator.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.Comparator; import java.util.HashMap; @@ -17,11 +17,11 @@ import lcsb.mapviewer.common.exception.NotImplementedException; * @author Piotr Gawron * */ -public class ComplexAliasComparator implements Comparator<ComplexAlias> { +public class ComplexComparator implements Comparator<Complex> { /** * Default class logger. */ - private static Logger logger = Logger.getLogger(ComplexAliasComparator.class); + private static Logger logger = Logger.getLogger(ComplexComparator.class); /** * Epsilon value used for comparison of doubles. @@ -34,19 +34,19 @@ public class ComplexAliasComparator implements Comparator<ComplexAlias> { * @param epsilon * {@link #epsilon} */ - public ComplexAliasComparator(double epsilon) { + public ComplexComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public ComplexAliasComparator() { + public ComplexComparator() { this(Configuration.EPSILON); } @Override - public int compare(ComplexAlias arg0, ComplexAlias arg1) { + public int compare(Complex arg0, Complex arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -58,7 +58,7 @@ public class ComplexAliasComparator implements Comparator<ComplexAlias> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(ComplexAlias.class)) { + if (arg0.getClass().equals(Complex.class)) { return internalCompare(arg0, arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); @@ -80,9 +80,9 @@ public class ComplexAliasComparator implements Comparator<ComplexAlias> { * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(ComplexAlias arg0, ComplexAlias arg1) { - SpeciesAliasComparator speciesAliasComparator = new SpeciesAliasComparator(epsilon); - AliasComparator aliasComparator = new AliasComparator(epsilon); + private int internalCompare(Complex arg0, Complex arg1) { + SpeciesComparator speciesAliasComparator = new SpeciesComparator(epsilon); + ElementComparator aliasComparator = new ElementComparator(epsilon); int result = speciesAliasComparator.internalCompare(arg0, arg1); if (result != 0) { return result; @@ -95,12 +95,12 @@ public class ComplexAliasComparator implements Comparator<ComplexAlias> { return integerComparator.compare(arg0.getAliases().size(), arg1.getAliases().size()); } - Map<String, Alias> map1 = new HashMap<>(); - Map<String, Alias> map2 = new HashMap<>(); + Map<String, Element> map1 = new HashMap<>(); + Map<String, Element> map2 = new HashMap<>(); - for (Alias alias : arg0.getAliases()) { + for (Element alias : arg0.getAliases()) { if (map1.get(alias.getAliasId()) != null) { - for (Alias alias2 : arg0.getAliases()) { + for (Element alias2 : arg0.getAliases()) { logger.debug(alias2.getAliasId()); } throw new InvalidArgumentException("Few aliases with the same id: " + alias.getAliasId()); @@ -108,15 +108,15 @@ public class ComplexAliasComparator implements Comparator<ComplexAlias> { map1.put(alias.getAliasId(), alias); } - for (Alias alias : arg1.getAliases()) { + for (Element alias : arg1.getAliases()) { if (map2.get(alias.getAliasId()) != null) { throw new InvalidArgumentException("Few aliases with the same id: " + alias.getAliasId()); } map2.put(alias.getAliasId(), alias); } - for (Alias alias : arg0.getAliases()) { - Alias alias2 = map2.get(alias.getAliasId()); + for (Element alias : arg0.getAliases()) { + Element alias2 = map2.get(alias.getAliasId()); int status = aliasComparator.compare(alias, alias2); if (status != 0) { logger.debug("child doesn't have a match: " + alias.getAliasId()); diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/DegradedAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Degraded.java similarity index 59% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/DegradedAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/Degraded.java index d3dd2cc51a..790b82fe0e 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/DegradedAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Degraded.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; @@ -7,27 +7,27 @@ import lcsb.mapviewer.common.exception.NotImplementedException; @Entity @DiscriminatorValue("DEGRADED_ALIAS") -public class DegradedAlias extends SpeciesAlias { +public class Degraded extends Species { /** * */ private static final long serialVersionUID = 1L; - DegradedAlias() { + Degraded() { } - public DegradedAlias(DegradedAlias original) { + public Degraded(Degraded original) { super(original); } - public DegradedAlias(String aliasId) { + public Degraded(String aliasId) { super.setAliasId(aliasId); } @Override - public DegradedAlias copy() { - if (this.getClass() == DegradedAlias.class) { - return new DegradedAlias(this); + public Degraded copy() { + if (this.getClass() == Degraded.class) { + return new Degraded(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/DegradedComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/DegradedComparator.java similarity index 71% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/DegradedComparator.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/DegradedComparator.java index c59ba6e2b4..7f16484bd8 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/DegradedComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/DegradedComparator.java @@ -1,23 +1,24 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.model.map.species; 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 Degraded. - * - * @author Piotr Gawron - * - * @see Degraded - */ public class DegradedComparator implements Comparator<Degraded> { + + /** + * Default class logger. + */ + @SuppressWarnings("unused") + private static Logger logger = Logger.getLogger(DegradedComparator.class); /** * Epsilon value used for comparison of doubles. */ - private double epsilon; + private double epsilon; /** * Constructor that requires {@link #epsilon} parameter. @@ -60,8 +61,9 @@ public class DegradedComparator implements Comparator<Degraded> { } /** - * This method compares only the fields that are defined in Degraded class in - * inheritence tree. It also calls the comparator for super class (Species). + * This method compares only the fields that are defined in DegradedAlias + * class in inheritence tree. By the design it calls also comparator of the + * upper (SpeciesAlias) class. * * @param arg0 * first object to compare @@ -71,12 +73,11 @@ public class DegradedComparator implements Comparator<Degraded> { * -1/1 is returned. */ private int internalCompare(Degraded arg0, Degraded arg1) { - SpeciesComparator speciesComparator = new SpeciesComparator(epsilon); - int result = speciesComparator.internalCompare(arg0, arg1); + SpeciesComparator speciesAliasComparator = new SpeciesComparator(epsilon); + int result = speciesAliasComparator.internalCompare(arg0, arg1); if (result != 0) { return result; } - return 0; } } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/DrugAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Drug.java similarity index 60% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/DrugAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/Drug.java index 094acaecf4..1cfa4f2d2d 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/DrugAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Drug.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; @@ -7,27 +7,27 @@ import lcsb.mapviewer.common.exception.NotImplementedException; @Entity @DiscriminatorValue("DRUG_ALIAS") -public class DrugAlias extends SpeciesAlias { +public class Drug extends Species { /** * */ private static final long serialVersionUID = 1L; - DrugAlias() { + Drug() { } - public DrugAlias(DrugAlias original) { + public Drug(Drug original) { super(original); } - public DrugAlias(String aliasId) { + public Drug(String aliasId) { setAliasId(aliasId); } @Override - public DrugAlias copy() { - if (this.getClass() == DrugAlias.class) { - return new DrugAlias(this); + public Drug copy() { + if (this.getClass() == Drug.class) { + return new Drug(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/DrugAliasComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/DrugComparator.java similarity index 70% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/DrugAliasComparator.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/DrugComparator.java index bd512689ee..cc33157ba8 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/DrugAliasComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/DrugComparator.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.Comparator; @@ -7,13 +7,13 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; -public class DrugAliasComparator implements Comparator<DrugAlias> { +public class DrugComparator implements Comparator<Drug> { /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(DrugAliasComparator.class); + private static Logger logger = Logger.getLogger(DrugComparator.class); /** * Epsilon value used for comparison of doubles. @@ -26,19 +26,19 @@ public class DrugAliasComparator implements Comparator<DrugAlias> { * @param epsilon * {@link #epsilon} */ - public DrugAliasComparator(double epsilon) { + public DrugComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public DrugAliasComparator() { + public DrugComparator() { this(Configuration.EPSILON); } @Override - public int compare(DrugAlias arg0, DrugAlias arg1) { + public int compare(Drug arg0, Drug arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -50,7 +50,7 @@ public class DrugAliasComparator implements Comparator<DrugAlias> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(DrugAlias.class)) { + if (arg0.getClass().equals(Drug.class)) { return internalCompare(arg0, arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); @@ -72,8 +72,8 @@ public class DrugAliasComparator implements Comparator<DrugAlias> { * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(DrugAlias arg0, DrugAlias arg1) { - SpeciesAliasComparator speciesAliasComparator = new SpeciesAliasComparator(epsilon); + private int internalCompare(Drug arg0, Drug arg1) { + SpeciesComparator speciesAliasComparator = new SpeciesComparator(epsilon); int result = speciesAliasComparator.internalCompare(arg0, arg1); if (result != 0) { return result; diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/Alias.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Element.java similarity index 96% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/Alias.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/Element.java index b2addc67b6..949081c1b2 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/Alias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Element.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.awt.Color; import java.awt.geom.Point2D; @@ -40,6 +40,8 @@ import org.hibernate.annotations.IndexColumn; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; +import lcsb.mapviewer.model.map.SearchIndex; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.layout.graphics.LayerText; import lcsb.mapviewer.model.map.model.AliasSubmodelConnection; import lcsb.mapviewer.model.map.model.Model; @@ -60,7 +62,7 @@ import lcsb.mapviewer.model.map.model.ModelData; @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "alias_type_db", discriminatorType = DiscriminatorType.STRING) @DiscriminatorValue("GENERIC_ALIAS") -public abstract class Alias implements AnnotatedObject, Serializable { +public abstract class Element implements AnnotatedObject, Serializable { /** * @@ -81,9 +83,9 @@ public abstract class Alias implements AnnotatedObject, Serializable { * Comparator of aliases that takes into consideration size (width*height) of * aliases. */ - public static final Comparator<Alias> SIZE_COMPARATOR = new Comparator<Alias>() { + public static final Comparator<Element> SIZE_COMPARATOR = new Comparator<Element>() { @Override - public int compare(Alias alias1, Alias alias2) { + public int compare(Element alias1, Element alias2) { double size = alias1.getWidth() * alias1.getHeight(); double size2 = alias2.getWidth() * alias2.getHeight(); @@ -100,7 +102,7 @@ public abstract class Alias implements AnnotatedObject, Serializable { /** * Default class logger. */ - private static Logger logger = Logger.getLogger(Alias.class); + private static Logger logger = Logger.getLogger(Element.class); /** * Database identifier. @@ -119,7 +121,7 @@ public abstract class Alias implements AnnotatedObject, Serializable { */ @Cascade({ CascadeType.ALL }) @ManyToOne - private Alias parent; + private Element parent; /** * Map model object to which alias belongs to. @@ -138,7 +140,7 @@ public abstract class Alias implements AnnotatedObject, Serializable { * compartment then null value is assigned. */ @ManyToOne - private CompartmentAlias compartmentAlias; + private Compartment compartmentAlias; /** * Unique string alias identifier within one model object (usually importet @@ -272,7 +274,7 @@ public abstract class Alias implements AnnotatedObject, Serializable { * @param param * source alias */ - protected Alias(Alias param) { + protected Element(Element param) { aliasId = param.getAliasId(); x = param.getX(); y = param.getY(); @@ -308,7 +310,7 @@ public abstract class Alias implements AnnotatedObject, Serializable { /** * Default constructor. */ - protected Alias() { + protected Element() { super(); aliasId = ""; x = 0.0; @@ -510,8 +512,8 @@ public abstract class Alias implements AnnotatedObject, Serializable { * object to be checked * @return true if alias2 lies in this object, false otherwise */ - public boolean contains(Alias alias2) { - if (alias2 instanceof SpeciesAlias) { + public boolean contains(Element alias2) { + if (alias2 instanceof Species) { Point2D p1 = new Point2D.Double(alias2.getX(), alias2.getY()); Point2D p2 = new Point2D.Double(alias2.getX(), alias2.getY() + alias2.getHeight()); Point2D p3 = new Point2D.Double(alias2.getX() + alias2.getWidth(), alias2.getY()); @@ -529,7 +531,7 @@ public abstract class Alias implements AnnotatedObject, Serializable { * * @return copy of the alias */ - public abstract Alias copy(); + public abstract Element copy(); /** * @@ -640,7 +642,7 @@ public abstract class Alias implements AnnotatedObject, Serializable { * @return the parent * @see #parent */ - public Alias getParent() { + public Element getParent() { return parent; } @@ -649,7 +651,7 @@ public abstract class Alias implements AnnotatedObject, Serializable { * the parent to set * @see #parent */ - public void setParent(Alias parent) { + public void setParent(Element parent) { this.parent = parent; } @@ -708,7 +710,7 @@ public abstract class Alias implements AnnotatedObject, Serializable { * @return the compartmentAlias * @see #compartmentAlias */ - public CompartmentAlias getCompartmentAlias() { + public Compartment getCompartmentAlias() { return compartmentAlias; } @@ -717,7 +719,7 @@ public abstract class Alias implements AnnotatedObject, Serializable { * the compartmentAlias to set * @see #compartmentAlias */ - public void setCompartmentAlias(CompartmentAlias compartmentAlias) { + public void setCompartmentAlias(Compartment compartmentAlias) { this.compartmentAlias = compartmentAlias; } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/AliasComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/ElementComparator.java similarity index 86% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/AliasComparator.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/ElementComparator.java index 6f479bbe47..382f342c6c 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/AliasComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/ElementComparator.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.Comparator; import java.util.HashSet; @@ -14,6 +14,8 @@ import lcsb.mapviewer.common.comparator.StringListComparator; import lcsb.mapviewer.common.comparator.StringSetComparator; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.MiriamData; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.compartment.CompartmentComparator; import lcsb.mapviewer.model.map.model.AliasSubmodelConnectionComparator; /** @@ -23,11 +25,11 @@ import lcsb.mapviewer.model.map.model.AliasSubmodelConnectionComparator; * @author Piotr Gawron * */ -public class AliasComparator implements Comparator<Alias> { +public class ElementComparator implements Comparator<Element> { /** * Default class logger. */ - private static Logger logger = Logger.getLogger(AliasComparator.class); + private static Logger logger = Logger.getLogger(ElementComparator.class); /** * Epsilon value used for comparison of doubles. @@ -40,19 +42,19 @@ public class AliasComparator implements Comparator<Alias> { * @param epsilon * {@link #epsilon} */ - public AliasComparator(double epsilon) { + public ElementComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public AliasComparator() { + public ElementComparator() { this(Configuration.EPSILON); } @Override - public int compare(Alias arg0, Alias arg1) { + public int compare(Element arg0, Element arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -64,15 +66,15 @@ public class AliasComparator implements Comparator<Alias> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0 instanceof ComplexAlias) { - ComplexAliasComparator caComparator = new ComplexAliasComparator(epsilon); - return caComparator.compare((ComplexAlias) arg0, (ComplexAlias) arg1); - } else if (arg0 instanceof CompartmentAlias) { - CompartmentAliasComparator caComparator = new CompartmentAliasComparator(epsilon); - return caComparator.compare((CompartmentAlias) arg0, (CompartmentAlias) arg1); - } else if (arg0 instanceof SpeciesAlias) { - SpeciesAliasComparator caComparator = new SpeciesAliasComparator(epsilon); - return caComparator.compare((SpeciesAlias) arg0, (SpeciesAlias) arg1); + if (arg0 instanceof Complex) { + ComplexComparator caComparator = new ComplexComparator(epsilon); + return caComparator.compare((Complex) arg0, (Complex) arg1); + } else if (arg0 instanceof Compartment) { + CompartmentComparator caComparator = new CompartmentComparator(epsilon); + return caComparator.compare((Compartment) arg0, (Compartment) arg1); + } else if (arg0 instanceof Species) { + SpeciesComparator caComparator = new SpeciesComparator(epsilon); + return caComparator.compare((Species) arg0, (Species) arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); } @@ -93,7 +95,7 @@ public class AliasComparator implements Comparator<Alias> { * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - public int internalCompare(Alias arg0, Alias arg1) { + public int internalCompare(Element arg0, Element arg1) { StringComparator stringComparator = new StringComparator(); IntegerComparator integerComparator = new IntegerComparator(); DoubleComparator doubleComparator = new DoubleComparator(epsilon); diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/GeneAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Gene.java similarity index 62% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/GeneAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/Gene.java index fc4f77e53e..12b015a77b 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/GeneAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Gene.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.ArrayList; import java.util.List; @@ -13,10 +13,11 @@ import org.hibernate.annotations.LazyCollection; import org.hibernate.annotations.LazyCollectionOption; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; @Entity @DiscriminatorValue("GENE_ALIAS") -public class GeneAlias extends SpeciesAlias { +public class Gene extends Species { /** * @@ -29,32 +30,32 @@ public class GeneAlias extends SpeciesAlias { @Cascade({ CascadeType.ALL }) @OneToMany(mappedBy = "species", orphanRemoval = true) @LazyCollection(LazyCollectionOption.FALSE) - private List<ModificationResidueAlias> modificationResidues = new ArrayList<>(); + private List<ModificationResidue> modificationResidues = new ArrayList<>(); - GeneAlias() { + Gene() { } - public GeneAlias(GeneAlias original) { + public Gene(Gene original) { super(original); - for (ModificationResidueAlias mr : original.getModificationResidues()) { - addModificationResidue(new ModificationResidueAlias(mr)); + for (ModificationResidue mr : original.getModificationResidues()) { + addModificationResidue(new ModificationResidue(mr)); } } - public void addModificationResidue(ModificationResidueAlias modificationResidue) { + public void addModificationResidue(ModificationResidue modificationResidue) { modificationResidues.add(modificationResidue); modificationResidue.setSpecies(this); } - public GeneAlias(String aliasId) { + public Gene(String aliasId) { setAliasId(aliasId); } @Override - public GeneAlias copy() { - if (this.getClass() == GeneAlias.class) { - return new GeneAlias(this); + public Gene copy() { + if (this.getClass() == Gene.class) { + return new Gene(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } @@ -64,7 +65,7 @@ public class GeneAlias extends SpeciesAlias { * @return the modificationResidues * @see #modificationResidues */ - public List<ModificationResidueAlias> getModificationResidues() { + public List<ModificationResidue> getModificationResidues() { return modificationResidues; } @@ -73,7 +74,7 @@ public class GeneAlias extends SpeciesAlias { * the modificationResidues to set * @see #modificationResidues */ - public void setModificationResidues(List<ModificationResidueAlias> modificationResidues) { + public void setModificationResidues(List<ModificationResidue> modificationResidues) { this.modificationResidues = modificationResidues; } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/GeneAliasComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/GeneComparator.java similarity index 70% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/GeneAliasComparator.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/GeneComparator.java index 111f52eee1..0481515dbf 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/GeneAliasComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/GeneComparator.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.Comparator; @@ -7,13 +7,13 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; -public class GeneAliasComparator implements Comparator<GeneAlias> { +public class GeneComparator implements Comparator<Gene> { /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(GeneAliasComparator.class); + private static Logger logger = Logger.getLogger(GeneComparator.class); /** * Epsilon value used for comparison of doubles. @@ -26,19 +26,19 @@ public class GeneAliasComparator implements Comparator<GeneAlias> { * @param epsilon * {@link #epsilon} */ - public GeneAliasComparator(double epsilon) { + public GeneComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public GeneAliasComparator() { + public GeneComparator() { this(Configuration.EPSILON); } @Override - public int compare(GeneAlias arg0, GeneAlias arg1) { + public int compare(Gene arg0, Gene arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -50,7 +50,7 @@ public class GeneAliasComparator implements Comparator<GeneAlias> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(GeneAlias.class)) { + if (arg0.getClass().equals(Gene.class)) { return internalCompare(arg0, arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); @@ -72,8 +72,8 @@ public class GeneAliasComparator implements Comparator<GeneAlias> { * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(GeneAlias arg0, GeneAlias arg1) { - SpeciesAliasComparator speciesAliasComparator = new SpeciesAliasComparator(epsilon); + private int internalCompare(Gene arg0, Gene arg1) { + SpeciesComparator speciesAliasComparator = new SpeciesComparator(epsilon); int result = speciesAliasComparator.internalCompare(arg0, arg1); if (result != 0) { return result; diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/GenericProteinAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/species/GenericProtein.java similarity index 52% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/GenericProteinAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/GenericProtein.java index c8a4556809..aa919053ca 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/GenericProteinAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/GenericProtein.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; @@ -7,27 +7,27 @@ import lcsb.mapviewer.common.exception.NotImplementedException; @Entity @DiscriminatorValue("GENERIC_PROTEIN_ALIAS") -public class GenericProteinAlias extends ProteinAlias { +public class GenericProtein extends Protein { /** * */ private static final long serialVersionUID = 1L; - GenericProteinAlias() { + GenericProtein() { } - public GenericProteinAlias(String aliasId) { + public GenericProtein(String aliasId) { super(aliasId); } - public GenericProteinAlias(GenericProteinAlias original) { + public GenericProtein(GenericProtein original) { super(original); } @Override - public GenericProteinAlias copy() { - if (this.getClass() == GenericProteinAlias.class) { - return new GenericProteinAlias(this); + public GenericProtein copy() { + if (this.getClass() == GenericProtein.class) { + return new GenericProtein(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/GenericProteinAliasComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/GenericProteinComparator.java similarity index 64% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/GenericProteinAliasComparator.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/GenericProteinComparator.java index 0b7f83b6e6..6b11bf5ef2 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/GenericProteinAliasComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/GenericProteinComparator.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.Comparator; @@ -7,13 +7,13 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; -public class GenericProteinAliasComparator implements Comparator<GenericProteinAlias> { +public class GenericProteinComparator implements Comparator<GenericProtein> { /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(GenericProteinAliasComparator.class); + private static Logger logger = Logger.getLogger(GenericProteinComparator.class); /** * Epsilon value used for comparison of doubles. @@ -27,19 +27,19 @@ public class GenericProteinAliasComparator implements Comparator<GenericProteinA * @param epsilon * {@link #epsilon} */ - public GenericProteinAliasComparator(double epsilon) { + public GenericProteinComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public GenericProteinAliasComparator() { + public GenericProteinComparator() { this(Configuration.EPSILON); } @Override - public int compare(GenericProteinAlias arg0, GenericProteinAlias arg1) { + public int compare(GenericProtein arg0, GenericProtein arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -51,7 +51,7 @@ public class GenericProteinAliasComparator implements Comparator<GenericProteinA } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(GenericProteinAlias.class)) { + if (arg0.getClass().equals(GenericProtein.class)) { return internalCompare(arg0, arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); @@ -63,8 +63,8 @@ public class GenericProteinAliasComparator implements Comparator<GenericProteinA /** * This method compares only the fields that are defined in - * {@link GenericProteinAlias} class in inheritence tree. By the design it - * calls also comparator of the upper ({@link ProteinAlias}) class. + * {@link GenericProtein} class in inheritence tree. By the design it + * calls also comparator of the upper ({@link Protein}) class. * * @param arg0 * first object to compare @@ -73,8 +73,8 @@ public class GenericProteinAliasComparator implements Comparator<GenericProteinA * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(GenericProteinAlias arg0, GenericProteinAlias arg1) { - ProteinAliasComparator proteinAliasComparator = new ProteinAliasComparator(epsilon); + private int internalCompare(GenericProtein arg0, GenericProtein arg1) { + ProteinComparator proteinAliasComparator = new ProteinComparator(epsilon); int result = proteinAliasComparator.internalCompare(arg0, arg1); if (result != 0) { return result; diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/IonAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Ion.java similarity index 61% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/IonAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/Ion.java index 874434612a..88bcd9956d 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/IonAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Ion.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; @@ -7,27 +7,27 @@ import lcsb.mapviewer.common.exception.NotImplementedException; @Entity @DiscriminatorValue("ION_ALIAS") -public class IonAlias extends ChemicalAlias { +public class Ion extends Chemical { /** * */ private static final long serialVersionUID = 1L; - IonAlias() { + Ion() { } - public IonAlias(IonAlias original) { + public Ion(Ion original) { super(original); } - public IonAlias(String aliasId) { + public Ion(String aliasId) { setAliasId(aliasId); } @Override - public IonAlias copy() { - if (this.getClass() == IonAlias.class) { - return new IonAlias(this); + public Ion copy() { + if (this.getClass() == Ion.class) { + return new Ion(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/IonChannelProteinAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/species/IonChannelProtein.java similarity index 51% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/IonChannelProteinAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/IonChannelProtein.java index a30b28d3b0..56463dfcb0 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/IonChannelProteinAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/IonChannelProtein.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; @@ -7,27 +7,27 @@ import lcsb.mapviewer.common.exception.NotImplementedException; @Entity @DiscriminatorValue("ION_CHANNEL_PROTEIN_ALIAS") -public class IonChannelProteinAlias extends ProteinAlias { +public class IonChannelProtein extends Protein { /** * */ private static final long serialVersionUID = 1L; - IonChannelProteinAlias() { + IonChannelProtein() { } - public IonChannelProteinAlias(IonChannelProteinAlias original) { + public IonChannelProtein(IonChannelProtein original) { super(original); } - public IonChannelProteinAlias(String aliasId) { + public IonChannelProtein(String aliasId) { setAliasId(aliasId); } @Override - public IonChannelProteinAlias copy() { - if (this.getClass() == IonChannelProteinAlias.class) { - return new IonChannelProteinAlias(this); + public IonChannelProtein copy() { + if (this.getClass() == IonChannelProtein.class) { + return new IonChannelProtein(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/IonChannelProteinAliasComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/IonChannelProteinComparator.java similarity index 69% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/IonChannelProteinAliasComparator.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/IonChannelProteinComparator.java index 2a8c9de3e2..276547baee 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/IonChannelProteinAliasComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/IonChannelProteinComparator.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.Comparator; @@ -7,13 +7,13 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; -public class IonChannelProteinAliasComparator implements Comparator<IonChannelProteinAlias> { +public class IonChannelProteinComparator implements Comparator<IonChannelProtein> { /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(IonChannelProteinAliasComparator.class); + private static Logger logger = Logger.getLogger(IonChannelProteinComparator.class); /** * Epsilon value used for comparison of doubles. @@ -26,19 +26,19 @@ public class IonChannelProteinAliasComparator implements Comparator<IonChannelPr * @param epsilon * {@link #epsilon} */ - public IonChannelProteinAliasComparator(double epsilon) { + public IonChannelProteinComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public IonChannelProteinAliasComparator() { + public IonChannelProteinComparator() { this(Configuration.EPSILON); } @Override - public int compare(IonChannelProteinAlias arg0, IonChannelProteinAlias arg1) { + public int compare(IonChannelProtein arg0, IonChannelProtein arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -50,7 +50,7 @@ public class IonChannelProteinAliasComparator implements Comparator<IonChannelPr } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(IonChannelProteinAlias.class)) { + if (arg0.getClass().equals(IonChannelProtein.class)) { return internalCompare(arg0, arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); @@ -72,8 +72,8 @@ public class IonChannelProteinAliasComparator implements Comparator<IonChannelPr * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(IonChannelProteinAlias arg0, IonChannelProteinAlias arg1) { - SpeciesAliasComparator speciesAliasComparator = new SpeciesAliasComparator(epsilon); + private int internalCompare(IonChannelProtein arg0, IonChannelProtein arg1) { + SpeciesComparator speciesAliasComparator = new SpeciesComparator(epsilon); int result = speciesAliasComparator.internalCompare(arg0, arg1); if (result != 0) { return result; diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/IonComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/IonComparator.java similarity index 70% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/IonComparator.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/IonComparator.java index 352ad337ba..e17cad0f42 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/IonComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/IonComparator.java @@ -1,23 +1,24 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.model.map.species; 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 Ion. - * - * @author Piotr Gawron - * - * @see Ion - */ public class IonComparator implements Comparator<Ion> { + /** + * Default class logger. + */ + @SuppressWarnings("unused") + private static Logger logger = Logger.getLogger(IonComparator.class); + /** * Epsilon value used for comparison of doubles. */ - private double epsilon; + private double epsilon; /** * Constructor that requires {@link #epsilon} parameter. @@ -60,9 +61,9 @@ public class IonComparator implements Comparator<Ion> { } /** - * This method compares only the fields that are defined in {@link Ion} class - * in inheritence tree. It also calls the {@link SpeciesComparator} for the - * super class ( {@link Species}). + * This method compares only the fields that are defined in {@link Ion} + * class in inheritence tree. By the design it calls also comparator of the + * upper {@link Chemical} class. * * @param arg0 * first object to compare @@ -72,12 +73,11 @@ public class IonComparator implements Comparator<Ion> { * -1/1 is returned. */ private int internalCompare(Ion arg0, Ion arg1) { - SpeciesComparator speciesComparator = new SpeciesComparator(epsilon); - int result = speciesComparator.internalCompare(arg0, arg1); + ChemicalComparator speciesAliasComparator = new ChemicalComparator(epsilon); + int result = speciesAliasComparator.internalCompare(arg0, arg1); if (result != 0) { return result; } return 0; } - } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/PhenotypeAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Phenotype.java similarity index 58% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/PhenotypeAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/Phenotype.java index 527a2a3284..c360b50a3f 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/PhenotypeAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Phenotype.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; @@ -7,28 +7,28 @@ import lcsb.mapviewer.common.exception.NotImplementedException; @Entity @DiscriminatorValue("PHENTOYPE_ALIAS") -public class PhenotypeAlias extends SpeciesAlias { +public class Phenotype extends Species { /** * */ private static final long serialVersionUID = 1L; - PhenotypeAlias() { + Phenotype() { } - public PhenotypeAlias(PhenotypeAlias original) { + public Phenotype(Phenotype original) { super(original); } - public PhenotypeAlias(String aliasId) { + public Phenotype(String aliasId) { setAliasId(aliasId); } @Override - public PhenotypeAlias copy() { - if (this.getClass() == PhenotypeAlias.class) { - return new PhenotypeAlias(this); + public Phenotype copy() { + if (this.getClass() == Phenotype.class) { + return new Phenotype(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/PhenotypeAliasComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/PhenotypeComparator.java similarity index 69% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/PhenotypeAliasComparator.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/PhenotypeComparator.java index f4891b9942..ad63c97a93 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/PhenotypeAliasComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/PhenotypeComparator.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.Comparator; @@ -7,13 +7,13 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; -public class PhenotypeAliasComparator implements Comparator<PhenotypeAlias> { +public class PhenotypeComparator implements Comparator<Phenotype> { /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(PhenotypeAliasComparator.class); + private static Logger logger = Logger.getLogger(PhenotypeComparator.class); /** * Epsilon value used for comparison of doubles. @@ -26,19 +26,19 @@ public class PhenotypeAliasComparator implements Comparator<PhenotypeAlias> { * @param epsilon * {@link #epsilon} */ - public PhenotypeAliasComparator(double epsilon) { + public PhenotypeComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public PhenotypeAliasComparator() { + public PhenotypeComparator() { this(Configuration.EPSILON); } @Override - public int compare(PhenotypeAlias arg0, PhenotypeAlias arg1) { + public int compare(Phenotype arg0, Phenotype arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -50,7 +50,7 @@ public class PhenotypeAliasComparator implements Comparator<PhenotypeAlias> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(PhenotypeAlias.class)) { + if (arg0.getClass().equals(Phenotype.class)) { return internalCompare(arg0, arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); @@ -72,8 +72,8 @@ public class PhenotypeAliasComparator implements Comparator<PhenotypeAlias> { * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(PhenotypeAlias arg0, PhenotypeAlias arg1) { - SpeciesAliasComparator speciesAliasComparator = new SpeciesAliasComparator(epsilon); + private int internalCompare(Phenotype arg0, Phenotype arg1) { + SpeciesComparator speciesAliasComparator = new SpeciesComparator(epsilon); int result = speciesAliasComparator.internalCompare(arg0, arg1); if (result != 0) { return result; diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ProteinAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Protein.java similarity index 69% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ProteinAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/Protein.java index 95d79fd264..7149cffe9d 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ProteinAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Protein.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.ArrayList; import java.util.List; @@ -12,9 +12,11 @@ import org.hibernate.annotations.CascadeType; import org.hibernate.annotations.LazyCollection; import org.hibernate.annotations.LazyCollectionOption; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; + @Entity @DiscriminatorValue("PROTEIN_ALIAS") -public abstract class ProteinAlias extends SpeciesAlias { +public abstract class Protein extends Species { /** * @@ -32,20 +34,20 @@ public abstract class ProteinAlias extends SpeciesAlias { @Cascade({ CascadeType.ALL }) @OneToMany(mappedBy = "species", orphanRemoval = true) @LazyCollection(LazyCollectionOption.FALSE) - private List<ModificationResidueAlias> modificationResidues = new ArrayList<>(); + private List<ModificationResidue> modificationResidues = new ArrayList<>(); - ProteinAlias() { + Protein() { } - public ProteinAlias(ProteinAlias original) { + public Protein(Protein original) { super(original); this.structuralState = original.getStructuralState(); - for (ModificationResidueAlias mr : original.getModificationResidues()) { - addModificationResidue(new ModificationResidueAlias(mr)); + for (ModificationResidue mr : original.getModificationResidues()) { + addModificationResidue(new ModificationResidue(mr)); } } - public ProteinAlias(String aliasId) { + public Protein(String aliasId) { super(aliasId); } @@ -55,7 +57,7 @@ public abstract class ProteinAlias extends SpeciesAlias { * @param modificationResidue * modification to add */ - public void addModificationResidue(ModificationResidueAlias modificationResidue) { + public void addModificationResidue(ModificationResidue modificationResidue) { modificationResidues.add(modificationResidue); modificationResidue.setSpecies(this); } @@ -64,7 +66,7 @@ public abstract class ProteinAlias extends SpeciesAlias { * @return the modificationResidues * @see #modificationResidues */ - public List<ModificationResidueAlias> getModificationResidues() { + public List<ModificationResidue> getModificationResidues() { return modificationResidues; } @@ -72,7 +74,7 @@ public abstract class ProteinAlias extends SpeciesAlias { * @param modificationResidues the modificationResidues to set * @see #modificationResidues */ - public void setModificationResidues(List<ModificationResidueAlias> modificationResidues) { + public void setModificationResidues(List<ModificationResidue> modificationResidues) { this.modificationResidues = modificationResidues; } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ProteinAliasComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/ProteinComparator.java similarity index 51% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ProteinAliasComparator.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/ProteinComparator.java index 2ef10ac313..5b0840457e 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ProteinAliasComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/ProteinComparator.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.Comparator; @@ -7,23 +7,23 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; -public class ProteinAliasComparator implements Comparator<ProteinAlias> { +public class ProteinComparator implements Comparator<Protein> { /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(ProteinAliasComparator.class); + private static Logger logger = Logger.getLogger(ProteinComparator.class); /** * Epsilon value used for comparison of doubles. */ private double epsilon; - private GenericProteinAliasComparator genericProteinAliasComparator; - private IonChannelProteinAliasComparator ionChannelProteinAliasComparator; - private ReceptorProteinAliasComparator receptorProteinAliasComparator; - private TruncatedProteinAliasComparator truncatedProteinAliasComparator; + private GenericProteinComparator genericProteinAliasComparator; + private IonChannelProteinComparator ionChannelProteinAliasComparator; + private ReceptorProteinComparator receptorProteinAliasComparator; + private TruncatedProteinComparator truncatedProteinAliasComparator; /** * Constructor that requires {@link #epsilon} parameter. @@ -31,23 +31,23 @@ public class ProteinAliasComparator implements Comparator<ProteinAlias> { * @param epsilon * {@link #epsilon} */ - public ProteinAliasComparator(double epsilon) { + public ProteinComparator(double epsilon) { this.epsilon = epsilon; - genericProteinAliasComparator = new GenericProteinAliasComparator(epsilon); - ionChannelProteinAliasComparator = new IonChannelProteinAliasComparator(epsilon); - receptorProteinAliasComparator = new ReceptorProteinAliasComparator(epsilon); - truncatedProteinAliasComparator = new TruncatedProteinAliasComparator(epsilon); + genericProteinAliasComparator = new GenericProteinComparator(epsilon); + ionChannelProteinAliasComparator = new IonChannelProteinComparator(epsilon); + receptorProteinAliasComparator = new ReceptorProteinComparator(epsilon); + truncatedProteinAliasComparator = new TruncatedProteinComparator(epsilon); } /** * Default constructor. */ - public ProteinAliasComparator() { + public ProteinComparator() { this(Configuration.EPSILON); } @Override - public int compare(ProteinAlias arg0, ProteinAlias arg1) { + public int compare(Protein arg0, Protein arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -59,16 +59,16 @@ public class ProteinAliasComparator implements Comparator<ProteinAlias> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(ProteinAlias.class)) { + if (arg0.getClass().equals(Protein.class)) { return internalCompare(arg0, arg1); - } else if (arg0.getClass().equals(GenericProteinAlias.class)) { - return genericProteinAliasComparator.compare((GenericProteinAlias) arg0, (GenericProteinAlias) arg1); - } else if (arg0.getClass().equals(IonChannelProteinAlias.class)) { - return ionChannelProteinAliasComparator.compare((IonChannelProteinAlias) arg0, (IonChannelProteinAlias) arg1); - } else if (arg0.getClass().equals(ReceptorProteinAlias.class)) { - return receptorProteinAliasComparator.compare((ReceptorProteinAlias) arg0, (ReceptorProteinAlias) arg1); - } else if (arg0.getClass().equals(TruncatedProteinAlias.class)) { - return truncatedProteinAliasComparator.compare((TruncatedProteinAlias) arg0, (TruncatedProteinAlias) arg1); + } else if (arg0.getClass().equals(GenericProtein.class)) { + return genericProteinAliasComparator.compare((GenericProtein) arg0, (GenericProtein) arg1); + } else if (arg0.getClass().equals(IonChannelProtein.class)) { + return ionChannelProteinAliasComparator.compare((IonChannelProtein) arg0, (IonChannelProtein) arg1); + } else if (arg0.getClass().equals(ReceptorProtein.class)) { + return receptorProteinAliasComparator.compare((ReceptorProtein) arg0, (ReceptorProtein) arg1); + } else if (arg0.getClass().equals(TruncatedProtein.class)) { + return truncatedProteinAliasComparator.compare((TruncatedProtein) arg0, (TruncatedProtein) arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); } @@ -89,8 +89,8 @@ public class ProteinAliasComparator implements Comparator<ProteinAlias> { * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - int internalCompare(ProteinAlias arg0, ProteinAlias arg1) { - SpeciesAliasComparator speciesAliasComparator = new SpeciesAliasComparator(epsilon); + int internalCompare(Protein arg0, Protein arg1) { + SpeciesComparator speciesAliasComparator = new SpeciesComparator(epsilon); int result = speciesAliasComparator.internalCompare(arg0, arg1); if (result != 0) { return result; diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ReceptorProteinAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/species/ReceptorProtein.java similarity index 52% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ReceptorProteinAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/ReceptorProtein.java index 26d5b88d83..71e5c768c2 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ReceptorProteinAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/ReceptorProtein.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; @@ -7,27 +7,27 @@ import lcsb.mapviewer.common.exception.NotImplementedException; @Entity @DiscriminatorValue("RECEPTOR_PROTEIN_ALIAS") -public class ReceptorProteinAlias extends ProteinAlias { +public class ReceptorProtein extends Protein { /** * */ private static final long serialVersionUID = 1L; - ReceptorProteinAlias() { + ReceptorProtein() { } - public ReceptorProteinAlias(ReceptorProteinAlias original) { + public ReceptorProtein(ReceptorProtein original) { super(original); } - public ReceptorProteinAlias(String aliasId) { + public ReceptorProtein(String aliasId) { super(aliasId); } @Override - public ReceptorProteinAlias copy() { - if (this.getClass() == ReceptorProteinAlias.class) { - return new ReceptorProteinAlias(this); + public ReceptorProtein copy() { + if (this.getClass() == ReceptorProtein.class) { + return new ReceptorProtein(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ReceptorProteinAliasComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/ReceptorProteinComparator.java similarity index 70% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ReceptorProteinAliasComparator.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/ReceptorProteinComparator.java index d4e9d1432a..f0bc587d0e 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ReceptorProteinAliasComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/ReceptorProteinComparator.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.Comparator; @@ -7,13 +7,13 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; -public class ReceptorProteinAliasComparator implements Comparator<ReceptorProteinAlias> { +public class ReceptorProteinComparator implements Comparator<ReceptorProtein> { /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(ReceptorProteinAliasComparator.class); + private static Logger logger = Logger.getLogger(ReceptorProteinComparator.class); /** * Epsilon value used for comparison of doubles. @@ -26,19 +26,19 @@ public class ReceptorProteinAliasComparator implements Comparator<ReceptorProtei * @param epsilon * {@link #epsilon} */ - public ReceptorProteinAliasComparator(double epsilon) { + public ReceptorProteinComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public ReceptorProteinAliasComparator() { + public ReceptorProteinComparator() { this(Configuration.EPSILON); } @Override - public int compare(ReceptorProteinAlias arg0, ReceptorProteinAlias arg1) { + public int compare(ReceptorProtein arg0, ReceptorProtein arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -50,7 +50,7 @@ public class ReceptorProteinAliasComparator implements Comparator<ReceptorProtei } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(ReceptorProteinAlias.class)) { + if (arg0.getClass().equals(ReceptorProtein.class)) { return internalCompare(arg0, arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); @@ -72,8 +72,8 @@ public class ReceptorProteinAliasComparator implements Comparator<ReceptorProtei * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(ReceptorProteinAlias arg0, ReceptorProteinAlias arg1) { - ProteinAliasComparator proteinAliasComparator = new ProteinAliasComparator(epsilon); + private int internalCompare(ReceptorProtein arg0, ReceptorProtein arg1) { + ProteinComparator proteinAliasComparator = new ProteinComparator(epsilon); int result = proteinAliasComparator.internalCompare(arg0, arg1); if (result != 0) { return result; diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/RnaAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Rna.java similarity index 64% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/RnaAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/Rna.java index 02276dd2cc..a06bcb114b 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/RnaAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Rna.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.ArrayList; import java.util.List; @@ -13,10 +13,11 @@ import org.hibernate.annotations.LazyCollection; import org.hibernate.annotations.LazyCollectionOption; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.species.field.RnaRegion; @Entity @DiscriminatorValue("RNA_ALIAS") -public class RnaAlias extends SpeciesAlias { +public class Rna extends Species { /** * @@ -29,32 +30,32 @@ public class RnaAlias extends SpeciesAlias { @Cascade({ CascadeType.ALL }) @OneToMany(mappedBy = "species", orphanRemoval = true) @LazyCollection(LazyCollectionOption.FALSE) - private List<RnaRegionAlias> regions = new ArrayList<>(); + private List<RnaRegion> regions = new ArrayList<>(); - RnaAlias() { + Rna() { } - public RnaAlias(RnaAlias original) { + public Rna(Rna original) { super(original); - for (RnaRegionAlias region : original.getRegions()) { - addRegion(new RnaRegionAlias(region)); + for (RnaRegion region : original.getRegions()) { + addRegion(new RnaRegion(region)); } } - public RnaAlias(String aliasId) { + public Rna(String aliasId) { super(); setAliasId(aliasId); } - public void addRegion(RnaRegionAlias rnaRegionAlias) { + public void addRegion(RnaRegion rnaRegionAlias) { regions.add(rnaRegionAlias); rnaRegionAlias.setSpecies(this); } @Override - public RnaAlias copy() { - if (this.getClass() == RnaAlias.class) { - return new RnaAlias(this); + public Rna copy() { + if (this.getClass() == Rna.class) { + return new Rna(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } @@ -64,7 +65,7 @@ public class RnaAlias extends SpeciesAlias { * @return the regions * @see #regions */ - public List<RnaRegionAlias> getRegions() { + public List<RnaRegion> getRegions() { return regions; } @@ -73,7 +74,7 @@ public class RnaAlias extends SpeciesAlias { * the regions to set * @see #regions */ - public void setRegions(List<RnaRegionAlias> regions) { + public void setRegions(List<RnaRegion> regions) { this.regions = regions; } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/RnaAliasComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/RnaComparator.java similarity index 71% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/RnaAliasComparator.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/RnaComparator.java index 180425ff2f..d5d3e6086a 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/RnaAliasComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/RnaComparator.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.Comparator; @@ -7,13 +7,13 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; -public class RnaAliasComparator implements Comparator<RnaAlias> { +public class RnaComparator implements Comparator<Rna> { /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(RnaAliasComparator.class); + private static Logger logger = Logger.getLogger(RnaComparator.class); /** * Epsilon value used for comparison of doubles. @@ -26,19 +26,19 @@ public class RnaAliasComparator implements Comparator<RnaAlias> { * @param epsilon * {@link #epsilon} */ - public RnaAliasComparator(double epsilon) { + public RnaComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public RnaAliasComparator() { + public RnaComparator() { this(Configuration.EPSILON); } @Override - public int compare(RnaAlias arg0, RnaAlias arg1) { + public int compare(Rna arg0, Rna arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -50,7 +50,7 @@ public class RnaAliasComparator implements Comparator<RnaAlias> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(RnaAlias.class)) { + if (arg0.getClass().equals(Rna.class)) { return internalCompare(arg0, arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); @@ -72,8 +72,8 @@ public class RnaAliasComparator implements Comparator<RnaAlias> { * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(RnaAlias arg0, RnaAlias arg1) { - SpeciesAliasComparator speciesAliasComparator = new SpeciesAliasComparator(epsilon); + private int internalCompare(Rna arg0, Rna arg1) { + SpeciesComparator speciesAliasComparator = new SpeciesComparator(epsilon); int result = speciesAliasComparator.internalCompare(arg0, arg1); if (result != 0) { return result; diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/SimpleMoleculeAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMolecule.java similarity index 56% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/SimpleMoleculeAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMolecule.java index 3d94966e2b..fbd3920c92 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/SimpleMoleculeAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMolecule.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; @@ -7,27 +7,27 @@ import lcsb.mapviewer.common.exception.NotImplementedException; @Entity @DiscriminatorValue("SIMPLE_MOLECULE_ALIAS") -public class SimpleMoleculeAlias extends ChemicalAlias { +public class SimpleMolecule extends Chemical { /** * */ private static final long serialVersionUID = 1L; - SimpleMoleculeAlias() { + SimpleMolecule() { } - public SimpleMoleculeAlias(SimpleMoleculeAlias original) { + public SimpleMolecule(SimpleMolecule original) { super(original); } - public SimpleMoleculeAlias(String aliasId) { + public SimpleMolecule(String aliasId) { setAliasId(aliasId); } @Override - public SimpleMoleculeAlias copy() { - if (this.getClass() == SimpleMoleculeAlias.class) { - return new SimpleMoleculeAlias(this); + public SimpleMolecule copy() { + if (this.getClass() == SimpleMolecule.class) { + return new SimpleMolecule(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/SimpleMoleculeAliasComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMoleculeComparator.java similarity index 67% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/SimpleMoleculeAliasComparator.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMoleculeComparator.java index 39ddf57491..46cbd69a10 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/SimpleMoleculeAliasComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMoleculeComparator.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.Comparator; @@ -7,13 +7,13 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; -public class SimpleMoleculeAliasComparator implements Comparator<SimpleMoleculeAlias> { +public class SimpleMoleculeComparator implements Comparator<SimpleMolecule> { /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(SimpleMoleculeAliasComparator.class); + private static Logger logger = Logger.getLogger(SimpleMoleculeComparator.class); /** * Epsilon value used for comparison of doubles. @@ -26,19 +26,19 @@ public class SimpleMoleculeAliasComparator implements Comparator<SimpleMoleculeA * @param epsilon * {@link #epsilon} */ - public SimpleMoleculeAliasComparator(double epsilon) { + public SimpleMoleculeComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public SimpleMoleculeAliasComparator() { + public SimpleMoleculeComparator() { this(Configuration.EPSILON); } @Override - public int compare(SimpleMoleculeAlias arg0, SimpleMoleculeAlias arg1) { + public int compare(SimpleMolecule arg0, SimpleMolecule arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -50,7 +50,7 @@ public class SimpleMoleculeAliasComparator implements Comparator<SimpleMoleculeA } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(SimpleMoleculeAlias.class)) { + if (arg0.getClass().equals(SimpleMolecule.class)) { return internalCompare(arg0, arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); @@ -72,8 +72,8 @@ public class SimpleMoleculeAliasComparator implements Comparator<SimpleMoleculeA * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(SimpleMoleculeAlias arg0, SimpleMoleculeAlias arg1) { - ChemicalAliasComparator chemicalAliasComparator = new ChemicalAliasComparator(epsilon); + private int internalCompare(SimpleMolecule arg0, SimpleMolecule arg1) { + ChemicalComparator chemicalAliasComparator = new ChemicalComparator(epsilon); int result = chemicalAliasComparator.internalCompare(arg0, arg1); if (result != 0) { return result; diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/SpeciesAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Species.java similarity index 89% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/SpeciesAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/Species.java index d5c353c94b..0683317e47 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/SpeciesAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Species.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.HashSet; import java.util.Set; @@ -17,16 +17,17 @@ import org.hibernate.annotations.Cascade; import org.hibernate.annotations.CascadeType; import lcsb.mapviewer.model.map.reaction.ReactionNode; +import lcsb.mapviewer.model.map.species.field.PositionToCompartment; /** - * {@link Alias} structure used for representing {@link Species}. + * Structure used for representing information about single element. * * @author Piotr Gawron * */ @Entity @DiscriminatorValue("Species Alias") -public abstract class SpeciesAlias extends Alias { +public abstract class Species extends Element { /** * @@ -37,7 +38,7 @@ public abstract class SpeciesAlias extends Alias { * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(SpeciesAlias.class); + private static Logger logger = Logger.getLogger(Species.class); /** * Is the alias active. @@ -76,7 +77,7 @@ public abstract class SpeciesAlias extends Alias { @ManyToOne @Cascade({ CascadeType.ALL }) @JoinColumn(name = "idComplexAliasDb") - private ComplexAlias complexAlias; + private Complex complexAlias; /** * List of reaction nodes that point to this alias. @@ -125,9 +126,9 @@ public abstract class SpeciesAlias extends Alias { * Cunstructor that set alias identifier. * * @param aliasId - * {@link Alias#aliasId} + * {@link Element#aliasId} */ - public SpeciesAlias(String aliasId) { + public Species(String aliasId) { this(); setAliasId(aliasId); } @@ -135,7 +136,7 @@ public abstract class SpeciesAlias extends Alias { /** * Default constructor. */ - public SpeciesAlias() { + public Species() { super(); activity = false; lineWidth = 1.0; @@ -149,7 +150,7 @@ public abstract class SpeciesAlias extends Alias { * @param alias * object from which data will be initialized */ - public SpeciesAlias(SpeciesAlias alias) { + public Species(Species alias) { super(alias); activity = alias.getActivity(); lineWidth = alias.getLineWidth(); @@ -225,7 +226,7 @@ public abstract class SpeciesAlias extends Alias { * @return the complexAlias * @see #complexAlias */ - public ComplexAlias getComplexAlias() { + public Complex getComplexAlias() { return complexAlias; } @@ -234,7 +235,7 @@ public abstract class SpeciesAlias extends Alias { * the complexAlias to set * @see #complexAlias */ - public void setComplexAlias(ComplexAlias complexAlias) { + public void setComplexAlias(Complex complexAlias) { this.complexAlias = complexAlias; } @@ -289,7 +290,7 @@ public abstract class SpeciesAlias extends Alias { this.aliasStateLabel = aliasStateLabel; } - public abstract SpeciesAlias copy(); + public abstract Species copy(); /** * @return the initialAmount diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/SpeciesAliasComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/SpeciesComparator.java similarity index 59% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/SpeciesAliasComparator.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/SpeciesComparator.java index d9ebdf31f6..bf38449447 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/SpeciesAliasComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/SpeciesComparator.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.Comparator; @@ -18,22 +18,22 @@ import lcsb.mapviewer.common.exception.NotImplementedException; * @author Piotr Gawron * */ -public class SpeciesAliasComparator implements Comparator<SpeciesAlias> { +public class SpeciesComparator implements Comparator<Species> { /** * Default class logger. */ - private Logger logger = Logger.getLogger(SpeciesAliasComparator.class); - - private AntisenseRnaAliasComparator antisenseRnaAliasComparator; - private ChemicalAliasComparator chemicalAliasComparator; - private ComplexAliasComparator complexAliasComparator; - private DegradedAliasComparator degradedAliasComparator; - private DrugAliasComparator drugAliasComparator; - private GeneAliasComparator geneAliasComparator; - private PhenotypeAliasComparator phenotypeAliasComparator; - private ProteinAliasComparator proteinAliasComparator; - private RnaAliasComparator rnaAliasComparator; - private UnknownAliasComparator unknownAliasComparator; + private Logger logger = Logger.getLogger(SpeciesComparator.class); + + private AntisenseRnaComparator antisenseRnaAliasComparator; + private ChemicalComparator chemicalAliasComparator; + private ComplexComparator complexAliasComparator; + private DegradedComparator degradedAliasComparator; + private DrugComparator drugAliasComparator; + private GeneComparator geneAliasComparator; + private PhenotypeComparator phenotypeAliasComparator; + private ProteinComparator proteinAliasComparator; + private RnaComparator rnaAliasComparator; + private UnknownComparator unknownAliasComparator; /** * Epsilon value used for comparison of doubles. @@ -46,29 +46,29 @@ public class SpeciesAliasComparator implements Comparator<SpeciesAlias> { * @param epsilon * {@link #epsilon} */ - public SpeciesAliasComparator(double epsilon) { + public SpeciesComparator(double epsilon) { this.epsilon = epsilon; - antisenseRnaAliasComparator = new AntisenseRnaAliasComparator(epsilon); - chemicalAliasComparator = new ChemicalAliasComparator(epsilon); - complexAliasComparator = new ComplexAliasComparator(epsilon); - degradedAliasComparator = new DegradedAliasComparator(epsilon); - drugAliasComparator = new DrugAliasComparator(epsilon); - geneAliasComparator = new GeneAliasComparator(epsilon); - phenotypeAliasComparator = new PhenotypeAliasComparator(epsilon); - proteinAliasComparator = new ProteinAliasComparator(epsilon); - rnaAliasComparator = new RnaAliasComparator(epsilon); - unknownAliasComparator = new UnknownAliasComparator(epsilon); + antisenseRnaAliasComparator = new AntisenseRnaComparator(epsilon); + chemicalAliasComparator = new ChemicalComparator(epsilon); + complexAliasComparator = new ComplexComparator(epsilon); + degradedAliasComparator = new DegradedComparator(epsilon); + drugAliasComparator = new DrugComparator(epsilon); + geneAliasComparator = new GeneComparator(epsilon); + phenotypeAliasComparator = new PhenotypeComparator(epsilon); + proteinAliasComparator = new ProteinComparator(epsilon); + rnaAliasComparator = new RnaComparator(epsilon); + unknownAliasComparator = new UnknownComparator(epsilon); } /** * Default constructor. */ - public SpeciesAliasComparator() { + public SpeciesComparator() { this(Configuration.EPSILON); } @Override - public int compare(SpeciesAlias arg0, SpeciesAlias arg1) { + public int compare(Species arg0, Species arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -80,27 +80,27 @@ public class SpeciesAliasComparator implements Comparator<SpeciesAlias> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(AntisenseRnaAlias.class)) { - return antisenseRnaAliasComparator.compare((AntisenseRnaAlias) arg0, (AntisenseRnaAlias) arg1); - } else if (arg0 instanceof ChemicalAlias) { - return chemicalAliasComparator.compare((ChemicalAlias) arg0, (ChemicalAlias) arg1); - } else if (arg0.getClass().equals(ComplexAlias.class)) { - return complexAliasComparator.compare((ComplexAlias) arg0, (ComplexAlias) arg1); - } else if (arg0.getClass().equals(DegradedAlias.class)) { - return degradedAliasComparator.compare((DegradedAlias) arg0, (DegradedAlias) arg1); - } else if (arg0.getClass().equals(DrugAlias.class)) { - return drugAliasComparator.compare((DrugAlias) arg0, (DrugAlias) arg1); - } else if (arg0.getClass().equals(GeneAlias.class)) { - return geneAliasComparator.compare((GeneAlias) arg0, (GeneAlias) arg1); - } else if (arg0.getClass().equals(PhenotypeAlias.class)) { - return phenotypeAliasComparator.compare((PhenotypeAlias) arg0, (PhenotypeAlias) arg1); - } else if (arg0 instanceof ProteinAlias) { - return proteinAliasComparator.compare((ProteinAlias) arg0, (ProteinAlias) arg1); - } else if (arg0.getClass().equals(RnaAlias.class)) { - return rnaAliasComparator.compare((RnaAlias) arg0, (RnaAlias) arg1); - } else if (arg0.getClass().equals(UnknownAlias.class)) { - return unknownAliasComparator.compare((UnknownAlias) arg0, (UnknownAlias) arg1); - } else if (arg0.getClass().equals(SpeciesAlias.class)) { + if (arg0.getClass().equals(AntisenseRna.class)) { + return antisenseRnaAliasComparator.compare((AntisenseRna) arg0, (AntisenseRna) arg1); + } else if (arg0 instanceof Chemical) { + return chemicalAliasComparator.compare((Chemical) arg0, (Chemical) arg1); + } else if (arg0.getClass().equals(Complex.class)) { + return complexAliasComparator.compare((Complex) arg0, (Complex) arg1); + } else if (arg0.getClass().equals(Degraded.class)) { + return degradedAliasComparator.compare((Degraded) arg0, (Degraded) arg1); + } else if (arg0.getClass().equals(Drug.class)) { + return drugAliasComparator.compare((Drug) arg0, (Drug) arg1); + } else if (arg0.getClass().equals(Gene.class)) { + return geneAliasComparator.compare((Gene) arg0, (Gene) arg1); + } else if (arg0.getClass().equals(Phenotype.class)) { + return phenotypeAliasComparator.compare((Phenotype) arg0, (Phenotype) arg1); + } else if (arg0 instanceof Protein) { + return proteinAliasComparator.compare((Protein) arg0, (Protein) arg1); + } else if (arg0.getClass().equals(Rna.class)) { + 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()); @@ -112,8 +112,8 @@ public class SpeciesAliasComparator implements Comparator<SpeciesAlias> { /** * This method compares only the fields that are defined in - * {@link SpeciesAlias} class in inheritence tree. By the design it calls also - * comparator of the upper ({@link Alias}) class. + * {@link Species} class in inheritence tree. By the design it calls also + * comparator of the upper ({@link Element}) class. * * @param arg0 * first object to compare @@ -122,8 +122,8 @@ public class SpeciesAliasComparator implements Comparator<SpeciesAlias> { * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - int internalCompare(SpeciesAlias arg0, SpeciesAlias arg1) { - AliasComparator aliasComparator = new AliasComparator(epsilon); + int internalCompare(Species arg0, Species arg1) { + ElementComparator aliasComparator = new ElementComparator(epsilon); int result = aliasComparator.internalCompare(arg0, arg1); if (result != 0) { return result; diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/TruncatedProteinAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/species/TruncatedProtein.java similarity index 51% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/TruncatedProteinAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/TruncatedProtein.java index ba0ba2b653..58a3d8c52a 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/TruncatedProteinAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/TruncatedProtein.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; @@ -7,27 +7,27 @@ import lcsb.mapviewer.common.exception.NotImplementedException; @Entity @DiscriminatorValue("TRUNCATED_PROTEIN_ALIAS") -public class TruncatedProteinAlias extends ProteinAlias { +public class TruncatedProtein extends Protein { /** * */ private static final long serialVersionUID = 1L; - TruncatedProteinAlias() { + TruncatedProtein() { } - public TruncatedProteinAlias(TruncatedProteinAlias original) { + public TruncatedProtein(TruncatedProtein original) { super(original); } - public TruncatedProteinAlias(String aliasId) { + public TruncatedProtein(String aliasId) { super(aliasId); } @Override - public TruncatedProteinAlias copy() { - if (this.getClass() == TruncatedProteinAlias.class) { - return new TruncatedProteinAlias(this); + public TruncatedProtein copy() { + if (this.getClass() == TruncatedProtein.class) { + return new TruncatedProtein(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/TruncatedProteinAliasComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/TruncatedProteinComparator.java similarity index 70% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/TruncatedProteinAliasComparator.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/TruncatedProteinComparator.java index 224da1286f..a8918abee6 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/TruncatedProteinAliasComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/TruncatedProteinComparator.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.Comparator; @@ -7,13 +7,13 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; -public class TruncatedProteinAliasComparator implements Comparator<TruncatedProteinAlias> { +public class TruncatedProteinComparator implements Comparator<TruncatedProtein> { /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(TruncatedProteinAliasComparator.class); + private static Logger logger = Logger.getLogger(TruncatedProteinComparator.class); /** * Epsilon value used for comparison of doubles. @@ -26,19 +26,19 @@ public class TruncatedProteinAliasComparator implements Comparator<TruncatedProt * @param epsilon * {@link #epsilon} */ - public TruncatedProteinAliasComparator(double epsilon) { + public TruncatedProteinComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public TruncatedProteinAliasComparator() { + public TruncatedProteinComparator() { this(Configuration.EPSILON); } @Override - public int compare(TruncatedProteinAlias arg0, TruncatedProteinAlias arg1) { + public int compare(TruncatedProtein arg0, TruncatedProtein arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -50,7 +50,7 @@ public class TruncatedProteinAliasComparator implements Comparator<TruncatedProt } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(TruncatedProteinAlias.class)) { + if (arg0.getClass().equals(TruncatedProtein.class)) { return internalCompare(arg0, arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); @@ -72,8 +72,8 @@ public class TruncatedProteinAliasComparator implements Comparator<TruncatedProt * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(TruncatedProteinAlias arg0, TruncatedProteinAlias arg1) { - SpeciesAliasComparator speciesAliasComparator = new SpeciesAliasComparator(epsilon); + private int internalCompare(TruncatedProtein arg0, TruncatedProtein arg1) { + SpeciesComparator speciesAliasComparator = new SpeciesComparator(epsilon); int result = speciesAliasComparator.internalCompare(arg0, arg1); if (result != 0) { return result; diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/UnknownAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Unknown.java similarity index 59% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/UnknownAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/Unknown.java index c3122332c2..39e4ccaae6 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/UnknownAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Unknown.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; @@ -7,28 +7,28 @@ import lcsb.mapviewer.common.exception.NotImplementedException; @Entity @DiscriminatorValue("UNKNOWN_ALIAS") -public class UnknownAlias extends SpeciesAlias { +public class Unknown extends Species { /** * */ private static final long serialVersionUID = 1L; - UnknownAlias() { + Unknown() { } - public UnknownAlias(UnknownAlias original) { + public Unknown(Unknown original) { super(original); } - public UnknownAlias(String aliasId) { + public Unknown(String aliasId) { setAliasId(aliasId); } @Override - public UnknownAlias copy() { - if (this.getClass() == UnknownAlias.class) { - return new UnknownAlias(this); + public Unknown copy() { + if (this.getClass() == Unknown.class) { + return new Unknown(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/UnknownAliasComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/UnknownComparator.java similarity index 69% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/UnknownAliasComparator.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/UnknownComparator.java index 0a9583364b..b0654cd439 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/UnknownAliasComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/UnknownComparator.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import java.util.Comparator; @@ -7,13 +7,13 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; -public class UnknownAliasComparator implements Comparator<UnknownAlias> { +public class UnknownComparator implements Comparator<Unknown> { /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(UnknownAliasComparator.class); + private static Logger logger = Logger.getLogger(UnknownComparator.class); /** * Epsilon value used for comparison of doubles. @@ -26,19 +26,19 @@ public class UnknownAliasComparator implements Comparator<UnknownAlias> { * @param epsilon * {@link #epsilon} */ - public UnknownAliasComparator(double epsilon) { + public UnknownComparator(double epsilon) { this.epsilon = epsilon; } /** * Default constructor. */ - public UnknownAliasComparator() { + public UnknownComparator() { this(Configuration.EPSILON); } @Override - public int compare(UnknownAlias arg0, UnknownAlias arg1) { + public int compare(Unknown arg0, Unknown arg1) { if (arg0 == null) { if (arg1 == null) { return 0; @@ -50,7 +50,7 @@ public class UnknownAliasComparator implements Comparator<UnknownAlias> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(UnknownAlias.class)) { + if (arg0.getClass().equals(Unknown.class)) { return internalCompare(arg0, arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); @@ -72,8 +72,8 @@ public class UnknownAliasComparator implements Comparator<UnknownAlias> { * @return if all fields are qual then returns 0. If they are different then * -1/1 is returned. */ - private int internalCompare(UnknownAlias arg0, UnknownAlias arg1) { - SpeciesAliasComparator speciesAliasComparator = new SpeciesAliasComparator(epsilon); + private int internalCompare(Unknown arg0, Unknown arg1) { + SpeciesComparator speciesAliasComparator = new SpeciesComparator(epsilon); int result = speciesAliasComparator.internalCompare(arg0, arg1); if (result != 0) { return result; diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/AntisenseRnaRegionAlias.java b/model/src/main/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegion.java similarity index 86% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/AntisenseRnaRegionAlias.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegion.java index b2f96d7a56..1b0dfbac41 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/AntisenseRnaRegionAlias.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegion.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species.field; import java.io.Serializable; @@ -18,12 +18,11 @@ import org.hibernate.annotations.CascadeType; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.species.AntisenseRna; /** * This structure contains information about antisense rna region (rna fragment - * of interest) for a specific - * {@link lcsb.mapviewer.converter.model.celldesigner.structure.AntisenseRna - * AntisenseRna}. + * of interest) for a specific {@link AntisenseRna}. * * @author Piotr Gawron * @@ -31,7 +30,7 @@ import lcsb.mapviewer.common.exception.NotImplementedException; @Entity @Table(name = "antisense_rna_region_table_new") @org.hibernate.annotations.GenericGenerator(name = "test-increment-strategy", strategy = "increment") -public class AntisenseRnaRegionAlias implements Serializable { +public class AntisenseRnaRegion implements Serializable { /** * @@ -40,8 +39,7 @@ public class AntisenseRnaRegionAlias implements Serializable { /** * Enum that enlists types of available modification regions in - * {@link lcsb.mapviewer.converter.model.celldesigner.structure.AntisenseRna - * AntisenseRna}. + * {@link AntisenseRna}. * * @author Piotr Gawron * @@ -112,7 +110,7 @@ public class AntisenseRnaRegionAlias implements Serializable { * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(AntisenseRnaRegionAlias.class.getName()); + private static Logger logger = Logger.getLogger(AntisenseRnaRegion.class); /** * Unique identifier in the database. @@ -171,12 +169,12 @@ public class AntisenseRnaRegionAlias implements Serializable { @Cascade({ CascadeType.ALL }) @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "idSpeciesDb") - private AntisenseRnaAlias species; + private AntisenseRna species; /** * Default constructor. */ - public AntisenseRnaRegionAlias() { + public AntisenseRnaRegion() { } @@ -186,7 +184,7 @@ public class AntisenseRnaRegionAlias implements Serializable { * @param original * object from which we initialize data */ - public AntisenseRnaRegionAlias(AntisenseRnaRegionAlias original) { + public AntisenseRnaRegion(AntisenseRnaRegion original) { this.idAntisenseRnaRegion = original.idAntisenseRnaRegion; this.name = original.name; this.size = original.size; @@ -199,9 +197,9 @@ public class AntisenseRnaRegionAlias implements Serializable { * * @return copy of the object */ - public AntisenseRnaRegionAlias copy() { - if (this.getClass() == AntisenseRnaRegionAlias.class) { - return new AntisenseRnaRegionAlias(this); + public AntisenseRnaRegion copy() { + if (this.getClass() == AntisenseRnaRegion.class) { + return new AntisenseRnaRegion(this); } else { throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass()); } @@ -245,7 +243,7 @@ public class AntisenseRnaRegionAlias implements Serializable { * @param mr * object from which we are updating data */ - public void update(AntisenseRnaRegionAlias mr) { + public void update(AntisenseRnaRegion mr) { if (this.idAntisenseRnaRegion != null && !this.idAntisenseRnaRegion.equals("") && !this.idAntisenseRnaRegion.equals(mr.getIdAntisenseRnaRegion())) { throw new InvalidArgumentException("Cannot update from mr with different id"); } @@ -374,7 +372,7 @@ public class AntisenseRnaRegionAlias implements Serializable { * @return the species * @see #species */ - public AntisenseRnaAlias getSpecies() { + public AntisenseRna getSpecies() { return species; } @@ -383,7 +381,7 @@ public class AntisenseRnaRegionAlias implements Serializable { * the species to set * @see #species */ - public void setSpecies(AntisenseRnaAlias species) { + public void setSpecies(AntisenseRna species) { this.species = species; } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/ModificationResidue.java b/model/src/main/java/lcsb/mapviewer/model/map/species/field/ModificationResidue.java similarity index 79% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/ModificationResidue.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/field/ModificationResidue.java index 6d78eb82d1..fda2fe6567 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/ModificationResidue.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/field/ModificationResidue.java @@ -1,13 +1,22 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.model.map.species.field; import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +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.layout.alias.ModificationResidueAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; +import lcsb.mapviewer.model.map.species.Species; /** * This class represent modification residue in protein and gene. However, it is @@ -17,6 +26,9 @@ import lcsb.mapviewer.model.map.layout.alias.ModificationState; * @author Piotr Gawron * */ +@Entity +@Table(name = "modification_residue_table_new") +@org.hibernate.annotations.GenericGenerator(name = "test-increment-strategy", strategy = "increment") public class ModificationResidue implements Serializable { /** @@ -30,6 +42,14 @@ public class ModificationResidue implements Serializable { @SuppressWarnings("unused") private static Logger logger = Logger.getLogger(ModificationResidue.class.getName()); + /** + * Unique identifier in the database. + */ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "iddb", unique = true, nullable = false) + private int id; + /** * Identifier of the modification. Must be unique in single map model. */ @@ -64,7 +84,9 @@ public class ModificationResidue implements Serializable { /** * Species to which this modification belong to. */ - private Species species; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "idSpeciesDb", nullable = false) + private Species species; /** * Default constructor. @@ -87,15 +109,6 @@ public class ModificationResidue implements Serializable { this.state = mr.state; } - public ModificationResidue(ModificationResidueAlias mr) { - this.idModificationResidue = mr.getIdModificationResidue(); - this.name = mr.getName(); - this.angle = mr.getAngle(); - this.size = mr.getSize(); - this.side = mr.getSide(); - this.state = mr.getState(); - } - /** * Updates fields in the object with the data given in the parameter * modification. @@ -177,6 +190,23 @@ public class ModificationResidue implements Serializable { } } + /** + * @return the idModificationResidue + * @see #id + */ + public int getId() { + return id; + } + + /** + * @param id + * the idModificationResidue to set + * @see #id + */ + public void setId(int id) { + this.id = id; + } + /** * @return the id * @see #idModificationResidue @@ -296,16 +326,4 @@ public class ModificationResidue implements Serializable { this.species = species; } - public ModificationResidueAlias createModificationResidueAlias() { - ModificationResidueAlias result = new ModificationResidueAlias(); - - result.setIdModificationResidue(this.getIdModificationResidue()); - result.setName(this.getName()); - result.setAngle(this.getAngle()); - result.setSize(this.getSize()); - result.setSide(this.getSide()); - result.setState(this.getState()); - return result; - } - } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ModificationState.java b/model/src/main/java/lcsb/mapviewer/model/map/species/field/ModificationState.java similarity index 93% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ModificationState.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/field/ModificationState.java index 5fa20a125a..da3b3308eb 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/ModificationState.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/field/ModificationState.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species.field; /** * Defines a type of modification (in protein or rna). Possible values are: diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/PositionToCompartment.java b/model/src/main/java/lcsb/mapviewer/model/map/species/field/PositionToCompartment.java similarity index 86% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/PositionToCompartment.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/field/PositionToCompartment.java index cb512ced9c..b9e143acd1 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/PositionToCompartment.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/field/PositionToCompartment.java @@ -1,9 +1,9 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species.field; /** * Defines possible position of * {@link lcsb.mapviewer.converter.model.celldesigner.structure.Species} on - * {@link lcsb.mapviewer.converter.model.celldesigner.structure.Compartment}. + * {@link lcsb.mapviewer.model.map.agregator.converter.model.celldesigner.structure.Compartment}. * * @author Piotr Gawron * diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/RnaRegion.java b/model/src/main/java/lcsb/mapviewer/model/map/species/field/RnaRegion.java similarity index 75% rename from converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/RnaRegion.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/field/RnaRegion.java index 7846d84e8c..d50f5c7354 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/RnaRegion.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/field/RnaRegion.java @@ -1,21 +1,32 @@ -package lcsb.mapviewer.converter.model.celldesigner.structure; +package lcsb.mapviewer.model.map.species.field; import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; -import lcsb.mapviewer.model.map.layout.alias.RnaRegionAlias; +import lcsb.mapviewer.model.map.species.Rna; /** * This structure contains information about rna region (rna fragment of - * interest) for a specific - * {@link lcsb.mapviewer.converter.model.celldesigner.structure.Rna Rna}. + * interest) for a specific {@link Rna}. * * @author Piotr Gawron * */ +@Entity +@Table(name = "rna_region_table_new") +@org.hibernate.annotations.GenericGenerator(name = "test-increment-strategy", strategy = "increment") public class RnaRegion implements Serializable { /** @@ -34,12 +45,20 @@ public class RnaRegion implements Serializable { @SuppressWarnings("unused") private static Logger logger = Logger.getLogger(RnaRegion.class.getName()); + /** + * Unique identifier in the database. + */ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "iddb", unique = true, nullable = false) + private int id; + /** * Identifier of the region. Unique in the * {@link lcsb.mapviewer.model.map.model.Model}. */ + @Column(name = "idrnaregion") private String idRnaRegion = ""; - /** * Type of the region in the rna. There are three possible values: * <ul> @@ -48,6 +67,8 @@ public class RnaRegion implements Serializable { * <li>Modification site.</li> * </ul> */ + + @Column(name = "type") private String type = ""; /** @@ -55,27 +76,33 @@ public class RnaRegion implements Serializable { * * @see ModificationState */ + @Column(name = "state") private ModificationState state = null; /** * Name of the region. */ + @Column(name = "name") private String name = ""; /** * Size of the region in the graphic representation. */ + @Column(name = "size") private double size = DEFAULT_SIZE; /** * Position on the species in graphic representation. */ + @Column(name = "pos") private Double pos; /** * Defines a species where the region belongs to. */ - private Rna species; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "idSpeciesDb") + private Rna species; /** * Default constructor. @@ -91,6 +118,7 @@ public class RnaRegion implements Serializable { * original {@link RnaRegion} */ public RnaRegion(RnaRegion mr) { + this.id = mr.id; this.idRnaRegion = mr.idRnaRegion; this.size = mr.size; setPos(mr.getPos()); @@ -160,6 +188,23 @@ public class RnaRegion implements Serializable { } + /** + * @return the idRnaRegion + * @see #idRnaRegion + */ + public int getId() { + return id; + } + + /** + * @param id + * the idRnaRegion to set + * @see #id + */ + public void setId(int id) { + this.id = id; + } + /** * @return the id * @see #id @@ -279,15 +324,4 @@ public class RnaRegion implements Serializable { this.species = species; } - public RnaRegionAlias createRnaRegionAlias() { - RnaRegionAlias result = new RnaRegionAlias(); - result.setIdRnaRegion(this.idRnaRegion); - result.setSize(this.size); - result.setPos(this.getPos()); - result.setType(this.type); - result.setState(this.state); - result.setName(this.name); - return result; - } - } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/package-info.java b/model/src/main/java/lcsb/mapviewer/model/map/species/package-info.java similarity index 70% rename from model/src/main/java/lcsb/mapviewer/model/map/layout/alias/package-info.java rename to model/src/main/java/lcsb/mapviewer/model/map/species/package-info.java index be05884687..274edba7f6 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/layout/alias/package-info.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/package-info.java @@ -1,6 +1,6 @@ -/** - * This package provides data structures that stores information about aliases - * for the map elements. - */ -package lcsb.mapviewer.model.map.layout.alias; - +/** + * This package provides data structures that stores information about aliases + * for the map elements. + */ +package lcsb.mapviewer.model.map.species; + 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 0ed029d9d2..dfa46de1b5 100644 --- a/model/src/main/java/lcsb/mapviewer/modelutils/map/ElementUtils.java +++ b/model/src/main/java/lcsb/mapviewer/modelutils/map/ElementUtils.java @@ -13,8 +13,8 @@ import org.reflections.Reflections; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.AnnotatedObject; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; /** * Class with some util method for {@link AnnotatedObject} objects. @@ -32,9 +32,9 @@ public final class ElementUtils { /** * Map between class names (used as user input) and implementation of - * {@link Alias} class. + * {@link Element} class. */ - private static Map<String, Class<? extends Alias>> elementClasses = null; + private static Map<String, Class<? extends Element>> elementClasses = null; /** * Map between class names (used as user input) and implementation of @@ -73,8 +73,8 @@ public final class ElementUtils { */ public String getElementTag(AnnotatedObject element, Object annotator) { String id = null; - if (element instanceof Alias) { - id = ((Alias) element).getAliasId(); + if (element instanceof Element) { + id = ((Element) element).getAliasId(); } else if (element instanceof Reaction) { id = ((Reaction) element).getIdReaction(); } else { @@ -143,14 +143,14 @@ public final class ElementUtils { } /** - * Returns list of classes that extends {@link Alias} class, but don't have + * Returns list of classes that extends {@link Element} class, but don't have * children (leaves in the hierarchy tree). * - * @return list of classes that extends {@link Alias} class, but don't have + * @return list of classes that extends {@link Element} class, but don't have * children (leaves in the hierarchy tree) */ - public List<Class<? extends Alias>> getAvailableElementSubclasses() { - List<Class<? extends Alias>> result = new ArrayList<Class<? extends Alias>>(); + public List<Class<? extends Element>> getAvailableElementSubclasses() { + List<Class<? extends Element>> result = new ArrayList<Class<? extends Element>>(); if (elementClasses == null) { refreshClasses(); } @@ -160,18 +160,18 @@ public final class ElementUtils { } /** - * Refresh list of known implementation of {@link Alias} class. + * Refresh list of known implementation of {@link Element} class. */ protected void refreshClasses() { - List<Class<? extends Alias>> tmp = new ArrayList<>(); + List<Class<? extends Element>> tmp = new ArrayList<>(); Reflections reflections = new Reflections("lcsb.mapviewer.model.map"); - elementClasses = new HashMap<String, Class<? extends Alias>>(); - Set<Class<? extends Alias>> classes = reflections.getSubTypesOf(Alias.class); + elementClasses = new HashMap<String, Class<? extends Element>>(); + Set<Class<? extends Element>> classes = reflections.getSubTypesOf(Element.class); Set<Class<?>> toRemove = new HashSet<Class<?>>(); - for (Class<? extends Alias> class1 : classes) { + for (Class<? extends Element> class1 : classes) { if (class1.isAnonymousClass() || class1.isMemberClass() || class1.isLocalClass()) { continue; } @@ -181,7 +181,7 @@ public final class ElementUtils { for (Class<?> clazz : toRemove) { tmp.remove(clazz); } - for (Class<? extends Alias> class1 : tmp) { + for (Class<? extends Element> class1 : tmp) { elementClasses.put(class1.getSimpleName(), class1); } @@ -248,7 +248,7 @@ public final class ElementUtils { * the elementClasses to set * @see #elementClasses */ - protected static void setElementClasses(Map<String, Class<? extends Alias>> elementClasses) { + protected static void setElementClasses(Map<String, Class<? extends Element>> elementClasses) { ElementUtils.elementClasses = elementClasses; } diff --git a/model/src/main/java/lcsb/mapviewer/modelutils/map/RequireAnnotationMap.java b/model/src/main/java/lcsb/mapviewer/modelutils/map/RequireAnnotationMap.java index 14364ccac3..2a844090f0 100644 --- a/model/src/main/java/lcsb/mapviewer/modelutils/map/RequireAnnotationMap.java +++ b/model/src/main/java/lcsb/mapviewer/modelutils/map/RequireAnnotationMap.java @@ -1,15 +1,15 @@ package lcsb.mapviewer.modelutils.map; import lcsb.mapviewer.model.map.AnnotatedObject; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaAlias; -import lcsb.mapviewer.model.map.layout.alias.ChemicalAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.DrugAlias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.AntisenseRna; +import lcsb.mapviewer.model.map.species.Chemical; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Drug; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.Phenotype; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Rna; /** * List of {@link AnnotatedObject} that must be annototed with at least one @@ -28,42 +28,42 @@ public enum RequireAnnotationMap { /** * {@link Protein}. */ - PROTEIN(ProteinAlias.class), + PROTEIN(Protein.class), /** * {@link Chemical}. */ - CHECMICAL(ChemicalAlias.class), + CHECMICAL(Chemical.class), /** * {@link Rna}. */ - RNA(RnaAlias.class), + RNA(Rna.class), /** * {@link Gene}. */ - GENE(GeneAlias.class), + GENE(Gene.class), /** * {@link Drug}. */ - DRUG(DrugAlias.class), + DRUG(Drug.class), /** * {@link ComplexSpecies}. */ - COMPLEX(ComplexAlias.class), + COMPLEX(Complex.class), /** * {@link AntisenseRna}. */ - ANTISENSE_RNA(AntisenseRnaAlias.class), + ANTISENSE_RNA(AntisenseRna.class), /** * {@link Phenotype}. */ - PHENOTYPE(PhenotypeAlias.class); + PHENOTYPE(Phenotype.class); /** * Class which should be annotated. 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 d56d039a13..262bc7b6ac 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/AllMapTests.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/AllMapTests.java @@ -4,6 +4,7 @@ import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; +import lcsb.mapviewer.model.map.compartment.AllCompartmentTests; import lcsb.mapviewer.model.map.graph.AllGraphTests; import lcsb.mapviewer.model.map.layout.AllLayoutTests; import lcsb.mapviewer.model.map.layout.graphics.AllGraphicsTests; @@ -13,7 +14,8 @@ import lcsb.mapviewer.model.map.reaction.AllReactionTests; import lcsb.mapviewer.model.map.statistics.AllStatisticsTests; @RunWith(Suite.class) -@SuiteClasses({ AliasInFewParentsExceptionTest.class, // +@SuiteClasses({ AllCompartmentTests.class, // + AliasInFewParentsExceptionTest.class, // AllGraphTests.class, // AllGraphicsTests.class, // AllLayoutTests.class, // 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 new file mode 100644 index 0000000000..fd6f1897ce --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/AllCompartmentTests.java @@ -0,0 +1,17 @@ +package lcsb.mapviewer.model.map.compartment; + +import org.junit.runner.RunWith; +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, // +}) +public class AllCompartmentTests { + +} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/BottomSquareCompartmentAliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/BottomSquareCompartmentAliasTest.java similarity index 70% rename from model/src/test/java/lcsb/mapviewer/model/map/layout/alias/BottomSquareCompartmentAliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/compartment/BottomSquareCompartmentAliasTest.java index fa17d8e743..2c60d8f85d 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/BottomSquareCompartmentAliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/BottomSquareCompartmentAliasTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.compartment; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; @@ -9,6 +9,8 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.compartment.BottomSquareCompartment; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; @@ -25,7 +27,7 @@ public class BottomSquareCompartmentAliasTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new BottomSquareCompartmentAlias()); + SerializationUtils.serialize(new BottomSquareCompartment()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -35,7 +37,7 @@ public class BottomSquareCompartmentAliasTest { @Test public void testConstructor1() { try { - BottomSquareCompartmentAlias alias = new BottomSquareCompartmentAlias(new CompartmentAlias()); + BottomSquareCompartment alias = new BottomSquareCompartment(new Compartment()); assertNotNull(alias); } catch (Exception e) { e.printStackTrace(); @@ -49,7 +51,7 @@ public class BottomSquareCompartmentAliasTest { Model model = new ModelFullIndexed(null); model.setWidth(1); model.setHeight(1); - BottomSquareCompartmentAlias alias = new BottomSquareCompartmentAlias(new CompartmentAlias(), model); + BottomSquareCompartment alias = new BottomSquareCompartment(new Compartment(), model); assertNotNull(alias); } catch (Exception e) { e.printStackTrace(); @@ -60,7 +62,7 @@ public class BottomSquareCompartmentAliasTest { @Test public void testCopy() { try { - BottomSquareCompartmentAlias alias = new BottomSquareCompartmentAlias().copy(); + BottomSquareCompartment alias = new BottomSquareCompartment().copy(); assertNotNull(alias); } catch (Exception e) { e.printStackTrace(); @@ -71,7 +73,7 @@ public class BottomSquareCompartmentAliasTest { @Test public void testInvalidCopy() { try { - new BottomSquareCompartmentAlias() { + new BottomSquareCompartment() { /** * diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/CompartmentAliasComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentAliasComparatorTest.java similarity index 68% rename from model/src/test/java/lcsb/mapviewer/model/map/layout/alias/CompartmentAliasComparatorTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentAliasComparatorTest.java index 1cf0304bcf..023498e219 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/CompartmentAliasComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentAliasComparatorTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.compartment; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -12,10 +12,15 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.InvalidArgumentException; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.compartment.CompartmentComparator; +import lcsb.mapviewer.model.map.compartment.PathwayCompartment; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class CompartmentAliasComparatorTest { - CompartmentAliasComparator comparator = new CompartmentAliasComparator(); + CompartmentComparator comparator = new CompartmentComparator(); @Before public void setUp() throws Exception { @@ -28,8 +33,8 @@ public class CompartmentAliasComparatorTest { @Test public void testEquals() { try { - CompartmentAlias alias1 = createCompartmentAlias(); - CompartmentAlias alias2 = createCompartmentAlias(); + Compartment alias1 = createCompartmentAlias(); + Compartment alias2 = createCompartmentAlias(); assertEquals(0, comparator.compare(alias1, alias2)); @@ -44,9 +49,9 @@ public class CompartmentAliasComparatorTest { @Test public void testDifferent2() { try { - CompartmentAlias alias1 = createCompartmentAlias(); + Compartment alias1 = createCompartmentAlias(); - assertTrue(comparator.compare(alias1, new ArtifitialCompartmentAlias()) != 0); + assertTrue(comparator.compare(alias1, new PathwayCompartment()) != 0); } catch (Exception e) { e.printStackTrace(); @@ -57,16 +62,16 @@ public class CompartmentAliasComparatorTest { @Test public void testInvalid() { try { - CompartmentAlias alias1 = createCompartmentAlias(); - CompartmentAlias alias2 = createCompartmentAlias(); + Compartment alias1 = createCompartmentAlias(); + Compartment alias2 = createCompartmentAlias(); - GenericProteinAlias alias = new GenericProteinAlias("1"); + GenericProtein alias = new GenericProtein("1"); alias1.getAliases().add(alias); - alias = new GenericProteinAlias("1"); + alias = new GenericProtein("1"); alias1.getAliases().add(alias); - alias2.getAliases().add(new GenericProteinAlias("b")); - alias2.getAliases().add(new GenericProteinAlias("a")); + alias2.getAliases().add(new GenericProtein("b")); + alias2.getAliases().add(new GenericProtein("a")); comparator.compare(alias1, alias2); fail("Exception expected"); @@ -81,16 +86,16 @@ public class CompartmentAliasComparatorTest { @Test public void testInvalid2() { try { - CompartmentAlias alias1 = createCompartmentAlias(); - CompartmentAlias alias2 = createCompartmentAlias(); + Compartment alias1 = createCompartmentAlias(); + Compartment alias2 = createCompartmentAlias(); - SpeciesAlias alias = new GenericProteinAlias("1"); + Species alias = new GenericProtein("1"); alias1.getAliases().add(alias); - alias = new GenericProteinAlias("1"); + alias = new GenericProtein("1"); alias1.getAliases().add(alias); - alias2.getAliases().add(new GenericProteinAlias("A")); - alias2.getAliases().add(new GenericProteinAlias("B")); + alias2.getAliases().add(new GenericProtein("A")); + alias2.getAliases().add(new GenericProtein("B")); comparator.compare(alias2, alias1); fail("Exception expected"); @@ -102,8 +107,8 @@ public class CompartmentAliasComparatorTest { } } - private CompartmentAlias createCompartmentAlias() { - CompartmentAlias result = new CompartmentAlias(); + private Compartment createCompartmentAlias() { + Compartment result = new Compartment(); result.setAliasId("asd"); result.setX(12.0); @@ -118,7 +123,7 @@ public class CompartmentAliasComparatorTest { result.setInnerWidth(65); result.setNamePoint(new Point2D.Double(9, 2)); - GenericProteinAlias alias = new GenericProteinAlias("S"); + GenericProtein alias = new GenericProtein("S"); alias.setName("a"); result.addAlias(alias); @@ -128,8 +133,8 @@ public class CompartmentAliasComparatorTest { @Test public void testDifferent() { try { - CompartmentAlias alias1 = createCompartmentAlias(); - CompartmentAlias alias2 = createCompartmentAlias(); + Compartment alias1 = createCompartmentAlias(); + Compartment alias2 = createCompartmentAlias(); assertTrue(comparator.compare(alias1, null) != 0); assertTrue(comparator.compare(null, alias1) != 0); @@ -161,7 +166,7 @@ public class CompartmentAliasComparatorTest { alias1 = createCompartmentAlias(); alias2 = createCompartmentAlias(); - alias1.addAlias(new GenericProteinAlias()); + alias1.addAlias(new GenericProtein("idd")); assertTrue(comparator.compare(alias1, alias2) != 0); assertTrue(comparator.compare(alias2, alias1) != 0); @@ -177,7 +182,7 @@ public class CompartmentAliasComparatorTest { alias1 = createCompartmentAlias(); alias2 = createCompartmentAlias(); - SpeciesAlias speciesAlias = (SpeciesAlias) alias1.getAliases().iterator().next(); + Species speciesAlias = (Species) alias1.getAliases().iterator().next(); speciesAlias.setName("new namne"); assertTrue(comparator.compare(alias1, alias2) != 0); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/CompartmentAliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentAliasTest.java similarity index 68% rename from model/src/test/java/lcsb/mapviewer/model/map/layout/alias/CompartmentAliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentAliasTest.java index 6600e5b85a..92c7be7d4d 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/CompartmentAliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentAliasTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.compartment; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -19,8 +19,14 @@ import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Complex; +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); @@ -39,12 +45,12 @@ public class CompartmentAliasTest { public void testCross() throws Exception { try { Model model = createCrossModel(); - Alias ldhbAlias1 = model.getAliasByAliasId("sa1115"); - Alias ldhbAlias2 = model.getAliasByAliasId("sa1117"); - Alias ldhbAlias3 = model.getAliasByAliasId("sa1119"); - Alias ldhbAlias4 = model.getAliasByAliasId("sa1121"); + Element ldhbAlias1 = model.getAliasByAliasId("sa1115"); + Element ldhbAlias2 = model.getAliasByAliasId("sa1117"); + Element ldhbAlias3 = model.getAliasByAliasId("sa1119"); + Element ldhbAlias4 = model.getAliasByAliasId("sa1121"); - CompartmentAlias cytosolAlias = (CompartmentAlias) model.getAliasByAliasId("ca1"); + Compartment cytosolAlias = (Compartment) model.getAliasByAliasId("ca1"); assertTrue(cytosolAlias.cross(ldhbAlias1)); assertTrue(cytosolAlias.cross(ldhbAlias2)); @@ -60,8 +66,8 @@ public class CompartmentAliasTest { @Test public void testCrossException() throws Exception { try { - CompartmentAlias alias = new CompartmentAlias(); - ComplexAlias alias2 = new ComplexAlias(); + Compartment alias = new Compartment(); + Complex alias2 = new Complex("idd"); alias2.setParent(alias2); alias.cross(alias2); @@ -76,12 +82,12 @@ public class CompartmentAliasTest { @Test public void testCross2() throws Exception { try { - CompartmentAlias alias = new CompartmentAlias(); + Compartment alias = new Compartment(); alias.setX(10.0); alias.setY(10.0); alias.setWidth(10.0); alias.setHeight(10.0); - ComplexAlias alias2 = new ComplexAlias(); + Complex alias2 = new Complex("idd"); alias2.setWidth(10.0); alias2.setHeight(10.0); alias2.setX(5.0); @@ -127,13 +133,13 @@ public class CompartmentAliasTest { @Test public void testContainsIdenticalSpecies() throws Exception { try { - CompartmentAlias alias = new CompartmentAlias(); + Compartment alias = new Compartment(); alias.setName("AS"); assertFalse(alias.containsIdenticalSpecies()); - SpeciesAlias sAlias = new GenericProteinAlias(); + Species sAlias = new GenericProtein("idd"); sAlias.setName("AS"); alias.addAlias(sAlias); @@ -148,16 +154,16 @@ public class CompartmentAliasTest { private Model createCrossModel() { Model model = new ModelFullIndexed(null); - model.addAlias(new CompartmentAlias("default")); + model.addAlias(new Compartment("default")); model.addAlias(createSpeciesAlias(3264.8333333333335, 7517.75, 86.0, 46.0, "sa1115")); model.addAlias(createSpeciesAlias(3267.6666666666665, 7438.75, 80.0, 40.0, "sa1117")); model.addAlias(createSpeciesAlias(3261.6666666666665, 7600.75, 92.0, 52.0, "sa1119")); model.addAlias(createSpeciesAlias(3203.666666666667, 7687.75, 98.0, 58.0, "sa1121")); - SpeciesAlias alias = createSpeciesAlias(7817.714285714286, 11287.642857142859, 80.0, 40.0, "sa1422"); - SpeciesAlias alias2 = createSpeciesAlias(8224.964285714286, 11241.392857142859, 80.0, 40.0, "sa1419"); - ComplexAlias alias3 = createComplexAlias(7804.714285714286, 11182.642857142859, 112.0, 172.0, "csa152"); + Species alias = createSpeciesAlias(7817.714285714286, 11287.642857142859, 80.0, 40.0, "sa1422"); + Species alias2 = createSpeciesAlias(8224.964285714286, 11241.392857142859, 80.0, 40.0, "sa1419"); + Complex alias3 = createComplexAlias(7804.714285714286, 11182.642857142859, 112.0, 172.0, "csa152"); alias3.addAlias(alias); alias3.addAlias(alias2); alias.setParent(alias3); @@ -171,8 +177,8 @@ public class CompartmentAliasTest { return model; } - private CompartmentAlias createCompartmentAlias(double x, double y, double width, double height, String aliasId) { - CompartmentAlias alias = new CompartmentAlias(aliasId); + private Compartment createCompartmentAlias(double x, double y, double width, double height, String aliasId) { + Compartment alias = new Compartment(aliasId); alias.setAliasId(aliasId); alias.setX(x); alias.setY(y); @@ -181,8 +187,8 @@ public class CompartmentAliasTest { return alias; } - private SpeciesAlias createSpeciesAlias(double x, double y, double width, double height, String aliasId) { - SimpleMoleculeAlias alias = new SimpleMoleculeAlias(aliasId); + private Species createSpeciesAlias(double x, double y, double width, double height, String aliasId) { + SimpleMolecule alias = new SimpleMolecule(aliasId); alias.setX(x); alias.setY(y); alias.setWidth(width); @@ -190,8 +196,8 @@ public class CompartmentAliasTest { return alias; } - private ComplexAlias createComplexAlias(double x, double y, double width, double height, String aliasId) { - ComplexAlias alias = new ComplexAlias(aliasId); + private Complex createComplexAlias(double x, double y, double width, double height, String aliasId) { + Complex alias = new Complex(aliasId); alias.setX(x); alias.setY(y); alias.setWidth(width); @@ -203,10 +209,10 @@ public class CompartmentAliasTest { public void testCrossWithComplexElements() throws Exception { try { Model model = createCrossModel(); - Alias ldhbAlias1 = model.getAliasByAliasId("sa1422"); - Alias ldhbAlias2 = model.getAliasByAliasId("sa1419"); + Element ldhbAlias1 = model.getAliasByAliasId("sa1422"); + Element ldhbAlias2 = model.getAliasByAliasId("sa1419"); - CompartmentAlias cytosolAlias = (CompartmentAlias) model.getAliasByAliasId("ca1"); + Compartment cytosolAlias = (Compartment) model.getAliasByAliasId("ca1"); assertTrue(cytosolAlias.cross(ldhbAlias1)); assertTrue(cytosolAlias.cross(ldhbAlias2)); @@ -220,7 +226,7 @@ public class CompartmentAliasTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new CompartmentAlias()); + SerializationUtils.serialize(new Compartment()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -230,9 +236,9 @@ public class CompartmentAliasTest { @Test public void testConstructor() { try { - CompartmentAlias alias = new CompartmentAlias(); - alias.addAlias(new GenericProteinAlias()); - CompartmentAlias copy = new CompartmentAlias(alias); + Compartment alias = new Compartment(); + alias.addAlias(new GenericProtein("idd")); + Compartment copy = new Compartment(alias); assertNotNull(copy); } catch (Exception e) { e.printStackTrace(); @@ -243,7 +249,7 @@ public class CompartmentAliasTest { @Test public void testSetters() { try { - CompartmentAlias alias = new CompartmentAlias(); + Compartment alias = new Compartment(); String invalidVal = "a1.6"; String val = "1.6"; Double dVal = 1.6; @@ -275,7 +281,7 @@ public class CompartmentAliasTest { alias.setNamePoint(2, 3); assertEquals(0, alias.getNamePoint().distance(2, 3), Configuration.EPSILON); - Set<Alias> aliases = new HashSet<>(); + Set<Element> aliases = new HashSet<>(); alias.setAliases(aliases); assertEquals(aliases, alias.getAliases()); @@ -289,9 +295,9 @@ public class CompartmentAliasTest { @Test public void testAddAlias() { try { - CompartmentAlias alias = new CompartmentAlias(); + Compartment alias = new Compartment(); - SpeciesAlias child = new GenericProteinAlias("id"); + Species child = new GenericProtein("id"); alias.addAlias(child); alias.addAlias(child); @@ -307,10 +313,10 @@ public class CompartmentAliasTest { @Test public void testAddInvalidAlias() { try { - CompartmentAlias alias = new CompartmentAlias(); + Compartment alias = new Compartment(); - SpeciesAlias child = new GenericProteinAlias("id"); - SpeciesAlias child2 = new GenericProteinAlias("id"); + Species child = new GenericProtein("id"); + Species child2 = new GenericProtein("id"); alias.addAlias(child); alias.addAlias(child2); @@ -327,10 +333,10 @@ public class CompartmentAliasTest { @Test public void testGetAllAlias() { try { - CompartmentAlias alias = new CompartmentAlias(); + Compartment alias = new Compartment(); - SpeciesAlias child = new GenericProteinAlias("id"); - CompartmentAlias child2 = new CompartmentAlias(); + Species child = new GenericProtein("id"); + Compartment child2 = new Compartment(); child2.addAlias(child); alias.addAlias(child2); @@ -345,7 +351,7 @@ public class CompartmentAliasTest { @Test public void testCopy() { try { - CompartmentAlias degraded = new CompartmentAlias().copy(); + Compartment degraded = new Compartment().copy(); assertNotNull(degraded); } catch (Exception e) { e.printStackTrace(); @@ -356,10 +362,10 @@ public class CompartmentAliasTest { @Test public void testRemoveAlias() { try { - CompartmentAlias comp = new CompartmentAlias(); - SpeciesAlias alias = new GenericProteinAlias(); + Compartment comp = new Compartment(); + Species alias = new GenericProtein("idd"); comp.addAlias(alias); - alias.setCompartmentAlias(new CompartmentAlias()); + alias.setCompartmentAlias(new Compartment()); comp.removeAlias(alias); @@ -373,7 +379,7 @@ public class CompartmentAliasTest { @Test public void testInvalidCopy() { try { - new CompartmentAlias() { + new Compartment() { /** * diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/LeftSquareCompartmentAliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/LeftSquareCompartmentAliasTest.java similarity index 70% rename from model/src/test/java/lcsb/mapviewer/model/map/layout/alias/LeftSquareCompartmentAliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/compartment/LeftSquareCompartmentAliasTest.java index af0f63b5e8..84f18497c9 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/LeftSquareCompartmentAliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/LeftSquareCompartmentAliasTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.compartment; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; @@ -9,6 +9,8 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.compartment.LeftSquareCompartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; @@ -25,7 +27,7 @@ public class LeftSquareCompartmentAliasTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new LeftSquareCompartmentAlias()); + SerializationUtils.serialize(new LeftSquareCompartment()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -35,7 +37,7 @@ public class LeftSquareCompartmentAliasTest { @Test public void testConstructor1() { try { - LeftSquareCompartmentAlias alias = new LeftSquareCompartmentAlias(new LeftSquareCompartmentAlias()); + LeftSquareCompartment alias = new LeftSquareCompartment(new LeftSquareCompartment()); assertNotNull(alias); } catch (Exception e) { e.printStackTrace(); @@ -49,7 +51,7 @@ public class LeftSquareCompartmentAliasTest { Model model = new ModelFullIndexed(null); model.setWidth(1); model.setHeight(1); - LeftSquareCompartmentAlias alias = new LeftSquareCompartmentAlias(new CompartmentAlias(), model); + LeftSquareCompartment alias = new LeftSquareCompartment(new Compartment(), model); assertNotNull(alias); } catch (Exception e) { e.printStackTrace(); @@ -60,7 +62,7 @@ public class LeftSquareCompartmentAliasTest { @Test public void testCopy() { try { - LeftSquareCompartmentAlias alias = new LeftSquareCompartmentAlias().copy(); + LeftSquareCompartment alias = new LeftSquareCompartment().copy(); assertNotNull(alias); } catch (Exception e) { e.printStackTrace(); @@ -71,7 +73,7 @@ public class LeftSquareCompartmentAliasTest { @Test public void testInvalidCopy() { try { - new LeftSquareCompartmentAlias() { + new LeftSquareCompartment() { /** * diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/RightSquareCompartmentAliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/RightSquareCompartmentAliasTest.java similarity index 70% rename from model/src/test/java/lcsb/mapviewer/model/map/layout/alias/RightSquareCompartmentAliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/compartment/RightSquareCompartmentAliasTest.java index 95a233c068..c0ab3d3710 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/RightSquareCompartmentAliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/RightSquareCompartmentAliasTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.compartment; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -10,6 +10,8 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.compartment.RightSquareCompartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; @@ -26,7 +28,7 @@ public class RightSquareCompartmentAliasTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new RightSquareCompartmentAlias()); + SerializationUtils.serialize(new RightSquareCompartment()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -37,7 +39,7 @@ public class RightSquareCompartmentAliasTest { @Test public void testConstructor1() { try { - RightSquareCompartmentAlias alias = new RightSquareCompartmentAlias(new RightSquareCompartmentAlias()); + RightSquareCompartment alias = new RightSquareCompartment(new RightSquareCompartment()); assertNotNull(alias); } catch (Exception e) { e.printStackTrace(); @@ -51,7 +53,7 @@ public class RightSquareCompartmentAliasTest { Model model = new ModelFullIndexed(null); model.setWidth(1); model.setHeight(1); - RightSquareCompartmentAlias alias = new RightSquareCompartmentAlias(new CompartmentAlias(), model); + RightSquareCompartment alias = new RightSquareCompartment(new Compartment(), model); assertNotNull(alias); } catch (Exception e) { e.printStackTrace(); @@ -62,7 +64,7 @@ public class RightSquareCompartmentAliasTest { @Test public void testCopy() { try { - RightSquareCompartmentAlias alias = new RightSquareCompartmentAlias().copy(); + RightSquareCompartment alias = new RightSquareCompartment().copy(); assertNotNull(alias); } catch (Exception e) { e.printStackTrace(); @@ -73,7 +75,7 @@ public class RightSquareCompartmentAliasTest { @Test public void testSetPoint() { try { - RightSquareCompartmentAlias alias = new RightSquareCompartmentAlias(); + RightSquareCompartment alias = new RightSquareCompartment(); alias.setPoint("10", "10"); assertTrue(alias.getWidth()<0); } catch (Exception e) { @@ -85,7 +87,7 @@ public class RightSquareCompartmentAliasTest { @Test public void testInvalidCopy() { try { - new RightSquareCompartmentAlias() { + new RightSquareCompartment() { /** * diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/TopSquareCompartmentAliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/TopSquareCompartmentAliasTest.java similarity index 71% rename from model/src/test/java/lcsb/mapviewer/model/map/layout/alias/TopSquareCompartmentAliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/compartment/TopSquareCompartmentAliasTest.java index a6306eb181..fc6a019068 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/TopSquareCompartmentAliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/TopSquareCompartmentAliasTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.compartment; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; @@ -9,6 +9,8 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.compartment.TopSquareCompartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; @@ -25,7 +27,7 @@ public class TopSquareCompartmentAliasTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new TopSquareCompartmentAlias()); + SerializationUtils.serialize(new TopSquareCompartment()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -36,7 +38,7 @@ public class TopSquareCompartmentAliasTest { @Test public void testConstructor1() { try { - TopSquareCompartmentAlias alias = new TopSquareCompartmentAlias(new TopSquareCompartmentAlias()); + TopSquareCompartment alias = new TopSquareCompartment(new TopSquareCompartment()); assertNotNull(alias); } catch (Exception e) { e.printStackTrace(); @@ -50,7 +52,7 @@ public class TopSquareCompartmentAliasTest { Model model = new ModelFullIndexed(null); model.setWidth(1); model.setHeight(1); - TopSquareCompartmentAlias alias = new TopSquareCompartmentAlias(new CompartmentAlias(), model); + TopSquareCompartment alias = new TopSquareCompartment(new Compartment(), model); assertNotNull(alias); } catch (Exception e) { e.printStackTrace(); @@ -61,7 +63,7 @@ public class TopSquareCompartmentAliasTest { @Test public void testCopy() { try { - TopSquareCompartmentAlias alias = new TopSquareCompartmentAlias().copy(); + TopSquareCompartment alias = new TopSquareCompartment().copy(); assertNotNull(alias); } catch (Exception e) { e.printStackTrace(); @@ -72,7 +74,7 @@ public class TopSquareCompartmentAliasTest { @Test public void testInvalidCopy() { try { - new TopSquareCompartmentAlias() { + new TopSquareCompartment() { /** * diff --git a/model/src/test/java/lcsb/mapviewer/model/map/graph/DataMiningTest.java b/model/src/test/java/lcsb/mapviewer/model/map/graph/DataMiningTest.java index bd6ed6c44c..9f0dfedcbf 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/graph/DataMiningTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/graph/DataMiningTest.java @@ -11,8 +11,8 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.GenericProtein; public class DataMiningTest { @@ -39,7 +39,7 @@ public class DataMiningTest { try { DataMining dm = new DataMining(); String description = "xdg"; - Alias element = new GenericProteinAlias("id"); + Element element = new GenericProtein("id"); Integer id = 61; List<MiriamData> references = new ArrayList<>(); List<MiriamData> suggestedConnections = new ArrayList<>(); 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 217cad91d9..8f9daf1179 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,14 +1,14 @@ package lcsb.mapviewer.model.map.layout; -import lcsb.mapviewer.model.map.layout.alias.AllAliasTests; 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; @RunWith(Suite.class) -@SuiteClasses({ AllAliasTests.class, // +@SuiteClasses({ AllSpeciesTests.class, // AllGraphicsTests.class, // ColorSchemaTest.class, // GenericColorSchemaTest.class, // diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/ColorSchemaTest.java b/model/src/test/java/lcsb/mapviewer/model/map/layout/ColorSchemaTest.java index b16bec7df7..181cce38fa 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/ColorSchemaTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/layout/ColorSchemaTest.java @@ -14,9 +14,9 @@ import org.junit.Test; import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Species; public class ColorSchemaTest { @@ -33,7 +33,7 @@ public class ColorSchemaTest { try { ColorSchema cs = new GenericColorSchema(); List<String> compartments = new ArrayList<>(); - List<Class<? extends Alias>> types = new ArrayList<>(); + List<Class<? extends Element>> types = new ArrayList<>(); String name = "S"; String generalIdentifier = "id"; List<Pair<MiriamType, String>> identifierColumns = new ArrayList<>(); @@ -149,7 +149,7 @@ public class ColorSchemaTest { assertNotNull(cs.toString()); cs.setName("gene name"); cs.addCompartment("A"); - cs.addType(SpeciesAlias.class); + cs.addType(Species.class); cs.setValue(1.2); cs.setColor(Color.BLACK); cs.setGeneralIdentifier("a"); @@ -206,9 +206,9 @@ public class ColorSchemaTest { public void testAddTypes() throws Exception { try { ColorSchema cs = new GenericColorSchema(); - List<Class<? extends Alias>> compartments = new ArrayList<>(); - compartments.add(SpeciesAlias.class); - compartments.add(ProteinAlias.class); + List<Class<? extends Element>> compartments = new ArrayList<>(); + compartments.add(Species.class); + compartments.add(Protein.class); cs.addTypes(compartments); assertEquals(2, cs.getTypes().size()); } catch (Exception e) { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/AllAliasTests.java b/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/AllAliasTests.java deleted file mode 100644 index cc98feb306..0000000000 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/AllAliasTests.java +++ /dev/null @@ -1,28 +0,0 @@ -package lcsb.mapviewer.model.map.layout.alias; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -@RunWith(Suite.class) -@SuiteClasses({ AliasComparatorTest.class, // - AliasGroupTest.class, // - AliasTest.class, // - ArtifitialCompartmentAliasTest.class, // - BottomSquareCompartmentAliasTest.class, // - CompartmentAliasComparatorTest.class, // - CompartmentAliasTest.class, // - ComplexAliasComparatorTest.class, // - ComplexAliasTest.class, // - LeftSquareCompartmentAliasTest.class, // - OvalCompartmentAliasTest.class, // - RightSquareCompartmentAliasTest.class, // - SearchIndexTest.class, // - SpeciesAliasComparatorTest.class, // - SpeciesAliasTest.class, // - SquareCompartmentAliasTest.class, // - TopSquareCompartmentAliasTest.class,// -}) -public class AllAliasTests { - -} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/model/AliasSubmodelConnectionComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/model/AliasSubmodelConnectionComparatorTest.java index 3649aed846..6d28272b8a 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/model/AliasSubmodelConnectionComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/model/AliasSubmodelConnectionComparatorTest.java @@ -9,11 +9,11 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; 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.GenericProtein; public class AliasSubmodelConnectionComparatorTest { @@ -94,15 +94,15 @@ public class AliasSubmodelConnectionComparatorTest { Model model = new ModelFullIndexed(null); model.setNotes("Some description"); - GenericProteinAlias protein = new GenericProteinAlias("A"); + GenericProtein protein = new GenericProtein("A"); protein.setName("ad"); model.addAlias(protein); - GenericProteinAlias alias = new GenericProteinAlias("a_id"); + GenericProtein alias = new GenericProtein("a_id"); alias.setName("ad"); model.addAlias(alias); - model.addAlias(new CompartmentAlias("default")); + model.addAlias(new Compartment("default")); Layer layer = new Layer(); layer.setName("layer name"); @@ -120,8 +120,8 @@ public class AliasSubmodelConnectionComparatorTest { return result; } - private Alias createAlias() { - Alias alias = new GenericProteinAlias("alias_id"); + private Element createAlias() { + Element alias = new GenericProtein("alias_id"); alias.setColor(Color.BLACK); return alias; } 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 c2076026bb..83c038e0d1 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 @@ -16,15 +16,15 @@ import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamRelationType; import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.OverviewImage; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.compartment.PathwayCompartment; import lcsb.mapviewer.model.map.graph.DataMiningSet; import lcsb.mapviewer.model.map.layout.Layout; -import lcsb.mapviewer.model.map.layout.alias.ArtifitialCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.type.TransportReaction; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class ModelComparatorTest { Logger logger = Logger.getLogger(ModelComparatorTest.class); @@ -84,16 +84,16 @@ public class ModelComparatorTest { Model model1 = getModel(); Model model2 = getModel(); - CompartmentAlias alias = new ArtifitialCompartmentAlias(); + Compartment alias = new PathwayCompartment(); alias.setAliasId("1"); - CompartmentAlias alias2 = new ArtifitialCompartmentAlias(); + Compartment alias2 = new PathwayCompartment(); alias2.setAliasId("12"); model1.addAlias(alias); model1.addAlias(alias2); - alias = new ArtifitialCompartmentAlias(); + alias = new PathwayCompartment(); alias.setAliasId("1"); - alias2 = new ArtifitialCompartmentAlias(); + alias2 = new PathwayCompartment(); alias2.setAliasId("12"); model2.addAlias(alias); model2.addAlias(alias2); @@ -145,7 +145,7 @@ public class ModelComparatorTest { Model model1 = getModel(); Model model2 = getModel(); - SpeciesAlias mockAlias = Mockito.mock(SpeciesAlias.class); + Species mockAlias = Mockito.mock(Species.class); when(mockAlias.getAliasId()).thenReturn("1"); model1.addAlias(mockAlias); @@ -192,7 +192,7 @@ public class ModelComparatorTest { model1 = getModel(); model2 = getModel(); - GenericProteinAlias alias = new GenericProteinAlias("SAd"); + GenericProtein alias = new GenericProtein("SAd"); model1.addAlias(alias); @@ -210,7 +210,7 @@ public class ModelComparatorTest { model1 = getModel(); model2 = getModel(); - model1.addAlias(new CompartmentAlias("unk_id")); + model1.addAlias(new Compartment("unk_id")); assertTrue(comparator.compare(model1, model2) != 0); assertTrue(comparator.compare(model2, model1) != 0); @@ -242,7 +242,7 @@ public class ModelComparatorTest { model1 = getModel(); model2 = getModel(); - model1.addAlias(new GenericProteinAlias("ASdas")); + model1.addAlias(new GenericProtein("ASdas")); assertTrue(comparator.compare(model1, model2) != 0); assertTrue(comparator.compare(model2, model1) != 0); @@ -386,12 +386,12 @@ public class ModelComparatorTest { private Model getModel() { Model model = new ModelFullIndexed(null); model.setNotes("Some description"); - GenericProteinAlias alias = new GenericProteinAlias("a_id"); + GenericProtein alias = new GenericProtein("a_id"); alias.setName("ad"); model.addAlias(alias); - model.addAlias(new CompartmentAlias("default")); + model.addAlias(new Compartment("default")); Layer layer = new Layer(); layer.setName("layer name"); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelDataTest.java b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelDataTest.java index 56c1808e30..e5031f22c3 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelDataTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelDataTest.java @@ -20,12 +20,12 @@ import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.Project; import lcsb.mapviewer.model.map.OverviewImage; import lcsb.mapviewer.model.map.graph.DataMiningSet; +import lcsb.mapviewer.model.map.layout.BlockDiagram; import lcsb.mapviewer.model.map.layout.Layout; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.BlockDiagram; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; 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.GenericProtein; public class ModelDataTest { @@ -51,8 +51,8 @@ public class ModelDataTest { public void testAddAliases() { try { ModelData md = new ModelData(); - List<Alias> aliases = new ArrayList<>(); - aliases.add(new GenericProteinAlias("unk_id")); + List<Element> aliases = new ArrayList<>(); + aliases.add(new GenericProtein("unk_id")); md.addAliases(aliases); assertEquals(1, md.getAliases().size()); } catch (Exception e) { @@ -157,7 +157,7 @@ public class ModelDataTest { public void testRemoveAlias2() { try { ModelData md = new ModelData(); - md.removeAlias(new GenericProteinAlias("unk_id")); + md.removeAlias(new GenericProtein("unk_id")); } catch (Exception e) { e.printStackTrace(); throw e; @@ -168,7 +168,7 @@ public class ModelDataTest { public void testRemoveAlias3() { try { ModelData md = new ModelData(); - Alias alias = new GenericProteinAlias("unk_id"); + Element alias = new GenericProtein("unk_id"); md.addAlias(alias); assertEquals(1, md.getAliases().size()); md.removeAlias(alias); @@ -323,7 +323,7 @@ public class ModelDataTest { public void testGetters() { try { ModelData md = new ModelData(); - Set<Alias> aliases = new HashSet<>(); + Set<Element> aliases = new HashSet<>(); List<Layout> layouts = new ArrayList<>(); Set<Layer> layers = new HashSet<>(); Set<Reaction> reactions = new HashSet<>(); 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 00f0471eb2..968d063f21 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 @@ -29,19 +29,19 @@ import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.OverviewImage; import lcsb.mapviewer.model.map.OverviewImageLink; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.compartment.PathwayCompartment; import lcsb.mapviewer.model.map.graph.DataMiningSet; import lcsb.mapviewer.model.map.layout.Layout; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ArtifitialCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.reaction.Product; import lcsb.mapviewer.model.map.reaction.Reactant; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.type.TransportReaction; +import lcsb.mapviewer.model.map.species.Element; +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.user.User; public class ModelFullIndexedTest { @@ -59,13 +59,13 @@ public class ModelFullIndexedTest { public void testConstructor() { try { ModelFullIndexed model = new ModelFullIndexed(null); - SpeciesAlias proteinAlias = new GenericProteinAlias("1a"); - SpeciesAlias proteinAlias2 = new GenericProteinAlias("f"); - SpeciesAlias proteinAlias3 = new GenericProteinAlias("fa"); + Species proteinAlias = new GenericProtein("1a"); + Species proteinAlias2 = new GenericProtein("f"); + Species proteinAlias3 = new GenericProtein("fa"); - Alias compartmentAlias = new CompartmentAlias("aaa"); - Alias compartmentAlias3 = new CompartmentAlias("aaa3"); - Alias compartmentAlias2 = new ArtifitialCompartmentAlias(); + Element compartmentAlias = new Compartment("aaa"); + Element compartmentAlias3 = new Compartment("aaa3"); + Element compartmentAlias2 = new PathwayCompartment(); compartmentAlias2.setAliasId("aaa2"); model.addAlias(proteinAlias); model.addAlias(proteinAlias2); @@ -117,7 +117,7 @@ public class ModelFullIndexedTest { @Test public void testAddInvalidAlias() { try { - Alias alias = Mockito.mock(Alias.class); + Element alias = Mockito.mock(Element.class); ModelFullIndexed model = new ModelFullIndexed(null); model.addAlias(alias); @@ -137,7 +137,7 @@ public class ModelFullIndexedTest { try { ModelFullIndexed model = new ModelFullIndexed(null); - ComplexAlias alias = new ComplexAlias("1"); + Complex alias = new Complex("1"); model.addAlias(alias); try { @@ -171,11 +171,11 @@ public class ModelFullIndexedTest { try { ModelFullIndexed model = new ModelFullIndexed(null); - model.addAlias(new CompartmentAlias("default")); + model.addAlias(new Compartment("default")); - ComplexAlias alias = new ComplexAlias("1"); + Complex alias = new Complex("1"); - Alias proteinAlias = new GenericProteinAlias("asd"); + Element proteinAlias = new GenericProtein("asd"); proteinAlias.setAliasId("zz"); proteinAlias.setParent(alias); @@ -196,13 +196,13 @@ public class ModelFullIndexedTest { try { ModelFullIndexed model = new ModelFullIndexed(null); - CompartmentAlias compAlias = new CompartmentAlias("default"); + Compartment compAlias = new Compartment("default"); model.addAlias(compAlias); - ComplexAlias alias = new ComplexAlias("1"); + Complex alias = new Complex("1"); alias.setParent(compAlias); - Alias proteinAlias = new GenericProteinAlias("asd"); + Element proteinAlias = new GenericProtein("asd"); proteinAlias.setAliasId("zz"); proteinAlias.setParent(alias); @@ -224,7 +224,7 @@ public class ModelFullIndexedTest { ModelFullIndexed model = new ModelFullIndexed(null); assertNull(model.getAliasByAliasId("id")); - SpeciesAlias alias = new GenericProteinAlias("asd"); + Species alias = new GenericProtein("asd"); alias.setAliasId("id"); model.addAlias(alias); @@ -242,7 +242,7 @@ public class ModelFullIndexedTest { try { ModelFullIndexed model = new ModelFullIndexed(null); - CompartmentAlias alias = new CompartmentAlias("1"); + Compartment alias = new Compartment("1"); assertEquals(0, model.getCompartmentsAliases().size()); model.addAlias(alias); @@ -296,7 +296,7 @@ public class ModelFullIndexedTest { try { int aliasId = 12; ModelFullIndexed model = new ModelFullIndexed(null); - Alias alias = new GenericProteinAlias("1"); + Element alias = new GenericProtein("1"); alias.setId(aliasId); assertNull(model.getAliasByDbId(aliasId)); model.addAlias(alias); @@ -312,20 +312,20 @@ public class ModelFullIndexedTest { public void testGetSortedCompartmentAliases() { try { ModelFullIndexed model = new ModelFullIndexed(null); - CompartmentAlias alias = new CompartmentAlias("a1"); + Compartment alias = new Compartment("a1"); alias.setWidth(12); alias.setHeight(12); model.addAlias(alias); - alias = new CompartmentAlias("a2"); + alias = new Compartment("a2"); alias.setWidth(14); alias.setHeight(14); model.addAlias(alias); - alias = new CompartmentAlias("a3"); + alias = new Compartment("a3"); alias.setWidth(13); alias.setHeight(13); model.addAlias(alias); - List<CompartmentAlias> aliases = model.getSortedCompartmentsAliases(); + List<Compartment> aliases = model.getSortedCompartmentsAliases(); assertEquals(196.0, aliases.get(0).getSize(), Configuration.EPSILON); assertEquals(169.0, aliases.get(1).getSize(), Configuration.EPSILON); assertEquals(144.0, aliases.get(2).getSize(), Configuration.EPSILON); @@ -340,12 +340,12 @@ public class ModelFullIndexedTest { public void testRemoveCompartmentAliases() { try { ModelFullIndexed model = new ModelFullIndexed(null); - CompartmentAlias alias = new CompartmentAlias("a1"); + Compartment alias = new Compartment("a1"); alias.setWidth(12); alias.setHeight(12); model.addAlias(alias); - alias = new CompartmentAlias("a2"); + alias = new Compartment("a2"); alias.setWidth(14); alias.setHeight(14); model.addAlias(alias); @@ -365,18 +365,18 @@ public class ModelFullIndexedTest { try { ModelFullIndexed model = new ModelFullIndexed(null); - CompartmentAlias alias = new CompartmentAlias("1"); + Compartment alias = new Compartment("1"); alias.setWidth(100); alias.setHeight(100); - List<Alias> aliases = new ArrayList<>(); + List<Element> aliases = new ArrayList<>(); aliases.add(alias); - ComplexAlias cAlias = new ComplexAlias("ca1"); + Complex cAlias = new Complex("ca1"); aliases.add(cAlias); cAlias.setWidth(10); cAlias.setHeight(10); - SpeciesAlias sAlias = new GenericProteinAlias("a1"); + Species sAlias = new GenericProtein("a1"); aliases.add(sAlias); sAlias.setWidth(20); sAlias.setHeight(20); @@ -387,7 +387,7 @@ public class ModelFullIndexedTest { assertEquals(1, model.getComplexAliases().size()); assertEquals(1, model.getNotComplexSpeciesAliases().size()); - List<Alias> sortedAliases = model.getSortedAliases(); + List<Element> sortedAliases = model.getSortedAliases(); assertEquals(alias, sortedAliases.get(0)); assertEquals(sAlias, sortedAliases.get(1)); @@ -404,9 +404,9 @@ public class ModelFullIndexedTest { try { ModelFullIndexed model = new ModelFullIndexed(null); - CompartmentAlias parentAlias = new CompartmentAlias("parent_id"); + Compartment parentAlias = new Compartment("parent_id"); - CompartmentAlias alias = new CompartmentAlias("child_id"); + Compartment alias = new Compartment("child_id"); alias.setParent(parentAlias); model.addAlias(alias); @@ -426,22 +426,22 @@ public class ModelFullIndexedTest { public void testRemoveComplexAlias() { try { ModelFullIndexed model = new ModelFullIndexed(null); - model.addAlias(new CompartmentAlias("default")); + model.addAlias(new Compartment("default")); - ComplexAlias parentAlias = new ComplexAlias("a"); + Complex parentAlias = new Complex("a"); - ComplexAlias alias = new ComplexAlias("b"); + Complex alias = new Complex("b"); alias.setParent(parentAlias); alias.setAliasId("1"); - alias.setCompartmentAlias(new CompartmentAlias("comp_alias")); - alias.setComplexAlias(new ComplexAlias("d")); + alias.setCompartmentAlias(new Compartment("comp_alias")); + alias.setComplexAlias(new Complex("d")); model.addAlias(alias); assertEquals(2, model.getAliases().size()); - alias.setComplexAlias(new ComplexAlias("xxx")); + alias.setComplexAlias(new Complex("xxx")); model.removeAlias(alias); assertEquals(1, model.getAliases().size()); @@ -457,8 +457,8 @@ public class ModelFullIndexedTest { try { ModelFullIndexed model = new ModelFullIndexed(null); - Alias alias = new GenericProteinAlias("id"); - alias.setParent(Mockito.mock(Alias.class)); + Element alias = new GenericProtein("id"); + alias.setParent(Mockito.mock(Element.class)); model.removeAlias(alias); @@ -754,7 +754,7 @@ public class ModelFullIndexedTest { Double height = 13.0; String heightStr = "13.0"; int heightInt = 13; - Set<Alias> aliases = new HashSet<>(); + Set<Element> aliases = new HashSet<>(); List<Layout> layouts = new ArrayList<>(); int zoomLevels = 98; int tileSize = 1024; @@ -826,7 +826,7 @@ public class ModelFullIndexedTest { Reaction reaction = new Reaction(); reaction.setIdReaction(reactionId); model.addReaction(reaction); - SpeciesAlias alias = new GenericProteinAlias("2"); + Species alias = new GenericProtein("2"); model.addAlias(alias); Collection<AnnotatedObject> obj = model.getAnnotatedObjects(); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelSubmodelConnectionComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelSubmodelConnectionComparatorTest.java index ad3ac46f5e..fe5dcd2ee1 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelSubmodelConnectionComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelSubmodelConnectionComparatorTest.java @@ -7,11 +7,11 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class ModelSubmodelConnectionComparatorTest { @@ -86,11 +86,11 @@ public class ModelSubmodelConnectionComparatorTest { model.setNotes("Some description"); - SpeciesAlias alias = new GenericProteinAlias("a_id"); + Species alias = new GenericProtein("a_id"); alias.setName("ad"); model.addAlias(alias); - model.addAlias(new CompartmentAlias("default")); + model.addAlias(new Compartment("default")); Layer layer = new Layer(); layer.setName("layer name"); 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 6d33781d45..7aa22330bb 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 @@ -18,32 +18,29 @@ import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamRelationType; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; 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.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class ModelTest { Logger logger = Logger.getLogger(ModelTest.class); - private SpeciesAlias alias; + private Species alias; - private ComplexAlias cAlias; + private Complex cAlias; private Model model; - private CompartmentAlias compAlias; @Before public void setUp() throws Exception { model = new ModelFullIndexed(null); - alias = new GenericProteinAlias("sa1"); + alias = new GenericProtein("sa1"); - cAlias = new ComplexAlias("sa2"); - - compAlias = new CompartmentAlias("comp_id"); + cAlias = new Complex("sa2"); } @@ -55,7 +52,7 @@ public class ModelTest { public void testAddAlias() { try { model.addAlias(alias); - Alias sAlias = model.getAliasByAliasId(alias.getAliasId()); + Element sAlias = model.getAliasByAliasId(alias.getAliasId()); assertNotNull(sAlias); sAlias = model.getAliasByAliasId(alias.getAliasId() + "blbla"); assertNull(sAlias); @@ -69,12 +66,12 @@ public class ModelTest { @Test public void testGetAliasList() { try { - Set<Alias> aliases = model.getAliases(); + Set<Element> aliases = model.getAliases(); assertEquals(0, aliases.size()); model.addAlias(alias); assertEquals(1, aliases.size()); - Alias sAlias = model.getAliasByAliasId(alias.getAliasId()); + Element sAlias = model.getAliasByAliasId(alias.getAliasId()); assertNotNull(sAlias); sAlias = model.getAliasByAliasId(alias.getAliasId() + "blbla"); assertNull(sAlias); @@ -131,16 +128,16 @@ public class ModelTest { assertNotNull(elements); assertEquals(1, elements.size()); AnnotatedObject element = elements.iterator().next(); - assertTrue(element instanceof SpeciesAlias); - SpeciesAlias species = (SpeciesAlias) element; + assertTrue(element instanceof Species); + Species species = (Species) element; assertEquals("s5", species.getName()); elements = model.getElementsByAnnotation(new MiriamData(MiriamRelationType.BQ_MODEL_IS, MiriamType.CHEBI, "CHEBI:12")); assertNotNull(elements); assertEquals(1, elements.size()); element = elements.iterator().next(); - assertTrue(element instanceof CompartmentAlias); - CompartmentAlias compartment = (CompartmentAlias) element; + assertTrue(element instanceof Compartment); + Compartment compartment = (Compartment) element; assertEquals("c1", compartment.getName()); elements = model.getElementsByAnnotation(new MiriamData(MiriamRelationType.BQ_MODEL_IS, MiriamType.CHEBI, "CHEBI:12234")); @@ -156,24 +153,24 @@ public class ModelTest { private Model createModel() { Model model = new ModelFullIndexed(null); - SpeciesAlias proteinAlias = new GenericProteinAlias("sa1"); + Species proteinAlias = new GenericProtein("sa1"); proteinAlias.setName("s1"); model.addAlias(proteinAlias); - SpeciesAlias proteinAlias2 = new GenericProteinAlias("sa2"); + Species proteinAlias2 = new GenericProtein("sa2"); proteinAlias2.setName("s1"); model.addAlias(proteinAlias2); - SpeciesAlias proteinAlias3 = new GenericProteinAlias("sa3"); + Species proteinAlias3 = new GenericProtein("sa3"); proteinAlias3.setName("s1"); model.addAlias(proteinAlias3); - SpeciesAlias proteinAlias4 = new GenericProteinAlias("sa4"); + Species proteinAlias4 = new GenericProtein("sa4"); proteinAlias4.setName("s5"); proteinAlias4.addMiriamData(new MiriamData(MiriamRelationType.BQ_MODEL_IS, MiriamType.CHEMBL_TARGET, "CHEMBL12345")); model.addAlias(proteinAlias4); - CompartmentAlias compartmentAlias = new CompartmentAlias("cca"); + Compartment compartmentAlias = new Compartment("cca"); compartmentAlias.setName("c1"); compartmentAlias.addMiriamData(new MiriamData(MiriamRelationType.BQ_MODEL_IS, MiriamType.CHEBI, "CHEBI:12")); @@ -187,40 +184,40 @@ public class ModelTest { try { Model model = new ModelFullIndexed(null); - SpeciesAlias alias = new GenericProteinAlias("2"); + Species alias = new GenericProtein("2"); alias.setWidth(100); alias.setHeight(100); model.addAlias(alias); - alias = new GenericProteinAlias("3"); + alias = new GenericProtein("3"); alias.setWidth(10); alias.setHeight(10); model.addAlias(alias); - alias = new GenericProteinAlias("4"); + alias = new GenericProtein("4"); alias.setWidth(200); alias.setHeight(100); model.addAlias(alias); - CompartmentAlias cAlias = new CompartmentAlias("5"); + Compartment cAlias = new Compartment("5"); cAlias.setWidth(10); cAlias.setHeight(20); model.addAlias(cAlias); - cAlias = new CompartmentAlias("6"); + cAlias = new Compartment("6"); cAlias.setWidth(100); cAlias.setHeight(200); model.addAlias(cAlias); - cAlias = new CompartmentAlias("7"); + cAlias = new Compartment("7"); cAlias.setWidth(20); cAlias.setHeight(30); model.addAlias(cAlias); - List<Alias> sortedAliases = model.getAliasesSortedBySize(); + List<Element> sortedAliases = model.getAliasesSortedBySize(); if (sortedAliases.size() > 0) { double last = (sortedAliases.get(0)).getHeight() * (sortedAliases.get(0)).getWidth(); - for (Alias a : sortedAliases) { + for (Element a : sortedAliases) { assertTrue(last >= a.getHeight() * a.getWidth()); } } 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 daf95263a3..dbf30972ba 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 @@ -9,11 +9,11 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class SubmodelConnectionComparatorTest { @@ -165,12 +165,12 @@ public class SubmodelConnectionComparatorTest { model.setNotes("Some description"); - SpeciesAlias alias = new GenericProteinAlias("a_id"); + Species alias = new GenericProtein("a_id"); alias.setName("ad"); alias.setAliasId("a_id"); model.addAlias(alias); - model.addAlias(new CompartmentAlias("default")); + model.addAlias(new Compartment("default")); Layer layer = new Layer(); layer.setName("layer name"); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/modifier/CatalysisTest.java b/model/src/test/java/lcsb/mapviewer/model/map/modifier/CatalysisTest.java index 0d8269a0e6..ba1b40daf9 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/modifier/CatalysisTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/modifier/CatalysisTest.java @@ -10,7 +10,7 @@ import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaAlias; +import lcsb.mapviewer.model.map.species.AntisenseRna; public class CatalysisTest { @@ -35,7 +35,7 @@ public class CatalysisTest { @Test public void testConstructor() { try { - Catalysis modifier = new Catalysis(new AntisenseRnaAlias("unk_id")); + Catalysis modifier = new Catalysis(new AntisenseRna("unk_id")); assertNotNull(modifier); } catch (Exception e) { e.printStackTrace(); @@ -46,7 +46,7 @@ public class CatalysisTest { @Test public void testConstructor2() { try { - Catalysis modifier = new Catalysis(new AntisenseRnaAlias("unk_id")); + Catalysis modifier = new Catalysis(new AntisenseRna("unk_id")); modifier.setLine(new PolylineData()); Catalysis modifier2 = new Catalysis(modifier); assertNotNull(modifier2); @@ -59,7 +59,7 @@ public class CatalysisTest { @Test public void testCopy() { try { - Catalysis modifier = new Catalysis(new AntisenseRnaAlias("unk_id")); + Catalysis modifier = new Catalysis(new AntisenseRna("unk_id")); modifier.setLine(new PolylineData()); Catalysis modifier2 = modifier.copy(); assertNotNull(modifier2); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/modifier/InhibitionTest.java b/model/src/test/java/lcsb/mapviewer/model/map/modifier/InhibitionTest.java index c3818fc0da..3f8af64c8d 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/modifier/InhibitionTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/modifier/InhibitionTest.java @@ -10,7 +10,7 @@ import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; +import lcsb.mapviewer.model.map.species.GenericProtein; public class InhibitionTest { @@ -35,7 +35,7 @@ public class InhibitionTest { @Test public void testConstructor() { try { - Inhibition modifier = new Inhibition(new GenericProteinAlias("unk_id")); + Inhibition modifier = new Inhibition(new GenericProtein("unk_id")); assertNotNull(modifier); } catch (Exception e) { e.printStackTrace(); @@ -46,7 +46,7 @@ public class InhibitionTest { @Test public void testConstructor2() { try { - Inhibition modifier = new Inhibition(new GenericProteinAlias("unk_id")); + Inhibition modifier = new Inhibition(new GenericProtein("unk_id")); modifier.setLine(new PolylineData()); Inhibition modifier2 = new Inhibition(modifier); assertNotNull(modifier2); @@ -59,7 +59,7 @@ public class InhibitionTest { @Test public void testCopy() { try { - Inhibition modifier = new Inhibition(new GenericProteinAlias("unk_id")); + Inhibition modifier = new Inhibition(new GenericProtein("unk_id")); modifier.setLine(new PolylineData()); Inhibition modifier2 = modifier.copy(); assertNotNull(modifier2); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/modifier/ModulationTest.java b/model/src/test/java/lcsb/mapviewer/model/map/modifier/ModulationTest.java index 5508d9c5a4..d465085a0e 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/modifier/ModulationTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/modifier/ModulationTest.java @@ -10,7 +10,7 @@ import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; +import lcsb.mapviewer.model.map.species.GenericProtein; public class ModulationTest { @@ -35,7 +35,7 @@ public class ModulationTest { @Test public void testConstructor() { try { - Modulation modifier = new Modulation(new GenericProteinAlias("unk_id")); + Modulation modifier = new Modulation(new GenericProtein("unk_id")); assertNotNull(modifier); } catch (Exception e) { e.printStackTrace(); @@ -46,7 +46,7 @@ public class ModulationTest { @Test public void testConstructor2() { try { - Modulation modifier = new Modulation(new GenericProteinAlias("unk_id")); + Modulation modifier = new Modulation(new GenericProtein("unk_id")); modifier.setLine(new PolylineData()); Modulation modifier2 = new Modulation(modifier); assertNotNull(modifier2); @@ -77,7 +77,7 @@ public class ModulationTest { @Test public void testCopy() { try { - Modulation modifier = new Modulation(new GenericProteinAlias("unk_id")); + Modulation modifier = new Modulation(new GenericProtein("unk_id")); modifier.setLine(new PolylineData()); Modulation modifier2 = modifier.copy(); assertNotNull(modifier2); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/modifier/PhysicalStimulationTest.java b/model/src/test/java/lcsb/mapviewer/model/map/modifier/PhysicalStimulationTest.java index b6f2ca0e75..106238c323 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/modifier/PhysicalStimulationTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/modifier/PhysicalStimulationTest.java @@ -10,7 +10,7 @@ import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; +import lcsb.mapviewer.model.map.species.GenericProtein; public class PhysicalStimulationTest { @@ -35,7 +35,7 @@ public class PhysicalStimulationTest { @Test public void testConstructor() { try { - PhysicalStimulation modifier = new PhysicalStimulation(new GenericProteinAlias("unk_id")); + PhysicalStimulation modifier = new PhysicalStimulation(new GenericProtein("unk_id")); assertNotNull(modifier); } catch (Exception e) { e.printStackTrace(); @@ -46,7 +46,7 @@ public class PhysicalStimulationTest { @Test public void testConstructor2() { try { - PhysicalStimulation modifier = new PhysicalStimulation(new GenericProteinAlias("unk_id")); + PhysicalStimulation modifier = new PhysicalStimulation(new GenericProtein("unk_id")); modifier.setLine(new PolylineData()); PhysicalStimulation modifier2 = new PhysicalStimulation(modifier); assertNotNull(modifier2); @@ -77,7 +77,7 @@ public class PhysicalStimulationTest { @Test public void testCopy() { try { - PhysicalStimulation modifier = new PhysicalStimulation(new GenericProteinAlias("unk_id")); + PhysicalStimulation modifier = new PhysicalStimulation(new GenericProtein("unk_id")); modifier.setLine(new PolylineData()); PhysicalStimulation modifier2 = modifier.copy(); assertNotNull(modifier2); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/modifier/TriggerTest.java b/model/src/test/java/lcsb/mapviewer/model/map/modifier/TriggerTest.java index f6ea1e96e4..f0d3ebb23b 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/modifier/TriggerTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/modifier/TriggerTest.java @@ -10,7 +10,7 @@ import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; +import lcsb.mapviewer.model.map.species.GenericProtein; public class TriggerTest { @@ -35,7 +35,7 @@ public class TriggerTest { @Test public void testConstructor() { try { - Trigger modifier = new Trigger(new GenericProteinAlias("unk_id")); + Trigger modifier = new Trigger(new GenericProtein("unk_id")); assertNotNull(modifier); } catch (Exception e) { e.printStackTrace(); @@ -46,7 +46,7 @@ public class TriggerTest { @Test public void testConstructor2() { try { - Trigger modifier = new Trigger(new GenericProteinAlias("unk_id")); + Trigger modifier = new Trigger(new GenericProtein("unk_id")); modifier.setLine(new PolylineData()); Trigger modifier2 = new Trigger(modifier); assertNotNull(modifier2); @@ -59,7 +59,7 @@ public class TriggerTest { @Test public void testCopy() { try { - Trigger modifier = new Trigger(new GenericProteinAlias("unk_id")); + Trigger modifier = new Trigger(new GenericProtein("unk_id")); modifier.setLine(new PolylineData()); Trigger modifier2 = modifier.copy(); assertNotNull(modifier2); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/modifier/UnknownCatalysisTest.java b/model/src/test/java/lcsb/mapviewer/model/map/modifier/UnknownCatalysisTest.java index 8e2a4eff08..dcf4d289ae 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/modifier/UnknownCatalysisTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/modifier/UnknownCatalysisTest.java @@ -10,7 +10,7 @@ import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; +import lcsb.mapviewer.model.map.species.GenericProtein; public class UnknownCatalysisTest { @@ -35,7 +35,7 @@ public class UnknownCatalysisTest { @Test public void testConstructor() { try { - UnknownCatalysis modifier = new UnknownCatalysis(new GenericProteinAlias("unk_id")); + UnknownCatalysis modifier = new UnknownCatalysis(new GenericProtein("unk_id")); assertNotNull(modifier); } catch (Exception e) { e.printStackTrace(); @@ -46,7 +46,7 @@ public class UnknownCatalysisTest { @Test public void testConstructor2() { try { - UnknownCatalysis modifier = new UnknownCatalysis(new GenericProteinAlias("unk_id")); + UnknownCatalysis modifier = new UnknownCatalysis(new GenericProtein("unk_id")); modifier.setLine(new PolylineData()); UnknownCatalysis modifier2 = new UnknownCatalysis(modifier); assertNotNull(modifier2); @@ -59,7 +59,7 @@ public class UnknownCatalysisTest { @Test public void testCopy() { try { - UnknownCatalysis modifier = new UnknownCatalysis(new GenericProteinAlias("unk_id")); + UnknownCatalysis modifier = new UnknownCatalysis(new GenericProtein("unk_id")); modifier.setLine(new PolylineData()); UnknownCatalysis modifier2 = modifier.copy(); assertNotNull(modifier2); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/modifier/UnknownInhibitionTest.java b/model/src/test/java/lcsb/mapviewer/model/map/modifier/UnknownInhibitionTest.java index 9d6214a920..c50a4c87e2 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/modifier/UnknownInhibitionTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/modifier/UnknownInhibitionTest.java @@ -10,7 +10,7 @@ import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; +import lcsb.mapviewer.model.map.species.GenericProtein; public class UnknownInhibitionTest { @@ -35,7 +35,7 @@ public class UnknownInhibitionTest { @Test public void testConstructor() { try { - UnknownInhibition modifier = new UnknownInhibition(new GenericProteinAlias("unk_id")); + UnknownInhibition modifier = new UnknownInhibition(new GenericProtein("unk_id")); assertNotNull(modifier); } catch (Exception e) { e.printStackTrace(); @@ -46,7 +46,7 @@ public class UnknownInhibitionTest { @Test public void testConstructor2() { try { - UnknownInhibition modifier = new UnknownInhibition(new GenericProteinAlias("unk_id")); + UnknownInhibition modifier = new UnknownInhibition(new GenericProtein("unk_id")); modifier.setLine(new PolylineData()); UnknownInhibition modifier2 = new UnknownInhibition(modifier); assertNotNull(modifier2); @@ -59,7 +59,7 @@ public class UnknownInhibitionTest { @Test public void testCopy() { try { - UnknownInhibition modifier = new UnknownInhibition(new GenericProteinAlias("unk_id")); + UnknownInhibition modifier = new UnknownInhibition(new GenericProtein("unk_id")); modifier.setLine(new PolylineData()); UnknownInhibition modifier2 = modifier.copy(); assertNotNull(modifier2); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/reaction/NodeOperatorComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/reaction/NodeOperatorComparatorTest.java index 3b161e9152..752671aace 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/reaction/NodeOperatorComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/reaction/NodeOperatorComparatorTest.java @@ -10,9 +10,9 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class NodeOperatorComparatorTest { @@ -74,7 +74,7 @@ public class NodeOperatorComparatorTest { operator2 = createNodeOperator(); Reactant reactant = (Reactant) operator1.getInputs().get(0); - reactant.setAlias(new GenericProteinAlias("id666")); + reactant.setAlias(new GenericProtein("id666")); assertTrue(comparator.compare(operator1, operator2) != 0); assertTrue(comparator.compare(operator2, operator1) != 0); @@ -100,7 +100,7 @@ public class NodeOperatorComparatorTest { private NodeOperator createNodeOperator() { AndOperator result = new AndOperator(); - SpeciesAlias alias0 = new GenericProteinAlias("id0"); + Species alias0 = new GenericProtein("id0"); alias0.setName("protein a"); alias0.setX(12.0); alias0.setY(1.0); @@ -111,7 +111,7 @@ public class NodeOperatorComparatorTest { result.addOutput(product); - SpeciesAlias alias1 = new GenericProteinAlias("id1"); + Species alias1 = new GenericProtein("id1"); alias1.setName("protein b"); alias1.setX(120.0); alias1.setY(10.0); @@ -122,7 +122,7 @@ public class NodeOperatorComparatorTest { result.addInput(reactant); - SpeciesAlias alias2 = new GeneAlias("id2"); + Species alias2 = new Gene("id2"); alias2.setName("gene b"); alias2.setX(320.0); alias2.setY(30.0); 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 1c987b9b18..e6c1ceb06f 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 @@ -13,13 +13,13 @@ import lcsb.mapviewer.model.graphics.PolylineData; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamRelationType; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; -import lcsb.mapviewer.model.map.layout.alias.UnknownAlias; import lcsb.mapviewer.model.map.modifier.Catalysis; import lcsb.mapviewer.model.map.reaction.type.StateTransitionReaction; import lcsb.mapviewer.model.map.reaction.type.TransportReaction; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.SimpleMolecule; +import lcsb.mapviewer.model.map.species.Species; +import lcsb.mapviewer.model.map.species.Unknown; public class ReactionComparatorTest { @@ -248,19 +248,19 @@ public class ReactionComparatorTest { private Reaction createReaction() { Reaction reaction = new Reaction(); - SpeciesAlias alias = new GenericProteinAlias("id1"); + Species alias = new GenericProtein("id1"); alias.setName("ASD"); Reactant reactant = new Reactant(alias); - SpeciesAlias alias2 = new GenericProteinAlias("id2"); + Species alias2 = new GenericProtein("id2"); alias2.setName("ASD2"); Reactant reactant2 = new Reactant(alias2); - SpeciesAlias moelculeAlias = new SimpleMoleculeAlias("id3"); + Species moelculeAlias = new SimpleMolecule("id3"); moelculeAlias.setName("mol"); Product product = new Product(moelculeAlias); - SpeciesAlias unknownAlias = new UnknownAlias("id4"); + Species unknownAlias = new Unknown("id4"); unknownAlias.setName("unk"); Modifier modifier = new Catalysis(unknownAlias); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/reaction/ReactionNodeComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/reaction/ReactionNodeComparatorTest.java index 89c180e1e8..c317a22021 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/reaction/ReactionNodeComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/reaction/ReactionNodeComparatorTest.java @@ -10,9 +10,9 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.model.graphics.PolylineData; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class ReactionNodeComparatorTest { @@ -73,7 +73,7 @@ public class ReactionNodeComparatorTest { operator1 = createNodeOperator(); operator2 = createNodeOperator(); - operator1.setAlias(new GenericProteinAlias("new_id")); + operator1.setAlias(new GenericProtein("new_id")); assertTrue(comparator.compare(operator1, operator2) != 0); assertTrue(comparator.compare(operator2, operator1) != 0); @@ -94,7 +94,7 @@ public class ReactionNodeComparatorTest { private ReactionNode createNodeOperator() { - SpeciesAlias alias2 = new GeneAlias("id_1"); + Species alias2 = new Gene("id_1"); alias2.setName("gene b"); alias2.setX(320.0); alias2.setY(30.0); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/reaction/ReactionTest.java b/model/src/test/java/lcsb/mapviewer/model/map/reaction/ReactionTest.java index d31a79533a..12a353ab6b 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/reaction/ReactionTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/reaction/ReactionTest.java @@ -25,25 +25,25 @@ import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.graphics.PolylineData; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; 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.modifier.Catalysis; import lcsb.mapviewer.model.map.reaction.type.DissociationReaction; import lcsb.mapviewer.model.map.reaction.type.HeterodimerAssociationReaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class ReactionTest extends ModelTestFunctions { Logger logger = Logger.getLogger(ReactantTest.class); - private SpeciesAlias alias; + private Species alias; @Before public void setUp() throws Exception { - alias = new GenericProteinAlias("sa1"); + alias = new GenericProtein("sa1"); } @After @@ -235,7 +235,7 @@ public class ReactionTest extends ModelTestFunctions { assertEquals(0, reaction1.getVisibilityLevel()); Reactant reactant = new Reactant(); - Alias alias = new GenericProteinAlias("id_xyz"); + Element alias = new GenericProtein("id_xyz"); alias.setVisibilityLevel(2); reactant.setAlias(alias); reaction1.addReactant(reactant); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/AliasComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/AliasComparatorTest.java similarity index 59% rename from model/src/test/java/lcsb/mapviewer/model/map/layout/alias/AliasComparatorTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/AliasComparatorTest.java index 802c590322..768b5697b4 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/AliasComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/AliasComparatorTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -12,16 +12,23 @@ 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 { - AliasComparator comparator = new AliasComparator(); + ElementComparator comparator = new ElementComparator(); @Before public void setUp() throws Exception { @@ -34,7 +41,7 @@ public class AliasComparatorTest { @Test public void testCompareException() throws Exception { try { - comparator.compare(Mockito.mock(Alias.class), Mockito.mock(Alias.class)); + comparator.compare(Mockito.mock(Element.class), Mockito.mock(Element.class)); fail("Exception should occur"); } catch (NotImplementedException e) { @@ -48,8 +55,8 @@ public class AliasComparatorTest { @Test public void testEquals() throws Exception { try { - assertEquals(0, comparator.compare(new GenericProteinAlias("id2"), new GenericProteinAlias("id2"))); - assertEquals(0, comparator.compare(new ComplexAlias(), new ComplexAlias())); + 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) { @@ -61,39 +68,39 @@ public class AliasComparatorTest { @Test public void testDifferent() throws Exception { try { - assertTrue(comparator.compare(new GenericProteinAlias("id2"), new GenericProteinAlias("id1")) != 0); + assertTrue(comparator.compare(new GenericProtein("id2"), new GenericProtein("id1")) != 0); - assertTrue(comparator.compare(null, new GenericProteinAlias()) != 0); - assertTrue(comparator.compare(new GenericProteinAlias(), null) != 0); - assertTrue(comparator.compare(new GenericProteinAlias(), new ComplexAlias()) != 0); + assertTrue(comparator.compare(null, new GenericProtein()) != 0); + assertTrue(comparator.compare(new GenericProtein(), null) != 0); + assertTrue(comparator.compare(new GenericProtein(), new Complex()) != 0); - SpeciesAlias sa1 = new GenericProteinAlias("id2"); - SpeciesAlias sa2 = new GenericProteinAlias("id2"); + Species sa1 = new GenericProtein("id2"); + Species sa2 = new GenericProtein("id2"); sa2.setY(2); assertTrue(comparator.compare(sa1, sa2) != 0); - sa1 = new GenericProteinAlias("id2"); - sa2 = new GenericProteinAlias("id2"); + sa1 = new GenericProtein("id2"); + sa2 = new GenericProtein("id2"); sa2.setY(2); assertTrue(comparator.compare(sa1, sa2) != 0); - sa1 = new GenericProteinAlias("id2"); - sa2 = new GenericProteinAlias("id2"); + sa1 = new GenericProtein("id2"); + sa2 = new GenericProtein("id2"); sa2.setHeight(2); assertTrue(comparator.compare(sa1, sa2) != 0); - sa1 = new GenericProteinAlias("id2"); - sa2 = new GenericProteinAlias("id2"); + sa1 = new GenericProtein("id2"); + sa2 = new GenericProtein("id2"); sa2.setFontSize(2); assertTrue(comparator.compare(sa1, sa2) != 0); - sa1 = new GenericProteinAlias("id2"); - sa2 = new GenericProteinAlias("id2"); + sa1 = new GenericProtein("id2"); + sa2 = new GenericProtein("id2"); sa2.setColor(Color.BLUE); assertTrue(comparator.compare(sa1, sa2) != 0); - sa1 = new GenericProteinAlias("id2"); - sa2 = new GenericProteinAlias("id2"); + sa1 = new GenericProtein("id2"); + sa2 = new GenericProtein("id2"); sa2.setVisibilityLevel(6); assertTrue(comparator.compare(sa1, sa2) != 0); @@ -106,8 +113,8 @@ public class AliasComparatorTest { @Test public void testCompareSubmodel() throws Exception { try { - Alias alias1 = createAlias(); - Alias alias2 = createAlias(); + Element alias1 = createAlias(); + Element alias2 = createAlias(); assertEquals(0, comparator.compare(alias1, alias2)); alias1.setSubmodel(null); @@ -128,8 +135,8 @@ public class AliasComparatorTest { } } - private Alias createAlias() { - Alias result = new GenericProteinAlias("id2"); + private Element createAlias() { + Element result = new GenericProtein("id2"); AliasSubmodelConnection submodel = new AliasSubmodelConnection(getModel(), SubmodelType.DOWNSTREAM_TARGETS); result.setSubmodel(submodel); return result; @@ -139,15 +146,15 @@ public class AliasComparatorTest { Model model = new ModelFullIndexed(null); model.setNotes("Some description"); - GenericProteinAlias protein = new GenericProteinAlias("A"); + GenericProtein protein = new GenericProtein("A"); protein.setName("ad"); model.addAlias(protein); - ProteinAlias alias = new GenericProteinAlias("a_id"); + Protein alias = new GenericProtein("a_id"); alias.setName("ad"); model.addAlias(alias); - model.addAlias(new CompartmentAlias("default")); + model.addAlias(new Compartment("default")); Layer layer = new Layer(); layer.setName("layer name"); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/AliasGroupTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/AliasGroupTest.java similarity index 65% rename from model/src/test/java/lcsb/mapviewer/model/map/layout/alias/AliasGroupTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/AliasGroupTest.java index d9502c7273..058e4f8f56 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/AliasGroupTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/AliasGroupTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertEquals; @@ -10,6 +10,10 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import lcsb.mapviewer.model.map.layout.ElementGroup; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.GenericProtein; + public class AliasGroupTest { @Before @@ -23,7 +27,7 @@ public class AliasGroupTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new AliasGroup()); + SerializationUtils.serialize(new ElementGroup()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -33,9 +37,9 @@ public class AliasGroupTest { @Test public void testGetters() { try { - AliasGroup group = new AliasGroup(); + ElementGroup group = new ElementGroup(); String idGroup = "str"; - List<Alias> aliases = new ArrayList<>(); + List<Element> aliases = new ArrayList<>(); group.setIdGroup(idGroup); group.setAliases(aliases); @@ -51,8 +55,8 @@ public class AliasGroupTest { @Test public void testAddAlias() { try { - AliasGroup group = new AliasGroup(); - group.addAlias(new GenericProteinAlias()); + ElementGroup group = new ElementGroup(); + group.addAlias(new GenericProtein()); assertEquals(1, group.getAliases().size()); } catch (Exception e) { e.printStackTrace(); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/AliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/AliasTest.java similarity index 85% rename from model/src/test/java/lcsb/mapviewer/model/map/layout/alias/AliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/AliasTest.java index b62ef6a5e0..02340a265c 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/AliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/AliasTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -17,11 +17,16 @@ import org.junit.Test; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.InvalidArgumentException; +import lcsb.mapviewer.model.map.SearchIndex; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.layout.graphics.LayerText; 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 { @@ -37,8 +42,8 @@ public class AliasTest { @Test public void testDistance1() { - SpeciesAlias alias; - alias = new GenericProteinAlias(); + Species alias; + alias = new GenericProtein(); alias.setWidth(10); alias.setHeight(20); alias.setX(100.0); @@ -49,8 +54,8 @@ public class AliasTest { @Test public void testDistance2() { - SpeciesAlias alias; - alias = new GenericProteinAlias(); + Species alias; + alias = new GenericProtein(); alias.setWidth(10); alias.setHeight(20); alias.setX(100.0); @@ -61,8 +66,8 @@ public class AliasTest { @Test public void testDistance6() { - SpeciesAlias alias; - alias = new GenericProteinAlias(); + Species alias; + alias = new GenericProtein(); alias.setWidth(10); alias.setHeight(20); alias.setX(100.0); @@ -73,8 +78,8 @@ public class AliasTest { @Test public void testDistance3() { - SpeciesAlias alias; - alias = new GenericProteinAlias(); + Species alias; + alias = new GenericProtein(); alias.setWidth(10); alias.setHeight(20); alias.setX(100.0); @@ -85,8 +90,8 @@ public class AliasTest { @Test public void testDistance4() { - SpeciesAlias alias; - alias = new GenericProteinAlias(); + Species alias; + alias = new GenericProtein(); alias.setWidth(10); alias.setHeight(20); alias.setX(100.0); @@ -98,10 +103,10 @@ public class AliasTest { @Test public void testConstructor() { try { - GenericProteinAlias alias = new GenericProteinAlias(); + GenericProtein alias = new GenericProtein(); alias.addSearchIndex(new SearchIndex()); alias.setSubmodel(new AliasSubmodelConnection()); - Alias copy = new GenericProteinAlias(alias); + Element copy = new GenericProtein(alias); assertNotNull(copy); } catch (Exception e) { e.printStackTrace(); @@ -112,7 +117,7 @@ public class AliasTest { @Test public void testIncreaseBorder() { try { - SpeciesAlias alias = new GenericProteinAlias(); + Species alias = new GenericProtein(); assertEquals(0.0, alias.getSize(), Configuration.EPSILON); alias.increaseBorder(2); assertEquals(16.0, alias.getSize(), Configuration.EPSILON); @@ -125,7 +130,7 @@ public class AliasTest { @Test public void testGetters() { try { - SpeciesAlias alias = new GenericProteinAlias(); + Species alias = new GenericProtein(); Double nullDouble = null; String xStr = "1.2"; Double x = 1.2; @@ -139,7 +144,7 @@ public class AliasTest { String heightStr = "4.0"; Double height = 4.0; ModelData modelData = new ModelData(); - CompartmentAlias compartmentAlias = new CompartmentAlias(); + Compartment compartmentAlias = new Compartment("idd"); int id = 72; int transparencyLevel = 2; Model model = new ModelFullIndexed(modelData); @@ -218,10 +223,10 @@ public class AliasTest { @Test public void testContainsAlias() { try { - SpeciesAlias alias = new GenericProteinAlias(); + Species alias = new GenericProtein(); alias.setWidth(100); alias.setHeight(100); - SpeciesAlias alias2 = new GenericProteinAlias(); + Species alias2 = new GenericProtein(); alias2.setX(-2); alias2.setY(-2); alias2.setWidth(100); @@ -244,7 +249,7 @@ public class AliasTest { alias2.setHeight(200); assertFalse(alias.contains(alias2)); - CompartmentAlias alias3 = new CompartmentAlias(); + Compartment alias3 = new Compartment("idd"); alias3.setX(2); alias3.setY(2); alias3.setWidth(10); @@ -279,7 +284,7 @@ public class AliasTest { @Test public void testContainsLayerText() { try { - SpeciesAlias alias = new GenericProteinAlias(); + Species alias = new GenericProtein(); alias.setWidth(100); alias.setHeight(100); LayerText alias2 = new LayerText(); 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 new file mode 100644 index 0000000000..851a16e81f --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/AllSpeciesTests.java @@ -0,0 +1,27 @@ +package lcsb.mapviewer.model.map.species; + +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; + +@RunWith(Suite.class) +@SuiteClasses({ + AliasGroupTest.class, // + AliasTest.class, // + ArtifitialCompartmentAliasTest.class, // + ComplexAliasComparatorTest.class, // + ComplexAliasTest.class, // + SearchIndexTest.class, // + SpeciesAliasComparatorTest.class, // + SpeciesAliasTest.class, // +}) +public class AllSpeciesTests { + +} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/ArtifitialCompartmentAliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/ArtifitialCompartmentAliasTest.java similarity index 67% rename from model/src/test/java/lcsb/mapviewer/model/map/layout/alias/ArtifitialCompartmentAliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/ArtifitialCompartmentAliasTest.java index d4d7c28c60..2150eef721 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/ArtifitialCompartmentAliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/ArtifitialCompartmentAliasTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -10,6 +10,9 @@ import org.junit.Before; import org.junit.Test; 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 { @@ -24,9 +27,9 @@ public class ArtifitialCompartmentAliasTest { @Test public void test() throws Exception { try { - CompartmentAliasComparator comparator = new CompartmentAliasComparator(); - CompartmentAlias alias = new ArtifitialCompartmentAlias(); - CompartmentAlias copy = alias.copy(); + CompartmentComparator comparator = new CompartmentComparator(); + Compartment alias = new PathwayCompartment(); + Compartment copy = alias.copy(); assertEquals(0, comparator.compare(alias, copy)); } catch (Exception e) { @@ -39,7 +42,7 @@ public class ArtifitialCompartmentAliasTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new ArtifitialCompartmentAlias()); + SerializationUtils.serialize(new PathwayCompartment()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -49,7 +52,7 @@ public class ArtifitialCompartmentAliasTest { @Test public void testGetters() { try { - ArtifitialCompartmentAlias alias = new ArtifitialCompartmentAlias(); + PathwayCompartment alias = new PathwayCompartment(); String title = "tit27"; alias.setName(title); assertEquals(title, alias.getName()); @@ -63,7 +66,7 @@ public class ArtifitialCompartmentAliasTest { @Test public void testInvalidCopy() { try { - new ArtifitialCompartmentAlias() { + new PathwayCompartment() { /** * @@ -81,7 +84,7 @@ public class ArtifitialCompartmentAliasTest { @Test public void testCopy() { try { - ArtifitialCompartmentAlias degraded = new ArtifitialCompartmentAlias().copy(); + PathwayCompartment degraded = new PathwayCompartment().copy(); assertNotNull(degraded); } catch (Exception e) { e.printStackTrace(); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/ComplexAliasComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexAliasComparatorTest.java similarity index 68% rename from model/src/test/java/lcsb/mapviewer/model/map/layout/alias/ComplexAliasComparatorTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/ComplexAliasComparatorTest.java index 2577ab598d..9c63b53a90 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/ComplexAliasComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexAliasComparatorTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -12,10 +12,14 @@ 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 { - ComplexAliasComparator comparator = new ComplexAliasComparator(); + ComplexComparator comparator = new ComplexComparator(); @Before public void setUp() throws Exception { @@ -28,8 +32,8 @@ public class ComplexAliasComparatorTest { @Test public void testEquals() { try { - ComplexAlias alias1 = createComplexAlias(); - ComplexAlias alias2 = createComplexAlias(); + Complex alias1 = createComplexAlias(); + Complex alias2 = createComplexAlias(); assertEquals(0, comparator.compare(alias1, alias2)); @@ -41,8 +45,8 @@ public class ComplexAliasComparatorTest { } } - private ComplexAlias createComplexAlias() { - ComplexAlias result = new ComplexAlias(); + private Complex createComplexAlias() { + Complex result = new Complex(); result.setName("complex"); result.setAliasId("asd"); @@ -54,7 +58,7 @@ public class ComplexAliasComparatorTest { result.setColor(Color.BLUE); result.setVisibilityLevel(14); - SpeciesAlias alias = new GenericProteinAlias("S"); + Species alias = new GenericProtein("S"); alias.setName("a"); result.addAlias(alias); @@ -64,8 +68,8 @@ public class ComplexAliasComparatorTest { @Test public void testDifferent() { try { - ComplexAlias alias1 = createComplexAlias(); - ComplexAlias alias2 = createComplexAlias(); + Complex alias1 = createComplexAlias(); + Complex alias2 = createComplexAlias(); assertTrue(comparator.compare(alias1, null) != 0); assertTrue(comparator.compare(null, alias1) != 0); @@ -81,7 +85,7 @@ public class ComplexAliasComparatorTest { alias1 = createComplexAlias(); alias2 = createComplexAlias(); - alias1.addAlias(new GenericProteinAlias("id")); + alias1.addAlias(new GenericProtein("id")); assertTrue(comparator.compare(alias1, alias2) != 0); assertTrue(comparator.compare(alias2, alias1) != 0); @@ -97,7 +101,7 @@ public class ComplexAliasComparatorTest { alias1 = createComplexAlias(); alias2 = createComplexAlias(); - SpeciesAlias speciesAlias = (SpeciesAlias) alias1.getAliases().iterator().next(); + Species speciesAlias = (Species) alias1.getAliases().iterator().next(); speciesAlias.setName("new namne"); assertTrue(comparator.compare(alias1, alias2) != 0); @@ -111,7 +115,7 @@ public class ComplexAliasComparatorTest { assertTrue(comparator.compare(alias1, alias2) != 0); assertTrue(comparator.compare(alias2, alias1) != 0); - assertTrue(comparator.compare(alias2, new ComplexAlias() { + assertTrue(comparator.compare(alias2, new Complex() { private static final long serialVersionUID = 1L; }) != 0); @@ -124,16 +128,16 @@ public class ComplexAliasComparatorTest { @Test public void testInvalid() { try { - ComplexAlias alias1 = createComplexAlias(); - ComplexAlias alias2 = createComplexAlias(); + Complex alias1 = createComplexAlias(); + Complex alias2 = createComplexAlias(); - GenericProteinAlias alias = new GenericProteinAlias("1"); + GenericProtein alias = new GenericProtein("1"); alias1.getAliases().add(alias); - alias = new GenericProteinAlias("1"); + alias = new GenericProtein("1"); alias1.getAliases().add(alias); - alias2.getAliases().add(new GenericProteinAlias("b")); - alias2.getAliases().add(new GenericProteinAlias("a")); + alias2.getAliases().add(new GenericProtein("b")); + alias2.getAliases().add(new GenericProtein("a")); comparator.compare(alias1, alias2); fail("Exception expected"); @@ -148,7 +152,7 @@ public class ComplexAliasComparatorTest { @Test public void testInvalid3() { try { - class Tmp extends ComplexAlias { + class Tmp extends Complex { private static final long serialVersionUID = 1L; } ; @@ -168,16 +172,16 @@ public class ComplexAliasComparatorTest { @Test public void testInvalid2() { try { - ComplexAlias alias1 = createComplexAlias(); - ComplexAlias alias2 = createComplexAlias(); + Complex alias1 = createComplexAlias(); + Complex alias2 = createComplexAlias(); - SpeciesAlias alias = new GenericProteinAlias("1"); + Species alias = new GenericProtein("1"); alias1.getAliases().add(alias); - alias = new GenericProteinAlias("1"); + alias = new GenericProtein("1"); alias1.getAliases().add(alias); - alias2.getAliases().add(new GenericProteinAlias("A")); - alias2.getAliases().add(new GenericProteinAlias("B")); + alias2.getAliases().add(new GenericProtein("A")); + alias2.getAliases().add(new GenericProtein("B")); comparator.compare(alias2, alias1); fail("Exception expected"); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/ComplexAliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexAliasTest.java similarity index 65% rename from model/src/test/java/lcsb/mapviewer/model/map/layout/alias/ComplexAliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/ComplexAliasTest.java index 2390121c6d..6019ce77f2 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/ComplexAliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexAliasTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -10,6 +10,9 @@ import org.junit.Before; import org.junit.Test; 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; public class ComplexAliasTest { @@ -24,7 +27,7 @@ public class ComplexAliasTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new ComplexAlias()); + SerializationUtils.serialize(new Complex()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -34,9 +37,9 @@ public class ComplexAliasTest { @Test public void testConstructor() { try { - ComplexAlias complex = new ComplexAlias(); - complex.addAlias(new GenericProteinAlias()); - ComplexAlias copy = new ComplexAlias(complex); + Complex complex = new Complex(); + complex.addAlias(new GenericProtein()); + Complex copy = new Complex(complex); assertNotNull(copy); } catch (Exception e) { @@ -48,13 +51,13 @@ public class ComplexAliasTest { @Test public void testAddAlias() { try { - ComplexAlias complex = new ComplexAlias(); - SpeciesAlias alias = new GenericProteinAlias("id1"); + Complex complex = new Complex(); + Species alias = new GenericProtein("id1"); complex.addAlias(alias); assertEquals(1, complex.getAllChildrenAliases().size()); complex.addAlias(alias); assertEquals(1, complex.getAllChildrenAliases().size()); - SpeciesAlias alias2 = new GenericProteinAlias("s"); + Species alias2 = new GenericProtein("s"); complex.addAlias(alias2); assertEquals(2, complex.getAllChildrenAliases().size()); } catch (Exception e) { @@ -66,12 +69,12 @@ public class ComplexAliasTest { @Test public void testGetAllChildren() { try { - ComplexAlias complex = new ComplexAlias(); + Complex complex = new Complex(); - complex.addAlias(new GenericProteinAlias("1")); - ComplexAlias complex2 = new ComplexAlias("c3"); - complex2.addAlias(new GenericProteinAlias("2")); - complex2.addAlias(new GenericProteinAlias("4")); + complex.addAlias(new GenericProtein("1")); + Complex complex2 = new Complex("c3"); + complex2.addAlias(new GenericProtein("2")); + complex2.addAlias(new GenericProtein("4")); complex.addAlias(complex2); @@ -87,12 +90,12 @@ public class ComplexAliasTest { @Test public void testRemoveAlias() { try { - ComplexAlias complex = new ComplexAlias(); + Complex complex = new Complex(); - SpeciesAlias alias = new GenericProteinAlias("1"); + Species alias = new GenericProtein("1"); complex.addAlias(alias); - complex.addAlias(new GenericProteinAlias("2")); - complex.addAlias(new GenericProteinAlias("4")); + complex.addAlias(new GenericProtein("2")); + complex.addAlias(new GenericProtein("4")); assertEquals(3, complex.getAliases().size()); complex.removeAlias(alias); @@ -109,8 +112,8 @@ public class ComplexAliasTest { @Test public void testCopy() { try { - ComplexAlias original = new ComplexAlias(); - ComplexAlias copy = original.copy(); + Complex original = new Complex(); + Complex copy = original.copy(); assertNotNull(copy); } catch (Exception e) { e.printStackTrace(); @@ -121,7 +124,7 @@ public class ComplexAliasTest { @Test public void testInvalidCopy() { try { - new ComplexAlias() { + new Complex() { /** * diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/ModificationStateTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/ModificationStateTest.java similarity index 83% rename from model/src/test/java/lcsb/mapviewer/model/map/layout/alias/ModificationStateTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/ModificationStateTest.java index 4f2f9a91c8..1a1987dc82 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/ModificationStateTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/ModificationStateTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -7,6 +7,8 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import lcsb.mapviewer.model.map.species.field.ModificationState; + public class ModificationStateTest { @Before diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/OvalCompartmentAliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/OvalCompartmentAliasTest.java similarity index 70% rename from model/src/test/java/lcsb/mapviewer/model/map/layout/alias/OvalCompartmentAliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/OvalCompartmentAliasTest.java index 9faf499ccb..728f9f04f8 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/OvalCompartmentAliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/OvalCompartmentAliasTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; @@ -9,6 +9,7 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.compartment.OvalCompartment; public class OvalCompartmentAliasTest { @@ -23,7 +24,7 @@ public class OvalCompartmentAliasTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new OvalCompartmentAlias()); + SerializationUtils.serialize(new OvalCompartment()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -33,8 +34,8 @@ public class OvalCompartmentAliasTest { @Test public void testConstructor() { try { - OvalCompartmentAlias original = new OvalCompartmentAlias(); - OvalCompartmentAlias copy = new OvalCompartmentAlias(original); + OvalCompartment original = new OvalCompartment(); + OvalCompartment copy = new OvalCompartment(original); assertNotNull(copy); } catch (Exception e) { e.printStackTrace(); @@ -45,8 +46,8 @@ public class OvalCompartmentAliasTest { @Test public void testCopy() { try { - OvalCompartmentAlias original = new OvalCompartmentAlias(); - OvalCompartmentAlias copy = original.copy(); + OvalCompartment original = new OvalCompartment(); + OvalCompartment copy = original.copy(); assertNotNull(copy); } catch (Exception e) { e.printStackTrace(); @@ -57,7 +58,7 @@ public class OvalCompartmentAliasTest { @Test public void testInvalidCopy() { try { - new OvalCompartmentAlias() { + new OvalCompartment() { /** * diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/PositionToCompartmentTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/PositionToCompartmentTest.java similarity index 83% rename from model/src/test/java/lcsb/mapviewer/model/map/layout/alias/PositionToCompartmentTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/PositionToCompartmentTest.java index 9758966dda..d8ca94fbd5 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/PositionToCompartmentTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/PositionToCompartmentTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -7,6 +7,8 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import lcsb.mapviewer.model.map.species.field.PositionToCompartment; + public class PositionToCompartmentTest { @Before diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/SearchIndexTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/SearchIndexTest.java similarity index 87% rename from model/src/test/java/lcsb/mapviewer/model/map/layout/alias/SearchIndexTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/SearchIndexTest.java index 4d61d33148..c32f503d9a 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/SearchIndexTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/SearchIndexTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -10,6 +10,9 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.SearchIndex; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Gene; public class SearchIndexTest { @@ -101,7 +104,7 @@ public class SearchIndexTest { int id = 54; int weight = 8; String value = "val5"; - Alias alias = new GeneAlias(); + Element alias = new Gene(); SearchIndex index = new SearchIndex(); index.setId(id); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/SpeciesAliasComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesAliasComparatorTest.java similarity index 75% rename from model/src/test/java/lcsb/mapviewer/model/map/layout/alias/SpeciesAliasComparatorTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesAliasComparatorTest.java index ffbafe9f43..d0fe439e7c 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/SpeciesAliasComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesAliasComparatorTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -12,10 +12,14 @@ 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 { - SpeciesAliasComparator comparator = new SpeciesAliasComparator(); + SpeciesComparator comparator = new SpeciesComparator(); @Before public void setUp() throws Exception { @@ -28,14 +32,14 @@ public class SpeciesAliasComparatorTest { @Test public void testEquals() { try { - SpeciesAlias alias1 = createSpeciesAlias(); - SpeciesAlias alias2 = createSpeciesAlias(); + Species alias1 = createSpeciesAlias(); + Species alias2 = createSpeciesAlias(); assertEquals(0, comparator.compare(alias1, alias2)); assertEquals(0, comparator.compare(null, null)); - assertEquals(0, comparator.compare(new ComplexAlias(), new ComplexAlias())); + assertEquals(0, comparator.compare(new Complex(), new Complex())); } catch (Exception e) { e.printStackTrace(); @@ -47,7 +51,7 @@ public class SpeciesAliasComparatorTest { public void testCompareInvalid() { try { - SpeciesAlias alias = Mockito.mock(SpeciesAlias.class); + Species alias = Mockito.mock(Species.class); comparator.compare(alias, alias); fail("Exception expected"); @@ -58,8 +62,8 @@ public class SpeciesAliasComparatorTest { } } - private SpeciesAlias createSpeciesAlias() { - GenericProteinAlias result = new GenericProteinAlias(); + private Species createSpeciesAlias() { + GenericProtein result = new GenericProtein(); result.setName("a"); result.setAliasId("asd"); @@ -79,13 +83,13 @@ public class SpeciesAliasComparatorTest { @Test public void testDifferent() throws Exception { try { - SpeciesAlias alias1 = createSpeciesAlias(); - SpeciesAlias alias2 = createSpeciesAlias(); + Species alias1 = createSpeciesAlias(); + Species alias2 = createSpeciesAlias(); assertTrue(comparator.compare(alias1, null) != 0); assertTrue(comparator.compare(null, alias1) != 0); - assertTrue(comparator.compare(new ComplexAlias(), alias1) != 0); + assertTrue(comparator.compare(new Complex(), alias1) != 0); alias1 = createSpeciesAlias(); alias2 = createSpeciesAlias(); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/SpeciesAliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesAliasTest.java similarity index 74% rename from model/src/test/java/lcsb/mapviewer/model/map/layout/alias/SpeciesAliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesAliasTest.java index ee478ed37c..585a6b15d6 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/SpeciesAliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesAliasTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertEquals; @@ -10,6 +10,8 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.model.map.reaction.ReactionNode; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; public class SpeciesAliasTest { @@ -24,7 +26,7 @@ public class SpeciesAliasTest { @Test public void testGetter() { try { - SpeciesAlias alias = new GenericProteinAlias("id"); + Species alias = new GenericProtein("id"); String state = "as"; Set<ReactionNode> node = new HashSet<>(); alias.setState(state); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/SquareCompartmentAliasTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/SquareCompartmentAliasTest.java similarity index 69% rename from model/src/test/java/lcsb/mapviewer/model/map/layout/alias/SquareCompartmentAliasTest.java rename to model/src/test/java/lcsb/mapviewer/model/map/species/SquareCompartmentAliasTest.java index 88af098c8a..609af84b7b 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/layout/alias/SquareCompartmentAliasTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/SquareCompartmentAliasTest.java @@ -1,4 +1,4 @@ -package lcsb.mapviewer.model.map.layout.alias; +package lcsb.mapviewer.model.map.species; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; @@ -9,6 +9,7 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.compartment.SquareCompartment; public class SquareCompartmentAliasTest { @@ -23,7 +24,7 @@ public class SquareCompartmentAliasTest { @Test public void testSerialization() { try { - SerializationUtils.serialize(new SquareCompartmentAlias()); + SerializationUtils.serialize(new SquareCompartment()); } catch (Exception e) { e.printStackTrace(); throw e; @@ -33,8 +34,8 @@ public class SquareCompartmentAliasTest { @Test public void testConstructor() { try { - SquareCompartmentAlias original = new SquareCompartmentAlias(); - SquareCompartmentAlias copy = new SquareCompartmentAlias(original); + SquareCompartment original = new SquareCompartment(); + SquareCompartment copy = new SquareCompartment(original); assertNotNull(copy); } catch (Exception e) { e.printStackTrace(); @@ -45,8 +46,8 @@ public class SquareCompartmentAliasTest { @Test public void testCopy() { try { - SquareCompartmentAlias original = new SquareCompartmentAlias(); - SquareCompartmentAlias copy = original.copy(); + SquareCompartment original = new SquareCompartment(); + SquareCompartment copy = original.copy(); assertNotNull(copy); } catch (Exception e) { e.printStackTrace(); @@ -57,7 +58,7 @@ public class SquareCompartmentAliasTest { @Test public void testInvalidCopy() { try { - new SquareCompartmentAlias() { + new SquareCompartment() { /** * diff --git a/model/src/test/java/lcsb/mapviewer/modelutils/map/ElementUtilsTest.java b/model/src/test/java/lcsb/mapviewer/modelutils/map/ElementUtilsTest.java index 0bc877fd6c..949c2fb8e5 100644 --- a/model/src/test/java/lcsb/mapviewer/modelutils/map/ElementUtilsTest.java +++ b/model/src/test/java/lcsb/mapviewer/modelutils/map/ElementUtilsTest.java @@ -16,12 +16,12 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.IonAlias; -import lcsb.mapviewer.model.map.layout.alias.IonChannelProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.type.UnknownNegativeInfluenceReaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Ion; +import lcsb.mapviewer.model.map.species.IonChannelProtein; +import lcsb.mapviewer.model.map.species.Protein; public class ElementUtilsTest { Logger logger = Logger.getLogger(ElementUtilsTest.class); @@ -93,9 +93,9 @@ public class ElementUtilsTest { try { ElementUtils elementUtils = new ElementUtils(); - List<Class<? extends Alias>> list = elementUtils.getAvailableElementSubclasses(); - assertTrue(list.contains(IonChannelProteinAlias.class)); - assertFalse(list.contains(ProteinAlias.class)); + List<Class<? extends Element>> list = elementUtils.getAvailableElementSubclasses(); + assertTrue(list.contains(IonChannelProtein.class)); + assertFalse(list.contains(Protein.class)); } catch (Exception e) { e.printStackTrace(); throw e; @@ -106,8 +106,8 @@ public class ElementUtilsTest { public void tesClassByName() throws Exception { try { ElementUtils elementUtils = new ElementUtils(); - assertEquals(IonAlias.class, elementUtils.getClassByName(IonAlias.class.getSimpleName())); - assertEquals(IonAlias.class, elementUtils.getClassByName("Ion")); + assertEquals(Ion.class, elementUtils.getClassByName(Ion.class.getSimpleName())); + assertEquals(Ion.class, elementUtils.getClassByName("Ion")); assertNull(elementUtils.getClassByName("unknown class name")); } catch (Exception 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 3d76640ca2..5403bf1b76 100644 --- a/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/XML/ModelContructor.java +++ b/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/XML/ModelContructor.java @@ -26,20 +26,9 @@ import lcsb.mapviewer.converter.model.celldesigner.types.ModifierType; import lcsb.mapviewer.converter.model.celldesigner.types.ModifierTypeUtils; import lcsb.mapviewer.model.graphics.PolylineData; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationResidueAlias; -import lcsb.mapviewer.model.map.layout.alias.OvalCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; -import lcsb.mapviewer.model.map.layout.alias.SquareCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.UnknownAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.compartment.OvalCompartment; +import lcsb.mapviewer.model.map.compartment.SquareCompartment; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.layout.graphics.LayerOval; import lcsb.mapviewer.model.map.layout.graphics.LayerRect; @@ -60,6 +49,17 @@ import lcsb.mapviewer.model.map.reaction.type.HeterodimerAssociationReaction; import lcsb.mapviewer.model.map.reaction.type.ReducedNotation; import lcsb.mapviewer.model.map.reaction.type.TwoReactantReactionInterface; import lcsb.mapviewer.model.map.reaction.type.UnknownTransitionReaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Phenotype; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Rna; +import lcsb.mapviewer.model.map.species.SimpleMolecule; +import lcsb.mapviewer.model.map.species.Species; +import lcsb.mapviewer.model.map.species.Unknown; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; import lcsb.mapviewer.modelutils.map.ElementUtils; import lcsb.mapviewer.wikipathway.model.DataNode; import lcsb.mapviewer.wikipathway.model.Edge; @@ -121,7 +121,7 @@ public class ModelContructor { /** * List of {@link Shape#shape shapes} that are not supported to be part of a - * {@link ComplexAlias complex}. + * {@link Complex complex}. */ private static final Set<String> INALID_COMPLEX_SHAPE_CHILDREN = new HashSet<>(); @@ -221,7 +221,7 @@ public class ModelContructor { /** * Map between graphId and aliases created from gpml elements. */ - private Map<String, Alias> id2alias; + private Map<String, Element> id2alias; /** * Default layer. @@ -232,7 +232,7 @@ public class ModelContructor { * Default constructor. */ private Data() { - id2alias = new HashMap<String, Alias>(); + id2alias = new HashMap<String, Element>(); layer = new Layer(); layer.setVisible(true); layer.setLayerId("1"); @@ -247,32 +247,32 @@ public class ModelContructor { * object from which species is created * @param data * ... - * @return {@link SpeciesAlias} created from input {@link DataNode} + * @return {@link Species} created from input {@link DataNode} */ - protected SpeciesAlias createAlias(DataNode dataNode, Data data) { - SpeciesAlias res = null; + protected Species createAlias(DataNode dataNode, Data data) { + Species res = null; String type = dataNode.getType(); if (type == null || type.equals("")) { type = null; } if (type != null && type.equalsIgnoreCase("Metabolite")) { - res = new SimpleMoleculeAlias(dataNode.getGraphId()); + res = new SimpleMolecule(dataNode.getGraphId()); } else if (type != null && type.equalsIgnoreCase("GeneProduct")) { - res = new GeneAlias(dataNode.getGraphId()); + res = new Gene(dataNode.getGraphId()); } else if (type != null && type.equalsIgnoreCase("Pathway")) { - res = new PhenotypeAlias(dataNode.getGraphId()); + res = new Phenotype(dataNode.getGraphId()); } else if (type != null && type.equalsIgnoreCase("Rna")) { - res = new RnaAlias(dataNode.getGraphId()); + res = new Rna(dataNode.getGraphId()); } else if (type != null && type.equalsIgnoreCase("Protein")) { - res = new GenericProteinAlias(dataNode.getGraphId()); + res = new GenericProtein(dataNode.getGraphId()); } else if (type != null && type.equalsIgnoreCase("Complex")) { - res = new ComplexAlias(dataNode.getGraphId()); + res = new Complex(dataNode.getGraphId()); } else if (type != null && type.equalsIgnoreCase("None")) { - res = new UnknownAlias(dataNode.getGraphId()); + res = new Unknown(dataNode.getGraphId()); } else { logger.warn("[" + dataNode.getGraphId() + "]\tUnknown species type: " + type + ". Using Unknown"); - res = new UnknownAlias(dataNode.getGraphId()); + res = new Unknown(dataNode.getGraphId()); } res.addMiriamData(dataNode.getReferences()); @@ -293,7 +293,7 @@ public class ModelContructor { */ protected void addComplexSpecies(Model model, Graph graph, Data data) { for (Group group : graph.getGroups()) { - ComplexAlias alias = new ComplexAlias(group.getGraphId()); + Complex alias = new Complex(group.getGraphId()); alias.setName(group.getGraphId()); if ("Complex".equalsIgnoreCase(group.getStyle())) { alias.setHypothetical(false); @@ -328,20 +328,20 @@ public class ModelContructor { */ protected void addElement(Model model, Graph graph, Data data) { for (DataNode dataNode : graph.getDataNodes()) { - SpeciesAlias species = createAlias(dataNode, data); + Species species = createAlias(dataNode, data); species.addMiriamData(biopaxParser.getMiriamData(graph.getBiopaxData(), dataNode.getBiopaxReference())); - Alias alias = updateAlias(dataNode, species); + Element alias = updateAlias(dataNode, species); data.id2alias.put(dataNode.getGraphId(), alias); model.addAlias(alias); } for (Label label : graph.getLabels()) { if (label.isTreatAsNode()) { - SpeciesAlias species = createSpecies(label); + Species species = createSpecies(label); species.addMiriamData(biopaxParser.getMiriamData(graph.getBiopaxData(), label.getBiopaxReference())); - Alias alias = updateAlias(label, species); + Element alias = updateAlias(label, species); data.id2alias.put(label.getGraphId(), alias); model.addAlias(alias); @@ -352,10 +352,10 @@ public class ModelContructor { } for (Shape shape : graph.getShapes()) { if (shape.isTreatAsNode()) { - SpeciesAlias species = createSpecies(shape); + Species species = createSpecies(shape); species.addMiriamData(biopaxParser.getMiriamData(graph.getBiopaxData(), shape.getBiopaxReference())); - Alias alias = updateAlias(shape, species); + Element alias = updateAlias(shape, species); data.id2alias.put(shape.getGraphId(), alias); model.addAlias(alias); @@ -370,8 +370,8 @@ public class ModelContructor { data.layer.addLayerRect(rect); } } else { - CompartmentAlias compartment = new CompartmentAlias(shape.getGraphId()); - Alias cmpAl = updateAlias(shape, compartment); + Compartment compartment = new Compartment(shape.getGraphId()); + Element cmpAl = updateAlias(shape, compartment); model.addAlias(cmpAl); } } @@ -379,9 +379,9 @@ public class ModelContructor { for (State state : graph.getStates()) { // TODO this might not work - Alias species = data.id2alias.get(state.getGraphRef()); + Element species = data.id2alias.get(state.getGraphRef()); if (state.getType() != null) { - ModificationResidueAlias mr = new ModificationResidueAlias(); + ModificationResidue mr = new ModificationResidue(); mr.setIdModificationResidue(state.getGraphId()); mr.setState(state.getType()); Double angle = null; @@ -406,16 +406,16 @@ public class ModelContructor { // CHECKSTYLE:ON mr.setAngle(angle); - if (species instanceof ProteinAlias) { - ((ProteinAlias) species).addModificationResidue(mr); - } else if (species instanceof GeneAlias) { - ((GeneAlias) species).addModificationResidue(mr); + if (species instanceof Protein) { + ((Protein) species).addModificationResidue(mr); + } else if (species instanceof Gene) { + ((Gene) species).addModificationResidue(mr); } else { logger.warn(state.getWarningPrefix() + "state for " + species.getClass().getSimpleName() + " is not supported."); } } else if (state.getStructuralState() != null) { - if (species instanceof ProteinAlias) { - ProteinAlias protein = ((ProteinAlias) species); + if (species instanceof Protein) { + Protein protein = ((Protein) species); if (protein.getStructuralState() == null) { protein.setStructuralState(state.getStructuralState()); } else { @@ -489,20 +489,20 @@ public class ModelContructor { /** * Creates alias for {@link GraphicalPathwayElement}. Type of the alias is - * defined by the parameter {@link SpeciesAlias} + * defined by the parameter {@link Species} * * @param gpmlElement * object from which alias will be create * @param alias * specie for which alias will be created - * @return {@link SpeciesAlias} created from input {@link Label} + * @return {@link Species} created from input {@link Label} */ - public Alias updateAlias(GraphicalPathwayElement gpmlElement, Alias alias) { - if (alias instanceof CompartmentAlias) { + public Element updateAlias(GraphicalPathwayElement gpmlElement, Element alias) { + if (alias instanceof Compartment) { if (((Shape) gpmlElement).getShape().equalsIgnoreCase("oval")) { - alias = new OvalCompartmentAlias((CompartmentAlias) alias); + alias = new OvalCompartment((Compartment) alias); } else { - alias = new SquareCompartmentAlias((CompartmentAlias) alias); + alias = new SquareCompartment((Compartment) alias); } } Rectangle2D rec = gpmlElement.getRectangle(); @@ -515,31 +515,31 @@ public class ModelContructor { } /** - * Creates {@link UnknownAlias species} from {@link Label}. + * Creates {@link Unknown species} from {@link Label}. * * @param label * original label from which output should be created - * @return {@link UnknownAlias} object created from input {@link Label} + * @return {@link Unknown} object created from input {@link Label} */ - private SpeciesAlias createSpecies(Label label) { + private Species createSpecies(Label label) { logger.warn(label.getWarningPrefix() + " Label cannot be part of reaction. Tranforming to Unknown"); - SpeciesAlias res = new UnknownAlias(label.getGraphId()); + Species res = new Unknown(label.getGraphId()); res.setName(label.getName()); return res; } /** - * Creates {@link UnknownAlias species} from {@link Shape}. + * Creates {@link Unknown species} from {@link Shape}. * * @param shape * original label from which output should be created - * @return {@link UnknownAlias} object created from input {@link Label} + * @return {@link Unknown} object created from input {@link Label} */ - private SpeciesAlias createSpecies(Shape shape) { + private Species createSpecies(Shape shape) { logger.warn(shape.getWarningPrefix() + " Shape can not be part of reaction. Tranforming to Unknown"); - SpeciesAlias res = new UnknownAlias(shape.getGraphId()); + Species res = new Unknown(shape.getGraphId()); res.setName(shape.getName()); return res; } @@ -557,13 +557,13 @@ public class ModelContructor { protected void putSpeciesIntoComplexes(Graph graph, Data data) throws UnknownChildClassException { for (Group group : graph.getGroups()) { - ComplexAlias complexSpecies = (ComplexAlias) data.id2alias.get(group.getGraphId()); + Complex complexSpecies = (Complex) data.id2alias.get(group.getGraphId()); for (PathwayElement pe : group.getNodes()) { - Alias species = data.id2alias.get(pe.getGraphId()); + Element species = data.id2alias.get(pe.getGraphId()); if (species != null) { - if (species instanceof SpeciesAlias) { + if (species instanceof Species) { - SpeciesAlias speciesAlias = (SpeciesAlias) species; + Species speciesAlias = (Species) species; speciesAlias.setComplexAlias(complexSpecies); complexSpecies.addAlias(speciesAlias); @@ -836,7 +836,7 @@ public class ModelContructor { throw new InvalidStateException("This modifier is invalid"); } - Modifier mod = createModifierByType(modifierType, (SpeciesAlias) data.id2alias.get(id)); + Modifier mod = createModifierByType(modifierType, (Species) data.id2alias.get(id)); ModifierType mt = mtu.getModifierTypeForClazz(mod.getClass()); @@ -868,12 +868,12 @@ public class ModelContructor { * @param modifierType * type of modifier in reaction to create * @param alias - * {@link SpeciesAlias alias } to which modifier is attached + * {@link Species alias } to which modifier is attached * @return new instance of the modifierType */ - private Modifier createModifierByType(Class<? extends ReactionNode> modifierType, SpeciesAlias alias) { + private Modifier createModifierByType(Class<? extends ReactionNode> modifierType, Species alias) { try { - Modifier result = (Modifier) modifierType.getConstructor(SpeciesAlias.class).newInstance(alias); + Modifier result = (Modifier) modifierType.getConstructor(Species.class).newInstance(alias); return result; } catch (Exception e) { throw new InvalidArgumentException("Cannot create modifier.", e); @@ -956,18 +956,18 @@ public class ModelContructor { } /** - * Method that put {@link SpeciesAlias aliases} that are not assigned into any - * {@link CompartmentAlias} into a proper compartment. + * Method that put {@link Species aliases} that are not assigned into any + * {@link Compartment} into a proper compartment. * * @param model * model where aliases will be modifed */ private void putAliasesIntoCompartments(Model model) { - for (Alias alias : model.getAliases()) { + for (Element alias : model.getAliases()) { if (alias.getParent() == null) { - if (alias instanceof SpeciesAlias) { - CompartmentAlias selectedAlias = null; - for (CompartmentAlias cAlias : model.getCompartmentsAliases()) { + if (alias instanceof Species) { + Compartment selectedAlias = null; + for (Compartment cAlias : model.getCompartmentsAliases()) { if (cAlias.cross(alias)) { if (selectedAlias == null) { selectedAlias = cAlias; @@ -991,17 +991,17 @@ public class ModelContructor { * model where operation is performed */ private void removeEmptyComplexes(Model model) { - Set<Alias> aliasesInReaction = new HashSet<>(); + Set<Element> aliasesInReaction = new HashSet<>(); for (Reaction reaction : model.getReactions()) { for (ReactionNode node : reaction.getReactionNodes()) { aliasesInReaction.add(node.getAlias()); } } - List<Alias> toRemove = new ArrayList<>(); + List<Element> toRemove = new ArrayList<>(); ElementUtils eu = new ElementUtils(); - for (Alias alias : model.getAliases()) { - if (alias instanceof ComplexAlias) { - ComplexAlias cAlias = (ComplexAlias) alias; + for (Element alias : model.getAliases()) { + if (alias instanceof Complex) { + Complex cAlias = (Complex) alias; if (cAlias.getSize() <= EPSILON && cAlias.getAllChildrenAliases().size() == 0) { if (aliasesInReaction.contains(alias)) { logger.warn(eu.getElementTag(alias) + "Empty element is invalid, but it's a part of reaction."); @@ -1012,7 +1012,7 @@ public class ModelContructor { } } } - for (Alias alias : toRemove) { + for (Element alias : toRemove) { model.removeAlias(alias); } } @@ -1025,8 +1025,8 @@ public class ModelContructor { * model where complexes are placed */ private void assignNamesToComplexes(Model model) { - for (Alias alias : model.getAliases()) { - if (alias instanceof ComplexAlias) { + for (Element alias : model.getAliases()) { + if (alias instanceof Complex) { if (alias.getName() == null || (alias.getName().isEmpty())) { for (Layer layer : model.getLayers()) { LayerText toRemove = null; @@ -1055,8 +1055,8 @@ public class ModelContructor { * model where compartments are placed */ private void assignNamesToCompartments(Model model) { - for (Alias alias : model.getAliases()) { - if (alias instanceof CompartmentAlias) { + for (Element alias : model.getAliases()) { + if (alias instanceof Compartment) { if (alias.getName() == null || alias.getName().isEmpty()) { for (Layer layer : model.getLayers()) { LayerText toRemove = null; @@ -1100,25 +1100,25 @@ public class ModelContructor { * model where assignments are fixed. */ private void fixCompartmentAliases(Model model) { - List<CompartmentAlias> aliases = model.getCompartmentsAliases(); + List<Compartment> aliases = model.getCompartmentsAliases(); // clear all assignments - for (CompartmentAlias compartmentAlias : aliases) { + for (Compartment compartmentAlias : aliases) { compartmentAlias.getAliases().clear(); } - for (Alias alias : model.getAliases()) { + for (Element alias : model.getAliases()) { // elements inside complexes shouldn't be considered - if (alias instanceof SpeciesAlias) { - if (((SpeciesAlias) alias).getComplexAlias() != null) { + if (alias instanceof Species) { + if (((Species) alias).getComplexAlias() != null) { continue; } } // skip compartments - if (alias instanceof CompartmentAlias) { + if (alias instanceof Compartment) { continue; } - CompartmentAlias parentAlias = null; - for (CompartmentAlias compartmentAlias : aliases) { + Compartment parentAlias = null; + for (Compartment compartmentAlias : aliases) { if (compartmentAlias.contains(alias)) { if (parentAlias == null) { parentAlias = compartmentAlias; 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 3d19dc42b2..cdfc86cc56 100644 --- a/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/XML/ModelToGPML.java +++ b/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/XML/ModelToGPML.java @@ -12,21 +12,8 @@ import lcsb.mapviewer.converter.ConverterException; import lcsb.mapviewer.model.graphics.PolylineData; import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaAlias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.DegradedAlias; -import lcsb.mapviewer.model.map.layout.alias.DrugAlias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.IonAlias; -import lcsb.mapviewer.model.map.layout.alias.OvalCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; -import lcsb.mapviewer.model.map.layout.alias.UnknownAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.compartment.OvalCompartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.reaction.Modifier; import lcsb.mapviewer.model.map.reaction.NodeOperator; @@ -34,6 +21,19 @@ import lcsb.mapviewer.model.map.reaction.Product; import lcsb.mapviewer.model.map.reaction.Reactant; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.ReactionNode; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.AntisenseRna; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Degraded; +import lcsb.mapviewer.model.map.species.Drug; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.Ion; +import lcsb.mapviewer.model.map.species.Phenotype; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Rna; +import lcsb.mapviewer.model.map.species.SimpleMolecule; +import lcsb.mapviewer.model.map.species.Species; +import lcsb.mapviewer.model.map.species.Unknown; import lcsb.mapviewer.wikipathway.utils.Geo; /** @@ -107,27 +107,27 @@ public class ModelToGPML { * species for which gpml type will be returned * @return String - type */ - private String getType(SpeciesAlias species) { + private String getType(Species species) { String res = ""; - if (species instanceof AntisenseRnaAlias) { + if (species instanceof AntisenseRna) { res = "Rna"; - } else if (species instanceof RnaAlias) { + } else if (species instanceof Rna) { res = "Rna"; - } else if (species instanceof GeneAlias) { + } else if (species instanceof Gene) { res = "GeneProduct"; - } else if (species instanceof ProteinAlias) { + } else if (species instanceof Protein) { res = "Protein"; - } else if (species instanceof SimpleMoleculeAlias) { + } else if (species instanceof SimpleMolecule) { res = "Metabolite"; - } else if (species instanceof IonAlias) { + } else if (species instanceof Ion) { res = "Metabolite"; - } else if (species instanceof DrugAlias) { + } else if (species instanceof Drug) { res = "Metabolite"; - } else if (species instanceof PhenotypeAlias) { + } else if (species instanceof Phenotype) { res = "Pathway"; - } else if (species instanceof UnknownAlias) { + } else if (species instanceof Unknown) { res = "Unknown"; - } else if (species instanceof DegradedAlias) { + } else if (species instanceof Degraded) { res = "Unknown"; } else { throw new InvalidArgumentException("Unknown class type: " + species.getClass()); @@ -145,23 +145,23 @@ public class ModelToGPML { * alias for which rectangle border is calculated * @return rectangle border for alias */ - private Rectangle2D getRectangle(Alias alias) { + private Rectangle2D getRectangle(Element alias) { Rectangle2D res = null; - if (alias instanceof ComplexAlias) { - ComplexAlias ca = (ComplexAlias) alias; + if (alias instanceof Complex) { + Complex ca = (Complex) alias; if (ca.getAliases().size() == 0) { res = (Rectangle2D) ca.getBorder().clone(); } else { res = getRectangle(ca.getAliases().get(0)); - for (Alias al : ca.getAliases()) { + for (Element al : ca.getAliases()) { Rectangle2D.union(res, getRectangle(al), res); } res = new Rectangle2D.Double( res.getX() - GROUP_RECTANGLE_BORDER_MARGIN, res.getY() - GROUP_RECTANGLE_BORDER_MARGIN, res.getWidth() + 2 * GROUP_RECTANGLE_BORDER_MARGIN, res.getHeight() + 2 * GROUP_RECTANGLE_BORDER_MARGIN); } - } else if (alias instanceof SpeciesAlias) { + } else if (alias instanceof Species) { res = (Rectangle2D) alias.getBorder().clone(); } return res; @@ -273,11 +273,11 @@ public class ModelToGPML { * compartment alias * @return string with list of species names in a compartment */ - private String getAllNames(CompartmentAlias ca) { + private String getAllNames(Compartment ca) { StringBuilder res = new StringBuilder(""); - for (Alias a : ca.getAllSubAliases()) { - if (a instanceof SpeciesAlias) { - SpeciesAlias sp = (SpeciesAlias) a; + for (Element a : ca.getAllSubAliases()) { + if (a instanceof Species) { + Species sp = (Species) a; res.append(sp.getName() + ";"); } } @@ -294,11 +294,11 @@ public class ModelToGPML { */ private String getComparments(Model model) { StringBuilder comparments = new StringBuilder(""); - for (CompartmentAlias ca : model.getCompartmentsAliases()) { + for (Compartment ca : model.getCompartmentsAliases()) { double x = ca.getCenterX(), y = ca.getCenterY(), h = ca.getHeight(), w = ca.getWidth(); String shape; - if (ca instanceof OvalCompartmentAlias) { + if (ca instanceof OvalCompartment) { shape = "Oval"; } else { shape = "Rectangle"; @@ -411,8 +411,8 @@ public class ModelToGPML { protected String getDataNodes(Model model) throws ConverterException { StringBuilder dataNodes = new StringBuilder(""); - for (SpeciesAlias sa : model.getNotComplexSpeciesAliases()) { - if (!(sa instanceof ComplexAlias)) { + for (Species sa : model.getNotComplexSpeciesAliases()) { + if (!(sa instanceof Complex)) { dataNodes.append(" <DataNode TextLabel=\"" + sa.getName() + "\" GraphId=\"" + sa.getAliasId() + "\" Type=\"" + getType(sa) + "\""); if (sa.getComplexAlias() != null) { dataNodes.append(" GroupRef=\"" + sa.getComplexAlias().getAliasId() + "\""); @@ -447,7 +447,7 @@ public class ModelToGPML { } /** Special Case for empty Complexes **/ - for (ComplexAlias ca : model.getComplexAliases()) { + for (Complex ca : model.getComplexAliases()) { if (ca.getAliases().size() == 0) { dataNodes.append(" <DataNode TextLabel=\"" + ca.getName() + "\" GraphId=\"" + ca.getAliasId() + "\" Type=\"Complex\""); if (ca.getComplexAlias() != null) { @@ -480,7 +480,7 @@ public class ModelToGPML { protected String getGroups(Model model) { StringBuilder groups = new StringBuilder(""); - for (ComplexAlias ca : model.getComplexAliases()) { + for (Complex ca : model.getComplexAliases()) { if (ca.getAliases().size() > 0) { groups.append(" <Group GroupId=\"" + ca.getAliasId() + "\" GraphId=\"" + ca.getAliasId() + "\""); if (ca.getComplexAlias() != null) { diff --git a/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/model/GpmlModificationType.java b/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/model/GpmlModificationType.java index 28c1614bd0..47b8237bf1 100644 --- a/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/model/GpmlModificationType.java +++ b/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/model/GpmlModificationType.java @@ -1,6 +1,6 @@ package lcsb.mapviewer.wikipathway.model; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; +import lcsb.mapviewer.model.map.species.field.ModificationState; /** * This enum represents type of line in GPML format. diff --git a/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/model/State.java b/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/model/State.java index e0214ab593..244f58f44b 100644 --- a/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/model/State.java +++ b/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/model/State.java @@ -6,8 +6,8 @@ import java.util.List; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.field.ModificationState; /** * Class used to store data about {@link DataNode} state from .gpml. @@ -38,7 +38,7 @@ public class State extends GraphicalPathwayElement { private String graphRef; /** - * State correspondig to {@link ProteinAlias#structuralState protein structural state}. + * State correspondig to {@link Protein#structuralState protein structural state}. */ private String structuralState; diff --git a/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/ComplexReactionToModelTest.java b/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/ComplexReactionToModelTest.java index b961c5363e..c2086f350b 100644 --- a/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/ComplexReactionToModelTest.java +++ b/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/ComplexReactionToModelTest.java @@ -11,11 +11,11 @@ import java.nio.charset.StandardCharsets; import lcsb.mapviewer.converter.ConverterParams; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelComparator; import lcsb.mapviewer.model.map.reaction.AbstractNode; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.wikipathway.XML.GPMLToModel; import org.apache.log4j.Logger; @@ -176,8 +176,8 @@ public class ComplexReactionToModelTest { assertFalse(Color.BLACK.equals(reaction.getReactants().get(0).getLine().getColor())); - Alias redAlias = model.getAliasByAliasId("d9620"); - Alias blackAlias = model.getAliasByAliasId("d046f"); + Element redAlias = model.getAliasByAliasId("d9620"); + Element blackAlias = model.getAliasByAliasId("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 1d8c019c63..181a15f9ee 100644 --- a/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/GPMLToModelTest.java +++ b/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/GPMLToModelTest.java @@ -20,13 +20,13 @@ import lcsb.mapviewer.converter.graphics.AbstractImageGenerator; import lcsb.mapviewer.converter.graphics.PngImageGenerator; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser; import lcsb.mapviewer.converter.model.celldesigner.geometry.ReactionCellDesignerConverter; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelComparator; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.Protein; import lcsb.mapviewer.wikipathway.XML.GPMLToModel; public class GPMLToModelTest { @@ -403,7 +403,7 @@ public class GPMLToModelTest { try { String fileName = "testFiles/complex/hypothetical_complex.gpml"; Model model = new GPMLToModel().getModel(fileName); - for (ComplexAlias species : model.getComplexAliases()) { + for (Complex species : model.getComplexAliases()) { 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 (ComplexAlias species : model.getComplexAliases()) { + for (Complex species : model.getComplexAliases()) { 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 (ComplexAlias species : model.getComplexAliases()) { + for (Complex species : model.getComplexAliases()) { if ("p70 S6 Kinases".equals(species.getName())) { nameFound = true; } @@ -453,7 +453,7 @@ public class GPMLToModelTest { try { String fileName = "testFiles/compartment/compartment_name.gpml"; Model model = new GPMLToModel().getModel(fileName); - for (CompartmentAlias compartment : model.getCompartmentsAliases()) { + for (Compartment compartment : model.getCompartmentsAliases()) { assertEquals("Compartment parsed from gpml should have a valid name", "Label", compartment.getName()); } assertEquals(0, model.getCreationWarnings().size()); @@ -580,7 +580,7 @@ public class GPMLToModelTest { Model model1 = new GPMLToModel().getModel(fileName); assertEquals(0, model1.getCreationWarnings().size()); - GeneAlias protein = (GeneAlias)model1.getAliasByAliasId("be3de"); + Gene protein = (Gene)model1.getAliasByAliasId("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()); - GeneAlias protein = (GeneAlias)model1.getAliasByAliasId("be3de"); + Gene protein = (Gene)model1.getAliasByAliasId("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); - ProteinAlias protein = (ProteinAlias) model1.getAliasByName("Protein").get(0); + Protein protein = (Protein) model1.getAliasByName("Protein").get(0); assertEquals(0, protein.getModificationResidues().size()); assertEquals("GTP", protein.getStructuralState()); diff --git a/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/BugTest.java b/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/BugTest.java index f4057ac931..0232a42c1d 100644 --- a/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/BugTest.java +++ b/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/BugTest.java @@ -12,10 +12,10 @@ import org.junit.Test; import lcsb.mapviewer.converter.ConverterParams; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelComparator; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Complex; import lcsb.mapviewer.wikipathway.WikipathwaysTestFunctions; public class BugTest extends WikipathwaysTestFunctions { @@ -45,8 +45,8 @@ public class BugTest extends WikipathwaysTestFunctions { assertEquals(7, model1.getCreationWarnings().size()); int complexes = 0; - for (Alias alias : model1.getAliases()) { - if (alias instanceof ComplexAlias) { + for (Element alias : model1.getAliases()) { + if (alias instanceof Complex) { complexes++; } } 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 26f5cfec57..f4696072ab 100644 --- a/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/ModelToGPMLTest.java +++ b/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/ModelToGPMLTest.java @@ -16,10 +16,10 @@ import lcsb.mapviewer.converter.ConverterParams; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.GenericProtein; import lcsb.mapviewer.wikipathway.WikipathwaysTestFunctions; public class ModelToGPMLTest extends WikipathwaysTestFunctions { @@ -62,7 +62,7 @@ public class ModelToGPMLTest extends WikipathwaysTestFunctions { model.setWidth(1000); model.setHeight(1000); - GenericProteinAlias alias = new GenericProteinAlias("sa"); + GenericProtein alias = new GenericProtein("sa"); alias.setName("s2"); alias.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "SNCA")); alias.addMiriamData(new MiriamData(MiriamType.PUBMED, "123")); @@ -80,7 +80,7 @@ public class ModelToGPMLTest extends WikipathwaysTestFunctions { Model model2 = new GPMLToModel().getModel(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8))); - Alias p = model2.getAliasByAliasId("sa"); + Element p = model2.getAliasByAliasId("sa"); assertEquals(alias.getMiriamData().size(), p.getMiriamData().size()); for (MiriamData md : p.getMiriamData()) { diff --git a/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/StateParserTest.java b/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/StateParserTest.java index e4b453e25b..8cf9a8c01a 100644 --- a/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/StateParserTest.java +++ b/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/StateParserTest.java @@ -8,7 +8,7 @@ import org.junit.Test; import org.w3c.dom.Element; import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; +import lcsb.mapviewer.model.map.species.field.ModificationState; import lcsb.mapviewer.wikipathway.WikipathwaysTestFunctions; import lcsb.mapviewer.wikipathway.model.State; diff --git a/persist/src/db/10.0.3/fix_db_20161003.sql b/persist/src/db/10.0.3/fix_db_20161003.sql index 8e95a724a3..1443be02a5 100644 --- a/persist/src/db/10.0.3/fix_db_20161003.sql +++ b/persist/src/db/10.0.3/fix_db_20161003.sql @@ -71,4 +71,14 @@ drop table datamining; drop table associated_phenotype_element_table; drop table external_project; -drop table external_user; \ No newline at end of file +drop table external_user; + +-- clean info about annotations +delete from class_annotator_annotators_table ; +delete from class_annotator_table ; +delete from class_required_annotation_miriam_type_table ; +delete from class_required_annotation_table ; +delete from class_valid_annotation_miriam_type_table ; +delete from class_valid_annotation_table ; +update user_table set annotationschema_iddb =null; +delete from user_annotation_schema_table ; \ No newline at end of file diff --git a/persist/src/main/java/lcsb/mapviewer/persist/dao/map/graph/DataMiningDao.java b/persist/src/main/java/lcsb/mapviewer/persist/dao/map/graph/DataMiningDao.java index 3e9ff16669..71d0a089b7 100644 --- a/persist/src/main/java/lcsb/mapviewer/persist/dao/map/graph/DataMiningDao.java +++ b/persist/src/main/java/lcsb/mapviewer/persist/dao/map/graph/DataMiningDao.java @@ -8,7 +8,7 @@ import org.apache.log4j.Logger; import org.hibernate.Query; import lcsb.mapviewer.model.map.graph.DataMining; -import lcsb.mapviewer.model.map.layout.alias.Alias; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.persist.dao.BaseDao; /** @@ -40,7 +40,7 @@ public class DataMiningDao extends BaseDao<DataMining> { * node for which data mining entries should be returned * @return the data mining elements for unified node */ - public Collection<DataMining> getMissingConnectionForElement(Alias node) { + public Collection<DataMining> getMissingConnectionForElement(Element node) { if (node.getId() == 0) { return new ArrayList<DataMining>(); } else { diff --git a/persist/src/main/java/lcsb/mapviewer/persist/dao/map/layout/alias/AliasDao.java b/persist/src/main/java/lcsb/mapviewer/persist/dao/map/layout/alias/AliasDao.java index 2ed1749f8a..3f697e5c4e 100644 --- a/persist/src/main/java/lcsb/mapviewer/persist/dao/map/layout/alias/AliasDao.java +++ b/persist/src/main/java/lcsb/mapviewer/persist/dao/map/layout/alias/AliasDao.java @@ -1,21 +1,21 @@ -package lcsb.mapviewer.persist.dao.map.layout.alias; - -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.persist.dao.BaseDao; - -/** - * Data Access Object class for Alias class. - * - * @author Piotr Gawron - * - */ -public class AliasDao extends BaseDao<Alias> { - - /** - * Default constructor. - */ - public AliasDao() { - super(Alias.class); - } - -} +package lcsb.mapviewer.persist.dao.map.layout.alias; + +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.persist.dao.BaseDao; + +/** + * Data Access Object class for Alias class. + * + * @author Piotr Gawron + * + */ +public class AliasDao extends BaseDao<Element> { + + /** + * Default constructor. + */ + public AliasDao() { + super(Element.class); + } + +} diff --git a/persist/src/main/resources/applicationContext-persist.xml b/persist/src/main/resources/applicationContext-persist.xml index 841302ad1f..6ef66e1cfa 100644 --- a/persist/src/main/resources/applicationContext-persist.xml +++ b/persist/src/main/resources/applicationContext-persist.xml @@ -156,49 +156,44 @@ <value>lcsb.mapviewer.model.map.layout.ReferenceGenome</value> <value>lcsb.mapviewer.model.map.layout.ReferenceGenomeGeneMapping</value> - <value>lcsb.mapviewer.model.map.layout.alias.Alias</value> - <value>lcsb.mapviewer.model.map.layout.alias.AntisenseRnaAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.ArtifitialCompartmentAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.BottomSquareCompartmentAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.ChemicalAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.CompartmentAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.ComplexAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.DegradedAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.DrugAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.GeneAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.IonAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.IonChannelProteinAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.LeftSquareCompartmentAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.OvalCompartmentAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.ReceptorProteinAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.RightSquareCompartmentAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.RnaAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.SpeciesAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.SearchIndex</value> - <value>lcsb.mapviewer.model.map.layout.alias.SquareCompartmentAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.TopSquareCompartmentAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.TruncatedProteinAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.UnknownAlias</value> - - <value>lcsb.mapviewer.model.map.layout.alias.ModificationResidueAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.RnaRegionAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.AntisenseRnaRegionAlias</value> + <value>lcsb.mapviewer.model.map.compartment.PathwayCompartment</value> + <value>lcsb.mapviewer.model.map.compartment.BottomSquareCompartment</value> + <value>lcsb.mapviewer.model.map.compartment.Compartment</value> + <value>lcsb.mapviewer.model.map.compartment.LeftSquareCompartment</value> + <value>lcsb.mapviewer.model.map.compartment.OvalCompartment</value> + <value>lcsb.mapviewer.model.map.compartment.RightSquareCompartment</value> + <value>lcsb.mapviewer.model.map.compartment.SquareCompartment</value> + <value>lcsb.mapviewer.model.map.compartment.TopSquareCompartment</value> - + <value>lcsb.mapviewer.model.map.species.Element</value> + <value>lcsb.mapviewer.model.map.species.AntisenseRna</value> + <value>lcsb.mapviewer.model.map.species.Chemical</value> + <value>lcsb.mapviewer.model.map.species.Complex</value> + <value>lcsb.mapviewer.model.map.species.Degraded</value> + <value>lcsb.mapviewer.model.map.species.Drug</value> + <value>lcsb.mapviewer.model.map.species.Gene</value> + <value>lcsb.mapviewer.model.map.species.GenericProtein</value> + <value>lcsb.mapviewer.model.map.species.Ion</value> + <value>lcsb.mapviewer.model.map.species.IonChannelProtein</value> + <value>lcsb.mapviewer.model.map.species.Phenotype</value> + <value>lcsb.mapviewer.model.map.species.ReceptorProtein</value> + <value>lcsb.mapviewer.model.map.species.Rna</value> + <value>lcsb.mapviewer.model.map.species.SimpleMolecule</value> + <value>lcsb.mapviewer.model.map.species.Species</value> + <value>lcsb.mapviewer.model.map.species.TruncatedProtein</value> + <value>lcsb.mapviewer.model.map.species.Unknown</value> + + <value>lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion</value> + <value>lcsb.mapviewer.model.map.species.field.ModificationResidue</value> + <value>lcsb.mapviewer.model.map.species.field.RnaRegion</value> <value>lcsb.mapviewer.model.map.layout.graphics.Layer</value> <value>lcsb.mapviewer.model.map.layout.graphics.LayerText</value> <value>lcsb.mapviewer.model.map.layout.graphics.LayerRect</value> <value>lcsb.mapviewer.model.map.layout.graphics.LayerOval</value> - <value>lcsb.mapviewer.model.map.layout.alias.AntisenseRnaRegionAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.ModificationResidueAlias</value> - <value>lcsb.mapviewer.model.map.layout.alias.RnaRegionAlias</value> - <value>lcsb.mapviewer.model.map.MiriamData</value> + <value>lcsb.mapviewer.model.map.SearchIndex</value> </list> </property> <property name="hibernateProperties"> diff --git a/persist/src/test/java/lcsb/mapviewer/persist/dao/ProjectDaoTest.java b/persist/src/test/java/lcsb/mapviewer/persist/dao/ProjectDaoTest.java index 9d254af509..b7e079d5b2 100644 --- a/persist/src/test/java/lcsb/mapviewer/persist/dao/ProjectDaoTest.java +++ b/persist/src/test/java/lcsb/mapviewer/persist/dao/ProjectDaoTest.java @@ -14,13 +14,13 @@ import org.junit.Test; import lcsb.mapviewer.model.Project; import lcsb.mapviewer.model.map.OverviewImage; import lcsb.mapviewer.model.map.OverviewModelLink; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelComparator; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.SimpleMolecule; +import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.persist.PersistTestFunctions; public class ProjectDaoTest extends PersistTestFunctions { @@ -176,9 +176,9 @@ public class ProjectDaoTest extends PersistTestFunctions { model.addAlias(createSpeciesAlias(261.6666666666665, 600.75, 92.0, 52.0, "sa1119")); model.addAlias(createSpeciesAlias(203.666666666667, 687.75, 98.0, 58.0, "sa1121")); - SpeciesAlias alias = createSpeciesAlias(817.714285714286, 287.642857142859, 80.0, 40.0, "sa1422"); - SpeciesAlias alias2 = createSpeciesAlias(224.964285714286, 241.392857142859, 80.0, 40.0, "sa1419"); - ComplexAlias alias3 = createComplexAlias(804.714285714286, 182.642857142859, 112.0, 172.0, "csa152"); + Species alias = createSpeciesAlias(817.714285714286, 287.642857142859, 80.0, 40.0, "sa1422"); + Species alias2 = createSpeciesAlias(224.964285714286, 241.392857142859, 80.0, 40.0, "sa1419"); + Complex alias3 = createComplexAlias(804.714285714286, 182.642857142859, 112.0, 172.0, "csa152"); alias3.addAlias(alias); alias3.addAlias(alias2); alias.setParent(alias3); @@ -194,8 +194,8 @@ public class ProjectDaoTest extends PersistTestFunctions { return model; } - private CompartmentAlias createCompartmentAlias(double x, double y, double width, double height, String aliasId) { - CompartmentAlias alias = new CompartmentAlias(aliasId); + private Compartment createCompartmentAlias(double x, double y, double width, double height, String aliasId) { + Compartment alias = new Compartment(aliasId); alias.setX(x); alias.setY(y); alias.setWidth(width); @@ -203,8 +203,8 @@ public class ProjectDaoTest extends PersistTestFunctions { return alias; } - private SpeciesAlias createSpeciesAlias(double x, double y, double width, double height, String aliasId) { - SpeciesAlias alias = new SimpleMoleculeAlias(aliasId); + private Species createSpeciesAlias(double x, double y, double width, double height, String aliasId) { + Species alias = new SimpleMolecule(aliasId); alias.setX(x); alias.setY(y); alias.setWidth(width); @@ -212,8 +212,8 @@ public class ProjectDaoTest extends PersistTestFunctions { return alias; } - private ComplexAlias createComplexAlias(double x, double y, double width, double height, String aliasId) { - ComplexAlias alias = new ComplexAlias(aliasId); + private Complex createComplexAlias(double x, double y, double width, double height, String aliasId) { + Complex alias = new Complex(aliasId); alias.setX(x); alias.setY(y); alias.setWidth(width); diff --git a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/CommentDaoTest.java b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/CommentDaoTest.java index 0544fad958..4b8a46b053 100644 --- a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/CommentDaoTest.java +++ b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/CommentDaoTest.java @@ -13,11 +13,7 @@ import lcsb.mapviewer.model.map.Comment; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamRelationType; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationResidueAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.layout.graphics.LayerRect; import lcsb.mapviewer.model.map.model.Model; @@ -26,6 +22,10 @@ import lcsb.mapviewer.model.map.reaction.Product; import lcsb.mapviewer.model.map.reaction.Reactant; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.type.TransportReaction; +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.field.ModificationResidue; import lcsb.mapviewer.persist.PersistTestFunctions; public class CommentDaoTest extends PersistTestFunctions { @@ -102,7 +102,7 @@ public class CommentDaoTest extends PersistTestFunctions { private Model createModel() { Model model = new ModelFullIndexed(null); - GenericProteinAlias alias = createSpeciesAlias(264.8333333333335, 517.75, 86.0, 46.0, "sa2"); + GenericProtein alias = createSpeciesAlias(264.8333333333335, 517.75, 86.0, 46.0, "sa2"); model.addAlias(alias); alias = createSpeciesAlias(267.6666666666665, 438.75, 80.0, 40.0, "sa1117"); model.addAlias(alias); @@ -112,8 +112,8 @@ public class CommentDaoTest extends PersistTestFunctions { model.addAlias(alias); alias = createSpeciesAlias(817.714285714286, 287.642857142859, 80.0, 40.0, "sa1422"); - SpeciesAlias alias2 = createSpeciesAlias(224.964285714286, 241.392857142859, 80.0, 40.0, "sa1419"); - ComplexAlias alias3 = createComplexAlias(804.714285714286, 182.642857142859, 112.0, 172.0, "csa152"); + Species alias2 = createSpeciesAlias(224.964285714286, 241.392857142859, 80.0, 40.0, "sa1419"); + Complex alias3 = createComplexAlias(804.714285714286, 182.642857142859, 112.0, 172.0, "csa152"); alias3.addAlias(alias); alias3.addAlias(alias2); alias.setParent(alias3); @@ -123,7 +123,7 @@ public class CommentDaoTest extends PersistTestFunctions { model.addAlias(alias2); model.addAlias(alias3); - CompartmentAlias cAlias = createCompartmentAlias(380.0, 416.0, 1893.0, 1866.0, "ca1"); + Compartment cAlias = createCompartmentAlias(380.0, 416.0, 1893.0, 1866.0, "ca1"); model.addAlias(cAlias); model.setWidth(2000); model.setHeight(2000); @@ -144,7 +144,7 @@ public class CommentDaoTest extends PersistTestFunctions { alias = createSpeciesAlias(264.8333333333335, 517.75, 86.0, 46.0, "pr1"); model.addAlias(alias); - ModificationResidueAlias mr = new ModificationResidueAlias(); + ModificationResidue mr = new ModificationResidue(); mr.setName("mr"); alias.addModificationResidue(mr); @@ -152,8 +152,8 @@ public class CommentDaoTest extends PersistTestFunctions { return model; } - private CompartmentAlias createCompartmentAlias(double x, double y, double width, double height, String aliasId) { - CompartmentAlias alias = new CompartmentAlias(aliasId); + private Compartment createCompartmentAlias(double x, double y, double width, double height, String aliasId) { + Compartment alias = new Compartment(aliasId); alias.setX(x); alias.setY(y); alias.setWidth(width); @@ -161,8 +161,8 @@ public class CommentDaoTest extends PersistTestFunctions { return alias; } - private GenericProteinAlias createSpeciesAlias(double x, double y, double width, double height, String aliasId) { - GenericProteinAlias alias = new GenericProteinAlias(aliasId); + private GenericProtein createSpeciesAlias(double x, double y, double width, double height, String aliasId) { + GenericProtein alias = new GenericProtein(aliasId); alias.setName("SNCA"); alias.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "SNCA")); alias.addMiriamData(new MiriamData(MiriamType.HGNC, "11138")); @@ -173,8 +173,8 @@ public class CommentDaoTest extends PersistTestFunctions { return alias; } - private ComplexAlias createComplexAlias(double x, double y, double width, double height, String aliasId) { - ComplexAlias alias = new ComplexAlias(aliasId); + private Complex createComplexAlias(double x, double y, double width, double height, String aliasId) { + Complex alias = new Complex(aliasId); alias.setX(x); alias.setY(y); alias.setWidth(width); 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 0f3d09e5df..d1e9e9cf83 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 @@ -18,13 +18,8 @@ import lcsb.mapviewer.model.cache.UploadedFileEntry; 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.Layout; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationResidueAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.layout.graphics.LayerRect; import lcsb.mapviewer.model.map.model.Model; @@ -33,6 +28,11 @@ import lcsb.mapviewer.model.map.reaction.Product; import lcsb.mapviewer.model.map.reaction.Reactant; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.type.TransportReaction; +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; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; import lcsb.mapviewer.persist.PersistTestFunctions; public class LayoutDaoTest extends PersistTestFunctions { @@ -149,7 +149,7 @@ public class LayoutDaoTest extends PersistTestFunctions { private Model createModel() { Model model = new ModelFullIndexed(null); - SpeciesAlias alias = createSpeciesAlias(264.8333333333335, 517.75, 86.0, 46.0, "sa2"); + Species alias = createSpeciesAlias(264.8333333333335, 517.75, 86.0, 46.0, "sa2"); model.addAlias(alias); alias = createSpeciesAlias(267.6666666666665, 438.75, 80.0, 40.0, "sa1117"); model.addAlias(alias); @@ -159,8 +159,8 @@ public class LayoutDaoTest extends PersistTestFunctions { model.addAlias(alias); alias = createSpeciesAlias(817.714285714286, 287.642857142859, 80.0, 40.0, "sa1422"); - SpeciesAlias alias2 = createSpeciesAlias(224.964285714286, 241.392857142859, 80.0, 40.0, "sa1419"); - ComplexAlias alias3 = createComplexAlias(804.714285714286, 182.642857142859, 112.0, 172.0, "csa152"); + Species alias2 = createSpeciesAlias(224.964285714286, 241.392857142859, 80.0, 40.0, "sa1419"); + Complex alias3 = createComplexAlias(804.714285714286, 182.642857142859, 112.0, 172.0, "csa152"); alias3.addAlias(alias); alias3.addAlias(alias2); alias.setParent(alias3); @@ -170,7 +170,7 @@ public class LayoutDaoTest extends PersistTestFunctions { model.addAlias(alias2); model.addAlias(alias3); - CompartmentAlias cAlias = createCompartmentAlias(380.0, 416.0, 1893.0, 1866.0, "ca1"); + Compartment cAlias = createCompartmentAlias(380.0, 416.0, 1893.0, 1866.0, "ca1"); model.addAlias(cAlias); model.setWidth(2000); model.setHeight(2000); @@ -188,10 +188,10 @@ public class LayoutDaoTest extends PersistTestFunctions { reaction.setIdReaction("re" + identifierCounter++); model.addReaction(reaction); - ProteinAlias protein = createSpeciesAlias(264.8333333333335, 517.75, 86.0, 46.0, "pr1"); + Protein protein = createSpeciesAlias(264.8333333333335, 517.75, 86.0, 46.0, "pr1"); model.addAlias(protein); - ModificationResidueAlias mr = new ModificationResidueAlias(); + ModificationResidue mr = new ModificationResidue(); mr.setName("mr"); protein.addModificationResidue(mr); @@ -199,8 +199,8 @@ public class LayoutDaoTest extends PersistTestFunctions { return model; } - private CompartmentAlias createCompartmentAlias(double x, double y, double width, double height, String aliasId) { - CompartmentAlias alias = new CompartmentAlias(aliasId); + private Compartment createCompartmentAlias(double x, double y, double width, double height, String aliasId) { + Compartment alias = new Compartment(aliasId); alias.setX(x); alias.setY(y); alias.setWidth(width); @@ -208,8 +208,8 @@ public class LayoutDaoTest extends PersistTestFunctions { return alias; } - private ProteinAlias createSpeciesAlias(double x, double y, double width, double height, String aliasId) { - GenericProteinAlias alias = new GenericProteinAlias("s" + identifierCounter++); + private Protein createSpeciesAlias(double x, double y, double width, double height, String aliasId) { + GenericProtein alias = new GenericProtein("s" + identifierCounter++); alias.setAliasId(aliasId); alias.setX(x); alias.setY(y); @@ -218,8 +218,8 @@ public class LayoutDaoTest extends PersistTestFunctions { return alias; } - private ComplexAlias createComplexAlias(double x, double y, double width, double height, String aliasId) { - ComplexAlias alias = new ComplexAlias(aliasId); + private Complex createComplexAlias(double x, double y, double width, double height, String aliasId) { + Complex alias = new Complex(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 bb1dd1c877..ed8a97c14c 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 @@ -17,15 +17,9 @@ import lcsb.mapviewer.model.Project; 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.graph.DataMiningSet; import lcsb.mapviewer.model.map.layout.Layout; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationResidueAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.layout.graphics.Layer; import lcsb.mapviewer.model.map.layout.graphics.LayerRect; import lcsb.mapviewer.model.map.model.Model; @@ -35,6 +29,12 @@ import lcsb.mapviewer.model.map.reaction.Product; import lcsb.mapviewer.model.map.reaction.Reactant; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.type.TransportReaction; +import lcsb.mapviewer.model.map.species.Element; +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; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; import lcsb.mapviewer.persist.PersistTestFunctions; public class ModelDaoTest extends PersistTestFunctions { @@ -106,15 +106,15 @@ public class ModelDaoTest extends PersistTestFunctions { // check if we really performed a test boolean test = false; - for (Alias alias : model.getAliases()) { + for (Element alias : model.getAliases()) { assertNotNull(fullModel.getAliasByAliasId(alias.getAliasId())); test = true; } assertTrue(test); test = false; - for (Alias alias : model.getAliases()) { - if (alias instanceof CompartmentAlias) { + for (Element alias : model.getAliases()) { + if (alias instanceof Compartment) { assertNotNull(fullModel.getCompartmentAliasByCompartmentAliasId(alias.getAliasId())); test = true; } @@ -216,8 +216,8 @@ public class ModelDaoTest extends PersistTestFunctions { projectDao.evict(project); Model model2 = new ModelFullIndexed(modelDao.getById(model.getId())); - ProteinAlias originalSpecies = (ProteinAlias) model.getAliasByAliasId("pr1"); - ProteinAlias fromDbSpecies = (ProteinAlias) model2.getAliasByAliasId("pr1"); + Protein originalSpecies = (Protein) model.getAliasByAliasId("pr1"); + Protein fromDbSpecies = (Protein) model2.getAliasByAliasId("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())); - ProteinAlias originalSpecies = (ProteinAlias) model.getAliasByAliasId("pr1"); - ProteinAlias fromDbSpecies = (ProteinAlias) model2.getAliasByAliasId("pr1"); + Protein originalSpecies = (Protein) model.getAliasByAliasId("pr1"); + Protein fromDbSpecies = (Protein) model2.getAliasByAliasId("pr1"); assertFalse(originalSpecies.equals(fromDbSpecies)); assertEquals(originalSpecies.getMiriamData().size(), fromDbSpecies.getMiriamData().size()); @@ -329,7 +329,7 @@ public class ModelDaoTest extends PersistTestFunctions { private Model createModel() { Model model = new ModelFullIndexed(null); - GenericProteinAlias alias = createSpeciesAlias(264.8333333333335, 517.75, 86.0, 46.0, "sa2"); + GenericProtein alias = createSpeciesAlias(264.8333333333335, 517.75, 86.0, 46.0, "sa2"); model.addAlias(alias); alias = createSpeciesAlias(267.6666666666665, 438.75, 80.0, 40.0, "sa1117"); model.addAlias(alias); @@ -339,8 +339,8 @@ public class ModelDaoTest extends PersistTestFunctions { model.addAlias(alias); alias = createSpeciesAlias(817.714285714286, 287.642857142859, 80.0, 40.0, "sa1422"); - SpeciesAlias alias2 = createSpeciesAlias(224.964285714286, 241.392857142859, 80.0, 40.0, "sa1419"); - ComplexAlias alias3 = createComplexAlias(804.714285714286, 182.642857142859, 112.0, 172.0, "csa152"); + Species alias2 = createSpeciesAlias(224.964285714286, 241.392857142859, 80.0, 40.0, "sa1419"); + Complex alias3 = createComplexAlias(804.714285714286, 182.642857142859, 112.0, 172.0, "csa152"); alias3.addAlias(alias); alias3.addAlias(alias2); alias.setParent(alias3); @@ -350,7 +350,7 @@ public class ModelDaoTest extends PersistTestFunctions { model.addAlias(alias2); model.addAlias(alias3); - CompartmentAlias cAlias = createCompartmentAlias(380.0, 416.0, 1893.0, 1866.0, "ca1"); + Compartment cAlias = createCompartmentAlias(380.0, 416.0, 1893.0, 1866.0, "ca1"); model.addAlias(cAlias); model.setWidth(2000); model.setHeight(2000); @@ -371,7 +371,7 @@ public class ModelDaoTest extends PersistTestFunctions { alias = createSpeciesAlias(264.8333333333335, 517.75, 86.0, 46.0, "pr1"); model.addAlias(alias); - ModificationResidueAlias mr = new ModificationResidueAlias(); + ModificationResidue mr = new ModificationResidue(); mr.setName("mr"); alias.addModificationResidue(mr); @@ -379,8 +379,8 @@ public class ModelDaoTest extends PersistTestFunctions { return model; } - private CompartmentAlias createCompartmentAlias(double x, double y, double width, double height, String aliasId) { - CompartmentAlias alias = new CompartmentAlias(aliasId); + private Compartment createCompartmentAlias(double x, double y, double width, double height, String aliasId) { + Compartment alias = new Compartment(aliasId); alias.setX(x); alias.setY(y); alias.setWidth(width); @@ -388,8 +388,8 @@ public class ModelDaoTest extends PersistTestFunctions { return alias; } - private GenericProteinAlias createSpeciesAlias(double x, double y, double width, double height, String aliasId) { - GenericProteinAlias alias = new GenericProteinAlias(aliasId); + private GenericProtein createSpeciesAlias(double x, double y, double width, double height, String aliasId) { + GenericProtein alias = new GenericProtein(aliasId); alias.setName("SNCA"); alias.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "SNCA")); alias.addMiriamData(new MiriamData(MiriamType.HGNC, "11138")); @@ -401,8 +401,8 @@ public class ModelDaoTest extends PersistTestFunctions { return alias; } - private ComplexAlias createComplexAlias(double x, double y, double width, double height, String aliasId) { - ComplexAlias alias = new ComplexAlias(aliasId); + private Complex createComplexAlias(double x, double y, double width, double height, String aliasId) { + Complex alias = new Complex(aliasId); alias.setX(x); alias.setY(y); alias.setWidth(width); diff --git a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/graph/DataMiningDaoTest.java b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/graph/DataMiningDaoTest.java index 3956dea410..352746c1d4 100644 --- a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/graph/DataMiningDaoTest.java +++ b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/graph/DataMiningDaoTest.java @@ -10,10 +10,10 @@ import org.springframework.beans.factory.annotation.Autowired; import lcsb.mapviewer.model.Project; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.graph.DataMining; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.GenericProtein; import lcsb.mapviewer.persist.PersistTestFunctions; public class DataMiningDaoTest extends PersistTestFunctions { @@ -31,7 +31,7 @@ public class DataMiningDaoTest extends PersistTestFunctions { @Test public void testGetConnections() { - assertEquals(0, dataMiningDao.getMissingConnectionForElement(new GenericProteinAlias("id")).size()); + assertEquals(0, dataMiningDao.getMissingConnectionForElement(new GenericProtein("id")).size()); } @Test @@ -41,7 +41,7 @@ public class DataMiningDaoTest extends PersistTestFunctions { Project project = new Project(); project.setProjectId(projectId); Model model = new ModelFullIndexed(null); - Alias alias = new GenericProteinAlias("some_el_id"); + Element alias = new GenericProtein("some_el_id"); model.addAlias(alias); project.addModel(model); projectDao.add(project); @@ -66,7 +66,7 @@ public class DataMiningDaoTest extends PersistTestFunctions { @Test public void testGetConnections2() { - Alias species = new GenericProteinAlias("id"); + Element species = new GenericProtein("id"); species.setId(1); assertEquals(0, dataMiningDao.getMissingConnectionForElement(species).size()); } 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 c9222bafd7..1e05e8b055 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 @@ -8,16 +8,16 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.model.Project; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.SearchIndex; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.SearchIndex; +import lcsb.mapviewer.model.map.compartment.Compartment; 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.species.Element; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.SimpleMolecule; +import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.persist.PersistTestFunctions; public class AliasDaoTest extends PersistTestFunctions { @@ -50,7 +50,7 @@ public class AliasDaoTest extends PersistTestFunctions { Model model = createModel(); project.addModel(model); - SpeciesAlias alias = (SpeciesAlias) model.getAliasByAliasId("sa2"); + Species alias = (Species) model.getAliasByAliasId("sa2"); alias.getSearchIndexes().add(new SearchIndex("blabla")); @@ -58,7 +58,7 @@ public class AliasDaoTest extends PersistTestFunctions { Model model2 = new ModelFullIndexed(modelDao.getById(model.getId())); - SpeciesAlias alias2 = (SpeciesAlias) aliasDao.getById(model2.getAliasByAliasId("sa2").getId()); + Species alias2 = (Species) aliasDao.getById(model2.getAliasByAliasId("sa2").getId()); assertEquals(1, alias2.getSearchIndexes().size()); @@ -76,9 +76,9 @@ public class AliasDaoTest extends PersistTestFunctions { model.addAlias(createSpeciesAlias(261.6666666666665, 600.75, 92.0, 52.0, "sa1119")); model.addAlias(createSpeciesAlias(203.666666666667, 687.75, 98.0, 58.0, "sa1121")); - SpeciesAlias alias = createSpeciesAlias(817.714285714286, 287.642857142859, 80.0, 40.0, "sa1422"); - SpeciesAlias alias2 = createSpeciesAlias(224.964285714286, 241.392857142859, 80.0, 40.0, "sa1419"); - ComplexAlias alias3 = createComplexAlias(804.714285714286, 182.642857142859, 112.0, 172.0, "csa152"); + Species alias = createSpeciesAlias(817.714285714286, 287.642857142859, 80.0, 40.0, "sa1422"); + Species alias2 = createSpeciesAlias(224.964285714286, 241.392857142859, 80.0, 40.0, "sa1419"); + Complex alias3 = createComplexAlias(804.714285714286, 182.642857142859, 112.0, 172.0, "csa152"); alias3.addAlias(alias); alias3.addAlias(alias2); alias.setParent(alias3); @@ -94,8 +94,8 @@ public class AliasDaoTest extends PersistTestFunctions { return model; } - private CompartmentAlias createCompartmentAlias(double x, double y, double width, double height, String aliasId) { - CompartmentAlias alias = new CompartmentAlias(aliasId); + private Compartment createCompartmentAlias(double x, double y, double width, double height, String aliasId) { + Compartment alias = new Compartment(aliasId); alias.setX(x); alias.setY(y); alias.setWidth(width); @@ -103,8 +103,8 @@ public class AliasDaoTest extends PersistTestFunctions { return alias; } - private SpeciesAlias createSpeciesAlias(double x, double y, double width, double height, String aliasId) { - SimpleMoleculeAlias alias = new SimpleMoleculeAlias(aliasId); + private Species createSpeciesAlias(double x, double y, double width, double height, String aliasId) { + SimpleMolecule alias = new SimpleMolecule(aliasId); alias.setX(x); alias.setY(y); alias.setWidth(width); @@ -112,8 +112,8 @@ public class AliasDaoTest extends PersistTestFunctions { return alias; } - private ComplexAlias createComplexAlias(double x, double y, double width, double height, String aliasId) { - ComplexAlias alias = new ComplexAlias(aliasId); + private Complex createComplexAlias(double x, double y, double width, double height, String aliasId) { + Complex alias = new Complex(aliasId); alias.setX(x); alias.setY(y); alias.setWidth(width); @@ -127,7 +127,7 @@ public class AliasDaoTest extends PersistTestFunctions { long count = modelDao.getCount(); Model model = createModel(); Model model1 = createModel(); - Alias alias = model.getAliasByAliasId("sa2"); + Element alias = model.getAliasByAliasId("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 4f9125351f..a1a99c857e 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 @@ -12,20 +12,20 @@ import org.junit.Test; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamRelationType; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaAlias; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaRegionAlias; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaRegionAlias.AntisenseRnaRegionType; -import lcsb.mapviewer.model.map.layout.alias.ChemicalAlias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.IonAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationResidueAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationState; -import lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaRegionAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.species.AntisenseRna; +import lcsb.mapviewer.model.map.species.Chemical; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Ion; +import lcsb.mapviewer.model.map.species.Phenotype; +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.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 { @@ -51,7 +51,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { public void testAdd() throws Exception { try { - GenericProteinAlias sp = new GenericProteinAlias(testIdAlias); + GenericProtein sp = new GenericProtein(testIdAlias); sp.setCharge(testChargeVal); sp.setInitialAmount(testInitialAmount); sp.setInitialConcentration(testInitialConcentration); @@ -59,7 +59,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { sp.setNotes(testNotes); sp.setOnlySubstanceUnits(testOnlySubstanceunits); - CompartmentAlias parent = new CompartmentAlias("comp id"); + Compartment parent = new Compartment("comp id"); sp.setParent(parent); MiriamData md = new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.UNKNOWN, "c"); @@ -67,7 +67,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { aliasDao.add(sp); - SpeciesAlias sp2 = (SpeciesAlias) aliasDao.getById(sp.getId()); + Species sp2 = (Species) aliasDao.getById(sp.getId()); assertNotNull(sp2); assertEquals(sp.getCharge(), sp2.getCharge()); assertEquals(sp.getAliasId(), sp2.getAliasId()); @@ -77,7 +77,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { assertEquals(sp.getNotes(), sp2.getNotes()); assertEquals(sp.hasOnlySubstanceUnits(), sp2.hasOnlySubstanceUnits()); - CompartmentAlias parent2 = (CompartmentAlias) sp2.getParent(); + Compartment parent2 = (Compartment) sp2.getParent(); assertNotNull(parent2); assertEquals("comp id", parent2.getAliasId()); @@ -90,7 +90,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { assertEquals(md.getResource(), md2.getResource()); aliasDao.delete(sp); - sp2 = (SpeciesAlias) aliasDao.getById(sp.getId()); + sp2 = (Species) aliasDao.getById(sp.getId()); assertNull(sp2); } catch (Exception e) { @@ -103,8 +103,8 @@ public class AliasDaoTest2 extends PersistTestFunctions { public void testProtein() throws Exception { try { - ProteinAlias protein = new GenericProteinAlias(testIdAlias); - ModificationResidueAlias mr = new ModificationResidueAlias(); + Protein protein = new GenericProtein(testIdAlias); + ModificationResidue mr = new ModificationResidue(); mr.setAngle(2.0); mr.setName("name"); mr.setSide("side"); @@ -114,7 +114,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { aliasDao.add(protein); - ProteinAlias sp2 = (ProteinAlias) aliasDao.getById(protein.getId()); + Protein sp2 = (Protein) aliasDao.getById(protein.getId()); assertNotNull(sp2); assertEquals(protein.getAliasId(), sp2.getAliasId()); @@ -129,7 +129,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { assertEquals(sp2.getModificationResidues().get(0).getState(), mr.getState()); aliasDao.delete(sp2); - sp2 = (ProteinAlias) aliasDao.getById(protein.getId()); + sp2 = (Protein) aliasDao.getById(protein.getId()); assertNull(sp2); } catch (Exception e) { @@ -142,8 +142,8 @@ public class AliasDaoTest2 extends PersistTestFunctions { public void testRna() throws Exception { try { - RnaAlias sp = new RnaAlias(testIdAlias); - RnaRegionAlias mr = new RnaRegionAlias(); + Rna sp = new Rna(testIdAlias); + RnaRegion mr = new RnaRegion(); mr.setName("name"); mr.setSize(3.0); mr.setState(ModificationState.DONT_CARE); @@ -152,7 +152,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { aliasDao.add(sp); aliasDao.evict(sp); - RnaAlias sp2 = (RnaAlias) aliasDao.getById(sp.getId()); + Rna sp2 = (Rna) aliasDao.getById(sp.getId()); assertNotNull(sp2); assertEquals(sp.getAliasId(), sp2.getAliasId()); @@ -165,7 +165,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { assertEquals(sp2.getRegions().get(0).getState(), mr.getState()); aliasDao.delete(sp2); - sp2 = (RnaAlias) aliasDao.getById(sp.getId()); + sp2 = (Rna) aliasDao.getById(sp.getId()); assertNull(sp2); } catch (Exception e) { @@ -178,8 +178,8 @@ public class AliasDaoTest2 extends PersistTestFunctions { public void testAntisenseRna() throws Exception { try { - AntisenseRnaAlias sp = new AntisenseRnaAlias(testIdAlias); - AntisenseRnaRegionAlias mr = new AntisenseRnaRegionAlias(); + AntisenseRna sp = new AntisenseRna(testIdAlias); + AntisenseRnaRegion mr = new AntisenseRnaRegion(); mr.setName("name"); mr.setSize(3.0); mr.setType(AntisenseRnaRegionType.MODIFICATION_SITE); @@ -189,7 +189,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { aliasDao.add(sp); aliasDao.evict(sp); - AntisenseRnaAlias sp2 = (AntisenseRnaAlias) aliasDao.getById(sp.getId()); + AntisenseRna sp2 = (AntisenseRna) aliasDao.getById(sp.getId()); assertNotNull(sp2); assertEquals(sp.getAliasId(), sp2.getAliasId()); @@ -203,7 +203,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { assertEquals(sp2.getRegions().get(0).getType(), mr.getType()); aliasDao.delete(sp2); - sp2 = (AntisenseRnaAlias) aliasDao.getById(sp.getId()); + sp2 = (AntisenseRna) aliasDao.getById(sp.getId()); assertNull(sp2); } catch (Exception e) { @@ -215,7 +215,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { @Test public void testSynonymsInAlias() throws Exception { try { - ProteinAlias protein = new GenericProteinAlias(testIdAlias); + Protein protein = new GenericProtein(testIdAlias); protein.addSynonym("Synonym"); protein.addSynonym("Synonym A"); protein.addSynonym("A"); @@ -228,7 +228,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { aliasDao.flush(); aliasDao.evict(protein); - ProteinAlias sp2 = (ProteinAlias) aliasDao.getById(protein.getId()); + Protein sp2 = (Protein) aliasDao.getById(protein.getId()); assertNotNull(sp2.getSynonyms()); assertEquals(protein.getSynonyms().size(), sp2.getSynonyms().size()); @@ -245,7 +245,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { } aliasDao.delete(sp2); - sp2 = (ProteinAlias) aliasDao.getById(protein.getId()); + sp2 = (Protein) aliasDao.getById(protein.getId()); assertNull(sp2); } catch (Exception e) { @@ -257,7 +257,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { @Test public void testChemicals() throws Exception { try { - ChemicalAlias ion = new IonAlias(testIdAlias); + Chemical ion = new Ion(testIdAlias); ion.setInChI("come inchi"); ion.setInChIKey("keyyy"); ion.setSmiles("smile"); @@ -266,7 +266,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { aliasDao.flush(); aliasDao.evict(ion); - IonAlias sp2 = (IonAlias) aliasDao.getById(ion.getId()); + Ion sp2 = (Ion) aliasDao.getById(ion.getId()); assertNotNull(sp2.getSynonyms()); assertEquals(ion.getSynonyms().size(), sp2.getSynonyms().size()); @@ -276,7 +276,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { assertEquals(ion.getInChI(), sp2.getInChI()); aliasDao.delete(sp2); - sp2 = (IonAlias) aliasDao.getById(ion.getId()); + sp2 = (Ion) aliasDao.getById(ion.getId()); assertNull(sp2); } catch (Exception e) { @@ -288,19 +288,19 @@ public class AliasDaoTest2 extends PersistTestFunctions { @Test public void testPhenotype() throws Exception { try { - PhenotypeAlias phenotype = new PhenotypeAlias(testIdAlias); + Phenotype phenotype = new Phenotype(testIdAlias); aliasDao.add(phenotype); aliasDao.flush(); aliasDao.evict(phenotype); - PhenotypeAlias sp2 = (PhenotypeAlias) aliasDao.getById(phenotype.getId()); + Phenotype sp2 = (Phenotype) aliasDao.getById(phenotype.getId()); assertNotNull(sp2.getSynonyms()); assertEquals(phenotype.getSynonyms().size(), phenotype.getSynonyms().size()); aliasDao.delete(sp2); - sp2 = (PhenotypeAlias) aliasDao.getById(phenotype.getId()); + sp2 = (Phenotype) aliasDao.getById(phenotype.getId()); assertNull(sp2); } catch (Exception e) { diff --git a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AntisenseRnaTest.java b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AntisenseRnaTest.java index cd3d7063e7..8f8121b864 100644 --- a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AntisenseRnaTest.java +++ b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AntisenseRnaTest.java @@ -11,11 +11,11 @@ import org.junit.Test; import org.springframework.test.annotation.Rollback; import lcsb.mapviewer.model.Project; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaAlias; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaRegionAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion; +import lcsb.mapviewer.model.map.species.AntisenseRna; import lcsb.mapviewer.persist.PersistTestFunctions; @Rollback(true) @@ -56,11 +56,11 @@ public class AntisenseRnaTest extends PersistTestFunctions { Model model2 = new ModelFullIndexed(project2.getModels().iterator().next()); - Alias sp = model.getAliases().iterator().next(); - AntisenseRnaAlias ar = (AntisenseRnaAlias) sp; + Element sp = model.getAliases().iterator().next(); + AntisenseRna ar = (AntisenseRna) sp; - Alias sp2 = model2.getAliases().iterator().next(); - AntisenseRnaAlias ar2 = (AntisenseRnaAlias) sp2; + Element sp2 = model2.getAliases().iterator().next(); + AntisenseRna ar2 = (AntisenseRna) sp2; projectDao.delete(project2); @@ -74,8 +74,8 @@ public class AntisenseRnaTest extends PersistTestFunctions { private Model createModel() { Model model = new ModelFullIndexed(null); - AntisenseRnaAlias alias = new AntisenseRnaAlias("As"); - alias.addRegion(new AntisenseRnaRegionAlias()); + AntisenseRna alias = new AntisenseRna("As"); + alias.addRegion(new AntisenseRnaRegion()); alias.setX(1); alias.setY(2); alias.setWidth(10); diff --git a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/RnaTest.java b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/RnaTest.java index 6da43f4e7f..b275d90736 100644 --- a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/RnaTest.java +++ b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/RnaTest.java @@ -10,11 +10,11 @@ import org.junit.Before; import org.junit.Test; import lcsb.mapviewer.model.Project; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaRegionAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Rna; +import lcsb.mapviewer.model.map.species.field.RnaRegion; import lcsb.mapviewer.persist.PersistTestFunctions; public class RnaTest extends PersistTestFunctions { @@ -55,11 +55,11 @@ public class RnaTest extends PersistTestFunctions { Model model2 = new ModelFullIndexed(project2.getModels().iterator().next()); - Alias sp = model.getAliases().iterator().next(); - RnaAlias ar = (RnaAlias) sp; + Element sp = model.getAliases().iterator().next(); + Rna ar = (Rna) sp; - Alias sp2 = model2.getAliases().iterator().next(); - RnaAlias ar2 = (RnaAlias) sp2; + Element sp2 = model2.getAliases().iterator().next(); + Rna ar2 = (Rna) sp2; projectDao.delete(project2); @@ -73,8 +73,8 @@ public class RnaTest extends PersistTestFunctions { private Model createModel() { Model model = new ModelFullIndexed(null); - RnaAlias alias = new RnaAlias("As"); - alias.addRegion(new RnaRegionAlias()); + Rna alias = new Rna("As"); + alias.addRegion(new RnaRegion()); alias.setX(1); alias.setY(2); alias.setWidth(10); diff --git a/persist/src/test/java/lcsb/mapviewer/persist/dao/user/UserDaoTest.java b/persist/src/test/java/lcsb/mapviewer/persist/dao/user/UserDaoTest.java index caacbb840d..c36edb9b85 100644 --- a/persist/src/test/java/lcsb/mapviewer/persist/dao/user/UserDaoTest.java +++ b/persist/src/test/java/lcsb/mapviewer/persist/dao/user/UserDaoTest.java @@ -18,8 +18,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.crypto.password.PasswordEncoder; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.model.user.User; import lcsb.mapviewer.model.user.UserAnnotationSchema; import lcsb.mapviewer.model.user.UserClassAnnotators; @@ -243,7 +243,7 @@ public class UserDaoTest extends PersistTestFunctions { UserAnnotationSchema uas = new UserAnnotationSchema(); uas.setValidateMiriamTypes(true); UserClassAnnotators ca = new UserClassAnnotators(); - ca.setClassName(SpeciesAlias.class); + ca.setClassName(Species.class); ca.addAnnotator(String.class); ca.addAnnotator(Integer.class); uas.addClassAnnotator(ca); @@ -264,7 +264,7 @@ public class UserDaoTest extends PersistTestFunctions { assertNotNull(uas2); assertEquals(2, uas2.getClassAnnotators().size()); assertEquals(3, uas2.getClassValidAnnotators().size()); - assertEquals(SpeciesAlias.class.getCanonicalName(), uas.getClassAnnotators().get(0).getClassName()); + assertEquals(Species.class.getCanonicalName(), uas.getClassAnnotators().get(0).getClassName()); assertEquals(String.class.getCanonicalName(), uas.getClassAnnotators().get(0).getAnnotators().get(0)); assertEquals(Integer.class.getCanonicalName(), uas.getClassAnnotators().get(0).getAnnotators().get(1)); assertEquals(Reaction.class.getCanonicalName(), uas.getClassValidAnnotators().get(0).getClassName()); diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/DataFormatter.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/DataFormatter.java index 67c6241e77..6bd52eb98f 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/DataFormatter.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/DataFormatter.java @@ -11,8 +11,8 @@ import org.springframework.beans.factory.annotation.Autowired; import lcsb.mapviewer.annotation.services.MiriamConnector; import lcsb.mapviewer.annotation.services.annotators.AnnotatorException; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Complex; import lcsb.mapviewer.reactome.model.ReactomeCatalystActivity; import lcsb.mapviewer.reactome.model.ReactomeDatabaseObject; import lcsb.mapviewer.reactome.model.ReactomePhysicalEntity; @@ -54,16 +54,16 @@ public class DataFormatter { * @throws IOException * @throws AnnotatorException */ - private String speciesListToString(List<Alias> list) throws IOException, AnnotatorException { + private String speciesListToString(List<Element> list) throws IOException, AnnotatorException { String result = ""; - for (Alias species : list) { + for (Element species : list) { if (!result.equals("")) { result += ",<hr/>"; } result += species.getName() + "<br/>"; Set<MiriamData> ids = null; - if (species instanceof ComplexAlias) { - ids = rcu.getIdsForComplex((ComplexAlias) species); + if (species instanceof Complex) { + ids = rcu.getIdsForComplex((Complex) species); } else { ids = rcu.getIdsForSpecies(species); } diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/ElementUtil.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/ElementUtil.java index f3d7c1210c..e0d388081f 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/ElementUtil.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/ElementUtil.java @@ -15,7 +15,7 @@ import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.modelutils.map.ElementUtils; /** @@ -57,7 +57,7 @@ public class ElementUtil { * @throws AnnotatorException * thrown when there is a problem with accessing external resource */ - public Set<MiriamData> getMiriamByType(Alias element, MiriamType mt, boolean queryServer) throws AnnotatorException { + public Set<MiriamData> getMiriamByType(Element element, MiriamType mt, boolean queryServer) throws AnnotatorException { Set<MiriamData> result = new HashSet<MiriamData>(); for (MiriamData md : element.getMiriamData()) { if (mt.equals(md.getDataType())) { @@ -92,7 +92,7 @@ public class ElementUtil { * @throws AnnotatorException * thrown when there is a problem with accessing external server */ - private Collection<? extends MiriamData> getUniprot(Alias element) throws AnnotatorException { + private Collection<? extends MiriamData> getUniprot(Element element) throws AnnotatorException { Set<MiriamData> result = new HashSet<MiriamData>(); for (MiriamData md : element.getMiriamData()) { if (MiriamType.HGNC_SYMBOL.equals(md.getDataType()) || MiriamType.HGNC.equals(md.getDataType())) { diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/ReactionComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/ReactionComparator.java index 89c33c312e..1ec4d89ac5 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/ReactionComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/ReactionComparator.java @@ -7,10 +7,10 @@ import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.ReactionNode; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Phenotype; import lcsb.mapviewer.reactome.model.ReactomeCatalystActivity; import lcsb.mapviewer.reactome.model.ReactomeDatabaseObject; import lcsb.mapviewer.reactome.model.ReactomePhysicalEntity; @@ -63,16 +63,16 @@ public class ReactionComparator { } for (ReactionNode node : reaction.getReactionNodes()) { - if (node.getAlias() instanceof PhenotypeAlias) { + if (node.getAlias() instanceof Phenotype) { result.setStatus(MatchStatus.INVALID_REACTION_WITH_PHEONTYPE); return result; } } int matchingElements = 0; - Set<Alias> invalidReactionModifier = new HashSet<>(); - Set<Alias> invalidReactionInput = new HashSet<>(); - Set<Alias> invalidReactionOutput = new HashSet<>(); + Set<Element> invalidReactionModifier = new HashSet<>(); + Set<Element> invalidReactionInput = new HashSet<>(); + Set<Element> invalidReactionOutput = new HashSet<>(); Set<ReactomeDatabaseObject> validReactomeCatalyst = new HashSet<ReactomeDatabaseObject>(); Set<ReactomeDatabaseObject> validReactomeInput = new HashSet<ReactomeDatabaseObject>(); @@ -80,7 +80,7 @@ public class ReactionComparator { for (ReactionNode node : reaction.getModifiers()) { boolean verified = false; - Alias species = node.getAlias(); + Element species = node.getAlias(); for (ReactomeCatalystActivity catalystActivity : reactomeReaction.getCatalystActivities()) { if (nc.compareNodes(species, catalystActivity)) { @@ -95,7 +95,7 @@ public class ReactionComparator { } } for (ReactionNode node : reaction.getReactants()) { - Alias species = node.getAlias(); + Element species = node.getAlias(); boolean verified = false; for (ReactomePhysicalEntity input : reactomeReaction.getInputs()) { if (nc.compareNodes(species, input)) { @@ -110,7 +110,7 @@ public class ReactionComparator { } } for (ReactionNode node : reaction.getProducts()) { - Alias species = node.getAlias(); + Element species = node.getAlias(); boolean verified = false; for (ReactomePhysicalEntity input : reactomeReaction.getOutputs()) { if (nc.compareNodes(species, input)) { @@ -127,15 +127,15 @@ public class ReactionComparator { int totalElements = matchingElements; - for (Alias species : invalidReactionInput) { + for (Element species : invalidReactionInput) { result.addInvalidLocalInput(species); totalElements++; } - for (Alias species : invalidReactionModifier) { + for (Element species : invalidReactionModifier) { result.addInvalidLocalModifier(species); totalElements++; } - for (Alias species : invalidReactionOutput) { + for (Element species : invalidReactionOutput) { result.addInvalidLocalOutput(species); totalElements++; } diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/ReactomeQueryUtil.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/ReactomeQueryUtil.java index e14bb5e6bf..36b03907ce 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/ReactomeQueryUtil.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/ReactomeQueryUtil.java @@ -21,15 +21,15 @@ import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamRelationType; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ChemicalAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; -import lcsb.mapviewer.model.map.layout.alias.UnknownAlias; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.ReactionNode; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Chemical; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Phenotype; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Species; +import lcsb.mapviewer.model.map.species.Unknown; import lcsb.mapviewer.modelutils.map.ElementUtils; import lcsb.mapviewer.reactome.model.ReactomeCandidateSet; import lcsb.mapviewer.reactome.model.ReactomeCatalystActivity; @@ -97,7 +97,7 @@ public class ReactomeQueryUtil { * @return list of reactome reactions that contais all species given in the * parameter */ - public List<ReactomeReactionlikeEvent> getReactionsBetweenSpecies(List<Alias> speciesList) { + public List<ReactomeReactionlikeEvent> getReactionsBetweenSpecies(List<Element> speciesList) { return getReactionsBetweenSpecies(speciesList, false); } @@ -113,7 +113,7 @@ public class ReactomeQueryUtil { * @return list of reactome reactions that contais all species given in the * parameter */ - public List<ReactomeReactionlikeEvent> getReactionsBetweenSpecies(List<Alias> speciesList, boolean exact) { + public List<ReactomeReactionlikeEvent> getReactionsBetweenSpecies(List<Element> speciesList, boolean exact) { List<ReactomeReactionlikeEvent> result = getReactionsBetweenSpecies(speciesList, exact, false); if (result.size() == 0) { result = getReactionsBetweenSpecies(speciesList, exact, true); @@ -135,7 +135,7 @@ public class ReactomeQueryUtil { * @return list of reactome reactions that contais all species given in the * parameter */ - public List<ReactomeReactionlikeEvent> getReactionsBetweenSpecies(List<Alias> speciesList, boolean exact, boolean deepSearch) { + public List<ReactomeReactionlikeEvent> getReactionsBetweenSpecies(List<Element> speciesList, boolean exact, boolean deepSearch) { try { List<ReactomeReactionlikeEvent> result = new ArrayList<ReactomeReactionlikeEvent>(); @@ -146,8 +146,8 @@ public class ReactomeQueryUtil { List<List<ReactomePhysicalEntity>> entities = new ArrayList<List<ReactomePhysicalEntity>>(); int shortestIndex = -1; boolean notMolecule = true; - for (Alias species : speciesList) { - if (species instanceof ChemicalAlias) { + for (Element species : speciesList) { + if (species instanceof Chemical) { Set<MiriamData> chebiIds = new HashSet<MiriamData>(); chebiIds.add(chebiBackend.getChebiForChebiName(species.getName())); List<ReactomePhysicalEntity> entityList = rc.getEntitiesForChebiId(chebiIds, deepSearch); @@ -160,7 +160,7 @@ public class ReactomeQueryUtil { shortestIndex = entities.size() - 1; } } - } else if (species instanceof ProteinAlias) { + } else if (species instanceof Protein) { Set<MiriamData> uniprotId = elementUtil.getMiriamByType(species, MiriamType.UNIPROT, true); List<ReactomePhysicalEntity> entityList; if (uniprotId.size() > 0) { @@ -181,8 +181,8 @@ public class ReactomeQueryUtil { shortestIndex = entities.size() - 1; notMolecule = false; } - } else if (species instanceof ComplexAlias) { - Set<MiriamData> identifiers = getIdsForComplex((ComplexAlias) species); + } else if (species instanceof Complex) { + Set<MiriamData> identifiers = getIdsForComplex((Complex) species); if (identifiers == null) { return result; } @@ -199,7 +199,7 @@ public class ReactomeQueryUtil { shortestIndex = entities.size() - 1; notMolecule = false; } - } else if (species instanceof UnknownAlias) { + } else if (species instanceof Unknown) { // try to find by name List<ReactomePhysicalEntity> entityList = rc.getEntitiesForName(species.getName()); entities.add(entityList); @@ -214,7 +214,7 @@ public class ReactomeQueryUtil { shortestIndex = entities.size() - 1; notMolecule = false; } - } else if (species instanceof PhenotypeAlias) { + } else if (species instanceof Phenotype) { // we cannot do anything with phenotype return result; } else { @@ -330,7 +330,7 @@ public class ReactomeQueryUtil { * species to be checked * @return reactome stable identifier */ - public String getReactomeIdentifierForSpecies(Alias species) { + public String getReactomeIdentifierForSpecies(Element species) { String stableIdentifier = null; for (MiriamData md : species.getMiriamData()) { if (md.getDataType().equals(MiriamType.REACTOME)) { @@ -540,9 +540,9 @@ public class ReactomeQueryUtil { * service * @throws AnnotatorException */ - public Set<MiriamData> getIdsForComplex(ComplexAlias complex) throws IOException, AnnotatorException { + public Set<MiriamData> getIdsForComplex(Complex complex) throws IOException, AnnotatorException { Set<MiriamData> result = new HashSet<MiriamData>(); - for (SpeciesAlias species : complex.getAllSimpleChildren()) { + for (Species species : complex.getAllSimpleChildren()) { result.addAll(getIdsForSpecies(species)); } return result; @@ -559,13 +559,13 @@ public class ReactomeQueryUtil { * service * @throws AnnotatorException */ - public Set<MiriamData> getIdsForSpecies(Alias species) throws IOException, AnnotatorException { + public Set<MiriamData> getIdsForSpecies(Element species) throws IOException, AnnotatorException { Set<MiriamData> result = new HashSet<>(); - if (species instanceof ProteinAlias) { + if (species instanceof Protein) { result.addAll(elementUtil.getMiriamByType(species, MiriamType.UNIPROT, true)); - } else if (species instanceof PhenotypeAlias) { + } else if (species instanceof Phenotype) { return null; - } else if (species instanceof ChemicalAlias) { + } else if (species instanceof Chemical) { result.addAll(elementUtil.getMiriamByType(species, MiriamType.CHEBI, true)); } else { logger.warn("Don't know how to handle " + species.getClass() + " in a complex comparison."); @@ -626,7 +626,7 @@ public class ReactomeQueryUtil { * parametr. */ public ReactomeReactionlikeEvent getSimilarReaction(Reaction reaction) { - List<Alias> list = new ArrayList<>(); + List<Element> list = new ArrayList<>(); for (ReactionNode node : reaction.getReactionNodes()) { list.add(node.getAlias()); } diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ANodeComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ANodeComparator.java index 271a0e1dff..6e86182897 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ANodeComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ANodeComparator.java @@ -10,7 +10,7 @@ import lcsb.mapviewer.annotation.services.annotators.ChebiAnnotator; import lcsb.mapviewer.annotation.services.annotators.HgncAnnotator; import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.Alias; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.modelutils.map.ElementUtils; import lcsb.mapviewer.reactome.model.ReactomeDatabaseObject; import lcsb.mapviewer.reactome.utils.ComparatorException; @@ -31,7 +31,7 @@ import lcsb.mapviewer.reactome.utils.ReactomeQueryUtil; // TODO should implements comparable<T,U> @Transactional(value = "txManager") -public abstract class ANodeComparator<T extends Alias, U extends ReactomeDatabaseObject> { +public abstract class ANodeComparator<T extends Element, U extends ReactomeDatabaseObject> { /** * Default class logger. */ @@ -65,7 +65,7 @@ public abstract class ANodeComparator<T extends Alias, U extends ReactomeDatabas /** * Comparator that allows to compare everything with everything else. */ - private ANodeComparator<Alias, ReactomeDatabaseObject> globalComparator; + private ANodeComparator<Element, ReactomeDatabaseObject> globalComparator; /** * Type of the object in internal representation for which the comparator is @@ -169,7 +169,7 @@ public abstract class ANodeComparator<T extends Alias, U extends ReactomeDatabas /** * @return the globalComparator */ - protected ANodeComparator<Alias, ReactomeDatabaseObject> getGlobalComparator() { + protected ANodeComparator<Element, ReactomeDatabaseObject> getGlobalComparator() { return globalComparator; } @@ -177,7 +177,7 @@ public abstract class ANodeComparator<T extends Alias, U extends ReactomeDatabas * @param globalComparator * the globalComparator to set */ - protected void setGlobalComparator(ANodeComparator<Alias, ReactomeDatabaseObject> globalComparator) { + protected void setGlobalComparator(ANodeComparator<Element, ReactomeDatabaseObject> globalComparator) { this.globalComparator = globalComparator; } diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndCandidateSetComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndCandidateSetComparator.java index 41462001a2..21538e5bf7 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndCandidateSetComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndCandidateSetComparator.java @@ -1,9 +1,8 @@ package lcsb.mapviewer.reactome.utils.comparators; import org.apache.log4j.Logger; -import org.apache.poi.ss.formula.functions.Complex; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; +import lcsb.mapviewer.model.map.species.Complex; import lcsb.mapviewer.reactome.model.ReactomeCandidateSet; /** @@ -13,7 +12,7 @@ import lcsb.mapviewer.reactome.model.ReactomeCandidateSet; * @author Piotr Gawron * */ -public class ComplexAndCandidateSetComparator extends ANodeComparator<ComplexAlias, ReactomeCandidateSet> { +public class ComplexAndCandidateSetComparator extends ANodeComparator<Complex, ReactomeCandidateSet> { /** * Default class logger. @@ -24,11 +23,11 @@ public class ComplexAndCandidateSetComparator extends ANodeComparator<ComplexAli * Default constructor. */ public ComplexAndCandidateSetComparator() { - super(ComplexAlias.class, ReactomeCandidateSet.class); + super(Complex.class, ReactomeCandidateSet.class); } @Override - public boolean compareNodes(ComplexAlias species, ReactomeCandidateSet rSpecies) { + public boolean compareNodes(Complex species, ReactomeCandidateSet rSpecies) { logger.warn(getElementTag(species) + " and " + rSpecies.getClass() + ", " + rSpecies.getDbId() + " should be comparable, but how??? Assuming FALSE"); return false; } diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndCatalystComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndCatalystComparator.java index 74723b91a6..246a814ce6 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndCatalystComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndCatalystComparator.java @@ -1,9 +1,7 @@ package lcsb.mapviewer.reactome.utils.comparators; -import org.apache.poi.ss.formula.functions.Complex; - import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; +import lcsb.mapviewer.model.map.species.Complex; import lcsb.mapviewer.reactome.model.ReactomeCatalystActivity; import lcsb.mapviewer.reactome.model.ReactomeComplex; import lcsb.mapviewer.reactome.model.ReactomeDefinedSet; @@ -18,17 +16,17 @@ import lcsb.mapviewer.reactome.utils.ComparatorException; * @author Piotr Gawron * */ -public class ComplexAndCatalystComparator extends ANodeComparator<ComplexAlias, ReactomeCatalystActivity> { +public class ComplexAndCatalystComparator extends ANodeComparator<Complex, ReactomeCatalystActivity> { /** * Default constructor. */ public ComplexAndCatalystComparator() { - super(ComplexAlias.class, ReactomeCatalystActivity.class); + super(Complex.class, ReactomeCatalystActivity.class); } @Override - public boolean compareNodes(ComplexAlias species, ReactomeCatalystActivity cSpecies) throws ComparatorException { + public boolean compareNodes(Complex species, ReactomeCatalystActivity cSpecies) throws ComparatorException { ReactomePhysicalEntity pEntity = cSpecies.getPhysicalEntity(); if (pEntity instanceof ReactomeComplex) { return getGlobalComparator().compareNodes(species, (ReactomeComplex) pEntity); diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndComplexComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndComplexComparator.java index 80da4bc9ad..7cc7e873bb 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndComplexComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndComplexComparator.java @@ -3,10 +3,9 @@ package lcsb.mapviewer.reactome.utils.comparators; import java.util.Set; import org.apache.log4j.Logger; -import org.apache.poi.ss.formula.functions.Complex; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; +import lcsb.mapviewer.model.map.species.Complex; import lcsb.mapviewer.reactome.model.ReactomeComplex; import lcsb.mapviewer.reactome.utils.ComparatorException; @@ -17,22 +16,22 @@ import lcsb.mapviewer.reactome.utils.ComparatorException; * @author Piotr Gawron * */ -public class ComplexAndComplexComparator extends ANodeComparator<ComplexAlias, ReactomeComplex> { +public class ComplexAndComplexComparator extends ANodeComparator<Complex, ReactomeComplex> { /** * Default class logger. */ @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(ComplexAndComplexComparator.class); + private static Logger logger = Logger.getLogger(ComplexAndComplexComparator.class); /** * Default constructor. */ public ComplexAndComplexComparator() { - super(ComplexAlias.class, ReactomeComplex.class); + super(Complex.class, ReactomeComplex.class); } @Override - public boolean compareNodes(ComplexAlias complex, ReactomeComplex reactomeComplex) throws ComparatorException { + public boolean compareNodes(Complex complex, ReactomeComplex reactomeComplex) throws ComparatorException { try { Set<MiriamData> complex1Ids = getRcu().getIdsForComplex(complex); if (complex1Ids == null || complex1Ids.size() == 0) { diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndDefinedSetComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndDefinedSetComparator.java index 5970230458..3ce3152549 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndDefinedSetComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndDefinedSetComparator.java @@ -1,9 +1,8 @@ package lcsb.mapviewer.reactome.utils.comparators; import org.apache.log4j.Logger; -import org.apache.poi.ss.formula.functions.Complex; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; +import lcsb.mapviewer.model.map.species.Complex; import lcsb.mapviewer.reactome.model.ReactomeDefinedSet; /** @@ -13,7 +12,7 @@ import lcsb.mapviewer.reactome.model.ReactomeDefinedSet; * @author Piotr Gawron * */ -public class ComplexAndDefinedSetComparator extends ANodeComparator<ComplexAlias, ReactomeDefinedSet> { +public class ComplexAndDefinedSetComparator extends ANodeComparator<Complex, ReactomeDefinedSet> { /** * Default class logger. @@ -24,11 +23,11 @@ public class ComplexAndDefinedSetComparator extends ANodeComparator<ComplexAlias * Default constructor. */ public ComplexAndDefinedSetComparator() { - super(ComplexAlias.class, ReactomeDefinedSet.class); + super(Complex.class, ReactomeDefinedSet.class); } @Override - public boolean compareNodes(ComplexAlias species, ReactomeDefinedSet rSpecies) { + public boolean compareNodes(Complex species, ReactomeDefinedSet rSpecies) { logger.warn(getElementTag(species) + " and " + rSpecies.getClass() + ", " + rSpecies.getDbId() + " should be comparable, but how??? Assuming FALSE"); return false; } diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndEntityWithAccessionedSequenceComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndEntityWithAccessionedSequenceComparator.java index 6fd7bda33f..63c7a06813 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndEntityWithAccessionedSequenceComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndEntityWithAccessionedSequenceComparator.java @@ -3,11 +3,9 @@ package lcsb.mapviewer.reactome.utils.comparators; import java.util.HashSet; import java.util.Set; -import org.apache.poi.ss.formula.functions.Complex; - import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; +import lcsb.mapviewer.model.map.species.Complex; import lcsb.mapviewer.reactome.model.ReactomeEntityWithAccessionedSequence; import lcsb.mapviewer.reactome.model.ReactomeReferenceEntity; import lcsb.mapviewer.reactome.model.ReactomeReferenceGeneProduct; @@ -21,17 +19,17 @@ import lcsb.mapviewer.reactome.utils.ComparatorException; * @author Piotr Gawron * */ -public class ComplexAndEntityWithAccessionedSequenceComparator extends ANodeComparator<ComplexAlias, ReactomeEntityWithAccessionedSequence> { +public class ComplexAndEntityWithAccessionedSequenceComparator extends ANodeComparator<Complex, ReactomeEntityWithAccessionedSequence> { /** * Default constructor. */ public ComplexAndEntityWithAccessionedSequenceComparator() { - super(ComplexAlias.class, ReactomeEntityWithAccessionedSequence.class); + super(Complex.class, ReactomeEntityWithAccessionedSequence.class); } @Override - public boolean compareNodes(ComplexAlias complex, ReactomeEntityWithAccessionedSequence entity) throws ComparatorException { + public boolean compareNodes(Complex complex, ReactomeEntityWithAccessionedSequence entity) throws ComparatorException { Set<MiriamData> complex1Ids; try { complex1Ids = getRcu().getIdsForComplex(complex); diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndOtherEntityComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndOtherEntityComparator.java index b04274a805..b7f0acd9af 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndOtherEntityComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndOtherEntityComparator.java @@ -1,9 +1,8 @@ package lcsb.mapviewer.reactome.utils.comparators; import org.apache.log4j.Logger; -import org.apache.poi.ss.formula.functions.Complex; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; +import lcsb.mapviewer.model.map.species.Complex; import lcsb.mapviewer.reactome.model.ReactomeOtherEntity; /** @@ -13,7 +12,7 @@ import lcsb.mapviewer.reactome.model.ReactomeOtherEntity; * @author Piotr Gawron * */ -public class ComplexAndOtherEntityComparator extends ANodeComparator<ComplexAlias, ReactomeOtherEntity> { +public class ComplexAndOtherEntityComparator extends ANodeComparator<Complex, ReactomeOtherEntity> { /** * Default class logger. @@ -24,11 +23,11 @@ public class ComplexAndOtherEntityComparator extends ANodeComparator<ComplexAlia * Default constructor. */ public ComplexAndOtherEntityComparator() { - super(ComplexAlias.class, ReactomeOtherEntity.class); + super(Complex.class, ReactomeOtherEntity.class); } @Override - public boolean compareNodes(ComplexAlias species, ReactomeOtherEntity rSpecies) { + public boolean compareNodes(Complex species, ReactomeOtherEntity rSpecies) { logger.warn(getElementTag(species) + " and " + rSpecies.getClass() + ", " + rSpecies.getDbId() + " should be comparable, but how??? Assuming FALSE"); return false; } diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndSimpleEntityComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndSimpleEntityComparator.java index fecbce6275..dd7761548c 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndSimpleEntityComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ComplexAndSimpleEntityComparator.java @@ -3,12 +3,10 @@ package lcsb.mapviewer.reactome.utils.comparators; import java.util.HashSet; import java.util.Set; -import org.apache.poi.ss.formula.functions.Complex; - import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamRelationType; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; +import lcsb.mapviewer.model.map.species.Complex; import lcsb.mapviewer.reactome.model.ReactomeReferenceEntity; import lcsb.mapviewer.reactome.model.ReactomeReferenceMolecule; import lcsb.mapviewer.reactome.model.ReactomeSimpleEntity; @@ -21,17 +19,17 @@ import lcsb.mapviewer.reactome.utils.ComparatorException; * @author Piotr Gawron * */ -public class ComplexAndSimpleEntityComparator extends ANodeComparator<ComplexAlias, ReactomeSimpleEntity> { +public class ComplexAndSimpleEntityComparator extends ANodeComparator<Complex, ReactomeSimpleEntity> { /** * Default constructor. */ public ComplexAndSimpleEntityComparator() { - super(ComplexAlias.class, ReactomeSimpleEntity.class); + super(Complex.class, ReactomeSimpleEntity.class); } @Override - public boolean compareNodes(ComplexAlias complex, ReactomeSimpleEntity simpleEntity) throws ComparatorException { + public boolean compareNodes(Complex complex, ReactomeSimpleEntity simpleEntity) throws ComparatorException { Set<MiriamData> complex1Ids; try { complex1Ids = getRcu().getIdsForComplex(complex); diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/DegradedAndEntityWithAccessionedSequenceComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/DegradedAndEntityWithAccessionedSequenceComparator.java index c4a944aaf4..cc9e7d414a 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/DegradedAndEntityWithAccessionedSequenceComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/DegradedAndEntityWithAccessionedSequenceComparator.java @@ -1,22 +1,22 @@ package lcsb.mapviewer.reactome.utils.comparators; -import lcsb.mapviewer.model.map.layout.alias.DegradedAlias; +import lcsb.mapviewer.model.map.species.Degraded; import lcsb.mapviewer.reactome.model.ReactomeEntityWithAccessionedSequence; /** - * This class allows to compare {@link DegradedAlias} element (internal + * This class allows to compare {@link Degraded} element (internal * representation) and {@link ReactomeEntityWithAccessionedSequence} (reactome * model). * * @author Piotr Gawron * */ -public class DegradedAndEntityWithAccessionedSequenceComparator extends ANodeComparator<DegradedAlias, ReactomeEntityWithAccessionedSequence> { +public class DegradedAndEntityWithAccessionedSequenceComparator extends ANodeComparator<Degraded, ReactomeEntityWithAccessionedSequence> { /** * Default constructor. */ public DegradedAndEntityWithAccessionedSequenceComparator() { - super(DegradedAlias.class, ReactomeEntityWithAccessionedSequence.class); + super(Degraded.class, ReactomeEntityWithAccessionedSequence.class); } } diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/DrugAndCatalystComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/DrugAndCatalystComparator.java index b053e372fd..9558a7306c 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/DrugAndCatalystComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/DrugAndCatalystComparator.java @@ -2,17 +2,17 @@ package lcsb.mapviewer.reactome.utils.comparators; import org.apache.log4j.Logger; -import lcsb.mapviewer.model.map.layout.alias.DrugAlias; +import lcsb.mapviewer.model.map.species.Drug; import lcsb.mapviewer.reactome.model.ReactomeCatalystActivity; /** - * This class allows to compare {@link DrugAlias} element (internal + * This class allows to compare {@link Drug} element (internal * representation) and {@link ReactomeCatalystActivity} (reactome model). * * @author Piotr Gawron * */ -public class DrugAndCatalystComparator extends ANodeComparator<DrugAlias, ReactomeCatalystActivity> { +public class DrugAndCatalystComparator extends ANodeComparator<Drug, ReactomeCatalystActivity> { /** * Default class logger. */ @@ -22,11 +22,11 @@ public class DrugAndCatalystComparator extends ANodeComparator<DrugAlias, Reacto * Default constructor. */ public DrugAndCatalystComparator() { - super(DrugAlias.class, ReactomeCatalystActivity.class); + super(Drug.class, ReactomeCatalystActivity.class); } @Override - public boolean compareNodes(DrugAlias species, ReactomeCatalystActivity cSpecies) { + public boolean compareNodes(Drug species, ReactomeCatalystActivity cSpecies) { logger.warn("Don't know how to compare: " + species.getClass() + " and " + cSpecies.getClass() + ". Assuming false."); return false; } diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/GeneAndDefinedSetComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/GeneAndDefinedSetComparator.java index e399fcca7e..f2e0f7d0aa 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/GeneAndDefinedSetComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/GeneAndDefinedSetComparator.java @@ -2,17 +2,17 @@ package lcsb.mapviewer.reactome.utils.comparators; import org.apache.log4j.Logger; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; +import lcsb.mapviewer.model.map.species.Gene; import lcsb.mapviewer.reactome.model.ReactomeDefinedSet; /** - * This class allows to compare {@link GeneAlias} element (internal + * This class allows to compare {@link Gene} element (internal * representation) and {@link ReactomeDefinedSet} (reactome model). * * @author Piotr Gawron * */ -public class GeneAndDefinedSetComparator extends ANodeComparator<GeneAlias, ReactomeDefinedSet> { +public class GeneAndDefinedSetComparator extends ANodeComparator<Gene, ReactomeDefinedSet> { /** * Default class logger. @@ -23,11 +23,11 @@ public class GeneAndDefinedSetComparator extends ANodeComparator<GeneAlias, Reac * Default constructor. */ public GeneAndDefinedSetComparator() { - super(GeneAlias.class, ReactomeDefinedSet.class); + super(Gene.class, ReactomeDefinedSet.class); } @Override - public boolean compareNodes(GeneAlias species, ReactomeDefinedSet rSpecies) { + public boolean compareNodes(Gene species, ReactomeDefinedSet rSpecies) { logger.warn(getElementTag(species) + " and " + rSpecies.getClass() + ", " + rSpecies.getDbId() + " should be comparable, but how??? Assuming FALSE"); return false; } diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/GeneAndOtherEntityComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/GeneAndOtherEntityComparator.java index d43765ed4d..91cd665c34 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/GeneAndOtherEntityComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/GeneAndOtherEntityComparator.java @@ -2,17 +2,17 @@ package lcsb.mapviewer.reactome.utils.comparators; import org.apache.log4j.Logger; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; +import lcsb.mapviewer.model.map.species.Gene; import lcsb.mapviewer.reactome.model.ReactomeOtherEntity; /** - * This class allows to compare {@link GeneAlias} element (internal + * This class allows to compare {@link Gene} element (internal * representation) and {@link ReactomeOtherEntity} (reactome model). * * @author Piotr Gawron * */ -public class GeneAndOtherEntityComparator extends ANodeComparator<GeneAlias, ReactomeOtherEntity> { +public class GeneAndOtherEntityComparator extends ANodeComparator<Gene, ReactomeOtherEntity> { /** * Default class logger. @@ -23,11 +23,11 @@ public class GeneAndOtherEntityComparator extends ANodeComparator<GeneAlias, Rea * Default constructor. */ public GeneAndOtherEntityComparator() { - super(GeneAlias.class, ReactomeOtherEntity.class); + super(Gene.class, ReactomeOtherEntity.class); } @Override - public boolean compareNodes(GeneAlias species, ReactomeOtherEntity rSpecies) { + public boolean compareNodes(Gene species, ReactomeOtherEntity rSpecies) { logger.warn(getElementTag(species) + " and " + rSpecies.getClass() + ", " + rSpecies.getDbId() + " should be comparable, but how??? Assuming FALSE"); return false; } diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/IonAndCatalystComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/IonAndCatalystComparator.java index 64b37cd44c..6b0a640249 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/IonAndCatalystComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/IonAndCatalystComparator.java @@ -1,7 +1,7 @@ package lcsb.mapviewer.reactome.utils.comparators; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.layout.alias.IonAlias; +import lcsb.mapviewer.model.map.species.Ion; import lcsb.mapviewer.reactome.model.ReactomeCatalystActivity; import lcsb.mapviewer.reactome.model.ReactomeComplex; import lcsb.mapviewer.reactome.model.ReactomeDefinedSet; @@ -11,23 +11,23 @@ import lcsb.mapviewer.reactome.model.ReactomeSimpleEntity; import lcsb.mapviewer.reactome.utils.ComparatorException; /** - * This class allows to compare {@link IonAlias} element (internal + * This class allows to compare {@link Ion} element (internal * representation) and {@link ReactomeCatalystActivity} (reactome model). * * @author Piotr Gawron * */ -public class IonAndCatalystComparator extends ANodeComparator<IonAlias, ReactomeCatalystActivity> { +public class IonAndCatalystComparator extends ANodeComparator<Ion, ReactomeCatalystActivity> { /** * Default constructor. */ public IonAndCatalystComparator() { - super(IonAlias.class, ReactomeCatalystActivity.class); + super(Ion.class, ReactomeCatalystActivity.class); } @Override - public boolean compareNodes(IonAlias species, ReactomeCatalystActivity cSpecies) throws ComparatorException { + public boolean compareNodes(Ion species, ReactomeCatalystActivity cSpecies) throws ComparatorException { ReactomePhysicalEntity pEntity = cSpecies.getPhysicalEntity(); if (pEntity instanceof ReactomeComplex) { return getGlobalComparator().compareNodes(species, (ReactomeComplex) pEntity); diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/IonAndComplexComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/IonAndComplexComparator.java index 061b4ef15b..2c3efb2541 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/IonAndComplexComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/IonAndComplexComparator.java @@ -5,7 +5,7 @@ import java.util.List; import lcsb.mapviewer.annotation.services.annotators.ChebiSearchException; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.IonAlias; +import lcsb.mapviewer.model.map.species.Ion; import lcsb.mapviewer.reactome.model.ReactomeComplex; import lcsb.mapviewer.reactome.model.ReactomeDefinedSet; import lcsb.mapviewer.reactome.model.ReactomeEntityWithAccessionedSequence; @@ -16,23 +16,23 @@ import lcsb.mapviewer.reactome.model.ReactomeSimpleEntity; import lcsb.mapviewer.reactome.utils.ComparatorException; /** - * This class allows to compare {@link IonAlias} element (internal + * This class allows to compare {@link Ion} element (internal * representation) and {@link ReactomeComplex} (reactome model). * * @author Piotr Gawron * */ -public class IonAndComplexComparator extends ANodeComparator<IonAlias, ReactomeComplex> { +public class IonAndComplexComparator extends ANodeComparator<Ion, ReactomeComplex> { /** * Default constructor. */ public IonAndComplexComparator() { - super(IonAlias.class, ReactomeComplex.class); + super(Ion.class, ReactomeComplex.class); } @Override - public boolean compareNodes(IonAlias species, ReactomeComplex entity) throws ComparatorException { + public boolean compareNodes(Ion species, ReactomeComplex entity) throws ComparatorException { try { List<MiriamData> chebi1 = getChebiBackend().getOntologyChebiIdsForChebiName(species.getName()); String chebi2 = null; diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/IonAndDefinedSetComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/IonAndDefinedSetComparator.java index 104b0ddffc..0a34a14ccb 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/IonAndDefinedSetComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/IonAndDefinedSetComparator.java @@ -1,7 +1,7 @@ package lcsb.mapviewer.reactome.utils.comparators; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.layout.alias.IonAlias; +import lcsb.mapviewer.model.map.species.Ion; import lcsb.mapviewer.reactome.model.ReactomeComplex; import lcsb.mapviewer.reactome.model.ReactomeDefinedSet; import lcsb.mapviewer.reactome.model.ReactomeEntityWithAccessionedSequence; @@ -10,23 +10,23 @@ import lcsb.mapviewer.reactome.model.ReactomeSimpleEntity; import lcsb.mapviewer.reactome.utils.ComparatorException; /** - * This class allows to compare {@link IonAlias} element (internal + * This class allows to compare {@link Ion} element (internal * representation) and {@link ReactomeDefinedSet} (reactome model). * * @author Piotr Gawron * */ -public class IonAndDefinedSetComparator extends ANodeComparator<IonAlias, ReactomeDefinedSet> { +public class IonAndDefinedSetComparator extends ANodeComparator<Ion, ReactomeDefinedSet> { /** * Default constructor. */ public IonAndDefinedSetComparator() { - super(IonAlias.class, ReactomeDefinedSet.class); + super(Ion.class, ReactomeDefinedSet.class); } @Override - public boolean compareNodes(IonAlias species, ReactomeDefinedSet rSpecies) throws ComparatorException { + public boolean compareNodes(Ion species, ReactomeDefinedSet rSpecies) throws ComparatorException { boolean result = false; for (ReactomePhysicalEntity entity : rSpecies.getHasMembers()) { if (entity instanceof ReactomeSimpleEntity) { diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/IonAndEntityWithAccessionedSequenceComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/IonAndEntityWithAccessionedSequenceComparator.java index 9c6df33aa6..735254dcc1 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/IonAndEntityWithAccessionedSequenceComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/IonAndEntityWithAccessionedSequenceComparator.java @@ -1,27 +1,27 @@ package lcsb.mapviewer.reactome.utils.comparators; -import lcsb.mapviewer.model.map.layout.alias.IonAlias; +import lcsb.mapviewer.model.map.species.Ion; import lcsb.mapviewer.reactome.model.ReactomeEntityWithAccessionedSequence; /** - * This class allows to compare {@link IonAlias} element (internal + * This class allows to compare {@link Ion} element (internal * representation) and {@link ReactomeEntityWithAccessionedSequence} (reactome * model). * * @author Piotr Gawron * */ -public class IonAndEntityWithAccessionedSequenceComparator extends ANodeComparator<IonAlias, ReactomeEntityWithAccessionedSequence> { +public class IonAndEntityWithAccessionedSequenceComparator extends ANodeComparator<Ion, ReactomeEntityWithAccessionedSequence> { /** * Default constructor. */ public IonAndEntityWithAccessionedSequenceComparator() { - super(IonAlias.class, ReactomeEntityWithAccessionedSequence.class); + super(Ion.class, ReactomeEntityWithAccessionedSequence.class); } @Override - public boolean compareNodes(IonAlias species, ReactomeEntityWithAccessionedSequence simpleEntity) { + public boolean compareNodes(Ion species, ReactomeEntityWithAccessionedSequence simpleEntity) { return false; } diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/IonAndSimpleEntityComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/IonAndSimpleEntityComparator.java index 13b9678c85..7d22f28e59 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/IonAndSimpleEntityComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/IonAndSimpleEntityComparator.java @@ -5,28 +5,28 @@ import java.util.Set; import lcsb.mapviewer.annotation.services.annotators.ChebiSearchException; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.IonAlias; +import lcsb.mapviewer.model.map.species.Ion; import lcsb.mapviewer.reactome.model.ReactomeSimpleEntity; import lcsb.mapviewer.reactome.utils.ComparatorException; /** - * This class allows to compare {@link IonAlias} element (internal + * This class allows to compare {@link Ion} element (internal * representation) and {@link ReactomeSimpleEntity} (reactome model). * * @author Piotr Gawron * */ -public class IonAndSimpleEntityComparator extends ANodeComparator<IonAlias, ReactomeSimpleEntity> { +public class IonAndSimpleEntityComparator extends ANodeComparator<Ion, ReactomeSimpleEntity> { /** * Default constructor. */ public IonAndSimpleEntityComparator() { - super(IonAlias.class, ReactomeSimpleEntity.class); + super(Ion.class, ReactomeSimpleEntity.class); } @Override - public boolean compareNodes(IonAlias species, ReactomeSimpleEntity simpleEntity) throws ComparatorException { + public boolean compareNodes(Ion species, ReactomeSimpleEntity simpleEntity) throws ComparatorException { try { List<MiriamData> chebi1 = getChebiBackend().getOntologyChebiIdsForChebiName(species.getName()); if (chebi1.size() == 0) { // if we don't have id then return false (even diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MatchResult.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MatchResult.java index aa7c6ef1c9..60294e9c1e 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MatchResult.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MatchResult.java @@ -5,8 +5,8 @@ import java.util.List; import org.apache.log4j.Logger; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.reactome.model.ReactomeDatabaseObject; import lcsb.mapviewer.reactome.model.ReactomeReactionlikeEvent; @@ -46,15 +46,15 @@ public class MatchResult { /** * Which local reactants couldn't be matched into reactome nodes. */ - private List<Alias> invalidLocalInput = new ArrayList<>(); + private List<Element> invalidLocalInput = new ArrayList<>(); /** * Which local products couldn't be matched into reactome nodes. */ - private List<Alias> invalidLocalOutput = new ArrayList<>(); + private List<Element> invalidLocalOutput = new ArrayList<>(); /** * Which local modifiers couldn't be matched into reactome nodes. */ - private List<Alias> invalidLocalModifier = new ArrayList<>(); + private List<Element> invalidLocalModifier = new ArrayList<>(); /** * Which reactome reactants couldn't be matched into local reaction nodes. @@ -105,7 +105,7 @@ public class MatchResult { * @param invalidLocalInput * species to be added */ - public void addInvalidLocalInput(Alias invalidLocalInput) { + public void addInvalidLocalInput(Element invalidLocalInput) { this.invalidLocalInput.add(invalidLocalInput); } @@ -115,7 +115,7 @@ public class MatchResult { * @param invalidLocalOutput * species to be added */ - public void addInvalidLocalOutput(Alias invalidLocalOutput) { + public void addInvalidLocalOutput(Element invalidLocalOutput) { this.invalidLocalOutput.add(invalidLocalOutput); } @@ -125,7 +125,7 @@ public class MatchResult { * @param invalidLocalModifier * species to be added */ - public void addInvalidLocalModifier(Alias invalidLocalModifier) { + public void addInvalidLocalModifier(Element invalidLocalModifier) { this.invalidLocalModifier.add(invalidLocalModifier); } @@ -231,7 +231,7 @@ public class MatchResult { * @return the invalidLocalInput * @see #invalidLocalInput */ - public List<Alias> getInvalidLocalInput() { + public List<Element> getInvalidLocalInput() { return invalidLocalInput; } @@ -240,7 +240,7 @@ public class MatchResult { * the invalidLocalInput to set * @see #invalidLocalInput */ - public void setInvalidLocalInput(List<Alias> invalidLocalInput) { + public void setInvalidLocalInput(List<Element> invalidLocalInput) { this.invalidLocalInput = invalidLocalInput; } @@ -248,7 +248,7 @@ public class MatchResult { * @return the invalidLocalOutput * @see #invalidLocalOutput */ - public List<Alias> getInvalidLocalOutput() { + public List<Element> getInvalidLocalOutput() { return invalidLocalOutput; } @@ -257,7 +257,7 @@ public class MatchResult { * the invalidLocalOutput to set * @see #invalidLocalOutput */ - public void setInvalidLocalOutput(List<Alias> invalidLocalOutput) { + public void setInvalidLocalOutput(List<Element> invalidLocalOutput) { this.invalidLocalOutput = invalidLocalOutput; } @@ -265,7 +265,7 @@ public class MatchResult { * @return the invalidLocalModifier * @see #invalidLocalModifier */ - public List<Alias> getInvalidLocalModifier() { + public List<Element> getInvalidLocalModifier() { return invalidLocalModifier; } @@ -274,7 +274,7 @@ public class MatchResult { * the invalidLocalModifier to set * @see #invalidLocalModifier */ - public void setInvalidLocalModifier(List<Alias> invalidLocalModifier) { + public void setInvalidLocalModifier(List<Element> invalidLocalModifier) { this.invalidLocalModifier = invalidLocalModifier; } diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MoleculeAndCatalystComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MoleculeAndCatalystComparator.java index dd64991b26..83b4dc5d82 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MoleculeAndCatalystComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MoleculeAndCatalystComparator.java @@ -1,7 +1,7 @@ package lcsb.mapviewer.reactome.utils.comparators; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; +import lcsb.mapviewer.model.map.species.SimpleMolecule; import lcsb.mapviewer.reactome.model.ReactomeCatalystActivity; import lcsb.mapviewer.reactome.model.ReactomeComplex; import lcsb.mapviewer.reactome.model.ReactomeDefinedSet; @@ -11,23 +11,23 @@ import lcsb.mapviewer.reactome.model.ReactomeSimpleEntity; import lcsb.mapviewer.reactome.utils.ComparatorException; /** - * This class allows to compare {@link SimpleMoleculeAlias} element (internal + * This class allows to compare {@link SimpleMolecule} element (internal * representation) and {@link ReactomeCatalystActivity} (reactome model). * * @author Piotr Gawron * */ -public class MoleculeAndCatalystComparator extends ANodeComparator<SimpleMoleculeAlias, ReactomeCatalystActivity> { +public class MoleculeAndCatalystComparator extends ANodeComparator<SimpleMolecule, ReactomeCatalystActivity> { /** * Default constructor. */ public MoleculeAndCatalystComparator() { - super(SimpleMoleculeAlias.class, ReactomeCatalystActivity.class); + super(SimpleMolecule.class, ReactomeCatalystActivity.class); } @Override - public boolean compareNodes(SimpleMoleculeAlias species, ReactomeCatalystActivity cSpecies) throws ComparatorException { + public boolean compareNodes(SimpleMolecule species, ReactomeCatalystActivity cSpecies) throws ComparatorException { ReactomePhysicalEntity pEntity = cSpecies.getPhysicalEntity(); if (pEntity instanceof ReactomeComplex) { return getGlobalComparator().compareNodes(species, (ReactomeComplex) pEntity); diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MoleculeAndComplexComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MoleculeAndComplexComparator.java index 0221ea8f21..0f4c3b37b8 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MoleculeAndComplexComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MoleculeAndComplexComparator.java @@ -3,7 +3,7 @@ package lcsb.mapviewer.reactome.utils.comparators; import lcsb.mapviewer.annotation.services.annotators.ChebiSearchException; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; +import lcsb.mapviewer.model.map.species.SimpleMolecule; import lcsb.mapviewer.reactome.model.ReactomeComplex; import lcsb.mapviewer.reactome.model.ReactomeDefinedSet; import lcsb.mapviewer.reactome.model.ReactomeEntityWithAccessionedSequence; @@ -14,23 +14,23 @@ import lcsb.mapviewer.reactome.model.ReactomeSimpleEntity; import lcsb.mapviewer.reactome.utils.ComparatorException; /** - * This class allows to compare {@link SimpleMoleculeAlias} element (internal + * This class allows to compare {@link SimpleMolecule} element (internal * representation) and {@link ReactomeComplex} (reactome model). * * @author Piotr Gawron * */ -public class MoleculeAndComplexComparator extends ANodeComparator<SimpleMoleculeAlias, ReactomeComplex> { +public class MoleculeAndComplexComparator extends ANodeComparator<SimpleMolecule, ReactomeComplex> { /** * Default constructor. */ public MoleculeAndComplexComparator() { - super(SimpleMoleculeAlias.class, ReactomeComplex.class); + super(SimpleMolecule.class, ReactomeComplex.class); } @Override - public boolean compareNodes(SimpleMoleculeAlias species, ReactomeComplex entity) throws ComparatorException { + public boolean compareNodes(SimpleMolecule species, ReactomeComplex entity) throws ComparatorException { try { MiriamData chebi1 = getChebiBackend().getChebiForChebiName(species.getName()); String chebi2 = null; diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MoleculeAndDefinedSetComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MoleculeAndDefinedSetComparator.java index 3cbd349b76..1d5444c50d 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MoleculeAndDefinedSetComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MoleculeAndDefinedSetComparator.java @@ -1,7 +1,7 @@ package lcsb.mapviewer.reactome.utils.comparators; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; +import lcsb.mapviewer.model.map.species.SimpleMolecule; import lcsb.mapviewer.reactome.model.ReactomeComplex; import lcsb.mapviewer.reactome.model.ReactomeDefinedSet; import lcsb.mapviewer.reactome.model.ReactomeEntityWithAccessionedSequence; @@ -10,23 +10,23 @@ import lcsb.mapviewer.reactome.model.ReactomeSimpleEntity; import lcsb.mapviewer.reactome.utils.ComparatorException; /** - * This class allows to compare {@link SimpleMoleculeAlias} element (internal + * This class allows to compare {@link SimpleMolecule} element (internal * representation) and {@link ReactomeDefinedSet} (reactome model). * * @author Piotr Gawron * */ -public class MoleculeAndDefinedSetComparator extends ANodeComparator<SimpleMoleculeAlias, ReactomeDefinedSet> { +public class MoleculeAndDefinedSetComparator extends ANodeComparator<SimpleMolecule, ReactomeDefinedSet> { /** * Default constructor. */ public MoleculeAndDefinedSetComparator() { - super(SimpleMoleculeAlias.class, ReactomeDefinedSet.class); + super(SimpleMolecule.class, ReactomeDefinedSet.class); } @Override - public boolean compareNodes(SimpleMoleculeAlias species, ReactomeDefinedSet rSpecies) throws ComparatorException { + public boolean compareNodes(SimpleMolecule species, ReactomeDefinedSet rSpecies) throws ComparatorException { boolean result = false; for (ReactomePhysicalEntity entity : rSpecies.getHasMembers()) { if (entity instanceof ReactomeSimpleEntity) { diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MoleculeAndEntityWithAccessionedSequenceComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MoleculeAndEntityWithAccessionedSequenceComparator.java index 20d37fad35..7532e39b7f 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MoleculeAndEntityWithAccessionedSequenceComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MoleculeAndEntityWithAccessionedSequenceComparator.java @@ -1,27 +1,27 @@ package lcsb.mapviewer.reactome.utils.comparators; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; +import lcsb.mapviewer.model.map.species.SimpleMolecule; import lcsb.mapviewer.reactome.model.ReactomeEntityWithAccessionedSequence; /** - * This class allows to compare {@link SimpleMoleculeAlias} element (internal + * This class allows to compare {@link SimpleMolecule} element (internal * representation) and {@link ReactomeEntityWithAccessionedSequence} (reactome * model). * * @author Piotr Gawron * */ -public class MoleculeAndEntityWithAccessionedSequenceComparator extends ANodeComparator<SimpleMoleculeAlias, ReactomeEntityWithAccessionedSequence> { +public class MoleculeAndEntityWithAccessionedSequenceComparator extends ANodeComparator<SimpleMolecule, ReactomeEntityWithAccessionedSequence> { /** * Default constructor. */ public MoleculeAndEntityWithAccessionedSequenceComparator() { - super(SimpleMoleculeAlias.class, ReactomeEntityWithAccessionedSequence.class); + super(SimpleMolecule.class, ReactomeEntityWithAccessionedSequence.class); } @Override - public boolean compareNodes(SimpleMoleculeAlias species, ReactomeEntityWithAccessionedSequence simpleEntity) { + public boolean compareNodes(SimpleMolecule species, ReactomeEntityWithAccessionedSequence simpleEntity) { return false; } diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MoleculeAndSimpleEntityComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MoleculeAndSimpleEntityComparator.java index 74111693c1..e40a5f9535 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MoleculeAndSimpleEntityComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/MoleculeAndSimpleEntityComparator.java @@ -5,28 +5,28 @@ import java.util.Set; import lcsb.mapviewer.annotation.services.annotators.ChebiSearchException; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; +import lcsb.mapviewer.model.map.species.SimpleMolecule; import lcsb.mapviewer.reactome.model.ReactomeSimpleEntity; import lcsb.mapviewer.reactome.utils.ComparatorException; /** - * This class allows to compare {@link SimpleMoleculeAlias} element (internal + * This class allows to compare {@link SimpleMolecule} element (internal * representation) and {@link ReactomeSimpleEntity} (reactome model). * * @author Piotr Gawron * */ -public class MoleculeAndSimpleEntityComparator extends ANodeComparator<SimpleMoleculeAlias, ReactomeSimpleEntity> { +public class MoleculeAndSimpleEntityComparator extends ANodeComparator<SimpleMolecule, ReactomeSimpleEntity> { /** * Default constructor. */ public MoleculeAndSimpleEntityComparator() { - super(SimpleMoleculeAlias.class, ReactomeSimpleEntity.class); + super(SimpleMolecule.class, ReactomeSimpleEntity.class); } @Override - public boolean compareNodes(SimpleMoleculeAlias species, ReactomeSimpleEntity simpleEntity) throws ComparatorException { + public boolean compareNodes(SimpleMolecule species, ReactomeSimpleEntity simpleEntity) throws ComparatorException { try { List<MiriamData> chebi1 = getChebiBackend().getOntologyChebiIdsForChebiName(species.getName()); if (chebi1.size() == 0) { // if we don't have id then return false (even diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/NodeComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/NodeComparator.java index 032fe85cc8..29a4c8070f 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/NodeComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/NodeComparator.java @@ -6,8 +6,8 @@ import java.util.Map; import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Protein; import lcsb.mapviewer.persist.SpringApplicationContext; import lcsb.mapviewer.reactome.model.ReactomeDatabaseObject; import lcsb.mapviewer.reactome.utils.ComparatorException; @@ -19,7 +19,7 @@ import lcsb.mapviewer.reactome.utils.ComparatorException; * @author Piotr Gawron * */ -public class NodeComparator extends ANodeComparator<Alias, ReactomeDatabaseObject> { +public class NodeComparator extends ANodeComparator<Element, ReactomeDatabaseObject> { /** * Default class logger. */ @@ -36,7 +36,7 @@ public class NodeComparator extends ANodeComparator<Alias, ReactomeDatabaseObjec * implementation of {@link ANodeComparator}. */ public NodeComparator() { - super(Alias.class, ReactomeDatabaseObject.class); + super(Element.class, ReactomeDatabaseObject.class); } /** @@ -51,16 +51,16 @@ public class NodeComparator extends ANodeComparator<Alias, ReactomeDatabaseObjec } @Override - public boolean compareNodes(Alias species, ReactomeDatabaseObject reactomeSpecies) throws ComparatorException { + @SuppressWarnings({ "rawtypes", "unchecked" }) + public boolean compareNodes(Element species, ReactomeDatabaseObject reactomeSpecies) throws ComparatorException { String speciesName = species.getClass().getName(); - if (species instanceof ProteinAlias) { - speciesName = ProteinAlias.class.getName(); + if (species instanceof Protein) { + speciesName = Protein.class.getName(); } String serializedClassComparator = speciesName + "," + reactomeSpecies.getClass().getName(); if (serializedClassComparator.indexOf("_$$_javassist_") >= 0) { serializedClassComparator = serializedClassComparator.substring(0, serializedClassComparator.indexOf("_$$_javassist_")); } - @SuppressWarnings("rawtypes") ANodeComparator comparator = getComparator(serializedClassComparator); if (comparator != null) { return comparator.compareNodes(species, reactomeSpecies); diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndCandidateSetComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndCandidateSetComparator.java index 0ffe9cec14..0f245bffcd 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndCandidateSetComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndCandidateSetComparator.java @@ -4,7 +4,7 @@ import java.util.HashSet; import java.util.Set; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; +import lcsb.mapviewer.model.map.species.Protein; import lcsb.mapviewer.reactome.model.ReactomeCandidateSet; import lcsb.mapviewer.reactome.model.ReactomeComplex; import lcsb.mapviewer.reactome.model.ReactomeEntityWithAccessionedSequence; @@ -12,23 +12,23 @@ import lcsb.mapviewer.reactome.model.ReactomePhysicalEntity; import lcsb.mapviewer.reactome.utils.ComparatorException; /** - * This class allows to compare {@link ProteinAlias} element (internal + * This class allows to compare {@link Protein} element (internal * representation) and {@link ReactomeCandidateSet} (reactome model). * * @author Piotr Gawron * */ -public class ProteinAndCandidateSetComparator extends ANodeComparator<ProteinAlias, ReactomeCandidateSet> { +public class ProteinAndCandidateSetComparator extends ANodeComparator<Protein, ReactomeCandidateSet> { /** * Default constructor. */ public ProteinAndCandidateSetComparator() { - super(ProteinAlias.class, ReactomeCandidateSet.class); + super(Protein.class, ReactomeCandidateSet.class); } @Override - public boolean compareNodes(ProteinAlias species, ReactomeCandidateSet rSpecies) throws ComparatorException { + public boolean compareNodes(Protein species, ReactomeCandidateSet rSpecies) throws ComparatorException { boolean result = false; Set<ReactomePhysicalEntity> objects = new HashSet<ReactomePhysicalEntity>(); objects.addAll(rSpecies.getHasMembers()); diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndCatalystComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndCatalystComparator.java index 0d5249d6ca..037cc520ef 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndCatalystComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndCatalystComparator.java @@ -1,7 +1,7 @@ package lcsb.mapviewer.reactome.utils.comparators; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; +import lcsb.mapviewer.model.map.species.Protein; import lcsb.mapviewer.reactome.model.ReactomeCandidateSet; import lcsb.mapviewer.reactome.model.ReactomeCatalystActivity; import lcsb.mapviewer.reactome.model.ReactomeComplex; @@ -12,23 +12,23 @@ import lcsb.mapviewer.reactome.model.ReactomePhysicalEntity; import lcsb.mapviewer.reactome.utils.ComparatorException; /** - * This class allows to compare {@link ProteinAlias} element (internal + * This class allows to compare {@link Protein} element (internal * representation) and {@link ReactomeCatalystActivity} (reactome model). * * @author Piotr Gawron * */ -public class ProteinAndCatalystComparator extends ANodeComparator<ProteinAlias, ReactomeCatalystActivity> { +public class ProteinAndCatalystComparator extends ANodeComparator<Protein, ReactomeCatalystActivity> { /** * Default constructor. */ public ProteinAndCatalystComparator() { - super(ProteinAlias.class, ReactomeCatalystActivity.class); + super(Protein.class, ReactomeCatalystActivity.class); } @Override - public boolean compareNodes(ProteinAlias species, ReactomeCatalystActivity cSpecies) throws ComparatorException { + public boolean compareNodes(Protein species, ReactomeCatalystActivity cSpecies) throws ComparatorException { ReactomePhysicalEntity pEntity = cSpecies.getPhysicalEntity(); if (pEntity instanceof ReactomeComplex) { return getGlobalComparator().compareNodes(species, (ReactomeComplex) pEntity); diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndComplexComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndComplexComparator.java index 550064e07e..cd50e74ecc 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndComplexComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndComplexComparator.java @@ -7,18 +7,18 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; +import lcsb.mapviewer.model.map.species.Protein; import lcsb.mapviewer.reactome.model.ReactomeComplex; import lcsb.mapviewer.reactome.utils.ComparatorException; /** - * This class allows to compare {@link ProteinAlias} element (internal + * This class allows to compare {@link Protein} element (internal * representation) and {@link ReactomeComplex} (reactome model). * * @author Piotr Gawron * */ -public class ProteinAndComplexComparator extends ANodeComparator<ProteinAlias, ReactomeComplex> { +public class ProteinAndComplexComparator extends ANodeComparator<Protein, ReactomeComplex> { /** * Default class logger. */ @@ -29,11 +29,11 @@ public class ProteinAndComplexComparator extends ANodeComparator<ProteinAlias, R * Default constructor. */ public ProteinAndComplexComparator() { - super(ProteinAlias.class, ReactomeComplex.class); + super(Protein.class, ReactomeComplex.class); } @Override - public boolean compareNodes(ProteinAlias species, ReactomeComplex complex) throws ComparatorException { + public boolean compareNodes(Protein species, ReactomeComplex complex) throws ComparatorException { try { Set<MiriamData> uniprotIds1 = getElementUtil().getMiriamByType(species, MiriamType.UNIPROT, true); Set<MiriamData> uniprotIds2 = new HashSet<MiriamData>(); diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndDefinedSetComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndDefinedSetComparator.java index 65de0babef..eca0bb74ac 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndDefinedSetComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndDefinedSetComparator.java @@ -1,7 +1,7 @@ package lcsb.mapviewer.reactome.utils.comparators; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; +import lcsb.mapviewer.model.map.species.Protein; import lcsb.mapviewer.reactome.model.ReactomeComplex; import lcsb.mapviewer.reactome.model.ReactomeDefinedSet; import lcsb.mapviewer.reactome.model.ReactomeEntityWithAccessionedSequence; @@ -10,23 +10,23 @@ import lcsb.mapviewer.reactome.model.ReactomePolymer; import lcsb.mapviewer.reactome.utils.ComparatorException; /** - * This class allows to compare {@link ProteinAlias} element (internal + * This class allows to compare {@link Protein} element (internal * representation) and {@link ReactomeDefinedSet} (reactome model). * * @author Piotr Gawron * */ -public class ProteinAndDefinedSetComparator extends ANodeComparator<ProteinAlias, ReactomeDefinedSet> { +public class ProteinAndDefinedSetComparator extends ANodeComparator<Protein, ReactomeDefinedSet> { /** * Default constructor. */ public ProteinAndDefinedSetComparator() { - super(ProteinAlias.class, ReactomeDefinedSet.class); + super(Protein.class, ReactomeDefinedSet.class); } @Override - public boolean compareNodes(ProteinAlias species, ReactomeDefinedSet rSpecies) throws ComparatorException { + public boolean compareNodes(Protein species, ReactomeDefinedSet rSpecies) throws ComparatorException { boolean result = false; for (ReactomePhysicalEntity entity : rSpecies.getHasMembers()) { if (entity instanceof ReactomeComplex) { diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndEntityWithAccessionedSequenceComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndEntityWithAccessionedSequenceComparator.java index bb77ec02b0..037924e79c 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndEntityWithAccessionedSequenceComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndEntityWithAccessionedSequenceComparator.java @@ -7,21 +7,21 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; +import lcsb.mapviewer.model.map.species.Protein; import lcsb.mapviewer.reactome.model.ReactomeEntityWithAccessionedSequence; import lcsb.mapviewer.reactome.model.ReactomeReferenceEntity; import lcsb.mapviewer.reactome.model.ReactomeReferenceGeneProduct; import lcsb.mapviewer.reactome.utils.ComparatorException; /** - * This class allows to compare {@link ProteinAlias} element (internal + * This class allows to compare {@link Protein} element (internal * representation) and {@link ReactomeEntityWithAccessionedSequence} (reactome * model). * * @author Piotr Gawron * */ -public class ProteinAndEntityWithAccessionedSequenceComparator extends ANodeComparator<ProteinAlias, ReactomeEntityWithAccessionedSequence> { +public class ProteinAndEntityWithAccessionedSequenceComparator extends ANodeComparator<Protein, ReactomeEntityWithAccessionedSequence> { /** * Default class logger. */ @@ -32,11 +32,11 @@ public class ProteinAndEntityWithAccessionedSequenceComparator extends ANodeComp * Default constructor. */ public ProteinAndEntityWithAccessionedSequenceComparator() { - super(ProteinAlias.class, ReactomeEntityWithAccessionedSequence.class); + super(Protein.class, ReactomeEntityWithAccessionedSequence.class); } @Override - public boolean compareNodes(ProteinAlias species, ReactomeEntityWithAccessionedSequence entity) throws ComparatorException { + public boolean compareNodes(Protein species, ReactomeEntityWithAccessionedSequence entity) throws ComparatorException { try { Set<MiriamData> uniprotId1 = getElementUtil().getMiriamByType(species, MiriamType.UNIPROT, true); diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndGenomeEncodedEntity.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndGenomeEncodedEntity.java index dc85f16b9f..a5b731ef28 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndGenomeEncodedEntity.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndGenomeEncodedEntity.java @@ -2,17 +2,17 @@ package lcsb.mapviewer.reactome.utils.comparators; import org.apache.log4j.Logger; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; +import lcsb.mapviewer.model.map.species.Protein; import lcsb.mapviewer.reactome.model.ReactomeGenomeEncodedEntity; /** - * This class allows to compare {@link ProteinAlias} element (internal + * This class allows to compare {@link Protein} element (internal * representation) and {@link ReactomeGenomeEncodedEntity} (reactome model). * * @author Piotr Gawron * */ -public class ProteinAndGenomeEncodedEntity extends ANodeComparator<ProteinAlias, ReactomeGenomeEncodedEntity> { +public class ProteinAndGenomeEncodedEntity extends ANodeComparator<Protein, ReactomeGenomeEncodedEntity> { /** * Default class logger. */ @@ -23,11 +23,11 @@ public class ProteinAndGenomeEncodedEntity extends ANodeComparator<ProteinAlias, * Default constructor. */ public ProteinAndGenomeEncodedEntity() { - super(ProteinAlias.class, ReactomeGenomeEncodedEntity.class); + super(Protein.class, ReactomeGenomeEncodedEntity.class); } @Override - public boolean compareNodes(ProteinAlias species, ReactomeGenomeEncodedEntity entity) { + public boolean compareNodes(Protein species, ReactomeGenomeEncodedEntity entity) { for (String name : entity.getNames()) { if (name.trim().equalsIgnoreCase(name.trim())) { return true; diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndOtherEntityComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndOtherEntityComparator.java index ae0339ef61..96f121a16c 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndOtherEntityComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndOtherEntityComparator.java @@ -2,17 +2,17 @@ package lcsb.mapviewer.reactome.utils.comparators; import org.apache.log4j.Logger; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; +import lcsb.mapviewer.model.map.species.Protein; import lcsb.mapviewer.reactome.model.ReactomeOtherEntity; /** - * This class allows to compare {@link ProteinAlias} element (internal + * This class allows to compare {@link Protein} element (internal * representation) and {@link ReactomeOtherEntity} (reactome model). * * @author Piotr Gawron * */ -public class ProteinAndOtherEntityComparator extends ANodeComparator<ProteinAlias, ReactomeOtherEntity> { +public class ProteinAndOtherEntityComparator extends ANodeComparator<Protein, ReactomeOtherEntity> { /** * Default class logger. @@ -23,11 +23,11 @@ public class ProteinAndOtherEntityComparator extends ANodeComparator<ProteinAlia * Default constructor. */ public ProteinAndOtherEntityComparator() { - super(ProteinAlias.class, ReactomeOtherEntity.class); + super(Protein.class, ReactomeOtherEntity.class); } @Override - public boolean compareNodes(ProteinAlias species, ReactomeOtherEntity rSpecies) { + public boolean compareNodes(Protein species, ReactomeOtherEntity rSpecies) { logger.warn(getElementTag(species) + " and " + rSpecies.getClass() + ", " + rSpecies.getDbId() + " should be comparable, but how??? Assuming FALSE"); return false; } diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndPolymerComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndPolymerComparator.java index 2349aad77e..980eb07352 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndPolymerComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndPolymerComparator.java @@ -9,7 +9,7 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; +import lcsb.mapviewer.model.map.species.Protein; import lcsb.mapviewer.reactome.model.ReactomeComplex; import lcsb.mapviewer.reactome.model.ReactomeDefinedSet; import lcsb.mapviewer.reactome.model.ReactomeEntityWithAccessionedSequence; @@ -22,13 +22,13 @@ import lcsb.mapviewer.reactome.model.ReactomeSimpleEntity; import lcsb.mapviewer.reactome.utils.ComparatorException; /** - * This class allows to compare {@link ProteinAlias} element (internal + * This class allows to compare {@link Protein} element (internal * representation) and {@link ReactomePolymer} (reactome model). * * @author Piotr Gawron * */ -public class ProteinAndPolymerComparator extends ANodeComparator<ProteinAlias, ReactomePolymer> { +public class ProteinAndPolymerComparator extends ANodeComparator<Protein, ReactomePolymer> { /** * Default class logger. */ @@ -38,11 +38,11 @@ public class ProteinAndPolymerComparator extends ANodeComparator<ProteinAlias, R * Default constructor. */ public ProteinAndPolymerComparator() { - super(ProteinAlias.class, ReactomePolymer.class); + super(Protein.class, ReactomePolymer.class); } @Override - public boolean compareNodes(ProteinAlias species, ReactomePolymer polymer) throws ComparatorException { + public boolean compareNodes(Protein species, ReactomePolymer polymer) throws ComparatorException { Set<MiriamData> uniprotIds1 = new HashSet<MiriamData>(); Set<MiriamData> uniprotIds2 = new HashSet<MiriamData>(); for (MiriamData md : species.getMiriamData()) { diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndSimpleEntityComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndSimpleEntityComparator.java index c47a2e68bd..010d106bc2 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndSimpleEntityComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/ProteinAndSimpleEntityComparator.java @@ -1,26 +1,26 @@ package lcsb.mapviewer.reactome.utils.comparators; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; +import lcsb.mapviewer.model.map.species.Protein; import lcsb.mapviewer.reactome.model.ReactomeSimpleEntity; /** - * This class allows to compare {@link ProteinAlias} element (internal + * This class allows to compare {@link Protein} element (internal * representation) and {@link ReactomeSimpleEntity} (reactome model). * * @author Piotr Gawron * */ -public class ProteinAndSimpleEntityComparator extends ANodeComparator<ProteinAlias, ReactomeSimpleEntity> { +public class ProteinAndSimpleEntityComparator extends ANodeComparator<Protein, ReactomeSimpleEntity> { /** * Default constructor. */ public ProteinAndSimpleEntityComparator() { - super(ProteinAlias.class, ReactomeSimpleEntity.class); + super(Protein.class, ReactomeSimpleEntity.class); } @Override - public boolean compareNodes(ProteinAlias species, ReactomeSimpleEntity cSpecies) { + public boolean compareNodes(Protein species, ReactomeSimpleEntity cSpecies) { return false; } diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/UnknownAndCatalystComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/UnknownAndCatalystComparator.java index 79498edcd4..428415f981 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/UnknownAndCatalystComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/UnknownAndCatalystComparator.java @@ -1,30 +1,30 @@ package lcsb.mapviewer.reactome.utils.comparators; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.layout.alias.UnknownAlias; +import lcsb.mapviewer.model.map.species.Unknown; import lcsb.mapviewer.reactome.model.ReactomeCatalystActivity; import lcsb.mapviewer.reactome.model.ReactomeGenomeEncodedEntity; import lcsb.mapviewer.reactome.model.ReactomePhysicalEntity; import lcsb.mapviewer.reactome.utils.ComparatorException; /** - * This class allows to compare {@link UnknownAlias} element (internal + * This class allows to compare {@link Unknown} element (internal * representation) and {@link ReactomeCatalystActivity} (reactome model). * * @author Piotr Gawron * */ -public class UnknownAndCatalystComparator extends ANodeComparator<UnknownAlias, ReactomeCatalystActivity> { +public class UnknownAndCatalystComparator extends ANodeComparator<Unknown, ReactomeCatalystActivity> { /** * Default constructor. */ public UnknownAndCatalystComparator() { - super(UnknownAlias.class, ReactomeCatalystActivity.class); + super(Unknown.class, ReactomeCatalystActivity.class); } @Override - public boolean compareNodes(UnknownAlias species, ReactomeCatalystActivity cSpecies) throws ComparatorException { + public boolean compareNodes(Unknown species, ReactomeCatalystActivity cSpecies) throws ComparatorException { ReactomePhysicalEntity pEntity = cSpecies.getPhysicalEntity(); if (pEntity instanceof ReactomeGenomeEncodedEntity) { return getGlobalComparator().compareNodes(species, (ReactomeGenomeEncodedEntity) pEntity); diff --git a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/UnknownAndGenomeEncodedEntityComparator.java b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/UnknownAndGenomeEncodedEntityComparator.java index ff73b72d4c..18c6ed871c 100644 --- a/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/UnknownAndGenomeEncodedEntityComparator.java +++ b/reactome/src/main/java/lcsb/mapviewer/reactome/utils/comparators/UnknownAndGenomeEncodedEntityComparator.java @@ -1,26 +1,26 @@ package lcsb.mapviewer.reactome.utils.comparators; -import lcsb.mapviewer.model.map.layout.alias.UnknownAlias; +import lcsb.mapviewer.model.map.species.Unknown; import lcsb.mapviewer.reactome.model.ReactomeGenomeEncodedEntity; /** - * This class allows to compare {@link UnknownAlias} element (internal + * This class allows to compare {@link Unknown} element (internal * representation) and {@link ReactomeGenomeEncodedEntity} (reactome model). * * @author Piotr Gawron * */ -public class UnknownAndGenomeEncodedEntityComparator extends ANodeComparator<UnknownAlias, ReactomeGenomeEncodedEntity> { +public class UnknownAndGenomeEncodedEntityComparator extends ANodeComparator<Unknown, ReactomeGenomeEncodedEntity> { /** * Default constructor. */ public UnknownAndGenomeEncodedEntityComparator() { - super(UnknownAlias.class, ReactomeGenomeEncodedEntity.class); + super(Unknown.class, ReactomeGenomeEncodedEntity.class); } @Override - public boolean compareNodes(UnknownAlias species, ReactomeGenomeEncodedEntity entity) { + public boolean compareNodes(Unknown species, ReactomeGenomeEncodedEntity entity) { // we can compare the objects only using names... for (String name : entity.getNames()) { if (name.trim().equalsIgnoreCase(species.getName().trim())) { diff --git a/reactome/src/test/java/lcsb/mapviewer/reactome/utils/ReactomeQueryUtilTest.java b/reactome/src/test/java/lcsb/mapviewer/reactome/utils/ReactomeQueryUtilTest.java index 47c57ede08..16a106f1fb 100644 --- a/reactome/src/test/java/lcsb/mapviewer/reactome/utils/ReactomeQueryUtilTest.java +++ b/reactome/src/test/java/lcsb/mapviewer/reactome/utils/ReactomeQueryUtilTest.java @@ -18,10 +18,10 @@ import org.junit.Ignore; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.SimpleMolecule; import lcsb.mapviewer.reactome.ReactomeTestFunctions; import lcsb.mapviewer.reactome.model.ReactomeReactionlikeEvent; import lcsb.mapviewer.reactome.xml.ReactomeCatalystActivityParser; @@ -58,11 +58,11 @@ public class ReactomeQueryUtilTest extends ReactomeTestFunctions { public void testGetReactionsBetweenSpecies() { try { // based on reaction re1107 from PD_130712_3.xml - SimpleMoleculeAlias input = new SimpleMoleculeAlias("id1"); + SimpleMolecule input = new SimpleMolecule("id1"); input.setName("coenzyme A"); - SimpleMoleculeAlias output = new SimpleMoleculeAlias("id2"); + SimpleMolecule output = new SimpleMolecule("id2"); output.setName("acetyl-CoA"); - List<Alias> list = new ArrayList<>(); + List<Element> list = new ArrayList<>(); list.add(input); list.add(output); 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 4cd4facd8a..ae7fe04c5c 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 @@ -11,8 +11,8 @@ import org.junit.Ignore; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.reactome.ReactomeTestFunctions; import lcsb.mapviewer.reactome.model.ReactomeCatalystActivity; import lcsb.mapviewer.reactome.model.ReactomeDatabaseObject; @@ -55,7 +55,7 @@ public class NodeComparatorTest extends ReactomeTestFunctions { try { Model model = getModelForFile("testFiles/reactome/cell_designer_references/reaction.xml", true); - Alias speciesL_glu = model.getAliasByAliasId("sa6"); + Element speciesL_glu = model.getAliasByAliasId("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); - Alias speciesNADP_PLUS = model.getAliasByAliasId("sa5"); + Element speciesNADP_PLUS = model.getAliasByAliasId("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); - Alias h2o = model.getAliasByAliasId("sa7"); + Element h2o = model.getAliasByAliasId("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); - Alias oxoglutarate = model.getAliasByAliasId("sa1"); + Element oxoglutarate = model.getAliasByAliasId("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); - Alias nadph = model.getAliasByAliasId("sa2"); + Element nadph = model.getAliasByAliasId("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); - Alias hydron = model.getAliasByAliasId("sa3"); + Element hydron = model.getAliasByAliasId("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); - Alias hydron = model.getAliasByAliasId("sa4"); + Element hydron = model.getAliasByAliasId("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); - Alias species = model.getAliasByAliasId("csa1"); + Element species = model.getAliasByAliasId("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); - Alias species = model.getAliasByAliasId("sa1"); + Element species = model.getAliasByAliasId("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); - Alias species = model.getAliasByAliasId("sa1"); + Element species = model.getAliasByAliasId("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); - Alias species = model.getAliasByAliasId("csa1"); + Element species = model.getAliasByAliasId("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); - Alias species = model.getAliasByAliasId("sa1"); + Element species = model.getAliasByAliasId("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); - Alias species = model.getAliasByAliasId("sa1"); + Element species = model.getAliasByAliasId("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); - Alias species = model.getAliasByAliasId("sa1"); + Element species = model.getAliasByAliasId("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); - Alias species = model.getAliasByAliasId("sa1"); + Element species = model.getAliasByAliasId("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); - Alias species = model.getAliasByAliasId("sa1"); + Element species = model.getAliasByAliasId("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); - Alias species = model.getAliasByAliasId("csa1"); + Element species = model.getAliasByAliasId("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); - Alias species = model.getAliasByAliasId("sa1"); + Element species = model.getAliasByAliasId("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); - Alias species = model.getAliasByAliasId("csa1"); + Element species = model.getAliasByAliasId("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); - Alias species = model.getAliasByAliasId("sa1"); + Element species = model.getAliasByAliasId("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); - Alias species = model.getAliasByAliasId("csa1"); + Element species = model.getAliasByAliasId("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); - Alias species = model.getAliasByAliasId("sa1"); + Element species = model.getAliasByAliasId("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); - Alias species = model.getAliasByAliasId("csa1"); + Element species = model.getAliasByAliasId("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); - Alias species = model.getAliasByAliasId("sa1"); + Element species = model.getAliasByAliasId("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); - Alias species = model.getAliasByAliasId("sa1"); + Element species = model.getAliasByAliasId("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); - Alias species = model.getAliasByAliasId("csa1"); + Element species = model.getAliasByAliasId("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); - Alias species = model.getAliasByAliasId("sa1"); + Element species = model.getAliasByAliasId("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); - Alias species = model.getAliasByAliasId("sa1"); + Element species = model.getAliasByAliasId("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 6cb02ae5ce..c2961ae1f7 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/CommentService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/CommentService.java @@ -21,11 +21,11 @@ import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.InvalidClassException; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.Comment; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelData; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.model.user.User; import lcsb.mapviewer.persist.dao.map.CommentDao; import lcsb.mapviewer.services.interfaces.ICommentService; @@ -172,8 +172,8 @@ public class CommentService implements ICommentService { if (object != null) { comment.setTableName(object.getClass()); comment.setTableId(ObjectUtils.getIdOfObject(object)); - if (object instanceof Alias) { - comment.setSubmodel(((Alias) object).getModel()); + if (object instanceof Element) { + comment.setSubmodel(((Element) object).getModel()); } else if (object instanceof Reaction) { comment.setSubmodel(((Reaction) object).getModel()); } else { @@ -294,9 +294,9 @@ public class CommentService implements ICommentService { logger.warn("Invalid reaction dbID: " + comment.getTableId() + ". Table: " + comment.getTableName().getName()); } } else { - Alias alias = model.getAliasByDbId(comment.getTableId()); + Element alias = model.getAliasByDbId(comment.getTableId()); if (alias != null) { - identifier = ((SpeciesAlias) alias).getAliasId(); + identifier = ((Species) alias).getAliasId(); } else { logger.warn("Invalid alias dbID: " + comment.getTableId()); } @@ -550,7 +550,7 @@ public class CommentService implements ICommentService { return result; } else if (ElementIdentifierType.ALIAS.getJsName().equalsIgnoreCase(element.getType())) { for (FullCommentView comment : comments) { - if (Alias.class.equals(comment.getType())) { + if (Element.class.equals(comment.getType())) { if (comment.getIdObject().equals(element.getObjectId()) && comment.getModelId().equals(element.getModelId())) { for (Pair<String, String> c : comment.getComments()) { result.add(new CommentDetails(c.getLeft(), c.getRight())); diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/DataMiningService.java b/service/src/main/java/lcsb/mapviewer/services/impl/DataMiningService.java index 94ec03f711..691a276741 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/DataMiningService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/DataMiningService.java @@ -31,11 +31,11 @@ import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.graph.DataMining; import lcsb.mapviewer.model.map.graph.DataMiningSet; import lcsb.mapviewer.model.map.graph.DataMiningType; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelData; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.ReactionNode; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.persist.DbUtils; import lcsb.mapviewer.persist.dao.map.graph.DataMiningDao; import lcsb.mapviewer.persist.dao.map.graph.DataMiningSetDao; @@ -119,14 +119,14 @@ public class DataMiningService extends XmlParser implements IDataMiningService { private BiocompendiumAnnotator annotationRestService; @Override - public Collection<DataMining> getMissingConnections(Alias alias) { + public Collection<DataMining> getMissingConnections(Element alias) { return missingConnectionDao.getMissingConnectionForElement(alias); } @Override public void addMissingConnection(DataMining connection) { missingConnectionDao.add(connection); - Alias element = connection.getElement(); + Element element = connection.getElement(); String id = element.getName() + " (" + element.getStringType() + ")"; String toString = ""; for (MiriamData md : connection.getSuggestedConnections()) { @@ -139,7 +139,7 @@ public class DataMiningService extends XmlParser implements IDataMiningService { @Override public void deleteMissingConnection(DataMining connection, String reason) { missingConnectionDao.delete(connection); - Alias element = connection.getElement(); + Element element = connection.getElement(); String id = element.getName() + " (" + element.getStringType() + ")"; String toString = ""; for (MiriamData md : connection.getSuggestedConnections()) { @@ -157,12 +157,12 @@ public class DataMiningService extends XmlParser implements IDataMiningService { } @Override - public Collection<Alias> getSpeciesWithMissingConnectionsByGeneName(Model model, String geneName) { - Set<Alias> result = new HashSet<>(); + public Collection<Element> getSpeciesWithMissingConnectionsByGeneName(Model model, String geneName) { + Set<Element> result = new HashSet<>(); if (geneName == null) { return result; } - for (Alias element : model.getAliases()) { + for (Element element : model.getAliases()) { Collection<DataMining> set = missingConnectionDao.getMissingConnectionForElement(element); for (DataMining dataMining : set) { for (MiriamData md : dataMining.getSuggestedConnections()) { @@ -243,10 +243,10 @@ public class DataMiningService extends XmlParser implements IDataMiningService { @Override public void removeConnectionsForModel(ModelData model) { - Collection<Alias> nodes = model.getAliases(); + Collection<Element> nodes = model.getAliases(); dbUtils.setAutoFlush(false); - for (Alias node : nodes) { + for (Element node : nodes) { Collection<DataMining> mcs = missingConnectionDao.getMissingConnectionForElement(node); for (DataMining missingConnection : mcs) { missingConnectionDao.delete(missingConnection); @@ -261,7 +261,7 @@ public class DataMiningService extends XmlParser implements IDataMiningService { } @Override - public Set<DataMining> parseData(String filename, DataMiningType type, Collection<Alias> nodes, Set<Reaction> reactions, IProgressUpdater updater) + public Set<DataMining> parseData(String filename, DataMiningType type, Collection<Element> nodes, Set<Reaction> reactions, IProgressUpdater updater) throws IOException, InvalidDataMiningInputFile { InputStream is = new FileInputStream(filename); String name = new File(filename).getName(); @@ -285,7 +285,7 @@ public class DataMiningService extends XmlParser implements IDataMiningService { * @throws InvalidDataMiningInputFile * thrown when the input file is invalid */ - protected Set<DataMining> parseData(Collection<Alias> nodes, Set<Reaction> reactions, InputStream is, String warningPrefix) + protected Set<DataMining> parseData(Collection<Element> nodes, Set<Reaction> reactions, InputStream is, String warningPrefix) throws InvalidDataMiningInputFile { Set<DataMining> result = new HashSet<DataMining>(); String content = null; @@ -337,10 +337,10 @@ public class DataMiningService extends XmlParser implements IDataMiningService { if (targetColumnId == null) { throw new InvalidDataMiningInputFile(warningPrefix + " Column \"" + TARGET_COLUMN_NAME + "\" wasn't found in the input file."); } - Map<MiriamData, List<Alias>> map = new HashMap<>(); - for (Alias element : nodes) { + Map<MiriamData, List<Element>> map = new HashMap<>(); + for (Element element : nodes) { for (MiriamData md : element.getMiriamData()) { - List<Alias> elList = map.get(md); + List<Element> elList = map.get(md); if (elList == null) { elList = new ArrayList<>(); map.put(md, elList); @@ -391,9 +391,9 @@ public class DataMiningService extends XmlParser implements IDataMiningService { exists = reactionsHash.contains(new Pair<MiriamData, MiriamData>(md2, md1)); } if (!exists) { - List<Alias> listEl = map.get(md1); + List<Element> listEl = map.get(md1); if (listEl != null) { - for (Alias el : listEl) { + for (Element el : listEl) { DataMining dm = new DataMining(); dm.setElement(el); dm.setDescription(description); @@ -505,7 +505,7 @@ public class DataMiningService extends XmlParser implements IDataMiningService { } @Override - public Set<DataMining> parseData(DataMiningSet dataMiningSet, Collection<Alias> nodes, Set<Reaction> reactions, IProgressUpdater secondPartUpdater) + public Set<DataMining> parseData(DataMiningSet dataMiningSet, Collection<Element> nodes, Set<Reaction> reactions, IProgressUpdater secondPartUpdater) throws InvalidDataMiningInputFile { String name = dataMiningSet.getName(); String warningPrefix = "[Data mining, " + name + "] "; 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 b88827ddf6..ac91c3c6f9 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/ExporterService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/ExporterService.java @@ -19,30 +19,30 @@ import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.converter.model.celldesigner.reaction.ReactionLineData; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaAlias; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaRegionAlias; -import lcsb.mapviewer.model.map.layout.alias.ArtifitialCompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.DegradedAlias; -import lcsb.mapviewer.model.map.layout.alias.DrugAlias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.IonAlias; -import lcsb.mapviewer.model.map.layout.alias.ModificationResidueAlias; -import lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaRegionAlias; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; -import lcsb.mapviewer.model.map.layout.alias.UnknownAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; +import lcsb.mapviewer.model.map.compartment.PathwayCompartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.reaction.Modifier; import lcsb.mapviewer.model.map.reaction.Product; import lcsb.mapviewer.model.map.reaction.Reactant; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.ReactionNode; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.AntisenseRna; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Degraded; +import lcsb.mapviewer.model.map.species.Drug; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.Ion; +import lcsb.mapviewer.model.map.species.Phenotype; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Rna; +import lcsb.mapviewer.model.map.species.SimpleMolecule; +import lcsb.mapviewer.model.map.species.Species; +import lcsb.mapviewer.model.map.species.Unknown; +import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; +import lcsb.mapviewer.model.map.species.field.RnaRegion; import lcsb.mapviewer.services.interfaces.IExporterService; import lcsb.mapviewer.services.utils.data.ExportColumn; import lcsb.mapviewer.services.utils.data.ExportFileType; @@ -91,9 +91,9 @@ public class ExporterService implements IExporterService { } builder.append("\n"); for (Model model : parameters.getModels()) { - for (Alias alias : model.getAliases()) { - if (alias instanceof SpeciesAlias) { - SpeciesAlias speciesAlias = (SpeciesAlias) alias; + for (Element alias : model.getAliases()) { + if (alias instanceof Species) { + Species speciesAlias = (Species) alias; boolean toBeProcessed = false; // check type for (Class<?> type : parameters.getTypes()) { @@ -108,12 +108,12 @@ public class ExporterService implements IExporterService { // check where it lays toBeProcessed = (parameters.getIncludedAliases().size() == 0); - for (CompartmentAlias ca : parameters.getIncludedAliases()) { + for (Compartment ca : parameters.getIncludedAliases()) { if (ca.cross(alias)) { toBeProcessed = true; } } - for (CompartmentAlias ca : parameters.getExcludedAliases()) { + for (Compartment ca : parameters.getExcludedAliases()) { if (ca.cross(alias)) { toBeProcessed = false; } @@ -148,24 +148,24 @@ public class ExporterService implements IExporterService { * export string are generated for this alias * @return list of strings representing exported data */ - protected List<String> getExportStringForOneSpecies(SpeciesAlias species, ExporterParameters parameters) { + protected List<String> getExportStringForOneSpecies(Species species, ExporterParameters parameters) { if (parameters.getFileType() != ExportFileType.TAB_SEPARATED) { throw new InvalidArgumentException("Unhandled file type: " + parameters.getFileType()); } - List<CompartmentAlias> aliases = getComponentList(species); + List<Compartment> aliases = getComponentList(species); List<String> result = new ArrayList<String>(); - CompartmentAlias smallestCompartment = getCompartment(species); + Compartment smallestCompartment = getCompartment(species); List<ExportColumn> processedColumns = new ArrayList<ExportColumn>(); for (ExportColumn column : parameters.getColumns()) { - if (column.getClazz().isAssignableFrom(SpeciesAlias.class)) { + if (column.getClazz().isAssignableFrom(Species.class)) { processedColumns.add(column); } } - for (CompartmentAlias compartment : aliases) { + for (Compartment compartment : aliases) { String separator = ""; StringBuilder line = new StringBuilder(); for (ExportColumn column : processedColumns) { @@ -182,11 +182,11 @@ public class ExporterService implements IExporterService { } else if (column == ExportColumn.COMPONENT_NAME) { line.append(compartment.getName()); } else if (column == ExportColumn.NAME) { - if (species instanceof ComplexAlias) { + if (species instanceof Complex) { if (!parameters.isComplexElementsName()) { line.append(species.getName()); } else { - line.append(getComplexNameWithElements((ComplexAlias) species, parameters)); + line.append(getComplexNameWithElements((Complex) species, parameters)); } } else { line.append(species.getName()); @@ -232,19 +232,19 @@ public class ExporterService implements IExporterService { } /** - * Returns {@link CompartmentAlias} to which element belongs to. + * Returns {@link Compartment} to which element belongs to. * * @param element * alias of the element - * @return {@link CompartmentAlias} to which element belongs to + * @return {@link Compartment} to which element belongs to */ - private CompartmentAlias getCompartment(SpeciesAlias element) { - CompartmentAlias smallestAlias = null; - List<CompartmentAlias> compartmentAliases = new ArrayList<CompartmentAlias>(); + private Compartment getCompartment(Species element) { + Compartment smallestAlias = null; + List<Compartment> compartmentAliases = new ArrayList<Compartment>(); - for (CompartmentAlias alias : element.getModel().getCompartmentsAliases()) { + for (Compartment alias : element.getModel().getCompartmentsAliases()) { if (alias.cross(element)) { - if (!(alias instanceof ArtifitialCompartmentAlias)) { + if (!(alias instanceof PathwayCompartment)) { compartmentAliases.add(alias); } } @@ -253,7 +253,7 @@ public class ExporterService implements IExporterService { if (compartmentAliases.size() > 0) { smallestAlias = compartmentAliases.get(0); } - for (CompartmentAlias compartmentAlias : compartmentAliases) { + for (Compartment compartmentAlias : compartmentAliases) { if (compartmentAlias.getSize() < smallestAlias.getSize()) { smallestAlias = compartmentAlias; } @@ -266,14 +266,14 @@ public class ExporterService implements IExporterService { * * @param element * alias of the element - * @return list of {@link CompartmentAlias} representing pathways + * @return list of {@link Compartment} representing pathways */ - private List<CompartmentAlias> getComponentList(SpeciesAlias element) { + private List<Compartment> getComponentList(Species element) { Model model = element.getModel(); - List<CompartmentAlias> aliases = new ArrayList<CompartmentAlias>(); - for (CompartmentAlias alias : model.getCompartmentsAliases()) { - if (alias instanceof ArtifitialCompartmentAlias) { + List<Compartment> aliases = new ArrayList<Compartment>(); + for (Compartment alias : model.getCompartmentsAliases()) { + if (alias instanceof PathwayCompartment) { if (alias.cross(element)) { aliases.add(alias); } @@ -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) { - ArtifitialCompartmentAlias nullAlias = new ArtifitialCompartmentAlias(); + PathwayCompartment nullAlias = new PathwayCompartment(); nullAlias.setName("null"); aliases.add(nullAlias); } @@ -303,10 +303,10 @@ public class ExporterService implements IExporterService { * @return name of a complex with the names of all species included in this * complex */ - private String getComplexNameWithElements(ComplexAlias complex, ExporterParameters parameters) { + private String getComplexNameWithElements(Complex complex, ExporterParameters parameters) { StringBuilder result = new StringBuilder(); String separator = ""; - for (Alias species2 : complex.getAllSimpleChildren()) { + for (Element species2 : complex.getAllSimpleChildren()) { boolean add = false; if (parameters.getTypes().size() == 0) { add = true; @@ -368,7 +368,7 @@ public class ExporterService implements IExporterService { for (Reaction reaction : model.getReactions()) { int counter = 0; for (ReactionNode node : reaction.getReactionNodes()) { - Alias element = node.getAlias(); + Element element = node.getAlias(); for (Class<?> type : parameters.getTypes()) { if (type.isAssignableFrom(element.getClass())) { counter++; @@ -383,22 +383,22 @@ public class ExporterService implements IExporterService { } if (parameters.isMoleculeEdges()) { for (Model model : parameters.getModels()) { - for (Alias element : model.getAliases()) { - if (element instanceof SpeciesAlias) { - if (element instanceof SimpleMoleculeAlias) { + for (Element element : model.getAliases()) { + if (element instanceof Species) { + if (element instanceof SimpleMolecule) { boolean ok = false; - for (CompartmentAlias alias : parameters.getIncludedAliases()) { + for (Compartment alias : parameters.getIncludedAliases()) { if (alias.cross(element)) { ok = true; } } - for (CompartmentAlias alias : parameters.getExcludedAliases()) { + for (Compartment alias : parameters.getExcludedAliases()) { if (alias.cross(element)) { ok = false; } } if (ok) { - String string = getExportSingleInteractionStringFromSpecies((SimpleMoleculeAlias) element, parameters); + String string = getExportSingleInteractionStringFromSpecies((SimpleMolecule) element, parameters); if (parameters.getFileType() == ExportFileType.SIF) { if (!uniqueLines.contains(string.replace("molecule_type", "reaction_type"))) { uniqueLines.add(string); @@ -436,7 +436,7 @@ public class ExporterService implements IExporterService { * {@link ExporterParameters export parameters} * @return string representing exported reaction */ - protected String getExportSingleInteractionStringFromSpecies(SimpleMoleculeAlias species, ExporterParameters parameters) { + protected String getExportSingleInteractionStringFromSpecies(SimpleMolecule species, ExporterParameters parameters) { if (parameters.getFileType() != ExportFileType.SIF) { throw new InvalidArgumentException("Unsupported file format: " + parameters.getFileType()); } @@ -446,8 +446,8 @@ public class ExporterService implements IExporterService { for (Reaction reaction : model.getReactions()) { boolean goodReaction = false; for (ReactionNode node : reaction.getReactionNodes()) { - if (node.getAlias() instanceof SimpleMoleculeAlias) { - Alias species2 = node.getAlias(); + if (node.getAlias() instanceof SimpleMolecule) { + Element species2 = node.getAlias(); if (species.getName().equalsIgnoreCase(species2.getName())) { goodReaction = true; } @@ -461,31 +461,31 @@ public class ExporterService implements IExporterService { if (parameters.getIncludedAliases().size() == 0) { ok = true; } - for (CompartmentAlias alias2 : parameters.getIncludedAliases()) { + for (Compartment alias2 : parameters.getIncludedAliases()) { if (alias2.cross(node.getAlias())) { ok = true; break; } } - for (CompartmentAlias alias2 : parameters.getExcludedAliases()) { + for (Compartment alias2 : parameters.getExcludedAliases()) { if (alias2.cross(node.getAlias())) { ok = false; break; } } if (ok) { - Alias element = node.getAlias(); + Element element = node.getAlias(); for (Class<?> type : parameters.getTypes()) { if (type.isAssignableFrom(element.getClass())) { - if (element instanceof ComplexAlias) { + if (element instanceof Complex) { if (!parameters.isComplexElementsName()) { - elements.add(((SpeciesAlias) element).getName()); + elements.add(((Species) element).getName()); } else { - String name = getComplexNameWithElements((ComplexAlias) element, parameters); + String name = getComplexNameWithElements((Complex) element, parameters); elements.add(name); } } else { - elements.add(((SpeciesAlias) element).getName()); + elements.add(((Species) element).getName()); } break; } @@ -523,26 +523,26 @@ public class ExporterService implements IExporterService { List<String> result = new ArrayList<String>(); if (parameters.getFileType() == ExportFileType.SIF) { StringBuilder builder = new StringBuilder(); - Set<Alias> elements = new HashSet<>(); + Set<Element> elements = new HashSet<>(); for (ReactionNode node : reaction.getReactionNodes()) { boolean ok = false; if (parameters.getIncludedAliases().size() == 0) { ok = true; } - for (CompartmentAlias alias2 : parameters.getIncludedAliases()) { + for (Compartment alias2 : parameters.getIncludedAliases()) { if (alias2.cross(node.getAlias())) { ok = true; break; } } - for (CompartmentAlias alias2 : parameters.getExcludedAliases()) { + for (Compartment alias2 : parameters.getExcludedAliases()) { if (alias2.cross(node.getAlias())) { ok = false; break; } } if (ok) { - Alias element = node.getAlias(); + Element element = node.getAlias(); if (parameters.getTypes().size() == 0) { elements.add(element); } else { @@ -556,17 +556,17 @@ public class ExporterService implements IExporterService { } } Set<String> elementsNames = new HashSet<>(); - for (Alias element : elements) { - if (element instanceof ComplexAlias) { + for (Element element : elements) { + if (element instanceof Complex) { if (!parameters.isComplexElementsName()) { - elementsNames.add(((SpeciesAlias) element).getName()); + elementsNames.add(((Species) element).getName()); } else { - String name = getComplexNameWithElements((ComplexAlias) element, parameters); + String name = getComplexNameWithElements((Complex) element, parameters); elementsNames.add(name); } } else { - elementsNames.add(((SpeciesAlias) element).getName()); + elementsNames.add(((Species) element).getName()); } } @@ -628,13 +628,13 @@ public class ExporterService implements IExporterService { for (Reactant reactant : reaction.getReactants()) { result.append("REACTANT"); result.append("\t"); - result.append(getExportSingleSpecies((SpeciesAlias) reactant.getAlias(), parameters)); + result.append(getExportSingleSpecies((Species) reactant.getAlias(), parameters)); result.append("\t"); } for (Product product : reaction.getProducts()) { result.append("PRODUCT"); result.append("\t"); - result.append(getExportSingleSpecies((SpeciesAlias) product.getAlias(), parameters)); + result.append(getExportSingleSpecies((Species) product.getAlias(), parameters)); result.append("\t"); } for (Modifier modifier : reaction.getModifiers()) { @@ -642,7 +642,7 @@ public class ExporterService implements IExporterService { result.append("\t"); result.append("type=" + modifier.getClass().getSimpleName()); result.append("\t"); - result.append(getExportSingleSpecies((SpeciesAlias) modifier.getAlias(), parameters)); + result.append(getExportSingleSpecies((Species) modifier.getAlias(), parameters)); result.append("\t"); } return result.toString(); @@ -700,14 +700,14 @@ public class ExporterService implements IExporterService { if (splitReaction) { String base = builder.toString(); - Set<Alias> inputs = new HashSet<Alias>(); - Set<Alias> outputs = new HashSet<Alias>(); + Set<Element> inputs = new HashSet<Element>(); + Set<Element> outputs = new HashSet<Element>(); for (Reactant reactant : reaction.getReactants()) { if (!isAssignable(parameters, reactant.getAlias())) { continue; } - if (reactant.getAlias() instanceof ComplexAlias) { - inputs.addAll(((ComplexAlias) (reactant.getAlias())).getAllChildrenAliases()); + if (reactant.getAlias() instanceof Complex) { + inputs.addAll(((Complex) (reactant.getAlias())).getAllChildrenAliases()); } else { inputs.add(reactant.getAlias()); } @@ -716,8 +716,8 @@ public class ExporterService implements IExporterService { if (!isAssignable(parameters, product.getAlias())) { continue; } - if (product.getAlias() instanceof ComplexAlias) { - outputs.addAll(((ComplexAlias) (product.getAlias())).getAllChildrenAliases()); + if (product.getAlias() instanceof Complex) { + outputs.addAll(((Complex) (product.getAlias())).getAllChildrenAliases()); } else { outputs.add(product.getAlias()); } @@ -726,17 +726,17 @@ public class ExporterService implements IExporterService { if (!isAssignable(parameters, modifier.getAlias())) { continue; } - if (modifier.getAlias() instanceof ComplexAlias) { - inputs.addAll(((ComplexAlias) (modifier.getAlias())).getAllChildrenAliases()); + if (modifier.getAlias() instanceof Complex) { + inputs.addAll(((Complex) (modifier.getAlias())).getAllChildrenAliases()); } else { inputs.add(modifier.getAlias()); } } - for (Alias input : inputs) { + for (Element input : inputs) { if (!isAssignable(parameters, input)) { continue; } - for (Alias output : outputs) { + for (Element output : outputs) { if (!isAssignable(parameters, output)) { continue; } @@ -797,7 +797,7 @@ public class ExporterService implements IExporterService { * @return true if element can exist in export string, <code>false</code> * otherwise */ - private boolean isAssignable(ExporterParameters parameters, Alias element) { + private boolean isAssignable(ExporterParameters parameters, Element element) { boolean ok = false; for (Class<?> clazz : parameters.getTypes()) { if (clazz.isAssignableFrom(element.getClass())) { @@ -816,7 +816,7 @@ public class ExporterService implements IExporterService { * {@link ExporterParameters export parameters} * @return export string representation of the element */ - private String getExportSingleSpecies(SpeciesAlias alias, ExporterParameters parameters) { + private String getExportSingleSpecies(Species alias, ExporterParameters parameters) { if (parameters.getFileType() != ExportFileType.TAB_SEPARATED) { throw new InvalidArgumentException("Unsupported file format: " + parameters.getFileType()); } @@ -829,8 +829,8 @@ public class ExporterService implements IExporterService { sb.append("initialAmount=" + alias.getInitialAmount() + "\t"); sb.append("initialConcentration=" + alias.getInitialConcentration() + "\t"); String compartment = null; - if (alias.getParent() instanceof CompartmentAlias) { - compartment = ((CompartmentAlias) alias.getParent()).getName(); + if (alias.getParent() instanceof Compartment) { + compartment = ((Compartment) alias.getParent()).getName(); } sb.append("compartment=" + compartment); sb.append("\t"); @@ -845,15 +845,15 @@ public class ExporterService implements IExporterService { sb.append("positionToCompartment=" + alias.getPositionToCompartment()); sb.append("\t"); - if (alias instanceof ProteinAlias) { - ProteinAlias protein = (ProteinAlias) alias; + if (alias instanceof Protein) { + Protein protein = (Protein) alias; sb.append("dimer=" + protein.getHomodimer()); sb.append("\t"); sb.append("structuralState=" + protein.getStructuralState()); sb.append("\t"); sb.append("hypothetical=" + protein.isHypothetical()); sb.append("\t"); - for (ModificationResidueAlias mr : protein.getModificationResidues()) { + for (ModificationResidue mr : protein.getModificationResidues()) { sb.append("MODIFICATION RESIDUE"); sb.append("\t"); sb.append("angle=" + mr.getAngle()); @@ -872,9 +872,9 @@ public class ExporterService implements IExporterService { sb.append("state=" + mr.getState().getFullName() + "\t"); } } - } else if (alias instanceof GeneAlias) { - GeneAlias gene = (GeneAlias) alias; - for (ModificationResidueAlias mr : gene.getModificationResidues()) { + } else if (alias instanceof Gene) { + Gene gene = (Gene) alias; + for (ModificationResidue mr : gene.getModificationResidues()) { sb.append("MODIFICATION RESIDUE"); sb.append("\t"); sb.append("angle=" + mr.getAngle()); @@ -892,26 +892,26 @@ public class ExporterService implements IExporterService { sb.append("state=" + mr.getState().getFullName() + "\t"); } } - } else if (alias instanceof ComplexAlias) { - ComplexAlias complex = (ComplexAlias) alias; + } else if (alias instanceof Complex) { + Complex complex = (Complex) alias; sb.append("dimer=" + complex.getHomodimer()); sb.append("\t"); sb.append("hypothetical=" + complex.isHypothetical()); sb.append("\t"); - } else if (alias instanceof SimpleMoleculeAlias) { - SimpleMoleculeAlias molecule = (SimpleMoleculeAlias) alias; + } else if (alias instanceof SimpleMolecule) { + SimpleMolecule molecule = (SimpleMolecule) alias; sb.append("dimer=" + molecule.getHomodimer()); sb.append("\t"); - } else if (alias instanceof IonAlias) { + } else if (alias instanceof Ion) { sb.append(""); - } else if (alias instanceof PhenotypeAlias) { + } else if (alias instanceof Phenotype) { sb.append(""); - } else if (alias instanceof DrugAlias) { + } else if (alias instanceof Drug) { sb.append(""); - } else if (alias instanceof RnaAlias) { - RnaAlias rna = (RnaAlias) alias; - for (RnaRegionAlias region : rna.getRegions()) { + } else if (alias instanceof Rna) { + Rna rna = (Rna) alias; + for (RnaRegion region : rna.getRegions()) { sb.append("RNA_REGION"); sb.append("\t"); sb.append("type=" + region.getType()); @@ -925,9 +925,9 @@ public class ExporterService implements IExporterService { sb.append("pos=" + region.getPos()); sb.append("\t"); } - } else if (alias instanceof AntisenseRnaAlias) { - AntisenseRnaAlias antisenseRna = (AntisenseRnaAlias) alias; - for (AntisenseRnaRegionAlias region : antisenseRna.getRegions()) { + } else if (alias instanceof AntisenseRna) { + AntisenseRna antisenseRna = (AntisenseRna) alias; + for (AntisenseRnaRegion region : antisenseRna.getRegions()) { sb.append("RNA_REGION" + "\t"); if (region.getType() != null) { sb.append("type=" + region.getType().getName() + "\t"); @@ -936,9 +936,9 @@ public class ExporterService implements IExporterService { sb.append("size=" + region.getSize() + "\t"); sb.append("pos=" + region.getPos() + "\t"); } - } else if (alias instanceof UnknownAlias) { + } else if (alias instanceof Unknown) { sb.append(""); - } else if (alias instanceof DegradedAlias) { + } else if (alias instanceof Degraded) { sb.append(""); } else { throw new InvalidArgumentException("Invalid class type: " + alias.getClass()); @@ -975,16 +975,16 @@ public class ExporterService implements IExporterService { Set<String> uniqeLines = new HashSet<>(); StringBuilder builder = new StringBuilder(); for (Model model : parameters.getModels()) { - for (CompartmentAlias alias : model.getCompartmentsAliases()) { + for (Compartment alias : model.getCompartmentsAliases()) { // check where it lays boolean toBeProcessed = (parameters.getIncludedAliases().size() == 0); - for (CompartmentAlias ca : parameters.getIncludedAliases()) { + for (Compartment ca : parameters.getIncludedAliases()) { if (ca.cross(alias)) { toBeProcessed = true; } } - for (CompartmentAlias ca : parameters.getExcludedAliases()) { + for (Compartment ca : parameters.getExcludedAliases()) { if (ca.cross(alias)) { toBeProcessed = false; } @@ -1016,7 +1016,7 @@ public class ExporterService implements IExporterService { * parameters used in export * @return string srepresenting compartment in export format */ - private List<String> getExportStringForOneCompartment(CompartmentAlias compartment, ExporterParameters parameters) { + private List<String> getExportStringForOneCompartment(Compartment compartment, ExporterParameters parameters) { List<String> result = new ArrayList<String>(); if (parameters.getFileType() != ExportFileType.TAB_SEPARATED) { throw new InvalidArgumentException("Unhandled file type: " + parameters.getFileType()); @@ -1048,7 +1048,7 @@ public class ExporterService implements IExporterService { * alis for which identifier will be returned * @return identifier that should be used for a given alias */ - private String getId(Alias alias) { + private String getId(Element alias) { return alias.getAliasId(); } @@ -1066,7 +1066,7 @@ public class ExporterService implements IExporterService { models.addAll(model.getSubmodels()); Set<MiriamData> miriamDatas = new HashSet<>(); for (Model m : models) { - for (Alias element : m.getAliases()) { + for (Element element : m.getAliases()) { for (MiriamData md : element.getMiriamData()) { if (MiriamType.PUBMED.equals(md.getDataType())) { miriamDatas.add(md); diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/LayoutService.java b/service/src/main/java/lcsb/mapviewer/services/impl/LayoutService.java index 7727c2cc35..599b71bcf3 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/LayoutService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/LayoutService.java @@ -40,10 +40,10 @@ import lcsb.mapviewer.model.map.layout.GenericColorSchema; import lcsb.mapviewer.model.map.layout.InvalidColorSchemaException; import lcsb.mapviewer.model.map.layout.Layout; import lcsb.mapviewer.model.map.layout.LayoutStatus; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelSubmodelConnection; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.user.ObjectPrivilege; import lcsb.mapviewer.model.user.PrivilegeType; import lcsb.mapviewer.model.user.User; @@ -756,7 +756,7 @@ public class LayoutService implements ILayoutService { } sb.append("\t"); } else if (column.equals(ColorSchemaColumn.TYPE)) { - for (Class<? extends Alias> str : schema.getTypes()) { + for (Class<? extends Element> str : schema.getTypes()) { sb.append(str.getSimpleName() + ", "); } sb.append("\t"); @@ -812,7 +812,7 @@ public class LayoutService implements ILayoutService { } sb.append("\t"); } else if (column.equals(ColorSchemaColumn.TYPE)) { - for (Class<? extends Alias> str : schema.getTypes()) { + for (Class<? extends Element> str : schema.getTypes()) { sb.append(str.getSimpleName() + ", "); } sb.append("\t"); @@ -892,8 +892,8 @@ public class LayoutService implements ILayoutService { LightLayoutAliasViewFactory factory = new LightLayoutAliasViewFactory(); List<LightLayoutAliasView> result = new ArrayList<>(); for (Map.Entry<Object, ColorSchema> entry : command.getModifiedElements().entrySet()) { - if (entry.getKey() instanceof Alias) { - result.add(factory.create(new Pair<Alias, ColorSchema>((Alias) entry.getKey(), entry.getValue()))); + if (entry.getKey() instanceof Element) { + result.add(factory.create(new Pair<Element, ColorSchema>((Element) entry.getKey(), entry.getValue()))); } } return result; @@ -958,10 +958,10 @@ public class LayoutService implements ILayoutService { // TODO poor performance, improve it for (Map.Entry<Object, ColorSchema> entry : command.getModifiedElements().entrySet()) { - if (entry.getKey() instanceof Alias) { - Alias alias = (Alias) entry.getKey(); + if (entry.getKey() instanceof Element) { + Element alias = (Element) entry.getKey(); if (ids.contains(alias.getId())) { - result.add(factory.create(new Pair<Alias, ColorSchema>(alias, entry.getValue()))); + result.add(factory.create(new Pair<Element, ColorSchema>(alias, entry.getValue()))); } } } diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/ModelService.java b/service/src/main/java/lcsb/mapviewer/services/impl/ModelService.java index e465adb7c5..4752653eec 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/ModelService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/ModelService.java @@ -26,11 +26,11 @@ import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.layout.Layout; -import lcsb.mapviewer.model.map.layout.alias.Alias; 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.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.user.User; import lcsb.mapviewer.persist.dao.map.ModelDao; import lcsb.mapviewer.services.interfaces.ILayoutService; @@ -180,7 +180,7 @@ public class ModelService implements IModelService { if (model != null) { Set<Integer> pubmedIds = new HashSet<>(); - for (Alias element : model.getAliases()) { + for (Element element : model.getAliases()) { for (MiriamData md : element.getMiriamData()) { if (MiriamType.PUBMED.equals(md.getDataType())) { try { @@ -344,7 +344,7 @@ public class ModelService implements IModelService { if (model != null) { Set<MiriamData> pubmedIds = new HashSet<MiriamData>(); - for (Alias element : model.getAliases()) { + for (Element element : model.getAliases()) { pubmedIds.addAll(element.getMiriamData()); } for (Reaction reaction : model.getReactions()) { @@ -409,7 +409,7 @@ public class ModelService implements IModelService { } /** - * Returns list of {@link Alias aliases} for given identifiers. + * Returns list of {@link Element aliases} for given identifiers. * * @param model * model where aliases are located @@ -417,11 +417,11 @@ public class ModelService implements IModelService { * list of alias identifiers in a given submodel. Every {@link Pair} * contains information about {@link Model#getId() model identifier} * (in {@link Pair#left}) and - * {@link lcsb.mapviewer.model.map.layout.alias.Alias#getId() alias + * {@link lcsb.mapviewer.model.map.species.Element#getId() alias * identifier} (in {@link Pair#right}). - * @return list of {@link Alias aliases} for given identifiers + * @return list of {@link Element aliases} for given identifiers */ - private List<Alias> getAliasesByIds(Model model, List<Pair<Integer, Integer>> identifiers) { + private List<Element> getAliasesByIds(Model model, List<Pair<Integer, Integer>> identifiers) { Map<Integer, Set<Integer>> identifiersForMap = new HashMap<>(); for (Pair<Integer, Integer> pair : identifiers) { Set<Integer> set = identifiersForMap.get(pair.getLeft()); @@ -432,14 +432,14 @@ public class ModelService implements IModelService { set.add(pair.getRight()); } - List<Alias> result = new ArrayList<>(); + List<Element> result = new ArrayList<>(); List<Model> models = new ArrayList<>(); models.add(model); models.addAll(model.getSubmodels()); for (Model model2 : models) { Set<Integer> set = identifiersForMap.get(model2.getModelData().getId()); if (set != null) { - for (Alias alias : model2.getAliases()) { + for (Element alias : model2.getAliases()) { if (set.contains(alias.getId())) { result.add(alias); set.remove(alias.getId()); diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java b/service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java index f1fe2a0658..2668362530 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/ProjectService.java @@ -65,11 +65,11 @@ import lcsb.mapviewer.model.map.graph.DataMining; import lcsb.mapviewer.model.map.graph.DataMiningSet; import lcsb.mapviewer.model.map.layout.Layout; import lcsb.mapviewer.model.map.layout.LayoutStatus; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelData; import lcsb.mapviewer.model.map.model.ModelSubmodelConnection; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.user.ObjectPrivilege; import lcsb.mapviewer.model.user.PrivilegeType; import lcsb.mapviewer.model.user.User; @@ -783,7 +783,7 @@ public class ProjectService implements IProjectService { EventStorageLoggerAppender appender = new EventStorageLoggerAppender(); try { Logger.getRootLogger().addAppender(appender); - Set<Alias> nodes = new HashSet<>(); + Set<Element> nodes = new HashSet<>(); nodes.addAll(model.getAliases()); for (ModelSubmodelConnection connection : model.getSubmodelConnections()) { nodes.addAll(connection.getSubmodel().getAliases()); 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 4a9dc04c4a..e9e5789c5e 100644 --- a/service/src/main/java/lcsb/mapviewer/services/impl/SearchService.java +++ b/service/src/main/java/lcsb/mapviewer/services/impl/SearchService.java @@ -21,24 +21,24 @@ import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.DegradedAlias; -import lcsb.mapviewer.model.map.layout.alias.DrugAlias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.IonAlias; -import lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.SearchIndex; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; -import lcsb.mapviewer.model.map.layout.alias.UnknownAlias; +import lcsb.mapviewer.model.map.SearchIndex; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelSubmodelConnection; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.ReactionNode; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Degraded; +import lcsb.mapviewer.model.map.species.Drug; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.Ion; +import lcsb.mapviewer.model.map.species.Phenotype; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Rna; +import lcsb.mapviewer.model.map.species.SimpleMolecule; +import lcsb.mapviewer.model.map.species.Species; +import lcsb.mapviewer.model.map.species.Unknown; import lcsb.mapviewer.model.map.statistics.SearchType; import lcsb.mapviewer.persist.dao.map.ModelDao; import lcsb.mapviewer.services.interfaces.ISearchHistoryService; @@ -111,34 +111,34 @@ public class SearchService implements ISearchService { /** * This object maps class of elements on the map into short string prefixes - * used in the search query. For instance elements of the {@link ComplexAlias} + * used in the search query. For instance elements of the {@link Complex} * class could be searched with the prefix "complex" (example query: * "complex:alpha subcomplex"). */ - private Map<Class<? extends Alias>, String> speciesSearchPrefix = new HashMap<>(); + private Map<Class<? extends Element>, String> speciesSearchPrefix = new HashMap<>(); /** * This object maps short string prefixes into class of elements on the map * that will be searched. For instance prefix "complex" might refer to - * {@link ComplexAlias} class and and example query would look like: + * {@link Complex} class and and example query would look like: * "complex:alpha subcomplex". */ - private Map<String, Class<? extends Alias>> speciesSearchReversePrefix = new HashMap<>(); + private Map<String, Class<? extends Element>> speciesSearchReversePrefix = new HashMap<>(); /** * Default constructor that set list of prefixes used in the search queries. */ public SearchService() { - addSearchPrefix("complex", ComplexAlias.class); - addSearchPrefix("degrded", DegradedAlias.class); - addSearchPrefix("drug", DrugAlias.class); - addSearchPrefix("gene", GeneAlias.class); - addSearchPrefix("ion", IonAlias.class); - addSearchPrefix("phenotype", PhenotypeAlias.class); - addSearchPrefix("protein", ProteinAlias.class); - addSearchPrefix("rna", RnaAlias.class); - addSearchPrefix("molecule", SimpleMoleculeAlias.class); - addSearchPrefix("unknown", UnknownAlias.class); + addSearchPrefix("complex", Complex.class); + addSearchPrefix("degrded", Degraded.class); + addSearchPrefix("drug", Drug.class); + addSearchPrefix("gene", Gene.class); + addSearchPrefix("ion", Ion.class); + addSearchPrefix("phenotype", Phenotype.class); + addSearchPrefix("protein", Protein.class); + addSearchPrefix("rna", Rna.class); + addSearchPrefix("molecule", SimpleMolecule.class); + addSearchPrefix("unknown", Unknown.class); } /** @@ -149,7 +149,7 @@ public class SearchService implements ISearchService { * @param clazz * class for which this prefix stands */ - private void addSearchPrefix(String prefix, Class<? extends Alias> clazz) { + private void addSearchPrefix(String prefix, Class<? extends Element> clazz) { speciesSearchPrefix.put(clazz, prefix); speciesSearchReversePrefix.put(prefix, clazz); } @@ -231,17 +231,17 @@ public class SearchService implements ISearchService { * class type of the elements that limits the results * @return list of object found for the query string sorted by the score value */ - protected List<IHeavyView> searchByIndexedQuery(Model model, String query, int limit, Boolean perfectMatch, Class<? extends Alias> type) { + protected List<IHeavyView> searchByIndexedQuery(Model model, String query, int limit, Boolean perfectMatch, Class<? extends Element> type) { List<IHeavyView> result = new ArrayList<>(); 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, "")))); } else { - Set<Alias> aliases = model.getAliases(); + Set<Element> aliases = model.getAliases(); List<SearchResult> sortedResults = new ArrayList<SearchService.SearchResult>(); - for (Alias alias : aliases) { + for (Element alias : aliases) { if (type.isAssignableFrom(alias.getClass())) { List<SearchIndex> indexes = alias.getSearchIndexes(); if (indexes.size() == 0) { @@ -258,7 +258,7 @@ public class SearchService implements ISearchService { sortedResults.add(sResult); break; } - } else if (score > 0 || (query.equals("") && type != Alias.class)) { + } else if (score > 0 || (query.equals("") && type != Element.class)) { SearchResult sResult = new SearchResult(); sResult.setObj(alias); sResult.setScore(score); @@ -279,8 +279,8 @@ public class SearchService implements ISearchService { for (SearchResult searchResult : sortedResults) { if (searchResult.getObj() instanceof Reaction) { result.add(fullReactionViewFactory.create((Reaction) searchResult.getObj())); - } else if (searchResult.getObj() instanceof Alias) { - result.add(fullAliasViewFactory.create((Alias) searchResult.getObj())); + } else if (searchResult.getObj() instanceof Element) { + result.add(fullAliasViewFactory.create((Element) searchResult.getObj())); } else { throw new InvalidStateException("Unknown class type: " + searchResult.getObj().getClass()); } @@ -336,10 +336,10 @@ public class SearchService implements ISearchService { List<Object> results = new ArrayList<Object>(); - Set<Alias> aliases = params.getModel().getAliases(); + Set<Element> aliases = params.getModel().getAliases(); Point2D point = new Point2D.Double(params.getX(), params.getY()); - for (Alias alias : aliases) { - if (alias instanceof SpeciesAlias) { + for (Element alias : aliases) { + if (alias instanceof Species) { if (alias.contains(point)) { if (isVisible(alias, params)) { results.add(alias); @@ -364,8 +364,8 @@ public class SearchService implements ISearchService { result.addAll(reactionToResultList(r)); return result; } else if (nested) { - for (Alias alias : aliases) { - if (alias instanceof CompartmentAlias) { + for (Element alias : aliases) { + if (alias instanceof Compartment) { if (alias.contains(point)) { if (isVisible(alias, params)) { results.add(alias); @@ -377,10 +377,10 @@ public class SearchService implements ISearchService { } if (results.size() > 1) { - Alias alias = (Alias) results.get(0); + Element alias = (Element) results.get(0); for (Object obj : results) { - if (((Alias) (obj)).getSize() < alias.getSize()) { - alias = (Alias) obj; + if (((Element) (obj)).getSize() < alias.getSize()) { + alias = (Element) obj; } } results.clear(); @@ -390,8 +390,8 @@ public class SearchService implements ISearchService { return result; } else { Object obj = results.get(0); - if (obj instanceof Alias) { - result.add(fullAliasViewFactory.create((Alias) obj)); + if (obj instanceof Element) { + result.add(fullAliasViewFactory.create((Element) obj)); return result; } else if (obj instanceof Reaction) { result.addAll(reactionToResultList((Reaction) obj)); @@ -442,7 +442,7 @@ public class SearchService implements ISearchService { * @return <code>true</code> if alias is visible for the user, * <code>false</code> otherwise */ - private boolean isVisible(Alias alias, CoordinatesSearchParams params) { + private boolean isVisible(Element alias, CoordinatesSearchParams params) { if (params.getLevel() == null || params.getLayoutIdentfier() == null) { return true; } @@ -462,7 +462,7 @@ public class SearchService implements ISearchService { result.addAll(searchByMiriam(model, mt, limit)); } else { String indexQuery = searchIndexer.getQueryStringForIndex(query, speciesSearchReversePrefix.keySet()); - Class<? extends Alias> type = searchIndexer.getTypeForQuery(query, speciesSearchReversePrefix); + Class<? extends Element> type = searchIndexer.getTypeForQuery(query, speciesSearchReversePrefix); List<IHeavyView> partResult = searchByIndexedQuery(model, indexQuery, limit, perfectMatch, type); @@ -498,8 +498,8 @@ public class SearchService implements ISearchService { if (result.size() >= limit) { break; } - if (obj instanceof Alias) { - result.add(fullAliasViewFactory.create((Alias) obj)); + if (obj instanceof Element) { + result.add(fullAliasViewFactory.create((Element) obj)); } else if (obj instanceof Reaction) { result.addAll(reactionToResultList((Reaction) obj)); } else { @@ -537,8 +537,8 @@ public class SearchService implements ISearchService { for (Reaction reaction : model.getReactions()) { tmpList.add(new DistanceToObject(reaction, point)); } - for (Alias alias : model.getAliases()) { - if (alias instanceof SpeciesAlias) { + for (Element alias : model.getAliases()) { + if (alias instanceof Species) { tmpList.add(new DistanceToObject(alias, point)); } } @@ -589,7 +589,7 @@ public class SearchService implements ISearchService { * @param point * point from which the distance will be computed */ - DistanceToObject(Alias alias, Point2D point) { + DistanceToObject(Element alias, Point2D point) { reference = alias; distance = alias.getDistanceFromPoint(point); @@ -660,14 +660,14 @@ public class SearchService implements ISearchService { Map<String, List<String>> result = new HashMap<String, List<String>>(); Set<String> possibilities = new HashSet<String>(); - for (Alias alias : model.getAliases()) { - if (alias instanceof SpeciesAlias) { + for (Element alias : model.getAliases()) { + if (alias instanceof Species) { possibilities.addAll(getSearchPossibilitiesForAlias(alias)); } } for (ModelSubmodelConnection connection : model.getSubmodelConnections()) { - for (Alias alias : connection.getSubmodel().getModel().getAliases()) { - if (alias instanceof SpeciesAlias) { + for (Element alias : connection.getSubmodel().getModel().getAliases()) { + if (alias instanceof Species) { possibilities.addAll(getSearchPossibilitiesForAlias(alias)); } } @@ -715,7 +715,7 @@ public class SearchService implements ISearchService { * object for which we look for a list of searchable strings * @return the list of all human readable search possibilities for alias */ - private List<String> getSearchPossibilitiesForAlias(Alias element) { + private List<String> getSearchPossibilitiesForAlias(Element element) { List<String> result = new ArrayList<String>(); result.add(element.getName().trim().toLowerCase().replace(",", "")); for (String string : element.getSynonyms()) { diff --git a/service/src/main/java/lcsb/mapviewer/services/interfaces/IDataMiningService.java b/service/src/main/java/lcsb/mapviewer/services/interfaces/IDataMiningService.java index f0d7434918..231f5c6c88 100644 --- a/service/src/main/java/lcsb/mapviewer/services/interfaces/IDataMiningService.java +++ b/service/src/main/java/lcsb/mapviewer/services/interfaces/IDataMiningService.java @@ -8,10 +8,10 @@ import lcsb.mapviewer.common.IProgressUpdater; import lcsb.mapviewer.model.map.graph.DataMining; import lcsb.mapviewer.model.map.graph.DataMiningSet; import lcsb.mapviewer.model.map.graph.DataMiningType; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelData; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.utils.InvalidDataMiningInputFile; import lcsb.mapviewer.services.view.DataMiningSetView; @@ -30,7 +30,7 @@ public interface IDataMiningService { * alias to be investigated * @return set of suggested connections */ - Collection<DataMining> getMissingConnections(Alias alias); + Collection<DataMining> getMissingConnections(Element alias); /** * Adds new suggested connection. @@ -69,7 +69,7 @@ public interface IDataMiningService { * model from which suggested connections should taken * @return set of elements that has suggested connection to a geneName. */ - Collection<Alias> getSpeciesWithMissingConnectionsByGeneName(Model model, String geneName); + Collection<Element> getSpeciesWithMissingConnectionsByGeneName(Model model, String geneName); /** * Removes all suggested connections for model. @@ -107,7 +107,7 @@ public interface IDataMiningService { * @throws InvalidDataMiningInputFile * thrown when the input file is invalid */ - Set<DataMining> parseData(String filename, DataMiningType type, Collection<Alias> nodes, Set<Reaction> reactions, IProgressUpdater updater) + Set<DataMining> parseData(String filename, DataMiningType type, Collection<Element> nodes, Set<Reaction> reactions, IProgressUpdater updater) throws IOException, InvalidDataMiningInputFile; /** @@ -126,7 +126,7 @@ public interface IDataMiningService { * @throws InvalidDataMiningInputFile * thrown when the input file is invalid */ - Set<DataMining> parseData(DataMiningSet dataMiningSet, Collection<Alias> nodes, Set<Reaction> reactions, IProgressUpdater updater) + Set<DataMining> parseData(DataMiningSet dataMiningSet, Collection<Element> nodes, Set<Reaction> reactions, IProgressUpdater updater) throws InvalidDataMiningInputFile; /** diff --git a/service/src/main/java/lcsb/mapviewer/services/interfaces/IExporterService.java b/service/src/main/java/lcsb/mapviewer/services/interfaces/IExporterService.java index 0a33f3f3cb..83af2d42fc 100644 --- a/service/src/main/java/lcsb/mapviewer/services/interfaces/IExporterService.java +++ b/service/src/main/java/lcsb/mapviewer/services/interfaces/IExporterService.java @@ -8,7 +8,7 @@ import java.util.List; import java.util.Set; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.services.utils.data.ExportColumn; import lcsb.mapviewer.services.utils.data.ExportFileType; @@ -66,12 +66,12 @@ public interface IExporterService { * List of compartment aliases that should be included in export (empty list * means that everything should be included). */ - private Set<CompartmentAlias> includedAliases = new HashSet<CompartmentAlias>(); + private Set<Compartment> includedAliases = new HashSet<Compartment>(); /** * List of compartment aliases that should be excluded in export (empty list * means that anything should be excluded). */ - private Set<CompartmentAlias> excludedAliases = new HashSet<CompartmentAlias>(); + private Set<Compartment> excludedAliases = new HashSet<Compartment>(); /** * If false default complex name will be used for exporting complexes. If * true then the name will be a concatenated string of all complex @@ -122,7 +122,7 @@ public interface IExporterService { for (Model modelElement : models) { includedAliases.clear(); for (String string : included) { - for (CompartmentAlias alias : modelElement.getCompartmentsAliases()) { + for (Compartment alias : modelElement.getCompartmentsAliases()) { if (alias.getName().equalsIgnoreCase(string)) { includedAliases.add(alias); } @@ -131,7 +131,7 @@ public interface IExporterService { excludedAliases.clear(); for (String string : excluded) { - for (CompartmentAlias alias : modelElement.getCompartmentsAliases()) { + for (Compartment alias : modelElement.getCompartmentsAliases()) { if (alias.getName().equalsIgnoreCase(string)) { excludedAliases.add(alias); } @@ -153,7 +153,7 @@ public interface IExporterService { if (models.size() > 0) { for (Model model : models) { - for (CompartmentAlias alias : model.getCompartmentsAliases()) { + for (Compartment alias : model.getCompartmentsAliases()) { if (alias.getName().equalsIgnoreCase(included)) { includedAliases.add(alias); } @@ -189,7 +189,7 @@ public interface IExporterService { if (models.size() > 0) { for (Model model : models) { - for (CompartmentAlias alias : model.getCompartmentsAliases()) { + for (Compartment alias : model.getCompartmentsAliases()) { if (alias.getName().equalsIgnoreCase(excluded)) { excludedAliases.add(alias); } @@ -206,7 +206,7 @@ public interface IExporterService { * new element in {@link #excluded} * @return object with all parameters set */ - public ExporterParameters excluded(CompartmentAlias excluded) { + public ExporterParameters excluded(Compartment excluded) { this.excluded.add(excluded.getName()); excludedAliases.add(excluded); @@ -234,8 +234,8 @@ public interface IExporterService { * list of elements to add to {@link #excluded} * @return object with all parameters set */ - public ExporterParameters excluded(Collection<CompartmentAlias> excluded) { - for (CompartmentAlias string : excluded) { + public ExporterParameters excluded(Collection<Compartment> excluded) { + for (Compartment string : excluded) { excluded(string); } return this; @@ -451,7 +451,7 @@ public interface IExporterService { * @return the includedAliases * @see #includedAliases */ - public Set<CompartmentAlias> getIncludedAliases() { + public Set<Compartment> getIncludedAliases() { return includedAliases; } @@ -459,7 +459,7 @@ public interface IExporterService { * @return the excludedAliases * @see #excludedAliases */ - public Set<CompartmentAlias> getExcludedAliases() { + public Set<Compartment> getExcludedAliases() { return excludedAliases; } diff --git a/service/src/main/java/lcsb/mapviewer/services/interfaces/ILayoutService.java b/service/src/main/java/lcsb/mapviewer/services/interfaces/ILayoutService.java index 3ac6a7c631..98a3696f4e 100644 --- a/service/src/main/java/lcsb/mapviewer/services/interfaces/ILayoutService.java +++ b/service/src/main/java/lcsb/mapviewer/services/interfaces/ILayoutService.java @@ -457,7 +457,7 @@ public interface ILayoutService { List<LightLayoutReactionView> getReactionsForLayout(Model model, int layoutId); /** - * Returns mapping between {@link lcsb.mapviewer.model.map.layout.alias.Alias + * Returns mapping between {@link lcsb.mapviewer.model.map.species.Element * Alias}/ {@link lcsb.mapviewer.model.map.reaction.Reaction Reaction} and * {@link ColorSchema} used for coloring object in the layout given in the * parameter. @@ -484,7 +484,7 @@ public interface ILayoutService { * list of alias identifiers in a given submodel. Every {@link Pair} * contains information about {@link Model#getId() model identifier} * (in {@link Pair#left}) and - * {@link lcsb.mapviewer.model.map.layout.alias.Alias#getId() alias + * {@link lcsb.mapviewer.model.map.species.Element#getId() alias * identifier} (in {@link Pair#right}). * @return a list of {@link LightLayoutAliasView aliases} that are visualized * in a {@link lcsb.mapviewer.model.map.layout.Layout} diff --git a/service/src/main/java/lcsb/mapviewer/services/interfaces/IModelService.java b/service/src/main/java/lcsb/mapviewer/services/interfaces/IModelService.java index b5ed240210..6dd73441b5 100644 --- a/service/src/main/java/lcsb/mapviewer/services/interfaces/IModelService.java +++ b/service/src/main/java/lcsb/mapviewer/services/interfaces/IModelService.java @@ -1,145 +1,145 @@ -package lcsb.mapviewer.services.interfaces; - -import java.util.List; - -import lcsb.mapviewer.common.IProgressUpdater; -import lcsb.mapviewer.common.Pair; -import lcsb.mapviewer.model.map.model.Model; -import lcsb.mapviewer.model.map.model.ModelData; -import lcsb.mapviewer.model.user.User; -import lcsb.mapviewer.services.search.data.FullAliasView; -import lcsb.mapviewer.services.search.data.LightAliasView; -import lcsb.mapviewer.services.search.data.LightReactionView; -import lcsb.mapviewer.services.view.ModelView; -import lcsb.mapviewer.services.view.ProjectView; - -/** - * Service that manages models (maps). - * - * @author Piotr Gawron - * - */ -public interface IModelService { - - /** - * Returns the newest model for the project identified by the - * {@link lcsb.mapviewer.model.Project#projectId project identifier}. - * - * @param projectId - * {@link lcsb.mapviewer.model.Project#projectId project identifier} - * @return the newest model for the project - */ - Model getLastModelByProjectId(String projectId); - - /** - * Caches information about all pubmed articles for the given model. - * - * @param model - * model in which we are caching the data - * @param updater - * callback interface that update progress information - */ - void cacheAllPubmedIds(Model model, IProgressUpdater updater); - - /** - * Updates information in the model with the one taken from selectedProject. - * - * @param model - * model to update - * @param selectedProject - * source of data that should be used in the update - */ - void updateModel(ModelData model, ProjectView selectedProject); - - /** - * Removes model from application cache. - * - * @param model - * model to remove - */ - void removeModelFromCache(Model model); - - /** - * Caches information about all miriam resources in the model. - * - * @param model - * model in which we are caching the data - * @param updater - * callback interface that update progress information - */ - void cacheAllMiriamLinks(Model model, IProgressUpdater updater); - - /** - * Returns {@link ModelView} for the given model. - * - * @param model - * model fgor which view is returned. - * @param user - * user for which custom layouts should be added - * @return {@link ModelView} for the given {@link Model} - */ - ModelView getModelView(Model model, User user); - - /** - * Removes model from application cache. - * - * @param model - * model to remove - */ - void removeModelFromCache(ModelData model); - - /** - * Removes model from application cache. - * - * @param projectId - * identifier of the project - */ - void removeModelFromCacheByProjectId(String projectId); - - /** - * Returns list of {@link LightAliasView aliases} for given identifiers. - * - * @param model - * model where aliases are located - * @param identifiers - * list of alias identifiers in a given submodel. Every {@link Pair} - * contains information about {@link Model#getId() model identifier} - * (in {@link Pair#left}) and - * {@link lcsb.mapviewer.model.map.layout.alias.Alias#getId() alias - * identifier} (in {@link Pair#right}). - * @return list of {@link LightAliasView aliases} for given identifiers - */ - List<LightAliasView> getLightAliasesByIds(Model model, List<Pair<Integer, Integer>> identifiers); - - /** - * Returns list of {@link LightReactionView reactions} for given identifiers. - * - * @param model - * model where aliases are located - * @param identifiers - * list of reaction identifiers in a given submodel. Every - * {@link Pair} contains information about {@link Model#getId() model - * identifier} (in {@link Pair#left}) and - * {@link lcsb.mapviewer.model.map.reaction.Reaction#getId() reaction - * identifier} (in {@link Pair#right}). - * @return list of {@link LightReactionView reactions} for given identifiers - */ - List<LightReactionView> getLightReactionsByIds(Model model, List<Pair<Integer, Integer>> identifiers); - - /** - * Returns list of {@link FullAliasView aliases} (with full information) for - * given identifiers. - * - * @param model - * model where aliases are located - * @param identifiers - * list of alias identifiers in a given submodel. Every {@link Pair} - * contains information about {@link Model#getId() model identifier} - * (in {@link Pair#left}) and - * {@link lcsb.mapviewer.model.map.layout.alias.Alias#getId() alias - * identifier} (in {@link Pair#right}). - * @return list of {@link FullAliasView aliases} (with full information about - * aliases) for given identifiers - */ - List<FullAliasView> getFullAliasesByIds(Model model, List<Pair<Integer, Integer>> identifiers); -} +package lcsb.mapviewer.services.interfaces; + +import java.util.List; + +import lcsb.mapviewer.common.IProgressUpdater; +import lcsb.mapviewer.common.Pair; +import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.model.ModelData; +import lcsb.mapviewer.model.user.User; +import lcsb.mapviewer.services.search.data.FullAliasView; +import lcsb.mapviewer.services.search.data.LightAliasView; +import lcsb.mapviewer.services.search.data.LightReactionView; +import lcsb.mapviewer.services.view.ModelView; +import lcsb.mapviewer.services.view.ProjectView; + +/** + * Service that manages models (maps). + * + * @author Piotr Gawron + * + */ +public interface IModelService { + + /** + * Returns the newest model for the project identified by the + * {@link lcsb.mapviewer.model.Project#projectId project identifier}. + * + * @param projectId + * {@link lcsb.mapviewer.model.Project#projectId project identifier} + * @return the newest model for the project + */ + Model getLastModelByProjectId(String projectId); + + /** + * Caches information about all pubmed articles for the given model. + * + * @param model + * model in which we are caching the data + * @param updater + * callback interface that update progress information + */ + void cacheAllPubmedIds(Model model, IProgressUpdater updater); + + /** + * Updates information in the model with the one taken from selectedProject. + * + * @param model + * model to update + * @param selectedProject + * source of data that should be used in the update + */ + void updateModel(ModelData model, ProjectView selectedProject); + + /** + * Removes model from application cache. + * + * @param model + * model to remove + */ + void removeModelFromCache(Model model); + + /** + * Caches information about all miriam resources in the model. + * + * @param model + * model in which we are caching the data + * @param updater + * callback interface that update progress information + */ + void cacheAllMiriamLinks(Model model, IProgressUpdater updater); + + /** + * Returns {@link ModelView} for the given model. + * + * @param model + * model fgor which view is returned. + * @param user + * user for which custom layouts should be added + * @return {@link ModelView} for the given {@link Model} + */ + ModelView getModelView(Model model, User user); + + /** + * Removes model from application cache. + * + * @param model + * model to remove + */ + void removeModelFromCache(ModelData model); + + /** + * Removes model from application cache. + * + * @param projectId + * identifier of the project + */ + void removeModelFromCacheByProjectId(String projectId); + + /** + * Returns list of {@link LightAliasView aliases} for given identifiers. + * + * @param model + * model where aliases are located + * @param identifiers + * list of alias identifiers in a given submodel. Every {@link Pair} + * contains information about {@link Model#getId() model identifier} + * (in {@link Pair#left}) and + * {@link lcsb.mapviewer.model.map.species.Element#getId() alias + * identifier} (in {@link Pair#right}). + * @return list of {@link LightAliasView aliases} for given identifiers + */ + List<LightAliasView> getLightAliasesByIds(Model model, List<Pair<Integer, Integer>> identifiers); + + /** + * Returns list of {@link LightReactionView reactions} for given identifiers. + * + * @param model + * model where aliases are located + * @param identifiers + * list of reaction identifiers in a given submodel. Every + * {@link Pair} contains information about {@link Model#getId() model + * identifier} (in {@link Pair#left}) and + * {@link lcsb.mapviewer.model.map.reaction.Reaction#getId() reaction + * identifier} (in {@link Pair#right}). + * @return list of {@link LightReactionView reactions} for given identifiers + */ + List<LightReactionView> getLightReactionsByIds(Model model, List<Pair<Integer, Integer>> identifiers); + + /** + * Returns list of {@link FullAliasView aliases} (with full information) for + * given identifiers. + * + * @param model + * model where aliases are located + * @param identifiers + * list of alias identifiers in a given submodel. Every {@link Pair} + * contains information about {@link Model#getId() model identifier} + * (in {@link Pair#left}) and + * {@link lcsb.mapviewer.model.map.species.Element#getId() alias + * identifier} (in {@link Pair#right}). + * @return list of {@link FullAliasView aliases} (with full information about + * aliases) for given identifiers + */ + List<FullAliasView> getFullAliasesByIds(Model model, List<Pair<Integer, Integer>> identifiers); +} diff --git a/service/src/main/java/lcsb/mapviewer/services/search/SearchResultFactory.java b/service/src/main/java/lcsb/mapviewer/services/search/SearchResultFactory.java index 5597b0a318..080f82df06 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/SearchResultFactory.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/SearchResultFactory.java @@ -14,13 +14,13 @@ import lcsb.mapviewer.annotation.data.TargetType; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Rna; +import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.services.search.data.ElementIdentifier; import lcsb.mapviewer.services.search.data.ElementIdentifier.ElementIdentifierType; import lcsb.mapviewer.services.search.db.GeneRow; @@ -87,7 +87,7 @@ public abstract class SearchResultFactory<T, S extends ISearchResultView> extend return null; } else if (ElementIdentifierType.ALIAS.getJsName().equalsIgnoreCase(element.getType())) { Model m = model.getSubmodelById(element.getModelId()); - Alias alias = m.getAliasByDbId(Integer.valueOf(element.getObjectId())); + Element alias = m.getAliasByDbId(Integer.valueOf(element.getObjectId())); if (alias == null) { logger.warn("Alias with object id = " + element.getObjectId() + " is unknown."); return null; @@ -117,11 +117,11 @@ public abstract class SearchResultFactory<T, S extends ISearchResultView> extend * @param target * drug target to check * @param element - * {@link Alias} to check + * {@link Element} to check * @return <code>true</code> if drug target can target element, * <code>false</code> otherwise */ - protected boolean elementMatch(TargetView target, Alias element) { + protected boolean elementMatch(TargetView target, Element element) { if (target.getType().equals(TargetType.COMPLEX_PROTEIN.getCommonName())) { MiriamData targetAnnotation = annotationViewFactory.viewToObject(target.getAnnotation()); if (MiriamType.CHEMBL_TARGET.equals(targetAnnotation.getDataType())) { @@ -134,14 +134,14 @@ public abstract class SearchResultFactory<T, S extends ISearchResultView> extend ids.add(row.getAnnotation().getName()); } - if (element instanceof ComplexAlias) { - ComplexAlias complex = (ComplexAlias) element; - Set<SpeciesAlias> speciesSet = complex.getAllSimpleChildren(); + if (element instanceof Complex) { + Complex complex = (Complex) element; + Set<Species> speciesSet = complex.getAllSimpleChildren(); if (speciesSet.size() != ids.size()) { return false; } - for (Alias id : speciesSet) { + for (Element id : speciesSet) { if (!ids.contains(id.getName())) { return false; } @@ -161,7 +161,7 @@ public abstract class SearchResultFactory<T, S extends ISearchResultView> extend if (targetAnnotation != null && element.getMiriamData().contains(targetAnnotation)) { return true; } - if (element instanceof ProteinAlias || element instanceof RnaAlias || element instanceof GeneAlias) { + if (element instanceof Protein || element instanceof Rna || element instanceof Gene) { if (target.getProteins().size() > 0) { String hgncId = target.getProteins().get(0).getAnnotation().getName(); if (element.getName().equalsIgnoreCase(hgncId)) { @@ -171,7 +171,7 @@ public abstract class SearchResultFactory<T, S extends ISearchResultView> extend } return false; } else if (target.getType().equals(TargetType.PROTEIN_FAMILY.getCommonName())) { - if (element instanceof ProteinAlias || element instanceof RnaAlias || element instanceof GeneAlias) { + if (element instanceof Protein || element instanceof Rna || element instanceof Gene) { String hgncId = target.getProteins().get(0).getAnnotation().getName(); if (element.getName().equalsIgnoreCase(hgncId)) { return true; diff --git a/service/src/main/java/lcsb/mapviewer/services/search/comment/FullCommentViewFactory.java b/service/src/main/java/lcsb/mapviewer/services/search/comment/FullCommentViewFactory.java index 8a5d4112be..928f736018 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/comment/FullCommentViewFactory.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/comment/FullCommentViewFactory.java @@ -11,9 +11,9 @@ import com.google.gson.Gson; import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.map.Comment; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.overlay.IconManager; import lcsb.mapviewer.services.search.SearchResultFactory; import lcsb.mapviewer.services.search.data.ElementIdentifier; @@ -44,7 +44,7 @@ public class FullCommentViewFactory extends SearchResultFactory<List<Comment>, F if (comment.getTableName().getName().contains("Reaction")) { type = Reaction.class; } else { - type = Alias.class; + type = Element.class; } } else { point.setLocation(comment.getCoordinates().getX(), comment.getCoordinates().getY()); @@ -71,7 +71,7 @@ public class FullCommentViewFactory extends SearchResultFactory<List<Comment>, F if (Reaction.class.equals(comment.getType())) { result .add(new ElementIdentifier(comment.getIdObject(), comment.getModelId(), ElementIdentifierType.REACTION, IconManager.getInstance().getCommentIcon())); - } else if (Alias.class.equals(comment.getType())) { + } else if (Element.class.equals(comment.getType())) { result.add(new ElementIdentifier(comment.getIdObject(), comment.getModelId(), ElementIdentifierType.ALIAS, IconManager.getInstance().getCommentIcon())); } else if (Point2D.class.equals(comment.getType())) { result.add(new ElementIdentifier(comment.getIdObject(), comment.getModelId(), ElementIdentifierType.POINT, IconManager.getInstance().getCommentIcon())); diff --git a/service/src/main/java/lcsb/mapviewer/services/search/data/ElementIdentifier.java b/service/src/main/java/lcsb/mapviewer/services/search/data/ElementIdentifier.java index 84ba728014..50cdc872bb 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/data/ElementIdentifier.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/data/ElementIdentifier.java @@ -4,7 +4,7 @@ import java.io.Serializable; import org.apache.log4j.Logger; -import lcsb.mapviewer.model.map.layout.alias.Alias; +import lcsb.mapviewer.model.map.species.Element; /** * Light class identifing element to visualize on map in a browser. @@ -144,14 +144,14 @@ public class ElementIdentifier implements Serializable { } /** - * Constructor creating object from {@link Alias}. + * Constructor creating object from {@link Element}. * * @param speciesAlias - * {@link Alias} from which {@link ElementIdentifier} is created + * {@link Element} from which {@link ElementIdentifier} is created * @param icon * {@link #icon} */ - public ElementIdentifier(Alias speciesAlias, String icon) { + public ElementIdentifier(Element speciesAlias, String icon) { this(speciesAlias.getId(), speciesAlias.getModel().getId(), ElementIdentifierType.ALIAS, icon); } diff --git a/service/src/main/java/lcsb/mapviewer/services/search/data/FullAliasView.java b/service/src/main/java/lcsb/mapviewer/services/search/data/FullAliasView.java index 6c7cc8c1b9..05818c2851 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/data/FullAliasView.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/data/FullAliasView.java @@ -8,8 +8,8 @@ import java.util.Map; import org.apache.log4j.Logger; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.services.search.IHeavyView; import lcsb.mapviewer.services.view.AnnotationView; @@ -94,113 +94,113 @@ public class FullAliasView extends LightAliasView implements IHeavyView { /** * Description. * - * @see Alias#notes + * @see Element#notes */ private String notes; /** * Type of the alias. * - * @see Alias#getStringType() + * @see Element#getStringType() */ private String type; /** * Symbol of the element. * - * @see Alias#symbol + * @see Element#symbol */ private String symbol; /** * Full name of the element. * - * @see Alias#fullName + * @see Element#fullName */ private String fullName; /** * Abbreviation of the element. * - * @see Alias#abbreviation + * @see Element#abbreviation */ private String abbreviation; /** * Formula describing the element. * - * @see Alias#formula + * @see Element#formula */ private String formula; /** * Charge of the element. * - * @see SpeciesAlias#charge + * @see Species#charge */ private Integer charge; /** * Initial amount of species. * - * @see SpeciesAlias#initialAmount + * @see Species#initialAmount */ private Integer initialAmount = null; /** * Initial concentration of species. * - * @see SpeciesAlias#initialConcentration + * @see Species#initialConcentration */ private Integer initialConcentration = null; /** * Is only substance units allowed in a species. * - * @see SpeciesAlias#onlySubstanceUnits + * @see Species#onlySubstanceUnits */ private Boolean onlySubstanceUnits = null; /** * Name of the element. * - * @see Alias#name + * @see Element#name */ private String name = ""; /** - * Name of the {@link Alias#model}. + * Name of the {@link Element#model}. */ private String modelName; /** - * Name of the {@link Alias#submodel}. + * Name of the {@link Element#submodel}. */ private String submodelName; /** - * Id of the {@link Alias#submodel}. + * Id of the {@link Element#submodel}. */ private String submodelId; /** * List of synonyms of the element. * - * @see Alias#synonyms + * @see Element#synonyms */ private List<String> synonyms = new ArrayList<>(); /** * List of former symbols used by the entity represented by this element. * - * @see Alias#formerSymbols + * @see Element#formerSymbols */ private List<String> formerSymbols = new ArrayList<>(); /** * List of references for this element. * - * @see Alias#miriamData + * @see Element#miriamData */ private List<AnnotationView> references = new ArrayList<>(); @@ -218,7 +218,7 @@ public class FullAliasView extends LightAliasView implements IHeavyView { * @param icon * string with icon that should be used to visualize this alias */ - protected FullAliasView(Alias element, String icon) { + protected FullAliasView(Element element, String icon) { super(element, icon); setModelName(element.getModel().getName()); if (element != null) { @@ -231,8 +231,8 @@ public class FullAliasView extends LightAliasView implements IHeavyView { setSymbol(element.getSymbol()); addSynonyms(element.getSynonyms()); setType(element.getStringType()); - if (element instanceof SpeciesAlias) { - SpeciesAlias species = (SpeciesAlias) element; + if (element instanceof Species) { + Species species = (Species) element; setCharge(species.getCharge()); setInitialAmount(species.getInitialAmount()); setInitialConcentration(species.getInitialConcentration()); diff --git a/service/src/main/java/lcsb/mapviewer/services/search/data/FullAliasViewFactory.java b/service/src/main/java/lcsb/mapviewer/services/search/data/FullAliasViewFactory.java index d50755877a..7a3b63d52e 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/data/FullAliasViewFactory.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/data/FullAliasViewFactory.java @@ -24,10 +24,10 @@ import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.graph.DataMining; import lcsb.mapviewer.model.map.graph.DataMiningSet; import lcsb.mapviewer.model.map.graph.DataMiningType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ModificationResidueAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Species; +import lcsb.mapviewer.model.map.species.field.ModificationResidue; import lcsb.mapviewer.services.interfaces.IDataMiningService; import lcsb.mapviewer.services.overlay.ChebiTreeRow; import lcsb.mapviewer.services.search.ElementViewFactory; @@ -43,7 +43,7 @@ import lcsb.mapviewer.services.view.DataMiningViewFactory; * @author Piotr Gawron * */ -public class FullAliasViewFactory extends ElementViewFactory<Alias, FullAliasView> { +public class FullAliasViewFactory extends ElementViewFactory<Element, FullAliasView> { /** * How many rows with data mining information should be presented to the user. @@ -86,12 +86,12 @@ public class FullAliasViewFactory extends ElementViewFactory<Alias, FullAliasVie private ChebiAnnotator chebiBackend; @Override - public FullAliasView create(Alias alias) { + public FullAliasView create(Element alias) { return create(alias, null); } /** - * Creates {@link FullAliasView} from given {@link Alias}. + * Creates {@link FullAliasView} from given {@link Element}. * * @param element * alias for which view is created @@ -99,7 +99,7 @@ public class FullAliasViewFactory extends ElementViewFactory<Alias, FullAliasVie * icon that should be assigned to the view * @return {@link FullAliasView} for given alias */ - public FullAliasView create(Alias element, String icon) { + public FullAliasView create(Element element, String icon) { FullAliasView result = new FullAliasView(element, icon); if (element != null) { result.addReferences(annotationViewFactory.createList(element.getMiriamData())); @@ -153,7 +153,7 @@ public class FullAliasViewFactory extends ElementViewFactory<Alias, FullAliasVie } } } - if (element instanceof ProteinAlias) { + if (element instanceof Protein) { result.addOther("posttranslationalModifications", getPosttransationalModifications(element)); } @@ -170,12 +170,12 @@ public class FullAliasViewFactory extends ElementViewFactory<Alias, FullAliasVie * @return list of {@link PosttransationalModification} objects for object * alias */ - private List<PosttransationalModification> getPosttransationalModifications(Alias alias) { + private List<PosttransationalModification> getPosttransationalModifications(Element alias) { List<PosttransationalModification> result = new ArrayList<PosttransationalModification>(); - if (alias instanceof ProteinAlias) { - List<ModificationResidueAlias> modifications = ((ProteinAlias) alias).getModificationResidues(); + if (alias instanceof Protein) { + List<ModificationResidue> modifications = ((Protein) alias).getModificationResidues(); if (modifications.size() > 0) { - for (ModificationResidueAlias residue : modifications) { + for (ModificationResidue residue : modifications) { if (residue.getState() != null) { PosttransationalModification modification = new PosttransationalModification(); modification.setName(residue.getState().getFullName()); @@ -202,11 +202,11 @@ public class FullAliasViewFactory extends ElementViewFactory<Alias, FullAliasVie * max elements that should be presented * @return html table with data mining information */ - protected List<List<DataMiningView>> getDataMiningInformation(Alias alias, int maxMissingConnections) { + protected List<List<DataMiningView>> getDataMiningInformation(Element alias, int maxMissingConnections) { List<List<DataMiningView>> result = new ArrayList<>(); List<DataMiningView> enricoList = new ArrayList<>(); List<DataMiningView> mariaList = new ArrayList<>(); - if (!(alias instanceof SpeciesAlias)) { + if (!(alias instanceof Species)) { return result; } if (dataMiningService != null) { diff --git a/service/src/main/java/lcsb/mapviewer/services/search/data/LightAliasView.java b/service/src/main/java/lcsb/mapviewer/services/search/data/LightAliasView.java index aaa901ea9e..7c1c12657e 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/data/LightAliasView.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/data/LightAliasView.java @@ -1,104 +1,104 @@ -package lcsb.mapviewer.services.search.data; - -import java.awt.geom.Rectangle2D; - -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.services.search.ElementView; -import lcsb.mapviewer.services.search.ILightView; - -/** - * Light {@link ElementView view} for alias representing data that should be - * send to client. - * - * @author Piotr Gawron - * - */ -public class LightAliasView extends ElementView implements ILightView { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * Coordinates of the alias. - */ - private Rectangle2D bounds; - - /** - * Icon representing this alias on the map. - */ - private String icon; - - /** - * Default constructor. - * - * @param alias - * original {@link Alias} from which the object is created - * @param icon - * {@link #icon} - icon representing this alias on the map - */ - protected LightAliasView(Alias alias, String icon) { - super(alias.getId(), alias.getModel().getId()); - if (alias != null) { - this.bounds = new Rectangle2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight()); - } - setIcon(icon); - } - - /** - * Constructory copying data from the original object. - * - * @param original - * original object from which data will be copied - */ - protected LightAliasView(LightAliasView original) { - super(original.getUniqueId(), original.getModelId()); - setBounds( - new Rectangle2D.Double(original.getBounds().getX(), original.getBounds().getY(), original.getBounds().getWidth(), original.getBounds().getHeight())); - setIcon(original.getIcon()); - - } - - /** - * Constructor that should be used only for (de)serialization. - */ - protected LightAliasView() { - super(); - } - - /** - * @return the bounds - * @see #bounds - */ - public Rectangle2D getBounds() { - return bounds; - } - - /** - * @param bounds - * the bounds to set - * @see #bounds - */ - public void setBounds(Rectangle2D bounds) { - this.bounds = bounds; - } - - /** - * @return the icon - * @see #icon - */ - public String getIcon() { - return icon; - } - - /** - * @param icon - * the icon to set - * @see #icon - */ - public void setIcon(String icon) { - this.icon = icon; - } - -} +package lcsb.mapviewer.services.search.data; + +import java.awt.geom.Rectangle2D; + +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.services.search.ElementView; +import lcsb.mapviewer.services.search.ILightView; + +/** + * Light {@link ElementView view} for alias representing data that should be + * send to client. + * + * @author Piotr Gawron + * + */ +public class LightAliasView extends ElementView implements ILightView { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Coordinates of the alias. + */ + private Rectangle2D bounds; + + /** + * Icon representing this alias on the map. + */ + private String icon; + + /** + * Default constructor. + * + * @param alias + * original {@link Element} from which the object is created + * @param icon + * {@link #icon} - icon representing this alias on the map + */ + protected LightAliasView(Element alias, String icon) { + super(alias.getId(), alias.getModel().getId()); + if (alias != null) { + this.bounds = new Rectangle2D.Double(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight()); + } + setIcon(icon); + } + + /** + * Constructory copying data from the original object. + * + * @param original + * original object from which data will be copied + */ + protected LightAliasView(LightAliasView original) { + super(original.getUniqueId(), original.getModelId()); + setBounds( + new Rectangle2D.Double(original.getBounds().getX(), original.getBounds().getY(), original.getBounds().getWidth(), original.getBounds().getHeight())); + setIcon(original.getIcon()); + + } + + /** + * Constructor that should be used only for (de)serialization. + */ + protected LightAliasView() { + super(); + } + + /** + * @return the bounds + * @see #bounds + */ + public Rectangle2D getBounds() { + return bounds; + } + + /** + * @param bounds + * the bounds to set + * @see #bounds + */ + public void setBounds(Rectangle2D bounds) { + this.bounds = bounds; + } + + /** + * @return the icon + * @see #icon + */ + public String getIcon() { + return icon; + } + + /** + * @param icon + * the icon to set + * @see #icon + */ + public void setIcon(String icon) { + this.icon = icon; + } + +} diff --git a/service/src/main/java/lcsb/mapviewer/services/search/data/LightAliasViewFactory.java b/service/src/main/java/lcsb/mapviewer/services/search/data/LightAliasViewFactory.java index 8037197ab2..c3529e4861 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/data/LightAliasViewFactory.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/data/LightAliasViewFactory.java @@ -1,59 +1,59 @@ -package lcsb.mapviewer.services.search.data; - -import org.apache.log4j.Logger; - -import com.google.gson.Gson; - -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.services.search.ElementViewFactory; -import lcsb.mapviewer.services.search.ILightView; - -/** - * Factory class for {@link LightAliasView} class. - * - * @author Piotr Gawron - * - */ -public class LightAliasViewFactory extends ElementViewFactory<Alias, LightAliasView> { - - /** - * Default class logger. - */ - @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(LightAliasViewFactory.class); - - @Override - public LightAliasView create(Alias alias) { - return create(alias, null); - } - - /** - * Creates {@link LightAliasView} for {@link Alias}. - * - * @param alias - * alias for which view is created - * @param icon - * icon that should be assigned to the view - * @return {@link LightAliasView} for {@link Alias} - */ - public LightAliasView create(Alias alias, String icon) { - LightAliasView result = new LightAliasView(alias, icon); - return result; - } - - @Override - public String createGson(LightAliasView object) { - return new Gson().toJson(object); - } - - /** - * Creates {@link ILightView} from {@link FullAliasView}. - * - * @param object - * original object - * @return new light object - */ - public ILightView create(FullAliasView object) { - return new LightAliasView(object); - } -} +package lcsb.mapviewer.services.search.data; + +import org.apache.log4j.Logger; + +import com.google.gson.Gson; + +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.services.search.ElementViewFactory; +import lcsb.mapviewer.services.search.ILightView; + +/** + * Factory class for {@link LightAliasView} class. + * + * @author Piotr Gawron + * + */ +public class LightAliasViewFactory extends ElementViewFactory<Element, LightAliasView> { + + /** + * Default class logger. + */ + @SuppressWarnings("unused") + private static Logger logger = Logger.getLogger(LightAliasViewFactory.class); + + @Override + public LightAliasView create(Element alias) { + return create(alias, null); + } + + /** + * Creates {@link LightAliasView} for {@link Element}. + * + * @param alias + * alias for which view is created + * @param icon + * icon that should be assigned to the view + * @return {@link LightAliasView} for {@link Element} + */ + public LightAliasView create(Element alias, String icon) { + LightAliasView result = new LightAliasView(alias, icon); + return result; + } + + @Override + public String createGson(LightAliasView object) { + return new Gson().toJson(object); + } + + /** + * Creates {@link ILightView} from {@link FullAliasView}. + * + * @param object + * original object + * @return new light object + */ + public ILightView create(FullAliasView object) { + return new LightAliasView(object); + } +} diff --git a/service/src/main/java/lcsb/mapviewer/services/search/db/IDbSearchService.java b/service/src/main/java/lcsb/mapviewer/services/search/db/IDbSearchService.java index 6f718f8d3c..ff80e74959 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/db/IDbSearchService.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/db/IDbSearchService.java @@ -4,8 +4,8 @@ import java.util.Collection; import java.util.List; import lcsb.mapviewer.common.IProgressUpdater; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.view.AbstractView; /** @@ -54,7 +54,7 @@ public interface IDbSearchService<T extends AbstractView<?>> { * {@link lcsb.mapviewer.model.map.model.Model Model}) * @return list of drugs that targets something from the elements collection */ - List<T> getForTargets(Collection<Alias> targetElements, DbSearchCriteria searchCriteria); + List<T> getForTargets(Collection<Element> targetElements, DbSearchCriteria searchCriteria); /** * Creates empty {@link T} object. diff --git a/service/src/main/java/lcsb/mapviewer/services/search/db/chemical/ChemicalService.java b/service/src/main/java/lcsb/mapviewer/services/search/db/chemical/ChemicalService.java index 93f3f343eb..4b76eee0e9 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/db/chemical/ChemicalService.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/db/chemical/ChemicalService.java @@ -26,11 +26,11 @@ import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Rna; import lcsb.mapviewer.model.map.statistics.SearchType; import lcsb.mapviewer.services.interfaces.ISearchHistoryService; import lcsb.mapviewer.services.search.db.DbSearchCriteria; @@ -231,11 +231,11 @@ public class ChemicalService implements IChemicalService { } @Override - public List<ChemicalView> getForTargets(Collection<Alias> targets, DbSearchCriteria searchCriteria) { + public List<ChemicalView> getForTargets(Collection<Element> targets, DbSearchCriteria searchCriteria) { List<Chemical> chemicalList = new ArrayList<>(); Set<MiriamData> targetsMiriam = new HashSet<MiriamData>(); - for (Alias alias : targets) { - if (alias instanceof ProteinAlias || alias instanceof GeneAlias || alias instanceof RnaAlias) { + for (Element alias : targets) { + if (alias instanceof Protein || alias instanceof Gene || alias instanceof Rna) { boolean hgncFound = false; for (MiriamData md : alias.getMiriamData()) { if (MiriamType.HGNC_SYMBOL.equals(md.getDataType())) { diff --git a/service/src/main/java/lcsb/mapviewer/services/search/db/chemical/ChemicalViewFactory.java b/service/src/main/java/lcsb/mapviewer/services/search/db/chemical/ChemicalViewFactory.java index 6e8bc8d619..f475b4cbfa 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/db/chemical/ChemicalViewFactory.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/db/chemical/ChemicalViewFactory.java @@ -20,8 +20,8 @@ import lcsb.mapviewer.annotation.services.PubmedSearchException; import lcsb.mapviewer.annotation.services.annotators.AnnotatorException; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.overlay.IconManager; import lcsb.mapviewer.services.overlay.IconType; import lcsb.mapviewer.services.search.SearchResultFactory; @@ -177,7 +177,7 @@ public class ChemicalViewFactory extends SearchResultFactory<Chemical, ChemicalV for (Model model : models) { for (TargetView target : chemical.getTargetRows()) { if (target.getSelected() && target.getIcon() != null) { - for (Alias element : model.getAliases()) { + for (Element element : model.getAliases()) { if (elementMatch(target, element)) { result.add(new ElementIdentifier(element, target.getIcon())); } diff --git a/service/src/main/java/lcsb/mapviewer/services/search/db/drug/DrugService.java b/service/src/main/java/lcsb/mapviewer/services/search/db/drug/DrugService.java index c483e52a73..83108406d9 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/db/drug/DrugService.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/db/drug/DrugService.java @@ -23,10 +23,10 @@ import lcsb.mapviewer.common.IProgressUpdater; import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.Protein; import lcsb.mapviewer.model.map.statistics.SearchType; import lcsb.mapviewer.services.interfaces.ISearchHistoryService; import lcsb.mapviewer.services.search.db.DbSearchCriteria; @@ -242,11 +242,11 @@ public class DrugService implements IDrugService { } @Override - public List<DrugView> getForTargets(Collection<Alias> targets, DbSearchCriteria searchCriteria) { + public List<DrugView> getForTargets(Collection<Element> targets, DbSearchCriteria searchCriteria) { List<Drug> drugList = new ArrayList<Drug>(); Set<MiriamData> targetsMiriam = new HashSet<MiriamData>(); - for (Alias target : targets) { - if (target instanceof ProteinAlias || target instanceof GeneAlias) { + for (Element target : targets) { + if (target instanceof Protein || target instanceof Gene) { boolean hgncFound = false; for (MiriamData md : target.getMiriamData()) { if (MiriamType.HGNC_SYMBOL.equals(md.getDataType())) { 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 960958f958..074d19044c 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 @@ -17,8 +17,8 @@ import lcsb.mapviewer.annotation.data.Drug; import lcsb.mapviewer.annotation.data.Target; import lcsb.mapviewer.annotation.data.TargetType; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.overlay.IconManager; import lcsb.mapviewer.services.overlay.IconType; import lcsb.mapviewer.services.search.SearchResultFactory; @@ -147,8 +147,8 @@ public class DrugViewFactory extends SearchResultFactory<Drug, DrugView> { List<ElementIdentifier> result = new ArrayList<>(); for (Model m : models) { - List<Alias> species = m.getAliasByName(annotation.getName()); - for (Alias species2 : species) { + List<Element> species = m.getAliasByName(annotation.getName()); + for (Element species2 : species) { result.add(new ElementIdentifier(species2, icon)); } } @@ -169,7 +169,7 @@ public class DrugViewFactory extends SearchResultFactory<Drug, DrugView> { List<ElementIdentifier> result = new ArrayList<>(); for (Model m : models) { - for (Alias element : m.getAliases()) { + for (Element element : m.getAliases()) { if (elementMatch(complexTarget, element)) { result.add(new ElementIdentifier(element, complexTarget.getIcon())); } diff --git a/service/src/main/java/lcsb/mapviewer/services/search/db/mirna/MiRNAService.java b/service/src/main/java/lcsb/mapviewer/services/search/db/mirna/MiRNAService.java index cf5cf744d9..4a5558bc49 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/db/mirna/MiRNAService.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/db/mirna/MiRNAService.java @@ -23,11 +23,11 @@ import lcsb.mapviewer.common.IProgressUpdater; import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Rna; import lcsb.mapviewer.model.map.statistics.SearchType; import lcsb.mapviewer.services.interfaces.ISearchHistoryService; import lcsb.mapviewer.services.search.db.DbSearchCriteria; @@ -131,11 +131,11 @@ public class MiRNAService implements IMiRNAService { } @Override - public List<MiRNAView> getForTargets(Collection<Alias> targets, DbSearchCriteria searchCriteria) { + public List<MiRNAView> getForTargets(Collection<Element> targets, DbSearchCriteria searchCriteria) { List<MiRNA> mirnaList = new ArrayList<MiRNA>(); Set<MiriamData> targetsMiriam = new HashSet<MiriamData>(); - for (Alias element : targets) { - if (element instanceof ProteinAlias || element instanceof GeneAlias || element instanceof RnaAlias) { + for (Element element : targets) { + if (element instanceof Protein || element instanceof Gene || element instanceof Rna) { boolean hgncFound = false; for (MiriamData md : element.getMiriamData()) { if (MiriamType.HGNC_SYMBOL.equals(md.getDataType())) { diff --git a/service/src/main/java/lcsb/mapviewer/services/search/db/mirna/MiRNAViewFactory.java b/service/src/main/java/lcsb/mapviewer/services/search/db/mirna/MiRNAViewFactory.java index 4940f74a6e..595ec33ca5 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/db/mirna/MiRNAViewFactory.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/db/mirna/MiRNAViewFactory.java @@ -11,8 +11,8 @@ import com.google.gson.Gson; import lcsb.mapviewer.annotation.data.MiRNA; import lcsb.mapviewer.annotation.data.Target; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.overlay.IconManager; import lcsb.mapviewer.services.overlay.IconType; import lcsb.mapviewer.services.search.SearchResultFactory; @@ -102,7 +102,7 @@ public class MiRNAViewFactory extends SearchResultFactory<MiRNA, MiRNAView> { for (Model model : models) { for (TargetView target : searchResult.getTargetRows()) { if (target.getSelected() && target.getIcon() != null) { - for (Alias element : model.getAliases()) { + for (Element element : model.getAliases()) { if (elementMatch(target, element)) { result.add(new ElementIdentifier(element, target.getIcon())); } diff --git a/service/src/main/java/lcsb/mapviewer/services/search/layout/FullLayoutAliasView.java b/service/src/main/java/lcsb/mapviewer/services/search/layout/FullLayoutAliasView.java index 01e111ea77..2e13086fc9 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/layout/FullLayoutAliasView.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/layout/FullLayoutAliasView.java @@ -7,7 +7,7 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.model.map.layout.ColorSchema; import lcsb.mapviewer.model.map.layout.GeneVariation; -import lcsb.mapviewer.model.map.layout.alias.Alias; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.search.IHeavyView; import lcsb.mapviewer.services.search.data.LightAliasView; import lcsb.mapviewer.services.utils.data.ColorSchemaType; @@ -57,7 +57,7 @@ public class FullLayoutAliasView extends LightLayoutAliasView implements IHeavyV * @param alias * object for which vie is created */ - protected FullLayoutAliasView(Alias alias) { + protected FullLayoutAliasView(Element alias) { super(alias); } diff --git a/service/src/main/java/lcsb/mapviewer/services/search/layout/FullLayoutAliasViewFactory.java b/service/src/main/java/lcsb/mapviewer/services/search/layout/FullLayoutAliasViewFactory.java index 455cd161b0..d58e285eff 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/layout/FullLayoutAliasViewFactory.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/layout/FullLayoutAliasViewFactory.java @@ -7,7 +7,7 @@ import com.google.gson.Gson; import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.model.map.layout.ColorSchema; import lcsb.mapviewer.model.map.layout.GeneVariationColorSchema; -import lcsb.mapviewer.model.map.layout.alias.Alias; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.search.ElementViewFactory; import lcsb.mapviewer.services.utils.data.ColorSchemaType; @@ -17,7 +17,7 @@ import lcsb.mapviewer.services.utils.data.ColorSchemaType; * @author Piotr Gawron * */ -public class FullLayoutAliasViewFactory extends ElementViewFactory<Pair<Alias, ColorSchema>, FullLayoutAliasView> { +public class FullLayoutAliasViewFactory extends ElementViewFactory<Pair<Element, ColorSchema>, FullLayoutAliasView> { /** * Default class logger. */ @@ -25,7 +25,7 @@ public class FullLayoutAliasViewFactory extends ElementViewFactory<Pair<Alias, C private static Logger logger = Logger.getLogger(FullLayoutAliasViewFactory.class); @Override - public FullLayoutAliasView create(Pair<Alias, ColorSchema> pair) { + public FullLayoutAliasView create(Pair<Element, ColorSchema> pair) { ColorSchema schema = pair.getRight(); FullLayoutAliasView result = new FullLayoutAliasView(pair.getLeft()); diff --git a/service/src/main/java/lcsb/mapviewer/services/search/layout/LightLayoutAliasView.java b/service/src/main/java/lcsb/mapviewer/services/search/layout/LightLayoutAliasView.java index 00207463ec..bf8008175a 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/layout/LightLayoutAliasView.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/layout/LightLayoutAliasView.java @@ -1,93 +1,93 @@ -package lcsb.mapviewer.services.search.layout; - -import java.awt.Color; - -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.services.search.ElementView; - -/** - * Light {@link ElementView view} for alias representing data that should be - * send to client about alias related to - * {@link lcsb.mapviewer.model.map.layout.Layout}. - * - * @author Piotr Gawron - * - */ -public class LightLayoutAliasView extends ElementView { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * Value used to highlight {@link Alias} in a a layout. - */ - private Double value; - - /** - * Color used to highlight {@link Alias} in a layout. - */ - private Color color; - - /** - * Default constructor. - * - * @param alias - * original object from which this on is created - */ - protected LightLayoutAliasView(Alias alias) { - super(alias.getId(), alias.getModel().getId()); - } - - /** - * Constructor that should be used only for (de)serialization. - */ - protected LightLayoutAliasView() { - super(); - } - - /** - * @return the value - * @see #value - */ - public Double getValue() { - return value; - } - - /** - * @param value - * the value to set - * @see #value - */ - public void setValue(Double value) { - this.value = value; - } - - /** - * @return the color - * @see #color - */ - public Color getColor() { - return color; - } - - /** - * @param color - * the color to set - * @see #color - */ - public void setColor(Color color) { - this.color = color; - } - - @Override - public String toString() { - return "[" + this.getClass().getSimpleName() + "] " + // - "alias_id: " + getIdObject() + ", " + // - "value: " + getValue() + ", " + // - "color: " + getColor() + ", "; - - } - -} +package lcsb.mapviewer.services.search.layout; + +import java.awt.Color; + +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.services.search.ElementView; + +/** + * Light {@link ElementView view} for alias representing data that should be + * send to client about alias related to + * {@link lcsb.mapviewer.model.map.layout.Layout}. + * + * @author Piotr Gawron + * + */ +public class LightLayoutAliasView extends ElementView { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Value used to highlight {@link Element} in a a layout. + */ + private Double value; + + /** + * Color used to highlight {@link Element} in a layout. + */ + private Color color; + + /** + * Default constructor. + * + * @param alias + * original object from which this on is created + */ + protected LightLayoutAliasView(Element alias) { + super(alias.getId(), alias.getModel().getId()); + } + + /** + * Constructor that should be used only for (de)serialization. + */ + protected LightLayoutAliasView() { + super(); + } + + /** + * @return the value + * @see #value + */ + public Double getValue() { + return value; + } + + /** + * @param value + * the value to set + * @see #value + */ + public void setValue(Double value) { + this.value = value; + } + + /** + * @return the color + * @see #color + */ + public Color getColor() { + return color; + } + + /** + * @param color + * the color to set + * @see #color + */ + public void setColor(Color color) { + this.color = color; + } + + @Override + public String toString() { + return "[" + this.getClass().getSimpleName() + "] " + // + "alias_id: " + getIdObject() + ", " + // + "value: " + getValue() + ", " + // + "color: " + getColor() + ", "; + + } + +} diff --git a/service/src/main/java/lcsb/mapviewer/services/search/layout/LightLayoutAliasViewFactory.java b/service/src/main/java/lcsb/mapviewer/services/search/layout/LightLayoutAliasViewFactory.java index c3666b448b..4d0c874fd4 100644 --- a/service/src/main/java/lcsb/mapviewer/services/search/layout/LightLayoutAliasViewFactory.java +++ b/service/src/main/java/lcsb/mapviewer/services/search/layout/LightLayoutAliasViewFactory.java @@ -6,7 +6,7 @@ import com.google.gson.Gson; import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.model.map.layout.ColorSchema; -import lcsb.mapviewer.model.map.layout.alias.Alias; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.search.ElementViewFactory; /** @@ -15,7 +15,7 @@ import lcsb.mapviewer.services.search.ElementViewFactory; * @author Piotr Gawron * */ -public class LightLayoutAliasViewFactory extends ElementViewFactory<Pair<Alias, ColorSchema>, LightLayoutAliasView> { +public class LightLayoutAliasViewFactory extends ElementViewFactory<Pair<Element, ColorSchema>, LightLayoutAliasView> { /** * Default class logger. */ @@ -23,7 +23,7 @@ public class LightLayoutAliasViewFactory extends ElementViewFactory<Pair<Alias, private static Logger logger = Logger.getLogger(LightLayoutAliasViewFactory.class); @Override - public LightLayoutAliasView create(Pair<Alias, ColorSchema> pair) { + public LightLayoutAliasView create(Pair<Element, ColorSchema> pair) { LightLayoutAliasView result = new LightLayoutAliasView(pair.getLeft()); result.setColor(pair.getRight().getNormalizedColor()); result.setValue(pair.getRight().getValue()); 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 26a19f2fd5..cb448f1dd0 100644 --- a/service/src/main/java/lcsb/mapviewer/services/utils/SearchIndexer.java +++ b/service/src/main/java/lcsb/mapviewer/services/utils/SearchIndexer.java @@ -8,8 +8,8 @@ import java.util.Map.Entry; import org.apache.log4j.Logger; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.SearchIndex; +import lcsb.mapviewer.model.map.SearchIndex; +import lcsb.mapviewer.model.map.species.Element; /** * This class is responsible for seqrch queries. It allows to create an index @@ -27,7 +27,7 @@ public class SearchIndexer { private static final int SEARCH_SCORE_LEVEL_FOR_ALIAS_ID = 60; /** - * Base score of the index generated for {@link Alias#formerSymbols}. It will + * Base score of the index generated for {@link Element#formerSymbols}. It will * be used as a shift for {@link SearchIndex#weight} value. */ private static final int SEARCH_SCORE_LEVEL_FOR_SPECIES_FORMER_SYMBOL = 75; @@ -53,6 +53,7 @@ public class SearchIndexer { /** * Default class logger. */ + @SuppressWarnings("unused") private Logger logger = Logger.getLogger(SearchIndexer.class); /** @@ -72,7 +73,7 @@ public class SearchIndexer { * object to be indexed * @return list of indexes for an alias */ - public List<SearchIndex> createIndexForAlias(Alias species) { + public List<SearchIndex> createIndexForAlias(Element species) { List<SearchIndex> result = new ArrayList<>(); String id1 = species.getAliasId(); result.add(new SearchIndex(getIndexStringForString(id1), SEARCH_SCORE_LEVEL_FOR_ALIAS_ID)); @@ -165,13 +166,13 @@ public class SearchIndexer { * query * @return class of the element that might exist in the result */ - public Class<? extends Alias> getTypeForQuery(String string, Map<String, Class<? extends Alias>> speciesSearchReversePrefix) { + public Class<? extends Element> getTypeForQuery(String string, Map<String, Class<? extends Element>> speciesSearchReversePrefix) { String result = string; - for (Entry<String, Class<? extends Alias>> entry : speciesSearchReversePrefix.entrySet()) { + for (Entry<String, Class<? extends Element>> entry : speciesSearchReversePrefix.entrySet()) { if (result.startsWith(entry.getKey() + ":")) { return entry.getValue(); } } - return Alias.class; + return Element.class; } } diff --git a/service/src/main/java/lcsb/mapviewer/services/utils/data/ExportColumn.java b/service/src/main/java/lcsb/mapviewer/services/utils/data/ExportColumn.java index 259d006bce..93855824f8 100644 --- a/service/src/main/java/lcsb/mapviewer/services/utils/data/ExportColumn.java +++ b/service/src/main/java/lcsb/mapviewer/services/utils/data/ExportColumn.java @@ -1,7 +1,7 @@ package lcsb.mapviewer.services.utils.data; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Species; /** * This enum defines which columns are available in export function. @@ -14,27 +14,27 @@ public enum ExportColumn { /** * Name of the species. */ - NAME("Name", SpeciesAlias.class), // + NAME("Name", Species.class), // /** * Name of compartment. */ - COMPARTMENT_NAME("Compartment", SpeciesAlias.class), // + COMPARTMENT_NAME("Compartment", Species.class), // /** * Name of compartment. */ - POSITION_TO_COMPARTMENT("Position to compartment", SpeciesAlias.class), // + POSITION_TO_COMPARTMENT("Position to compartment", Species.class), // /** * Name of pathway. */ - COMPONENT_NAME("Pathway", SpeciesAlias.class), // + COMPONENT_NAME("Pathway", Species.class), // /** * Type of the species. */ - TYPE("Type", SpeciesAlias.class), // + TYPE("Type", Species.class), // /** * Identifier. @@ -44,12 +44,12 @@ public enum ExportColumn { /** * Complex in which element is localized. */ - COMPLEX("Parent complex", SpeciesAlias.class), // + COMPLEX("Parent complex", Species.class), // /** * Complex in which element is localized. */ - SUBMODEL("Submodel", SpeciesAlias.class), // + SUBMODEL("Submodel", Species.class), // /** * Reaction identifier. diff --git a/service/src/main/java/lcsb/mapviewer/services/view/CommentViewFactory.java b/service/src/main/java/lcsb/mapviewer/services/view/CommentViewFactory.java index fb6d77531a..a16772c76b 100644 --- a/service/src/main/java/lcsb/mapviewer/services/view/CommentViewFactory.java +++ b/service/src/main/java/lcsb/mapviewer/services/view/CommentViewFactory.java @@ -9,9 +9,9 @@ import com.google.gson.Gson; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.Comment; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; /** * Factory class for {@link CommentView} class. @@ -78,7 +78,7 @@ public class CommentViewFactory extends AbstractViewFactory<Comment, CommentView } } else { - Alias alias = model.getAliasByDbId(comment.getTableId()); + Element alias = model.getAliasByDbId(comment.getTableId()); if (alias != null) { title = alias.getName(); coordinates = alias.getCenter(); 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 511c58f34a..e8a9acaae8 100644 --- a/service/src/main/java/lcsb/mapviewer/services/view/PubmedAnnotatedElementsView.java +++ b/service/src/main/java/lcsb/mapviewer/services/view/PubmedAnnotatedElementsView.java @@ -8,8 +8,8 @@ import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.impl.SearchService; /** @@ -92,8 +92,8 @@ public class PubmedAnnotatedElementsView extends AbstractView<MiriamData> { * object to add */ public void addElement(AnnotatedObject annotatedObject) { - if (annotatedObject instanceof Alias) { - Alias alias = (Alias) annotatedObject; + if (annotatedObject instanceof Element) { + Element alias = (Element) annotatedObject; elements.add(new Pair<String, String>(alias.getName(), SearchService.SPECIES_SEARCH_PREFIX + ":" + alias.getAliasId())); } else if (annotatedObject instanceof Reaction) { Reaction reaction = (Reaction) annotatedObject; 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 d7307d9033..6c5d5baafb 100644 --- a/service/src/test/java/lcsb/mapviewer/services/impl/CommentServiceTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/impl/CommentServiceTest.java @@ -17,10 +17,10 @@ import org.springframework.test.annotation.Rollback; import lcsb.mapviewer.model.Project; import lcsb.mapviewer.model.map.Comment; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.ServiceTestFunctions; import lcsb.mapviewer.services.search.comment.FullCommentView; import lcsb.mapviewer.services.view.CommentView; @@ -30,8 +30,8 @@ public class CommentServiceTest extends ServiceTestFunctions { static Logger logger = Logger.getLogger(CommentServiceTest.class); Model model; Project project; - Alias alias; - Alias alias2; + Element alias; + Element alias2; private String projectId = "Some_id"; @Before @@ -47,10 +47,10 @@ public class CommentServiceTest extends ServiceTestFunctions { model = getModelForFile("testFiles/centeredAnchorInModifier.xml", false); model.setMapVersion("tes"); model.setTileSize(128); - Set<Alias> aliases = model.getAliases(); + Set<Element> aliases = model.getAliases(); alias = null; alias2 = null; - for (Alias nAlias : aliases) { + for (Element nAlias : aliases) { alias2 = alias; alias = nAlias; } @@ -172,7 +172,7 @@ public class CommentServiceTest extends ServiceTestFunctions { @Test public void testAddCommentForAlias() throws Exception { try { - Alias alias = model.getAliasByAliasId("sa1"); + Element alias = model.getAliasByAliasId("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/DataMiningServiceTest.java b/service/src/test/java/lcsb/mapviewer/services/impl/DataMiningServiceTest.java index ad5e461c1d..7c94ef9f11 100644 --- a/service/src/test/java/lcsb/mapviewer/services/impl/DataMiningServiceTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/impl/DataMiningServiceTest.java @@ -28,10 +28,10 @@ import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.graph.DataMining; import lcsb.mapviewer.model.map.graph.DataMiningSet; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Protein; import lcsb.mapviewer.services.ServiceTestFunctions; import lcsb.mapviewer.services.interfaces.IDataMiningService; @@ -41,8 +41,8 @@ public class DataMiningServiceTest extends ServiceTestFunctions { private Model model; private Project project; - private Set<Alias> nodes; - private Alias node; + private Set<Element> nodes; + private Element node; @Autowired IDataMiningService dm; @@ -105,7 +105,7 @@ public class DataMiningServiceTest extends ServiceTestFunctions { dataMiningService.addMissingConnection(connection); - Collection<Alias> coll = dataMiningService.getSpeciesWithMissingConnectionsByGeneName(model, "ABLA"); + Collection<Element> coll = dataMiningService.getSpeciesWithMissingConnectionsByGeneName(model, "ABLA"); assertNotNull(coll); assertTrue(coll.size() > 0); @@ -135,7 +135,7 @@ public class DataMiningServiceTest extends ServiceTestFunctions { GenericLog log = logDao.getLastLog(); logDao.delete(log); - Collection<Alias> elements = dataMiningService.getSpeciesWithMissingConnectionsByGeneName(model, "SOME2"); + Collection<Element> elements = dataMiningService.getSpeciesWithMissingConnectionsByGeneName(model, "SOME2"); assertEquals(1, elements.size()); dataMiningService.deleteMissingConnection(connection, "No reason"); @@ -160,10 +160,10 @@ public class DataMiningServiceTest extends ServiceTestFunctions { try { DataMiningSet dm = new DataMiningSet(); dm.setInputData(IOUtils.toByteArray(new FileInputStream("testFiles/data_mining/sample_input.txt"))); - Set<Alias> set = new HashSet<>(); - ProteinAlias p1 = new GenericProteinAlias("id1"); + Set<Element> set = new HashSet<>(); + Protein p1 = new GenericProtein("id1"); p1.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "SNCA")); - ProteinAlias p2 = new GenericProteinAlias("id2"); + Protein p2 = new GenericProtein("id2"); p2.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "SNCA")); set.add(p1); set.add(p2); diff --git a/service/src/test/java/lcsb/mapviewer/services/impl/DataMiningServiceTest2.java b/service/src/test/java/lcsb/mapviewer/services/impl/DataMiningServiceTest2.java index ea458a4882..2f44610057 100644 --- a/service/src/test/java/lcsb/mapviewer/services/impl/DataMiningServiceTest2.java +++ b/service/src/test/java/lcsb/mapviewer/services/impl/DataMiningServiceTest2.java @@ -21,13 +21,13 @@ import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.graph.DataMining; import lcsb.mapviewer.model.map.graph.DataMiningType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; import lcsb.mapviewer.model.map.reaction.Product; import lcsb.mapviewer.model.map.reaction.Reactant; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.SimpleMolecule; import lcsb.mapviewer.services.ServiceTestFunctions; @Rollback(true) @@ -45,14 +45,14 @@ public class DataMiningServiceTest2 extends ServiceTestFunctions { @Test public void testParseData() throws Exception { try { - Alias snca = new GenericProteinAlias("id1"); + Element snca = new GenericProtein("id1"); snca.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "SNCA")); - Alias park1 = new GenericProteinAlias("id2"); + Element park1 = new GenericProtein("id2"); park1.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "PARK1")); - SimpleMoleculeAlias sm = new SimpleMoleculeAlias("id3"); + SimpleMolecule sm = new SimpleMolecule("id3"); sm.addMiriamData(new MiriamData(MiriamType.CHEBI, "CHEBI:1234")); - Collection<Alias> nodes = new ArrayList<>(); + Collection<Element> nodes = new ArrayList<>(); nodes.add(snca); nodes.add(park1); @@ -108,10 +108,10 @@ public class DataMiningServiceTest2 extends ServiceTestFunctions { @Test public void testDataMiningMiriamDataFormat() throws Exception { try { - ProteinAlias snca = new GenericProteinAlias("id1"); + Protein snca = new GenericProtein("id1"); snca.addMiriamData(new MiriamData(MiriamType.HGNC, "18618")); - Collection<Alias> nodes = new ArrayList<>(); + Collection<Element> nodes = new ArrayList<>(); nodes.add(snca); Set<DataMining> res = dataMiningService @@ -136,12 +136,12 @@ public class DataMiningServiceTest2 extends ServiceTestFunctions { @Test public void testParseDataWithFiltering() throws Exception { try { - ProteinAlias park7 = new GenericProteinAlias("id1"); + Protein park7 = new GenericProtein("id1"); park7.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "PARK7")); - ProteinAlias park1 = new GenericProteinAlias("id2"); + Protein park1 = new GenericProtein("id2"); park1.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "PARK1")); - Collection<Alias> nodes = new ArrayList<>(); + Collection<Element> nodes = new ArrayList<>(); nodes.add(park7); nodes.add(park1); @@ -170,12 +170,12 @@ public class DataMiningServiceTest2 extends ServiceTestFunctions { @Test public void testParseDataWithFiltering2() throws Exception { try { - ProteinAlias park7 = new GenericProteinAlias("id1"); + Protein park7 = new GenericProtein("id1"); park7.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "PARK7")); - ProteinAlias park1 = new GenericProteinAlias("id2"); + Protein park1 = new GenericProtein("id2"); park1.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "PARK1")); - Collection<Alias> nodes = new ArrayList<>(); + Collection<Element> nodes = new ArrayList<>(); nodes.add(park7); nodes.add(park1); 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 e4a866d808..893a4663a9 100644 --- a/service/src/test/java/lcsb/mapviewer/services/impl/ExporterServiceTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/impl/ExporterServiceTest.java @@ -19,14 +19,14 @@ import org.springframework.beans.factory.annotation.Autowired; import lcsb.mapviewer.commands.CreateHierarchyCommand; import lcsb.mapviewer.converter.model.celldesigner.reaction.ReactionLineData; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.ReactionNode; +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; import lcsb.mapviewer.services.ServiceTestFunctions; import lcsb.mapviewer.services.interfaces.IExporterService; import lcsb.mapviewer.services.interfaces.IExporterService.ExporterParameters; @@ -69,7 +69,7 @@ public class ExporterServiceTest extends ServiceTestFunctions { // only proteins for self-made modules new CreateHierarchyCommand(model, 8, 80).execute(); - string = exporter.getExportSpeciesString(params.type(GenericProteinAlias.class)); + string = exporter.getExportSpeciesString(params.type(GenericProtein.class)); lines = string.split("\n"); assertTrue(lines.length > 1); @@ -81,7 +81,7 @@ public class ExporterServiceTest extends ServiceTestFunctions { assertEquals(ExportColumn.TYPE.getTitle(), textColumns[4]); } else { textColumns = string2.split("\t"); - assertEquals(GenericProteinAlias.class.getSimpleName(), textColumns[4]); + assertEquals(GenericProtein.class.getSimpleName(), textColumns[4]); if (!textColumns[2].equalsIgnoreCase(textColumns[3])) { differenceBetweenComponentCompartmnet = true; } @@ -123,7 +123,7 @@ public class ExporterServiceTest extends ServiceTestFunctions { try { Model model = getModelForFile("testFiles/export/hsp70.xml", true); - SpeciesAlias alias = (SpeciesAlias) model.getAliasByAliasId("csa1"); + Species alias = (Species) model.getAliasByAliasId("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 = (SpeciesAlias) model.getAliasByAliasId("csa3"); + alias = (Species) model.getAliasByAliasId("csa3"); elements = exporter.getExportStringForOneSpecies(alias, params); assertTrue(elements.size() > 0); @@ -156,7 +156,7 @@ public class ExporterServiceTest extends ServiceTestFunctions { assertTrue(string.contains("UBA6")); assertTrue(string.contains("AMP")); - elements = exporter.getExportStringForOneSpecies(alias, params.type(ProteinAlias.class)); + elements = exporter.getExportStringForOneSpecies(alias, params.type(Protein.class)); assertTrue(elements.size() > 0); string = elements.get(0); assertTrue(string.contains("UBA1")); @@ -173,8 +173,8 @@ public class ExporterServiceTest extends ServiceTestFunctions { public void testGetExportStringForOneReaction() throws Exception { try { Model model = getModelForFile("testFiles/export/reaction.xml", false); - Set<CompartmentAlias> aliases = new HashSet<>(); - for (CompartmentAlias alias : model.getCompartmentsAliases()) { + Set<Compartment> aliases = new HashSet<>(); + for (Compartment alias : model.getCompartmentsAliases()) { if (alias.getName().equalsIgnoreCase("Dopamine loaded synaptic vesicle")) aliases.add(alias); } @@ -183,8 +183,8 @@ public class ExporterServiceTest extends ServiceTestFunctions { ExporterParameters params = new IExporterService.ExporterParameters().model(model).// fileType(ExportFileType.SIF).// - type(ProteinAlias.class).// - type(ComplexAlias.class).// + type(Protein.class).// + type(Complex.class).// fileType(ExportFileType.SIF).// complexElementsName(false).// excluded(aliases); @@ -197,7 +197,7 @@ public class ExporterServiceTest extends ServiceTestFunctions { assertTrue(string.contains("trans-SNARE complex")); assertFalse(string.contains("VAMP2")); - params = new IExporterService.ExporterParameters().model(model).fileType(ExportFileType.SIF).type(ComplexAlias.class).type(ProteinAlias.class); + params = new IExporterService.ExporterParameters().model(model).fileType(ExportFileType.SIF).type(Complex.class).type(Protein.class); string = exporter.getExportSingleInteractionString(reaction, params).get(0); assertTrue(string.contains("VAMP2")); @@ -216,7 +216,7 @@ public class ExporterServiceTest extends ServiceTestFunctions { ExporterParameters params = new IExporterService.ExporterParameters().model(model).// fileType(ExportFileType.SIF).// complexElementsName(false).// - type(ComplexAlias.class).type(ProteinAlias.class); + type(Complex.class).type(Protein.class); String string = exporter.getExportSingleInteractionString(reaction, params).get(0); assertNotNull(string); assertTrue(string.contains("Calcium channel:RIMBP:RIM:MUNC13:RAB")); @@ -245,8 +245,8 @@ public class ExporterServiceTest extends ServiceTestFunctions { Reaction reaction = model.getReactionByReactionId("re11"); model.getReactions().clear(); model.addReaction(reaction); - Set<CompartmentAlias> aliases = new HashSet<CompartmentAlias>(); - aliases.add((CompartmentAlias) model.getAliasByAliasId("ca1")); + Set<Compartment> aliases = new HashSet<Compartment>(); + aliases.add((Compartment) model.getAliasByAliasId("ca1")); ExporterParameters params = new IExporterService.ExporterParameters() .model(model).fileType(ExportFileType.SIF).included("dopamine loaded synaptic vesicle"); assertEquals(0, exporter.getExportSingleInteractionString(reaction, params).size()); @@ -267,7 +267,7 @@ public class ExporterServiceTest extends ServiceTestFunctions { for (Reaction reaction : model.getReactions()) { String str = exporter .getExportSingleInteractionString( - reaction, new IExporterService.ExporterParameters().fileType(ExportFileType.TAB_SEPARATED).type(SpeciesAlias.class)) + reaction, new IExporterService.ExporterParameters().fileType(ExportFileType.TAB_SEPARATED).type(Species.class)) .get(0); List<String> strings = new ArrayList<String>(); @@ -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((SpeciesAlias) model.getAliasByAliasId("sa1"), params); + List<String> list = exporter.getExportStringForOneSpecies((Species) model.getAliasByAliasId("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((SpeciesAlias) model.getAliasByAliasId("sa2"), params); + list = exporter.getExportStringForOneSpecies((Species) model.getAliasByAliasId("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((SpeciesAlias) model.getAliasByAliasId("sa3"), params); + list = exporter.getExportStringForOneSpecies((Species) model.getAliasByAliasId("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((SpeciesAlias) model.getAliasByAliasId("sa4"), params); + list = exporter.getExportStringForOneSpecies((Species) model.getAliasByAliasId("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((SpeciesAlias) model.getAliasByAliasId("sa5"), params); + list = exporter.getExportStringForOneSpecies((Species) model.getAliasByAliasId("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((SpeciesAlias) model.getAliasByAliasId("sa6"), params); + list = exporter.getExportStringForOneSpecies((Species) model.getAliasByAliasId("sa6"), params); desc = list.get(0); compartment = desc.split("\t")[2]; assertEquals("null", compartment); @@ -420,7 +420,7 @@ public class ExporterServiceTest extends ServiceTestFunctions { Model model = getModelForFile("testFiles/export_with_artifitial_comp.xml", false); List<ExportColumn> columns = new ArrayList<ExportColumn>(); for (ExportColumn column : ExportColumn.values()) { - if (column.getClazz().isAssignableFrom(SpeciesAlias.class)) { + if (column.getClazz().isAssignableFrom(Species.class)) { columns.add(column); } } @@ -462,8 +462,8 @@ public class ExporterServiceTest extends ServiceTestFunctions { public void testGetTabSeparatedReaction() throws Exception { try { Model model = getModelForFile("testFiles/export/reaction.xml", false); - Set<CompartmentAlias> aliases = new HashSet<>(); - for (CompartmentAlias alias : model.getCompartmentsAliases()) { + Set<Compartment> aliases = new HashSet<>(); + for (Compartment alias : model.getCompartmentsAliases()) { if (alias.getName().equalsIgnoreCase("Dopamine loaded synaptic vesicle")) aliases.add(alias); } @@ -472,7 +472,7 @@ public class ExporterServiceTest extends ServiceTestFunctions { fileType(ExportFileType.TAB_SEPARATED).// column(ExportColumn.REACTION_ID).// column(ExportColumn.REACTION_TYPE).// - type(SpeciesAlias.class); + type(Species.class); String string = exporter.getExportInteractionString(params); assertTrue(string.indexOf("STATE_TRANSITION REACTANT") >= 0); @@ -490,7 +490,7 @@ public class ExporterServiceTest extends ServiceTestFunctions { Model model = getModelForFile("testFiles/export/new_line_file.xml", false); List<ExportColumn> columns = new ArrayList<ExportColumn>(); for (ExportColumn column : ExportColumn.values()) { - if (column.getClazz().isAssignableFrom(SpeciesAlias.class)) { + if (column.getClazz().isAssignableFrom(Species.class)) { columns.add(column); } } diff --git a/service/src/test/java/lcsb/mapviewer/services/impl/LayoutServiceTest2.java b/service/src/test/java/lcsb/mapviewer/services/impl/LayoutServiceTest2.java index 222ab908db..d26b05ac51 100644 --- a/service/src/test/java/lcsb/mapviewer/services/impl/LayoutServiceTest2.java +++ b/service/src/test/java/lcsb/mapviewer/services/impl/LayoutServiceTest2.java @@ -27,8 +27,8 @@ import lcsb.mapviewer.model.map.layout.GeneVariation; import lcsb.mapviewer.model.map.layout.GeneVariationColorSchema; import lcsb.mapviewer.model.map.layout.GenericColorSchema; import lcsb.mapviewer.model.map.layout.ReferenceGenomeType; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.GenericProtein; import lcsb.mapviewer.services.interfaces.ILayoutService.CreateLayoutParams; import lcsb.mapviewer.services.utils.ColorSchemaReader; import lcsb.mapviewer.services.utils.data.ColorSchemaColumn; @@ -70,7 +70,7 @@ public class LayoutServiceTest2 { cs.setName("UUU"); cs.setReactionIdentifier("RE ID"); cs.setReverseReaction(true); - cs.addType(GenericProteinAlias.class); + cs.addType(GenericProtein.class); cs.setValue(1111.1111); schemas.add(cs); @@ -109,7 +109,7 @@ public class LayoutServiceTest2 { cs.setName("UUU"); cs.setReactionIdentifier("RE ID"); cs.setReverseReaction(true); - cs.addType(GenericProteinAlias.class); + cs.addType(GenericProtein.class); cs.setValue(1111.1111); GeneVariation gv = new GeneVariation(); gv.setModifiedDna("C"); diff --git a/service/src/test/java/lcsb/mapviewer/services/impl/LogServiceTest.java b/service/src/test/java/lcsb/mapviewer/services/impl/LogServiceTest.java index a29b4fb7f8..2049084f81 100644 --- a/service/src/test/java/lcsb/mapviewer/services/impl/LogServiceTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/impl/LogServiceTest.java @@ -18,8 +18,8 @@ import lcsb.mapviewer.model.Project; import lcsb.mapviewer.model.log.GenericLog; import lcsb.mapviewer.model.log.LogType; import lcsb.mapviewer.model.map.graph.DataMining; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.ServiceTestFunctions; import lcsb.mapviewer.services.interfaces.ILogService.LogParams; @@ -30,8 +30,8 @@ public class LogServiceTest extends ServiceTestFunctions { private Model model; private Project project; - private Set<Alias> nodes; - private Alias node; + private Set<Element> nodes; + private Element node; private DataMining mc; @Before diff --git a/service/src/test/java/lcsb/mapviewer/services/impl/ModelServiceTest.java b/service/src/test/java/lcsb/mapviewer/services/impl/ModelServiceTest.java index 6430c72e62..f6cfdb028f 100644 --- a/service/src/test/java/lcsb/mapviewer/services/impl/ModelServiceTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/impl/ModelServiceTest.java @@ -22,8 +22,8 @@ import lcsb.mapviewer.converter.graphics.MapGenerator; import lcsb.mapviewer.converter.graphics.MapGenerator.MapGeneratorParams; import lcsb.mapviewer.model.Project; import lcsb.mapviewer.model.map.layout.Layout; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.ServiceTestFunctions; import lcsb.mapviewer.services.interfaces.IModelService; import lcsb.mapviewer.services.search.data.LightAliasView; @@ -83,8 +83,8 @@ public class ModelServiceTest extends ServiceTestFunctions { try { Model model = getModelForFile("testFiles/sample.xml", false); int counter = 0; - Alias alias0 = null; - for (Alias alias : model.getAliases()) { + Element alias0 = null; + for (Element alias : model.getAliases()) { if (counter == 0) { alias0 = alias; } 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 74b3894831..3858e05830 100644 --- a/service/src/test/java/lcsb/mapviewer/services/impl/ProjectServiceTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/impl/ProjectServiceTest.java @@ -37,11 +37,11 @@ import lcsb.mapviewer.model.ProjectStatus; import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.layout.Layout; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelSubmodelConnection; import lcsb.mapviewer.model.map.model.SubmodelType; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Protein; import lcsb.mapviewer.model.user.ObjectPrivilege; import lcsb.mapviewer.model.user.PrivilegeType; import lcsb.mapviewer.model.user.User; @@ -270,20 +270,20 @@ public class ProjectServiceTest extends ServiceTestFunctions { assertNotNull(s2Model); assertNotNull(s3Model); - Alias al1 = model.getAliasByAliasId("sa1"); + Element al1 = model.getAliasByAliasId("sa1"); assertNotNull(al1.getSubmodel()); assertEquals(SubmodelType.DOWNSTREAM_TARGETS, al1.getSubmodel().getType()); assertEquals(s1Model, al1.getSubmodel().getSubmodel().getModel()); - Alias al2 = model.getAliasByAliasId("sa2"); + Element al2 = model.getAliasByAliasId("sa2"); assertNull(al2.getSubmodel()); - Alias al4 = model.getAliasByAliasId("sa4"); + Element al4 = model.getAliasByAliasId("sa4"); assertNotNull(al4.getSubmodel()); assertEquals(SubmodelType.PATHWAY, al4.getSubmodel().getType()); assertEquals(s2Model, al4.getSubmodel().getSubmodel().getModel()); - Alias s1_al1 = s1Model.getAliasByAliasId("sa1"); + Element s1_al1 = s1Model.getAliasByAliasId("sa1"); assertNotNull(s1_al1.getSubmodel()); assertEquals(SubmodelType.DOWNSTREAM_TARGETS, s1_al1.getSubmodel().getType()); assertEquals(s3Model, s1_al1.getSubmodel().getSubmodel().getModel()); @@ -520,7 +520,7 @@ public class ProjectServiceTest extends ServiceTestFunctions { try { super.createUser(); UserAnnotationSchema schema = new UserAnnotationSchema(); - schema.addClassAnnotator(new UserClassAnnotators(ProteinAlias.class, modelAnnotator.getAvailableAnnotatorNames(ProteinAlias.class))); + schema.addClassAnnotator(new UserClassAnnotators(Protein.class, modelAnnotator.getAvailableAnnotatorNames(Protein.class))); user.setAnnotationSchema(schema); userDao.update(user); @@ -598,7 +598,7 @@ public class ProjectServiceTest extends ServiceTestFunctions { try { super.createUser(); UserAnnotationSchema schema = new UserAnnotationSchema(); - schema.addClassValidAnnotations(new UserClassValidAnnotations(ProteinAlias.class, MiriamType.values())); + schema.addClassValidAnnotations(new UserClassValidAnnotations(Protein.class, MiriamType.values())); user.setAnnotationSchema(schema); userDao.update(user); userDao.flush(); @@ -645,7 +645,7 @@ public class ProjectServiceTest extends ServiceTestFunctions { assertEquals("main", model.getName()); assertEquals(ProjectStatus.DONE, project.getStatus()); boolean dmFound = false; - for (Alias element : model.getAliases()) { + for (Element element : model.getAliases()) { if (dataMiningService.getMissingConnections(element).size() > 0) { dmFound = true; } diff --git a/service/src/test/java/lcsb/mapviewer/services/impl/SearchServiceTest.java b/service/src/test/java/lcsb/mapviewer/services/impl/SearchServiceTest.java index b39ff2b5a7..de566229ae 100644 --- a/service/src/test/java/lcsb/mapviewer/services/impl/SearchServiceTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/impl/SearchServiceTest.java @@ -22,21 +22,21 @@ import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamRelationType; import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.layout.Layout; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.DegradedAlias; -import lcsb.mapviewer.model.map.layout.alias.DrugAlias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.IonAlias; -import lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; -import lcsb.mapviewer.model.map.layout.alias.UnknownAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Degraded; +import lcsb.mapviewer.model.map.species.Drug; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Ion; +import lcsb.mapviewer.model.map.species.Phenotype; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Rna; +import lcsb.mapviewer.model.map.species.SimpleMolecule; +import lcsb.mapviewer.model.map.species.Species; +import lcsb.mapviewer.model.map.species.Unknown; import lcsb.mapviewer.services.ServiceTestFunctions; import lcsb.mapviewer.services.interfaces.ISearchService.CoordinatesSearchParams; import lcsb.mapviewer.services.search.data.FullAliasView; @@ -55,16 +55,16 @@ public class SearchServiceTest extends ServiceTestFunctions { @Before public void setUp() throws Exception { - addSearchPrefix("complex", ComplexAlias.class); - addSearchPrefix("degrded", DegradedAlias.class); - addSearchPrefix("drug", DrugAlias.class); - addSearchPrefix("gene", GeneAlias.class); - addSearchPrefix("ion", IonAlias.class); - addSearchPrefix("phenotype", PhenotypeAlias.class); - addSearchPrefix("protein", ProteinAlias.class); - addSearchPrefix("rna", RnaAlias.class); - addSearchPrefix("molecule", SimpleMoleculeAlias.class); - addSearchPrefix("unknown", UnknownAlias.class); + addSearchPrefix("complex", Complex.class); + addSearchPrefix("degrded", Degraded.class); + addSearchPrefix("drug", Drug.class); + addSearchPrefix("gene", Gene.class); + addSearchPrefix("ion", Ion.class); + addSearchPrefix("phenotype", Phenotype.class); + addSearchPrefix("protein", Protein.class); + addSearchPrefix("rna", Rna.class); + addSearchPrefix("molecule", SimpleMolecule.class); + addSearchPrefix("unknown", Unknown.class); } private void addSearchPrefix(String prefix, Class<?> clazz) { @@ -234,20 +234,20 @@ public class SearchServiceTest extends ServiceTestFunctions { List<Object> elements = searchService.getClosestElements(model, new Point2D.Double(0, 0), 5); assertNotNull(elements); assertEquals(5, elements.size()); - assertTrue(elements.get(0) instanceof SpeciesAlias); - SpeciesAlias sAlias = (SpeciesAlias) elements.get(0); + assertTrue(elements.get(0) instanceof Species); + Species sAlias = (Species) elements.get(0); assertEquals("s1", sAlias.getName()); assertTrue(elements.get(1) instanceof Reaction); Reaction reaction = (Reaction) elements.get(1); assertEquals("re1", reaction.getIdReaction()); - assertTrue(elements.get(2) instanceof SpeciesAlias); - sAlias = (SpeciesAlias) elements.get(2); + assertTrue(elements.get(2) instanceof Species); + sAlias = (Species) elements.get(2); assertEquals("s3", sAlias.getName()); assertTrue(elements.get(3) instanceof Reaction); reaction = (Reaction) elements.get(3); assertEquals("re2", reaction.getIdReaction()); - assertTrue(elements.get(4) instanceof SpeciesAlias); - sAlias = (SpeciesAlias) elements.get(4); + assertTrue(elements.get(4) instanceof Species); + sAlias = (Species) elements.get(4); assertEquals("s2", sAlias.getName()); } catch (Exception e) { @@ -274,14 +274,14 @@ public class SearchServiceTest extends ServiceTestFunctions { public void testGetAutocompleList() { try { Model model = new ModelFullIndexed(null); - SpeciesAlias proteinAlias = new GenericProteinAlias("a"); + Species proteinAlias = new GenericProtein("a"); proteinAlias.setName("PROT identifier"); proteinAlias.getSynonyms().add("PROT synonym"); proteinAlias.getSynonyms().add("another synonym"); proteinAlias.setFullName("Protein common name"); model.addAlias(proteinAlias); - SimpleMoleculeAlias alias = new SimpleMoleculeAlias("a2"); + SimpleMolecule alias = new SimpleMolecule("a2"); alias.setName("Molecule2"); model.addAlias(alias); @@ -322,12 +322,12 @@ public class SearchServiceTest extends ServiceTestFunctions { public void testGetAutocompleList2() { try { Model model = new ModelFullIndexed(null); - GenericProteinAlias proteinAlias = new GenericProteinAlias("a1"); + GenericProtein proteinAlias = new GenericProtein("a1"); proteinAlias.setName("PROT identifier"); proteinAlias.setNotes("Synonyms: PROT synonym, another synonym\nName: Protein common name"); model.addAlias(proteinAlias); - SimpleMoleculeAlias alias = new SimpleMoleculeAlias("a2"); + SimpleMolecule alias = new SimpleMolecule("a2"); alias.setName("Molecule2"); model.addAlias(alias); diff --git a/service/src/test/java/lcsb/mapviewer/services/search/SearchResultFactoryTest.java b/service/src/test/java/lcsb/mapviewer/services/search/SearchResultFactoryTest.java index e0001fc278..86b87af933 100644 --- a/service/src/test/java/lcsb/mapviewer/services/search/SearchResultFactoryTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/search/SearchResultFactoryTest.java @@ -10,8 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Rna; import lcsb.mapviewer.services.ServiceTestFunctions; import lcsb.mapviewer.services.search.db.DbSearchCriteria; import lcsb.mapviewer.services.search.db.GeneRow; @@ -51,7 +51,7 @@ public class SearchResultFactoryTest extends ServiceTestFunctions { } } - Alias element = new RnaAlias("id"); + Element element = new Rna("id"); element.setName(geneName); assertTrue(factory.elementMatch(target, element)); 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 69386a73bf..31df89988d 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 @@ -25,17 +25,17 @@ import lcsb.mapviewer.model.graphics.PolylineData; 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.Layout; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; import lcsb.mapviewer.model.map.reaction.Product; import lcsb.mapviewer.model.map.reaction.Reactant; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.type.NegativeInfluenceReaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.services.ServiceTestFunctions; import lcsb.mapviewer.services.overlay.ChebiTreeRow; @@ -47,15 +47,15 @@ public class FullAliasViewFactoryTest extends ServiceTestFunctions { @Autowired private ChebiAnnotator backend; - private SpeciesAlias alias; - private SpeciesAlias alias2; + private Species alias; + private Species alias2; private Point2D midPoint; private Reaction reaction; - private SpeciesAlias alias3; + private Species alias3; private Model model; - private CompartmentAlias compartmentAlias; + private Compartment compartmentAlias; @Before public void setUp() throws Exception { @@ -68,7 +68,7 @@ public class FullAliasViewFactoryTest extends ServiceTestFunctions { model.addLayout(new Layout()); model.getModelData().setId(-12); - alias = new GenericProteinAlias("AL1"); + alias = new GenericProtein("AL1"); alias.setName("blablabla"); alias.setNotes("nottttttes"); alias.setX(10.0); @@ -78,7 +78,7 @@ public class FullAliasViewFactoryTest extends ServiceTestFunctions { model.addAlias(alias); - alias2 = new GenericProteinAlias("AL2"); + alias2 = new GenericProtein("AL2"); alias2.setName("blablabla2"); alias2.setX(100.0); alias2.setY(120.0); @@ -99,7 +99,7 @@ public class FullAliasViewFactoryTest extends ServiceTestFunctions { model.addReaction(reaction); - alias3 = new GenericProteinAlias("AL3"); + alias3 = new GenericProtein("AL3"); alias3.setName("blablabla3"); alias3.setX(200.0); alias3.setY(120.0); @@ -111,7 +111,7 @@ public class FullAliasViewFactoryTest extends ServiceTestFunctions { model.addReaction(reaction); - compartmentAlias = new CompartmentAlias("AL4"); + compartmentAlias = new Compartment("AL4"); compartmentAlias.setX(10); compartmentAlias.setY(10); compartmentAlias.setWidth(10); @@ -126,7 +126,7 @@ public class FullAliasViewFactoryTest extends ServiceTestFunctions { @Test public void testCreateGson() { try { - Alias alias = new GenericProteinAlias("id"); + Element alias = new GenericProtein("id"); alias.setName("12"); alias.setModel(new ModelFullIndexed(null)); FullAliasView object = fullAliasViewFactory.create(alias); @@ -168,7 +168,7 @@ public class FullAliasViewFactoryTest extends ServiceTestFunctions { try { Model model = getModelForFile("testFiles/protein_with_modification.xml", true); model.setTileSize(256); - SpeciesAlias alias = (SpeciesAlias) model.getAliasByAliasId("sa1"); + Species alias = (Species) model.getAliasByAliasId("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); - SpeciesAlias alias = (SpeciesAlias) model.getAliasByAliasId("sa4"); + Species alias = (Species) model.getAliasByAliasId("sa4"); assertNotNull(alias); FullAliasView result = fullAliasViewFactory.create(alias); assertNotNull(result.getOther("chebiTree")); - alias = (SpeciesAlias) model.getAliasByAliasId("sa3"); + alias = (Species) model.getAliasByAliasId("sa3"); result = fullAliasViewFactory.create(alias); assertNull(result.getOther("chebiTree")); diff --git a/service/src/test/java/lcsb/mapviewer/services/search/data/LightAliasViewFactoryTest.java b/service/src/test/java/lcsb/mapviewer/services/search/data/LightAliasViewFactoryTest.java index 7671a2706b..74001678a2 100644 --- a/service/src/test/java/lcsb/mapviewer/services/search/data/LightAliasViewFactoryTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/search/data/LightAliasViewFactoryTest.java @@ -7,9 +7,9 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.GenericProtein; public class LightAliasViewFactoryTest { Logger logger = Logger.getLogger(LightAliasViewFactoryTest.class); @@ -27,7 +27,7 @@ public class LightAliasViewFactoryTest { @Test public void testCreateGson() throws Exception { try { - Alias alias = new GenericProteinAlias("id"); + Element alias = new GenericProtein("id"); alias.setModel(new ModelFullIndexed(null)); LightAliasView object = lightAliasViewFactory.create(alias); String gson = lightAliasViewFactory.createGson(object); diff --git a/service/src/test/java/lcsb/mapviewer/services/search/db/chemical/ChemicalServiceTest.java b/service/src/test/java/lcsb/mapviewer/services/search/db/chemical/ChemicalServiceTest.java index bda12a2d5b..bf03c7f2df 100644 --- a/service/src/test/java/lcsb/mapviewer/services/search/db/chemical/ChemicalServiceTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/search/db/chemical/ChemicalServiceTest.java @@ -14,8 +14,8 @@ import org.junit.Test; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Rna; import lcsb.mapviewer.services.ServiceTestFunctions; import lcsb.mapviewer.services.search.db.DbSearchCriteria; @@ -81,8 +81,8 @@ public class ChemicalServiceTest extends ServiceTestFunctions { @Test public void testSearchByElements4() throws Exception { try { - List<Alias> elements = new ArrayList<>(); - RnaAlias protein = new RnaAlias("id"); + List<Element> elements = new ArrayList<>(); + Rna protein = new Rna("id"); protein.setName("GDNF"); elements.add(protein); diff --git a/service/src/test/java/lcsb/mapviewer/services/search/db/drug/DrugServiceTest.java b/service/src/test/java/lcsb/mapviewer/services/search/db/drug/DrugServiceTest.java index 1b5e3e4540..30989b7ad9 100644 --- a/service/src/test/java/lcsb/mapviewer/services/search/db/drug/DrugServiceTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/search/db/drug/DrugServiceTest.java @@ -26,12 +26,12 @@ import lcsb.mapviewer.converter.zip.ZipEntryFile; import lcsb.mapviewer.model.Project; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; 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.species.Element; +import lcsb.mapviewer.model.map.species.GenericProtein; +import lcsb.mapviewer.model.map.species.Protein; import lcsb.mapviewer.services.ServiceTestFunctions; import lcsb.mapviewer.services.search.db.DbSearchCriteria; import lcsb.mapviewer.services.search.db.GeneRow; @@ -167,12 +167,12 @@ public class DrugServiceTest extends ServiceTestFunctions { @Test public void testSearchByElements() throws Exception { try { - List<Alias> elements = new ArrayList<>(); + List<Element> elements = new ArrayList<>(); List<DrugView> drugs = drugService.getForTargets(elements, new DbSearchCriteria()); assertNotNull(drugs); assertEquals(0, drugs.size()); - ProteinAlias protein = new GenericProteinAlias("id"); + Protein protein = new GenericProtein("id"); protein.setName("DRD2"); protein.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "DRD2")); elements.add(protein); @@ -190,8 +190,8 @@ public class DrugServiceTest extends ServiceTestFunctions { @Test public void testSearchByElements2() throws Exception { try { - List<Alias> elements = new ArrayList<>(); - ProteinAlias protein = new GenericProteinAlias("id"); + List<Element> elements = new ArrayList<>(); + Protein protein = new GenericProtein("id"); protein.setName("DRD2"); protein.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "DRD2")); elements.add(protein); @@ -209,8 +209,8 @@ public class DrugServiceTest extends ServiceTestFunctions { @Test public void testSearchByElements3() throws Exception { try { - List<Alias> elements = new ArrayList<>(); - ProteinAlias protein = new GenericProteinAlias("id"); + List<Element> elements = new ArrayList<>(); + Protein protein = new GenericProtein("id"); protein.setName("GLUD1"); protein.addMiriamData(new MiriamData(MiriamType.HGNC_SYMBOL, "GLUD1")); protein.addMiriamData(new MiriamData(MiriamType.ENTREZ, "2746")); 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 809ecc79d9..981396c266 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 @@ -18,8 +18,8 @@ import lcsb.mapviewer.annotation.data.Drug; import lcsb.mapviewer.annotation.data.Target; import lcsb.mapviewer.annotation.data.TargetType; import lcsb.mapviewer.model.map.MiriamData; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.ServiceTestFunctions; import lcsb.mapviewer.services.overlay.IconManager; import lcsb.mapviewer.services.search.data.ElementIdentifier; @@ -109,7 +109,7 @@ public class DrugViewFactoryTest extends ServiceTestFunctions { try { Drug drug = chemblParser.findDrug("AMANTADINE"); Model model = getModelForFile("testFiles/drug_target.xml", false); - Alias alias = model.getAliasByAliasId("sa9"); + Element alias = model.getAliasByAliasId("sa9"); alias.setName("M"); alias.setId(12); model.removeAlias(alias); diff --git a/service/src/test/java/lcsb/mapviewer/services/search/layout/FullLayoutAliasViewFactoryTest.java b/service/src/test/java/lcsb/mapviewer/services/search/layout/FullLayoutAliasViewFactoryTest.java index 17f59a8fc7..7c58a8a3db 100644 --- a/service/src/test/java/lcsb/mapviewer/services/search/layout/FullLayoutAliasViewFactoryTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/search/layout/FullLayoutAliasViewFactoryTest.java @@ -12,10 +12,10 @@ import org.junit.Test; import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.model.map.layout.ColorSchema; import lcsb.mapviewer.model.map.layout.GenericColorSchema; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.GenericProtein; public class FullLayoutAliasViewFactoryTest { @@ -37,11 +37,11 @@ public class FullLayoutAliasViewFactoryTest { public void testCreateGson() throws Exception { try { Model model = new ModelFullIndexed(null); - Alias alias = new GenericProteinAlias("id"); + Element alias = new GenericProtein("id"); alias.setModel(model); ColorSchema colorSchema = new GenericColorSchema(); colorSchema.setColor(Color.BLACK); - FullLayoutAliasView object = factory.create(new Pair<Alias, ColorSchema>(alias, colorSchema)); + FullLayoutAliasView object = factory.create(new Pair<Element, ColorSchema>(alias, colorSchema)); assertNotNull(factory.createGson(object)); } catch (Exception e) { e.printStackTrace(); diff --git a/service/src/test/java/lcsb/mapviewer/services/search/layout/LightLayoutAliasViewFactoryTest.java b/service/src/test/java/lcsb/mapviewer/services/search/layout/LightLayoutAliasViewFactoryTest.java index 895ea7d084..f3375530a2 100644 --- a/service/src/test/java/lcsb/mapviewer/services/search/layout/LightLayoutAliasViewFactoryTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/search/layout/LightLayoutAliasViewFactoryTest.java @@ -11,10 +11,10 @@ import org.junit.Test; import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.model.map.layout.ColorSchema; import lcsb.mapviewer.model.map.layout.GenericColorSchema; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.GenericProteinAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.GenericProtein; public class LightLayoutAliasViewFactoryTest { LightLayoutAliasViewFactory factory = new LightLayoutAliasViewFactory(); @@ -31,11 +31,11 @@ public class LightLayoutAliasViewFactoryTest { public void testCreateGson() throws Exception { try { Model model = new ModelFullIndexed(null); - Alias alias = new GenericProteinAlias("id"); + Element alias = new GenericProtein("id"); alias.setModel(model); ColorSchema colorSchema = new GenericColorSchema(); colorSchema.setColor(Color.BLACK); - LightLayoutAliasView object = factory.create(new Pair<Alias, ColorSchema>(alias, colorSchema)); + LightLayoutAliasView object = factory.create(new Pair<Element, ColorSchema>(alias, colorSchema)); assertNotNull(factory.createGson(object)); } catch (Exception e) { e.printStackTrace(); diff --git a/service/src/test/java/lcsb/mapviewer/services/utils/graph/MissingConnectionDaoTest.java b/service/src/test/java/lcsb/mapviewer/services/utils/graph/MissingConnectionDaoTest.java index 48ac7727e5..d6b812bb0e 100644 --- a/service/src/test/java/lcsb/mapviewer/services/utils/graph/MissingConnectionDaoTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/utils/graph/MissingConnectionDaoTest.java @@ -16,15 +16,15 @@ import lcsb.mapviewer.model.Project; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.graph.DataMining; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.ServiceTestFunctions; public class MissingConnectionDaoTest extends ServiceTestFunctions { static Logger logger = Logger.getLogger(MissingConnectionDaoTest.class); private Model model; - private Collection<Alias> nodes; + private Collection<Element> nodes; private Project project; @@ -50,7 +50,7 @@ public class MissingConnectionDaoTest extends ServiceTestFunctions { @Test public void testGetMissingConnections() { try { - Alias node = nodes.iterator().next(); + Element node = nodes.iterator().next(); DataMining mc = new DataMining(); mc.setDescription("desc a"); diff --git a/web/src/main/java/lcsb/mapviewer/bean/AbstractManagedBean.java b/web/src/main/java/lcsb/mapviewer/bean/AbstractManagedBean.java index e657b1c4d1..8caa363dc1 100644 --- a/web/src/main/java/lcsb/mapviewer/bean/AbstractManagedBean.java +++ b/web/src/main/java/lcsb/mapviewer/bean/AbstractManagedBean.java @@ -1,547 +1,547 @@ -package lcsb.mapviewer.bean; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.beans.PropertyVetoException; -import java.beans.VetoableChangeListener; -import java.beans.VetoableChangeSupport; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.annotation.PostConstruct; -import javax.faces.component.UIComponent; -import javax.faces.context.ExternalContext; -import javax.faces.context.FacesContext; - -import org.apache.commons.io.IOUtils; -import org.apache.log4j.Logger; - -import com.google.gson.Gson; - -import lcsb.mapviewer.bean.utils.IPrimefacesUtils; -import lcsb.mapviewer.bean.utils.PrimefacesUtils; -import lcsb.mapviewer.common.MimeType; -import lcsb.mapviewer.common.Pair; -import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.events.Event; -import lcsb.mapviewer.events.Listener; -import lcsb.mapviewer.model.map.model.Model; - -/** - * Abstarct bean class containing basic functionality common for all beans - * (property change listeners and vetoable property change listeners). - * - * @author Piotr Gawron - * - */ -public abstract class AbstractManagedBean implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * Util class used to access information about current reqruest and general - * information about P framework. - */ - private transient IPrimefacesUtils primefacesUtils = new PrimefacesUtils(); - - /** - * Default class logger. - */ - private static Logger logger = Logger.getLogger(AbstractManagedBean.class); - - /** - * Set of verification listeners called when some property is changed. It's - * marked transient because we don't want to store this in session. TODO it's - * should be modified. - */ - private final VetoableChangeSupport vchs = new VetoableChangeSupport(this); - - /** - * Set of listeners called when some property is changed. It's marked - * transient because we don't want to store this in session. TODO it's should - * be modified. - */ - private final PropertyChangeSupport pchs = new PropertyChangeSupport(this); - - /** - * This map contains information about {@link Listener listeners} that should - * be handled when {@link #callListeners(Event)} method is called. It's marked - * transient because we don't want to store this in session. TODO it's should - * be modified. - */ - private transient Map<Class<? extends Event>, List<Listener<?>>> listeners = new HashMap<Class<? extends Event>, List<Listener<?>>>(); - - - /** - * Default constructor. Adds generic log listener to property change - * listeners. - */ - public AbstractManagedBean() { - // logger property listener - PropertyChangeListener propertyChangeLogger = new PropertyChangeListener() { - @Override - public void propertyChange(final PropertyChangeEvent arg0) { - logger.debug("Property changed: " + arg0.getPropertyName() + ". Old: " + arg0.getOldValue() + " New: " + arg0.getNewValue()); - } - - }; - addPropertyChangeListener(propertyChangeLogger); - - } - - /** - * Method run after creating all the beans. It's used for data initalization. - */ - public abstract void init(); - - /** - * Initialize common data and call custom initializer of the bean. - */ - @PostConstruct - public void internalInit() { - createSession(); - logger.debug("Initializing bean: " + this); - - // call init method for specific bean - init(); - logger.debug("Bean: " + this + " initialized."); - } - - /** - * Creates http session if session hasn't been created yet. - */ - public void createSession() { - getPrimefacesUtils().createSession(); - } - - /** - * Add property change listener that can VETO (cancel) the property change. - * - * @param listener - * property listener - */ - public final void addVetoablePropertyChangeListener(final VetoableChangeListener listener) { - vchs.addVetoableChangeListener(listener); - } - - /** - * Removes property change l;istener that can VETO from the available - * listeners. - * - * @param listener - * listeren to be removed - */ - public final void removeVetoablePropertyChangeListener(final VetoableChangeListener listener) { - vchs.removeVetoableChangeListener(listener); - } - - /** - * Adds property change listener that is fired after property of a bean is - * changed. - * - * @param listener - * listener to be added - */ - public final void addPropertyChangeListener(final PropertyChangeListener listener) { - pchs.addPropertyChangeListener(listener); - } - - /** - * Removes property change listener from the list of all available listeners. - * - * @param listener - * listener to be removed - */ - public final void removePropertyChangeListener(final PropertyChangeListener listener) { - pchs.removePropertyChangeListener(listener); - } - - /** - * Method that fires all vetoable property change listener for a given - * property. - * - * @param propertyName - * property that has changed - * @param oldValue - * old value of the property - * @param newValue - * new value of the property - * @throws PropertyVetoException - * if the change shouldn't be made this exception is thrown - */ - protected final void fireVetoableChange(final String propertyName, final Object oldValue, final Object newValue) throws PropertyVetoException { - vchs.fireVetoableChange(propertyName, oldValue, newValue); - } - - /** - * Method fires property change listener for a given property. - * - * @param propertyName - * name of the property that has changed - * @param oldValue - * old value of the property - * @param newValue - * new value of the property - */ - protected final void firePropertyChange(final String propertyName, final Object oldValue, final Object newValue) { - if (oldValue != null || newValue != null) { - pchs.firePropertyChange(propertyName, oldValue, newValue); - } - } - - /** - * Returns list of all property change listeners for the bean (includes only - * standard property change listeners, vetoable property change listeners are - * excluded). - * - * @return list of property change listeners - */ - protected final PropertyChangeListener[] getPropertyChangeListeners() { - return pchs.getPropertyChangeListeners(); - } - - // TODO refactor these two methods to reduce copy-paste - - /** - * Method sends to a client response with an attached file. The content of the - * file is taken from the content param. Type defines MimeType of the content - * (text file, xml, etc.) - this helps browser to properly handle response. - * - * @param content - * - string with the file content - * @param fileName - * - name of the file that should popup in the client browser - * @param type - * - MIME type of the file - * @throws IOException - * exception thrown when there are some problems with sending file - */ - protected final void sendFileAsResponse(String content, String fileName, MimeType type) throws IOException { - // send the response to client - FacesContext fc = FacesContext.getCurrentInstance(); - ExternalContext ec = fc.getExternalContext(); - - ec.responseReset(); - ec.setResponseContentType(type.getTextRepresentation()); - ec.setResponseHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); - ec.addResponseHeader("Content-Type", type.getTextRepresentation()); - - OutputStream output = ec.getResponseOutputStream(); - PrintStream printStream = new PrintStream(output); - printStream.print(content); - - fc.responseComplete(); - } - - /** - * Method sends to a client response with an attached file. Type defines - * MimeType of the file content (text file, xml, etc.) - this helps browser to - * properly handle response. - * - * @param file - * - file which will be sent - * @param fileName - * - name of the file that should popup in the client browser - * @param type - * - MIME type of the file - * @throws IOException - * exception thrown when there are some problems with sending file - */ - protected void sendFileAsResponse(File file, String fileName, MimeType type) throws IOException { - - // start sending - FacesContext fc = FacesContext.getCurrentInstance(); - ExternalContext ec = fc.getExternalContext(); - - ec.responseReset(); - ec.setResponseContentType(type.getTextRepresentation()); - ec.setResponseHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); - - // attach file - OutputStream output = ec.getResponseOutputStream(); - FileInputStream is = new FileInputStream(file); - IOUtils.copy(is, output); - fc.responseComplete(); - - } - - /** - * Clears whole data shared by this bean. - */ - public abstract void clear(); - - /** - * Register new {@link Listener} in this bean. - * - * @param listener - * listener that should be added - */ - public void registerListener(Listener<?> listener) { - List<Listener<?>> listenerList = getListeners().get(listener.getEventClass()); - if (listenerList == null) { - listenerList = new ArrayList<Listener<?>>(); - listeners.put(listener.getEventClass(), listenerList); - } - listenerList.add(listener); - } - - /** - * This method will call all listeners associated with the specified - * {@link Event}. - * - * @param event - * {@link Event} for which listeners will be called - */ - protected void callListeners(Event event) { - List<Listener<?>> listenerList = getListeners().get(event.getClass()); - if (listenerList == null) { - logger.warn("No listeners found for event: " + event); - } else { - for (Listener<?> listener : listenerList) { - listener.handleEvent(event); - } - } - - } - - /** - * Unregister {@link Listener} from this bean. - * - * @param listener - * listener that should be removed - */ - public void unregisterListener(Listener<?> listener) { - List<Listener<?>> listenerList = listeners.get(listener.getEventClass()); - if (listenerList == null) { - listenerList = new ArrayList<Listener<?>>(); - listeners.put(listener.getEventClass(), listenerList); - } - if (listenerList.contains(listener)) { - listenerList.remove(listener); - } else { - throw new InvalidArgumentException("Listener " + listener + " wasn't registered."); - } - - } - - /** - * @param primefacesUtils - * the primefacesUtils to set - * @see #primefacesUtils - */ - protected void setPrimefacesUtils(IPrimefacesUtils primefacesUtils) { - this.primefacesUtils = primefacesUtils; - } - - /** - * Returns value of the parameter from http request call. - * - * @param name - * name of the parameter - * @return value of the request parameter - */ - protected String getRequestParameter(String name) { - return getPrimefacesUtils().getRequestParameter(name); - } - - /** - * Adds a parameter that will be stored in user session. - * - * @param key - * name of the parameter - * @param value - * value of the parameter - */ - protected void addSessionParam(String key, Object value) { - getPrimefacesUtils().addSessionParam(key, value); - } - - /** - * Gets a value of the parameter stored in user session. - * - * @param key - * name of the parameter - * @return value of the user session parameter - */ - protected Object getSessionParam(String key) { - return getPrimefacesUtils().getSessionParam(key); - } - - /** - * @return the version of primefaces library - */ - public String getPrimefacesVersion() { - return getPrimefacesUtils().getVersion(); - } - - /** - * Returns path on hard drive where the project is deplyed. - * - * @return path where the projest is running - */ - public String getProjectDeployPath() { - return getPrimefacesUtils().getPath(); - } - - /** - * Sends an error message to the client. - * - * @param message - * error message to be sent - */ - protected void sendError(String message) { - getPrimefacesUtils().error(message); - } - - /** - * Sends an error message to the client. - * - * @param message - * error message to be sent - * @param exception - * exception which caused the error - */ - protected void sendError(String message, Exception exception) { - logger.error(message, exception); - getPrimefacesUtils().error(message); - } - - /** - * Sends info message to the client. - * - * @param message - * info message to be sent - */ - protected void sendInfo(String message) { - getPrimefacesUtils().info(message); - } - - /** - * Returns ip address of current client. - * - * @return IP addresss of the client - */ - protected String getClientIpAddress() { - return getPrimefacesUtils().getClientIpAddress(); - } - - /** - * Returns a {@link UIComponent} corresponding to the client side component - * with the identifier given in the parameter. - * - * @param id - * identifier of a component - * @return {@link UIComponent} corresponding to the client side component with - * the identifier given in the parameter - */ - protected UIComponent findComponent(String id) { - return getPrimefacesUtils().findComponent(id); - } - - /** - * Returns bean identified by {@link Class}. - * - * @param clazz - * class of the bean - * @param <T> - * class of the bean - * @return bean identified by {@link Class} - */ - public <T> T findBean(Class<T> clazz) { - return getPrimefacesUtils().findBean(clazz); - } - - /** - * @return primefacesUtils. - */ - public IPrimefacesUtils getPrimefacesUtils() { - if (primefacesUtils == null) { - primefacesUtils = new PrimefacesUtils(); - } - return primefacesUtils; - } - - /** - * @return listeners. - */ - public Map<Class<? extends Event>, List<Listener<?>>> getListeners() { - if (listeners == null) { - listeners = new HashMap<Class<? extends Event>, List<Listener<?>>>(); - } - return listeners; - } - - /** - * @param listeners - * general listeners. - */ - public void setListeners(Map<Class<? extends Event>, List<Listener<?>>> listeners) { - this.listeners = listeners; - } - - /** - * Executes javascript code on the client browser. - * - * @param javascript - * javascript code - */ - public void executeJavascript(String javascript) { - getPrimefacesUtils().executeJavascript(javascript); - } - - /** - * Transform json string representing list of pairs with model and object id - * (it can be list of alias ids or reaction ids) into a {@link List} of - * {@link Pair pairs}. - * - * @param string - * list containing pairs of identifiers - * @return list of pairs with model and alias id: {@link Pair#left} contains - * {@link Model#getId()} and {@link Pair#right} conatins - * {@link lcsb.mapviewer.model.map.layout.alias.Alias#id}. - * - */ - protected List<Pair<Integer, Integer>> deserializeJsonIds(String string) { - List<Pair<Integer, Integer>> result = new ArrayList<>(); - @SuppressWarnings("unchecked") - List<List<?>> list = new Gson().fromJson(string, List.class); - for (List<?> list2 : list) { - Integer left = null; - Object leftObj = list2.get(0); - if (leftObj instanceof Double) { - left = ((Double) leftObj).intValue(); - } else if (leftObj instanceof String) { - left = Integer.valueOf((String) leftObj); - } else { - throw new InvalidArgumentException("Don't know how to handle class: " + leftObj.getClass()); - } - - Integer right = null; - Object rightObj = list2.get(1); - if (rightObj instanceof Double) { - right = ((Double) rightObj).intValue(); - } else if (rightObj instanceof String) { - right = Integer.valueOf((String) rightObj); - } else { - throw new InvalidArgumentException("Don't know how to handle class: " + rightObj.getClass()); - } - - result.add(new Pair<Integer, Integer>(left, right)); - } - return result; - } - - -} +package lcsb.mapviewer.bean; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.beans.PropertyVetoException; +import java.beans.VetoableChangeListener; +import java.beans.VetoableChangeSupport; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintStream; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.annotation.PostConstruct; +import javax.faces.component.UIComponent; +import javax.faces.context.ExternalContext; +import javax.faces.context.FacesContext; + +import org.apache.commons.io.IOUtils; +import org.apache.log4j.Logger; + +import com.google.gson.Gson; + +import lcsb.mapviewer.bean.utils.IPrimefacesUtils; +import lcsb.mapviewer.bean.utils.PrimefacesUtils; +import lcsb.mapviewer.common.MimeType; +import lcsb.mapviewer.common.Pair; +import lcsb.mapviewer.common.exception.InvalidArgumentException; +import lcsb.mapviewer.events.Event; +import lcsb.mapviewer.events.Listener; +import lcsb.mapviewer.model.map.model.Model; + +/** + * Abstarct bean class containing basic functionality common for all beans + * (property change listeners and vetoable property change listeners). + * + * @author Piotr Gawron + * + */ +public abstract class AbstractManagedBean implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Util class used to access information about current reqruest and general + * information about P framework. + */ + private transient IPrimefacesUtils primefacesUtils = new PrimefacesUtils(); + + /** + * Default class logger. + */ + private static Logger logger = Logger.getLogger(AbstractManagedBean.class); + + /** + * Set of verification listeners called when some property is changed. It's + * marked transient because we don't want to store this in session. TODO it's + * should be modified. + */ + private final VetoableChangeSupport vchs = new VetoableChangeSupport(this); + + /** + * Set of listeners called when some property is changed. It's marked + * transient because we don't want to store this in session. TODO it's should + * be modified. + */ + private final PropertyChangeSupport pchs = new PropertyChangeSupport(this); + + /** + * This map contains information about {@link Listener listeners} that should + * be handled when {@link #callListeners(Event)} method is called. It's marked + * transient because we don't want to store this in session. TODO it's should + * be modified. + */ + private transient Map<Class<? extends Event>, List<Listener<?>>> listeners = new HashMap<Class<? extends Event>, List<Listener<?>>>(); + + + /** + * Default constructor. Adds generic log listener to property change + * listeners. + */ + public AbstractManagedBean() { + // logger property listener + PropertyChangeListener propertyChangeLogger = new PropertyChangeListener() { + @Override + public void propertyChange(final PropertyChangeEvent arg0) { + logger.debug("Property changed: " + arg0.getPropertyName() + ". Old: " + arg0.getOldValue() + " New: " + arg0.getNewValue()); + } + + }; + addPropertyChangeListener(propertyChangeLogger); + + } + + /** + * Method run after creating all the beans. It's used for data initalization. + */ + public abstract void init(); + + /** + * Initialize common data and call custom initializer of the bean. + */ + @PostConstruct + public void internalInit() { + createSession(); + logger.debug("Initializing bean: " + this); + + // call init method for specific bean + init(); + logger.debug("Bean: " + this + " initialized."); + } + + /** + * Creates http session if session hasn't been created yet. + */ + public void createSession() { + getPrimefacesUtils().createSession(); + } + + /** + * Add property change listener that can VETO (cancel) the property change. + * + * @param listener + * property listener + */ + public final void addVetoablePropertyChangeListener(final VetoableChangeListener listener) { + vchs.addVetoableChangeListener(listener); + } + + /** + * Removes property change l;istener that can VETO from the available + * listeners. + * + * @param listener + * listeren to be removed + */ + public final void removeVetoablePropertyChangeListener(final VetoableChangeListener listener) { + vchs.removeVetoableChangeListener(listener); + } + + /** + * Adds property change listener that is fired after property of a bean is + * changed. + * + * @param listener + * listener to be added + */ + public final void addPropertyChangeListener(final PropertyChangeListener listener) { + pchs.addPropertyChangeListener(listener); + } + + /** + * Removes property change listener from the list of all available listeners. + * + * @param listener + * listener to be removed + */ + public final void removePropertyChangeListener(final PropertyChangeListener listener) { + pchs.removePropertyChangeListener(listener); + } + + /** + * Method that fires all vetoable property change listener for a given + * property. + * + * @param propertyName + * property that has changed + * @param oldValue + * old value of the property + * @param newValue + * new value of the property + * @throws PropertyVetoException + * if the change shouldn't be made this exception is thrown + */ + protected final void fireVetoableChange(final String propertyName, final Object oldValue, final Object newValue) throws PropertyVetoException { + vchs.fireVetoableChange(propertyName, oldValue, newValue); + } + + /** + * Method fires property change listener for a given property. + * + * @param propertyName + * name of the property that has changed + * @param oldValue + * old value of the property + * @param newValue + * new value of the property + */ + protected final void firePropertyChange(final String propertyName, final Object oldValue, final Object newValue) { + if (oldValue != null || newValue != null) { + pchs.firePropertyChange(propertyName, oldValue, newValue); + } + } + + /** + * Returns list of all property change listeners for the bean (includes only + * standard property change listeners, vetoable property change listeners are + * excluded). + * + * @return list of property change listeners + */ + protected final PropertyChangeListener[] getPropertyChangeListeners() { + return pchs.getPropertyChangeListeners(); + } + + // TODO refactor these two methods to reduce copy-paste + + /** + * Method sends to a client response with an attached file. The content of the + * file is taken from the content param. Type defines MimeType of the content + * (text file, xml, etc.) - this helps browser to properly handle response. + * + * @param content + * - string with the file content + * @param fileName + * - name of the file that should popup in the client browser + * @param type + * - MIME type of the file + * @throws IOException + * exception thrown when there are some problems with sending file + */ + protected final void sendFileAsResponse(String content, String fileName, MimeType type) throws IOException { + // send the response to client + FacesContext fc = FacesContext.getCurrentInstance(); + ExternalContext ec = fc.getExternalContext(); + + ec.responseReset(); + ec.setResponseContentType(type.getTextRepresentation()); + ec.setResponseHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); + ec.addResponseHeader("Content-Type", type.getTextRepresentation()); + + OutputStream output = ec.getResponseOutputStream(); + PrintStream printStream = new PrintStream(output); + printStream.print(content); + + fc.responseComplete(); + } + + /** + * Method sends to a client response with an attached file. Type defines + * MimeType of the file content (text file, xml, etc.) - this helps browser to + * properly handle response. + * + * @param file + * - file which will be sent + * @param fileName + * - name of the file that should popup in the client browser + * @param type + * - MIME type of the file + * @throws IOException + * exception thrown when there are some problems with sending file + */ + protected void sendFileAsResponse(File file, String fileName, MimeType type) throws IOException { + + // start sending + FacesContext fc = FacesContext.getCurrentInstance(); + ExternalContext ec = fc.getExternalContext(); + + ec.responseReset(); + ec.setResponseContentType(type.getTextRepresentation()); + ec.setResponseHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); + + // attach file + OutputStream output = ec.getResponseOutputStream(); + FileInputStream is = new FileInputStream(file); + IOUtils.copy(is, output); + fc.responseComplete(); + + } + + /** + * Clears whole data shared by this bean. + */ + public abstract void clear(); + + /** + * Register new {@link Listener} in this bean. + * + * @param listener + * listener that should be added + */ + public void registerListener(Listener<?> listener) { + List<Listener<?>> listenerList = getListeners().get(listener.getEventClass()); + if (listenerList == null) { + listenerList = new ArrayList<Listener<?>>(); + listeners.put(listener.getEventClass(), listenerList); + } + listenerList.add(listener); + } + + /** + * This method will call all listeners associated with the specified + * {@link Event}. + * + * @param event + * {@link Event} for which listeners will be called + */ + protected void callListeners(Event event) { + List<Listener<?>> listenerList = getListeners().get(event.getClass()); + if (listenerList == null) { + logger.warn("No listeners found for event: " + event); + } else { + for (Listener<?> listener : listenerList) { + listener.handleEvent(event); + } + } + + } + + /** + * Unregister {@link Listener} from this bean. + * + * @param listener + * listener that should be removed + */ + public void unregisterListener(Listener<?> listener) { + List<Listener<?>> listenerList = listeners.get(listener.getEventClass()); + if (listenerList == null) { + listenerList = new ArrayList<Listener<?>>(); + listeners.put(listener.getEventClass(), listenerList); + } + if (listenerList.contains(listener)) { + listenerList.remove(listener); + } else { + throw new InvalidArgumentException("Listener " + listener + " wasn't registered."); + } + + } + + /** + * @param primefacesUtils + * the primefacesUtils to set + * @see #primefacesUtils + */ + protected void setPrimefacesUtils(IPrimefacesUtils primefacesUtils) { + this.primefacesUtils = primefacesUtils; + } + + /** + * Returns value of the parameter from http request call. + * + * @param name + * name of the parameter + * @return value of the request parameter + */ + protected String getRequestParameter(String name) { + return getPrimefacesUtils().getRequestParameter(name); + } + + /** + * Adds a parameter that will be stored in user session. + * + * @param key + * name of the parameter + * @param value + * value of the parameter + */ + protected void addSessionParam(String key, Object value) { + getPrimefacesUtils().addSessionParam(key, value); + } + + /** + * Gets a value of the parameter stored in user session. + * + * @param key + * name of the parameter + * @return value of the user session parameter + */ + protected Object getSessionParam(String key) { + return getPrimefacesUtils().getSessionParam(key); + } + + /** + * @return the version of primefaces library + */ + public String getPrimefacesVersion() { + return getPrimefacesUtils().getVersion(); + } + + /** + * Returns path on hard drive where the project is deplyed. + * + * @return path where the projest is running + */ + public String getProjectDeployPath() { + return getPrimefacesUtils().getPath(); + } + + /** + * Sends an error message to the client. + * + * @param message + * error message to be sent + */ + protected void sendError(String message) { + getPrimefacesUtils().error(message); + } + + /** + * Sends an error message to the client. + * + * @param message + * error message to be sent + * @param exception + * exception which caused the error + */ + protected void sendError(String message, Exception exception) { + logger.error(message, exception); + getPrimefacesUtils().error(message); + } + + /** + * Sends info message to the client. + * + * @param message + * info message to be sent + */ + protected void sendInfo(String message) { + getPrimefacesUtils().info(message); + } + + /** + * Returns ip address of current client. + * + * @return IP addresss of the client + */ + protected String getClientIpAddress() { + return getPrimefacesUtils().getClientIpAddress(); + } + + /** + * Returns a {@link UIComponent} corresponding to the client side component + * with the identifier given in the parameter. + * + * @param id + * identifier of a component + * @return {@link UIComponent} corresponding to the client side component with + * the identifier given in the parameter + */ + protected UIComponent findComponent(String id) { + return getPrimefacesUtils().findComponent(id); + } + + /** + * Returns bean identified by {@link Class}. + * + * @param clazz + * class of the bean + * @param <T> + * class of the bean + * @return bean identified by {@link Class} + */ + public <T> T findBean(Class<T> clazz) { + return getPrimefacesUtils().findBean(clazz); + } + + /** + * @return primefacesUtils. + */ + public IPrimefacesUtils getPrimefacesUtils() { + if (primefacesUtils == null) { + primefacesUtils = new PrimefacesUtils(); + } + return primefacesUtils; + } + + /** + * @return listeners. + */ + public Map<Class<? extends Event>, List<Listener<?>>> getListeners() { + if (listeners == null) { + listeners = new HashMap<Class<? extends Event>, List<Listener<?>>>(); + } + return listeners; + } + + /** + * @param listeners + * general listeners. + */ + public void setListeners(Map<Class<? extends Event>, List<Listener<?>>> listeners) { + this.listeners = listeners; + } + + /** + * Executes javascript code on the client browser. + * + * @param javascript + * javascript code + */ + public void executeJavascript(String javascript) { + getPrimefacesUtils().executeJavascript(javascript); + } + + /** + * Transform json string representing list of pairs with model and object id + * (it can be list of alias ids or reaction ids) into a {@link List} of + * {@link Pair pairs}. + * + * @param string + * list containing pairs of identifiers + * @return list of pairs with model and alias id: {@link Pair#left} contains + * {@link Model#getId()} and {@link Pair#right} conatins + * {@link lcsb.mapviewer.model.map.species.Element#id}. + * + */ + protected List<Pair<Integer, Integer>> deserializeJsonIds(String string) { + List<Pair<Integer, Integer>> result = new ArrayList<>(); + @SuppressWarnings("unchecked") + List<List<?>> list = new Gson().fromJson(string, List.class); + for (List<?> list2 : list) { + Integer left = null; + Object leftObj = list2.get(0); + if (leftObj instanceof Double) { + left = ((Double) leftObj).intValue(); + } else if (leftObj instanceof String) { + left = Integer.valueOf((String) leftObj); + } else { + throw new InvalidArgumentException("Don't know how to handle class: " + leftObj.getClass()); + } + + Integer right = null; + Object rightObj = list2.get(1); + if (rightObj instanceof Double) { + right = ((Double) rightObj).intValue(); + } else if (rightObj instanceof String) { + right = Integer.valueOf((String) rightObj); + } else { + throw new InvalidArgumentException("Don't know how to handle class: " + rightObj.getClass()); + } + + result.add(new Pair<Integer, Integer>(left, right)); + } + return result; + } + + +} diff --git a/web/src/main/java/lcsb/mapviewer/bean/ChemicalBean.java b/web/src/main/java/lcsb/mapviewer/bean/ChemicalBean.java index dc92c1cc86..a0a0fd6a43 100644 --- a/web/src/main/java/lcsb/mapviewer/bean/ChemicalBean.java +++ b/web/src/main/java/lcsb/mapviewer/bean/ChemicalBean.java @@ -14,8 +14,8 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.Project; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.interfaces.IUserService; import lcsb.mapviewer.services.search.ElementIdentifierDetails; import lcsb.mapviewer.services.search.data.ElementIdentifier; @@ -239,8 +239,8 @@ public class ChemicalBean extends AbstractMarkerManagerBean<ChemicalView> implem Model model = getCurrentTopModel().getSubmodelById(element.getModelId()); - Alias alias = model.getAliasByDbId(Integer.valueOf(element.getObjectId())); - List<Alias> list = new ArrayList<>(); + Element alias = model.getAliasByDbId(Integer.valueOf(element.getObjectId())); + List<Element> list = new ArrayList<>(); list.add(alias); List<ChemicalView> chemicals = chemicalService .getForTargets(list, new DbSearchCriteria().model(getCurrentTopModel()).organisms(mapBean.getOrganism()).disease(getCurrentProject().getDisease())); diff --git a/web/src/main/java/lcsb/mapviewer/bean/DrugBean.java b/web/src/main/java/lcsb/mapviewer/bean/DrugBean.java index f1514b7ef7..dbd1bb3205 100644 --- a/web/src/main/java/lcsb/mapviewer/bean/DrugBean.java +++ b/web/src/main/java/lcsb/mapviewer/bean/DrugBean.java @@ -16,8 +16,8 @@ import lcsb.mapviewer.commands.SubModelCommand; import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.Project; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.user.PrivilegeType; import lcsb.mapviewer.model.user.User; import lcsb.mapviewer.services.interfaces.IUserService; @@ -338,8 +338,8 @@ public class DrugBean extends AbstractMarkerManagerBean<DrugView> implements Ser Model model = getCurrentTopModel().getSubmodelById(element.getModelId()); - Alias alias = model.getAliasByDbId(Integer.valueOf(element.getObjectId())); - List<Alias> list = new ArrayList<>(); + Element alias = model.getAliasByDbId(Integer.valueOf(element.getObjectId())); + List<Element> list = new ArrayList<>(); list.add(alias); List<DrugView> drugs = drugService.getForTargets(list, new DbSearchCriteria().model(getCurrentTopModel()).organisms(mapBean.getOrganism())); for (DrugView drugView : drugs) { diff --git a/web/src/main/java/lcsb/mapviewer/bean/ExportBean.java b/web/src/main/java/lcsb/mapviewer/bean/ExportBean.java index f289d8ad19..1f7734ae50 100644 --- a/web/src/main/java/lcsb/mapviewer/bean/ExportBean.java +++ b/web/src/main/java/lcsb/mapviewer/bean/ExportBean.java @@ -52,25 +52,25 @@ import lcsb.mapviewer.converter.model.sbgnml.SbgnmlXmlConverter; import lcsb.mapviewer.model.map.InconsistentModelException; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamType; +import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.layout.ColorSchema; import lcsb.mapviewer.model.map.layout.Layout; -import lcsb.mapviewer.model.map.layout.alias.Alias; -import lcsb.mapviewer.model.map.layout.alias.AntisenseRnaAlias; -import lcsb.mapviewer.model.map.layout.alias.CompartmentAlias; -import lcsb.mapviewer.model.map.layout.alias.ComplexAlias; -import lcsb.mapviewer.model.map.layout.alias.DegradedAlias; -import lcsb.mapviewer.model.map.layout.alias.DrugAlias; -import lcsb.mapviewer.model.map.layout.alias.GeneAlias; -import lcsb.mapviewer.model.map.layout.alias.IonAlias; -import lcsb.mapviewer.model.map.layout.alias.PhenotypeAlias; -import lcsb.mapviewer.model.map.layout.alias.ProteinAlias; -import lcsb.mapviewer.model.map.layout.alias.RnaAlias; -import lcsb.mapviewer.model.map.layout.alias.SimpleMoleculeAlias; -import lcsb.mapviewer.model.map.layout.alias.SpeciesAlias; -import lcsb.mapviewer.model.map.layout.alias.UnknownAlias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelSubmodelConnection; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.AntisenseRna; +import lcsb.mapviewer.model.map.species.Complex; +import lcsb.mapviewer.model.map.species.Degraded; +import lcsb.mapviewer.model.map.species.Drug; +import lcsb.mapviewer.model.map.species.Gene; +import lcsb.mapviewer.model.map.species.Ion; +import lcsb.mapviewer.model.map.species.Phenotype; +import lcsb.mapviewer.model.map.species.Protein; +import lcsb.mapviewer.model.map.species.Rna; +import lcsb.mapviewer.model.map.species.SimpleMolecule; +import lcsb.mapviewer.model.map.species.Species; +import lcsb.mapviewer.model.map.species.Unknown; import lcsb.mapviewer.services.interfaces.IExporterService; import lcsb.mapviewer.services.interfaces.IExporterService.ExporterParameters; import lcsb.mapviewer.services.interfaces.ILayoutService; @@ -289,7 +289,7 @@ public class ExportBean extends AbstractManagedBean { annotations.put(mt, 0); } for (Model model2 : models) { - for (Alias alias : model2.getAliases()) { + for (Element alias : model2.getAliases()) { for (MiriamData md : alias.getMiriamData()) { Integer amount = annotations.get(md.getDataType()); amount += 1; @@ -699,11 +699,11 @@ public class ExportBean extends AbstractManagedBean { } Set<String> components = new HashSet<String>(); - for (CompartmentAlias alias : model.getCompartmentsAliases()) { + for (Compartment alias : model.getCompartmentsAliases()) { components.add(alias.getName()); } for (ModelSubmodelConnection submodel : model.getSubmodelConnections()) { - for (CompartmentAlias alias : submodel.getSubmodel().getModel().getCompartmentsAliases()) { + for (Compartment alias : submodel.getSubmodel().getModel().getCompartmentsAliases()) { components.add(alias.getName()); } } @@ -893,7 +893,7 @@ public class ExportBean extends AbstractManagedBean { mapBean.addPropertyChangeListener(modelPropertyChangeListener); for (ExportColumn type : ExportColumn.values()) { - if (type.getClazz().isAssignableFrom(SpeciesAlias.class)) { + if (type.getClazz().isAssignableFrom(Species.class)) { speciesColumnMap.put(type.getTitle(), type); speciesColumnList.add(type.getTitle()); } @@ -1056,18 +1056,18 @@ public class ExportBean extends AbstractManagedBean { protected Map<String, Class<?>> getSpeciesTypeMap() { if (speciesTypeMap == null) { speciesTypeMap = new LinkedHashMap<>(); - speciesTypeMap.put("Antisense RNA", AntisenseRnaAlias.class); - speciesTypeMap.put("Complex", ComplexAlias.class); - speciesTypeMap.put("Degraded", DegradedAlias.class); - speciesTypeMap.put("Drug", DrugAlias.class); - speciesTypeMap.put("Gene", GeneAlias.class); - speciesTypeMap.put("Ion", IonAlias.class); - speciesTypeMap.put("Phenotype", PhenotypeAlias.class); - speciesTypeMap.put("Protein", ProteinAlias.class); - speciesTypeMap.put("RNA", RnaAlias.class); - speciesTypeMap.put("Molecule", SimpleMoleculeAlias.class); - speciesTypeMap.put("Unknown", UnknownAlias.class); - speciesTypeMap.put("All", SpeciesAlias.class); + speciesTypeMap.put("Antisense RNA", AntisenseRna.class); + speciesTypeMap.put("Complex", Complex.class); + speciesTypeMap.put("Degraded", Degraded.class); + speciesTypeMap.put("Drug", Drug.class); + speciesTypeMap.put("Gene", Gene.class); + speciesTypeMap.put("Ion", Ion.class); + speciesTypeMap.put("Phenotype", Phenotype.class); + speciesTypeMap.put("Protein", Protein.class); + speciesTypeMap.put("RNA", Rna.class); + speciesTypeMap.put("Molecule", SimpleMolecule.class); + speciesTypeMap.put("Unknown", Unknown.class); + speciesTypeMap.put("All", Species.class); } return speciesTypeMap; } @@ -1149,7 +1149,7 @@ public class ExportBean extends AbstractManagedBean { // if it's clean then remove coloring new ColorModelCommand(colorModel, new HashSet<>()).execute(); } - for (Alias alias : colorModel.getAliases()) { + for (Element alias : colorModel.getAliases()) { alias.setVisibilityLevel(0); } diff --git a/web/src/main/java/lcsb/mapviewer/bean/FeedbackBean.java b/web/src/main/java/lcsb/mapviewer/bean/FeedbackBean.java index 054068c878..9932115018 100644 --- a/web/src/main/java/lcsb/mapviewer/bean/FeedbackBean.java +++ b/web/src/main/java/lcsb/mapviewer/bean/FeedbackBean.java @@ -20,12 +20,12 @@ import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.Project; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.reaction.Modifier; import lcsb.mapviewer.model.map.reaction.Product; import lcsb.mapviewer.model.map.reaction.Reactant; import lcsb.mapviewer.model.map.reaction.Reaction; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.user.PrivilegeType; import lcsb.mapviewer.model.user.User; import lcsb.mapviewer.services.interfaces.ICommentService; @@ -269,8 +269,8 @@ public class FeedbackBean extends AbstractMarkerManagerBean<FullCommentView> imp public String getDescription(final Object object) { if (object instanceof Reaction) { return "Reaction: " + ((Reaction) object).getIdReaction(); - } else if (object instanceof Alias) { - Alias alias = (Alias) object; + } else if (object instanceof Element) { + Element alias = (Element) object; return alias.getStringType() + ": " + alias.getName(); } else { throw new InvalidArgumentException("Unknown class type: " + object.getClass()); diff --git a/web/src/main/java/lcsb/mapviewer/bean/MapBean.java b/web/src/main/java/lcsb/mapviewer/bean/MapBean.java index b36c42ac14..3dd2136c55 100644 --- a/web/src/main/java/lcsb/mapviewer/bean/MapBean.java +++ b/web/src/main/java/lcsb/mapviewer/bean/MapBean.java @@ -851,7 +851,7 @@ public class MapBean extends AbstractManagedBean implements Serializable { * Sends list of aliases (with given identifiers) to the browser. Identifiers * are passed as a json string in request parameter <i>ids</i>. Each * identifier is a pair containing information about {@link Model#getId() - * model id} and {@link lcsb.mapviewer.model.map.layout.alias.Alias#id alias + * model id} and {@link lcsb.mapviewer.model.map.species.Element#id alias * id}. Data is very light - contains only information about the location on * the model. * @@ -868,7 +868,7 @@ public class MapBean extends AbstractManagedBean implements Serializable { * Sends list of aliases (with given identifiers) to the browser. Identifiers * are passed as a json string in request parameter <i>ids</i>. Each * identifier is a pair containing information about {@link Model#getId() - * model id} and {@link lcsb.mapviewer.model.map.layout.alias.Alias#id alias + * model id} and {@link lcsb.mapviewer.model.map.species.Element#id alias * id}. Data is heavy - it contains all information related to the alias. * */ diff --git a/web/src/main/java/lcsb/mapviewer/bean/MiRNABean.java b/web/src/main/java/lcsb/mapviewer/bean/MiRNABean.java index 074aa86431..6915f552c1 100644 --- a/web/src/main/java/lcsb/mapviewer/bean/MiRNABean.java +++ b/web/src/main/java/lcsb/mapviewer/bean/MiRNABean.java @@ -13,8 +13,8 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Pair; import lcsb.mapviewer.common.exception.InvalidArgumentException; -import lcsb.mapviewer.model.map.layout.alias.Alias; import lcsb.mapviewer.model.map.model.Model; +import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.services.search.ElementIdentifierDetails; import lcsb.mapviewer.services.search.data.ElementIdentifier; import lcsb.mapviewer.services.search.data.ElementIdentifier.ElementIdentifierType; @@ -186,8 +186,8 @@ public class MiRNABean extends AbstractMarkerManagerBean<MiRNAView> implements S Model model = getCurrentTopModel().getSubmodelById(element.getModelId()); - Alias alias = model.getAliasByDbId(Integer.valueOf(element.getObjectId())); - List<Alias> list = new ArrayList<>(); + Element alias = model.getAliasByDbId(Integer.valueOf(element.getObjectId())); + List<Element> list = new ArrayList<>(); list.add(alias); List<MiRNAView> mirnas = miRNAService.getForTargets(list, new DbSearchCriteria().model(getCurrentTopModel()).organisms(mapBean.getOrganism())); for (MiRNAView mirnaView : mirnas) { -- GitLab