From 6eab06f8a1784f15f3b8ad89aeac94c317556957 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Fri, 13 Jul 2018 14:13:32 +0200 Subject: [PATCH] rest API provide information about all modifications --- .../element/species/SpeciesConverter.java | 3 +- .../element/species/SpeciesConverterTest.java | 3 +- .../src/main/js/gui/leftPanel/GuiUtils.js | 36 ++++++++---- .../resources/applicationContext-persist.xml | 1 + .../elements/ElementsRestImpl.java | 55 ++++++++++++++++--- 5 files changed, 74 insertions(+), 24 deletions(-) diff --git a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverter.java b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverter.java index f9e547396a..c707b3b147 100644 --- a/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverter.java +++ b/converter-graphics/src/main/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverter.java @@ -592,8 +592,7 @@ public abstract class SpeciesConverter<T extends Species> extends ElementConvert double y = modificationSite.getPosition().getY(); - Point2D p = modificationSite.getPosition(); - p.setLocation(p.getX(), p.getY() - DEFAULT_MODIFICATION_DIAMETER); + Point2D p = new Point2D.Double(modificationSite.getPosition().getX(), y - DEFAULT_MODIFICATION_DIAMETER); Ellipse2D ellipse = new Ellipse2D.Double(p.getX() - diameter / 2, p.getY() - diameter / 2, diameter, diameter); Color c = graphics.getColor(); diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverterTest.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverterTest.java index 16bdf0a9a1..4f67a317af 100644 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverterTest.java +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/bioEntity/element/species/SpeciesConverterTest.java @@ -25,8 +25,10 @@ import org.mockito.Mockito; import lcsb.mapviewer.commands.ColorExtractor; import lcsb.mapviewer.converter.graphics.ConverterParams; +import lcsb.mapviewer.converter.graphics.MapGenerator; import lcsb.mapviewer.converter.graphics.PngImageGenerator; import lcsb.mapviewer.converter.graphics.AbstractImageGenerator.Params; +import lcsb.mapviewer.converter.graphics.MapGenerator.MapGeneratorParams; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser; import lcsb.mapviewer.model.map.layout.ColorSchema; import lcsb.mapviewer.model.map.layout.GenericColorSchema; @@ -328,5 +330,4 @@ public class SpeciesConverterTest { return protein; } - } diff --git a/frontend-js/src/main/js/gui/leftPanel/GuiUtils.js b/frontend-js/src/main/js/gui/leftPanel/GuiUtils.js index b8815fc72e..e5ffcbc892 100644 --- a/frontend-js/src/main/js/gui/leftPanel/GuiUtils.js +++ b/frontend-js/src/main/js/gui/leftPanel/GuiUtils.js @@ -60,6 +60,12 @@ GuiUtils.prototype.createLabel = function (value) { return result; }; +/** + * + * @param {string} label + * @param {Object[]} value + * @returns {HTMLDivElement} + */ GuiUtils.prototype.createPostTranslationalModifications = function (label, value) { var result = document.createElement("div"); if (value !== undefined && value.length > 0) { @@ -71,19 +77,25 @@ GuiUtils.prototype.createPostTranslationalModifications = function (label, value }); for (var i = 0; i < value.length; i++) { var name = value[i].name; - var modificationStateType = self.getConfiguration().getModificationStateTypeByName(value[i].state); - var state = modificationStateType.getCommonName(); - var desc; - if (name !== null && name !== undefined && name !== "") { - desc = state + " at position " + name + ", "; - } else { - desc = state + ","; + var desc = undefined; + if (value[i].state !== undefined && value[i].name !== null) { + var modificationStateType = self.getConfiguration().getModificationStateTypeByName(value[i].state); + var state = modificationStateType.getCommonName(); + + if (name !== null && name !== undefined && name !== "") { + desc = state + " at position " + name + ", "; + } else { + desc = state + ","; + } + } + + if (desc !== undefined) { + var row = Functions.createElement({ + type: "li" + }); + row.appendChild(self.createLabelText(desc)); + list.appendChild(row); } - var row = Functions.createElement({ - type: "li" - }); - row.appendChild(self.createLabelText(desc)); - list.appendChild(row); } result.appendChild(list); } diff --git a/persist/src/main/resources/applicationContext-persist.xml b/persist/src/main/resources/applicationContext-persist.xml index 22f563b1a0..104c0fb09f 100644 --- a/persist/src/main/resources/applicationContext-persist.xml +++ b/persist/src/main/resources/applicationContext-persist.xml @@ -180,6 +180,7 @@ <value>lcsb.mapviewer.model.map.species.field.CodingRegion</value> <value>lcsb.mapviewer.model.map.species.field.ModificationSite</value> <value>lcsb.mapviewer.model.map.species.field.ProteinBindingDomain</value> + <value>lcsb.mapviewer.model.map.species.field.RegulatoryRegion</value> <value>lcsb.mapviewer.model.map.species.field.Residue</value> <value>lcsb.mapviewer.model.map.species.field.TranscriptionSite</value> <value>lcsb.mapviewer.model.map.species.field.UniprotRecord</value> diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/elements/ElementsRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/elements/ElementsRestImpl.java index ab6009bf4c..d2f3739d54 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/elements/ElementsRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/elements/ElementsRestImpl.java @@ -12,18 +12,27 @@ import org.springframework.transaction.annotation.Transactional; import lcsb.mapviewer.api.BaseRestImpl; import lcsb.mapviewer.api.QueryException; +import lcsb.mapviewer.common.exception.InvalidArgumentException; +import lcsb.mapviewer.converter.model.celldesigner.structure.fields.ModificationType; import lcsb.mapviewer.model.map.BioEntity; import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.species.AntisenseRna; 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.species.Species; import lcsb.mapviewer.model.map.species.field.AbstractSiteModification; +import lcsb.mapviewer.model.map.species.field.BindingRegion; +import lcsb.mapviewer.model.map.species.field.CodingRegion; import lcsb.mapviewer.model.map.species.field.ModificationResidue; -import lcsb.mapviewer.model.map.species.field.ModificationState; +import lcsb.mapviewer.model.map.species.field.ModificationSite; +import lcsb.mapviewer.model.map.species.field.ProteinBindingDomain; +import lcsb.mapviewer.model.map.species.field.RegulatoryRegion; +import lcsb.mapviewer.model.map.species.field.Residue; import lcsb.mapviewer.model.map.species.field.Structure; +import lcsb.mapviewer.model.map.species.field.TranscriptionSite; import lcsb.mapviewer.model.map.species.field.UniprotRecord; import lcsb.mapviewer.services.SecurityException; @@ -215,12 +224,16 @@ public class ElementsRestImpl extends BaseRestImpl { structuralState = protein.getStructuralState(); } else if (element instanceof Rna) { Rna rna = ((Rna) element); - modifications = getModifications(((Rna) element).getRegions()); + modifications = getModifications(rna.getRegions()); structuralState = rna.getState(); } else if (element instanceof AntisenseRna) { AntisenseRna antisenseRna = ((AntisenseRna) element); - modifications = getModifications(((AntisenseRna) element).getRegions()); + modifications = getModifications(antisenseRna.getRegions()); structuralState = antisenseRna.getState(); + } else if (element instanceof Gene) { + Gene gene = ((Gene) element); + modifications = getModifications(gene.getModificationResidues()); + structuralState = gene.getState(); } if (element instanceof Species) { structures = getStructures(((Species) element).getUniprots()); @@ -235,15 +248,39 @@ public class ElementsRestImpl extends BaseRestImpl { private List<Map<String, Object>> getModifications(List<? extends ModificationResidue> elements) { List<Map<String, Object>> result = new ArrayList<>(); for (ModificationResidue region : elements) { + Map<String, Object> row = new TreeMap<>(); + row.put("name", region.getName()); + row.put("modificationId", region.getIdModificationResidue()); if (region instanceof AbstractSiteModification) { - ModificationState state = ((AbstractSiteModification) region).getState(); - if (state != null) { - Map<String, Object> row = new TreeMap<>(); - row.put("name", region.getName()); - row.put("state", state.name()); - result.add(row); + AbstractSiteModification siteModification = ((AbstractSiteModification) region); + if (siteModification.getState() != null) { + row.put("state", siteModification.getState().name()); } } + String type = null; + if (region instanceof Residue) { + type = ModificationType.RESIDUE.name(); + } else if (region instanceof BindingRegion) { + type = ModificationType.BINDING_REGION.name(); + } else if (region instanceof CodingRegion) { + type = ModificationType.CODING_REGION.name(); + } else if (region instanceof ProteinBindingDomain) { + type = ModificationType.PROTEIN_BINDING_DOMAIN.name(); + } else if (region instanceof RegulatoryRegion) { + type = ModificationType.REGULATORY_REGION.name(); + } else if (region instanceof TranscriptionSite) { + if (((TranscriptionSite) region).getDirection().equals("LEFT")) { + type = ModificationType.TRANSCRIPTION_SITE_LEFT.name(); + } else { + type = ModificationType.TRANSCRIPTION_SITE_RIGHT.name(); + } + } else if (region instanceof ModificationSite) { + type = ModificationType.MODIFICATION_SITE.name(); + } else { + throw new InvalidArgumentException("Unknown class: " + region.getClass()); + } + row.put("type", type); + result.add(row); } return result; } -- GitLab