Commit 6eab06f8 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

rest API provide information about all modifications

parent 6043d89c
......@@ -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();
......
......@@ -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;
}
}
......@@ -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);
}
......
......@@ -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>
......
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment