Commit fc80ef23 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

pdb annotator fixed

parent f837b1ae
Pipeline #47149 failed with stage
in 8 minutes and 24 seconds
......@@ -14,8 +14,9 @@ import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import lcsb.mapviewer.annotation.cache.GeneralCacheInterface;
import lcsb.mapviewer.annotation.cache.WebPageDownloader;
......@@ -90,7 +91,8 @@ public class PdbAnnotator extends ElementAnnotator implements IExternalService {
Collection<Structure> structures = uniProtToPdb(getExampleValidAnnotation());
if (structures.size() > 0) {
if (structures.iterator().next().getPdbId() != null) { // TODO - is this id?
if (structures.iterator().next().getPdbId() != null) { // TODO - is this
// id?
status.setStatus(ExternalServiceStatusType.OK);
} else {
status.setStatus(ExternalServiceStatusType.CHANGED);
......@@ -206,19 +208,22 @@ public class PdbAnnotator extends ElementAnnotator implements IExternalService {
*/
private Collection<Structure> processMappingData(final String pageContentJson) {
Collection<Structure> result = new HashSet<Structure>();
Gson g = new Gson();
java.lang.reflect.Type t = new TypeToken<Map<String, List<PdbBestMappingEntry>>>() {
}.getType();
Map<String, List<PdbBestMappingEntry>> m = g.fromJson(pageContentJson, t);
if (m != null) {
for (final String key : m.keySet()) {
for (final PdbBestMappingEntry e : m.get(key)) {
if (e != null) {
result.add(e.convertToStructure());
// result.add(new MiriamData(MiriamType.PDB, e.pdb_id));
try {
ObjectMapper objectMapper = new ObjectMapper();
Map<String, List<PdbBestMappingEntry>> m = objectMapper.readValue(pageContentJson, new TypeReference<Map<String, List<PdbBestMappingEntry>>>() {
});
if (m != null) {
for (final String key : m.keySet()) {
for (final PdbBestMappingEntry e : m.get(key)) {
if (e != null) {
result.add(e.convertToStructure());
// result.add(new MiriamData(MiriamType.PDB, e.pdb_id));
}
}
}
}
} catch (IOException e1) {
logger.error(e1, e1);
}
return result;
......
package lcsb.mapviewer.annotation.services.annotators;
import com.fasterxml.jackson.annotation.JsonProperty;
import lcsb.mapviewer.model.map.species.field.Structure;
/**
......@@ -9,15 +11,34 @@ import lcsb.mapviewer.model.map.species.field.Structure;
*
*/
public class PdbBestMappingEntry {
@JsonProperty(value = "chain_id")
private String chainId;
@JsonProperty(value = "experimental_method")
private String experimentalMethod;
@JsonProperty(value = "pdb_id")
private String pdbId;
@JsonProperty(value = "start")
private int start;
@JsonProperty(value = "end")
private int end;
@JsonProperty(value = "unp_end")
private int unpEnd;
@JsonProperty(value = "coverage")
private double coverage;
@JsonProperty(value = "unp_start")
private int unpStart;
@JsonProperty(value = "resolution")
private double resolution;
@JsonProperty(value = "tax_id")
private int taxId;
public Structure convertToStructure() {
......
......@@ -11,7 +11,6 @@ import java.util.Set;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -48,8 +47,8 @@ public class PdbAnnotatorTest extends AnnotationTestFunctions {
Species protein = new GenericProtein("id");
protein.setName(uniprotId);
/*
* One needs to have the UniProt ID first. This tests simulates situation when
* the Uniprot annotator is called first.
* One needs to have the UniProt ID first. This tests simulates situation
* when the Uniprot annotator is called first.
*/
uniprotAnnotator.annotateElement(protein);
int cntAnnotations1 = protein.getMiriamData().size();
......@@ -77,7 +76,8 @@ public class PdbAnnotatorTest extends AnnotationTestFunctions {
ur = ur1;
}
}
// Test whether there is a uniprot record with the uniprot ID which was stored
// Test whether there is a uniprot record with the uniprot ID which was
// stored
assertNotNull(ur);
// Test whether structures are there
Set<Structure> ss = ur.getStructures();
......@@ -88,15 +88,9 @@ public class PdbAnnotatorTest extends AnnotationTestFunctions {
}
@Test
@Ignore
public void testAnnotate2() throws Exception {
Species protein = new GenericProtein("id");
protein.setName("P29373");
/*
* One needs to have the UniProt ID first, and Uniprot lookup through HGNC is
* included in PDB annotator. This tests simulates situation when the PDB
* annotator is called first.
*/
protein.addMiriamData(new MiriamData(MiriamType.UNIPROT, "P29373"));
pdbAnnotator.annotateElement(protein);
int cntAnnotations = protein.getMiriamData().size();
......@@ -114,9 +108,9 @@ public class PdbAnnotatorTest extends AnnotationTestFunctions {
}
@Test
@Ignore
public void testAnnotateNotUniprotAnnodated() throws Exception {
Species protein = new GenericProtein("id");
protein.addMiriamData(new MiriamData(MiriamType.UNIPROT, "P29373"));
protein.setName("P29373");
pdbAnnotator.annotateElement(protein);
......
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