Skip to content
Snippets Groups Projects
Commit f8f6c4cf authored by David Hoksza's avatar David Hoksza
Browse files

TAIR annotation called even when Uniprot annotation already exists (can come...

TAIR annotation called even when Uniprot annotation already exists (can come from different annotator and correspond to, e.g., different species)
parent 3db2180a
No related branches found
No related tags found
1 merge request!201Cellwall annotations
...@@ -25,6 +25,7 @@ import lcsb.mapviewer.annotation.services.annotators.GoAnnotator; ...@@ -25,6 +25,7 @@ import lcsb.mapviewer.annotation.services.annotators.GoAnnotator;
import lcsb.mapviewer.annotation.services.annotators.HgncAnnotator; import lcsb.mapviewer.annotation.services.annotators.HgncAnnotator;
import lcsb.mapviewer.annotation.services.annotators.PdbAnnotator; import lcsb.mapviewer.annotation.services.annotators.PdbAnnotator;
import lcsb.mapviewer.annotation.services.annotators.ReconAnnotator; import lcsb.mapviewer.annotation.services.annotators.ReconAnnotator;
import lcsb.mapviewer.annotation.services.annotators.TairAnnotator;
import lcsb.mapviewer.annotation.services.annotators.UniprotAnnotator; import lcsb.mapviewer.annotation.services.annotators.UniprotAnnotator;
import lcsb.mapviewer.common.IProgressUpdater; import lcsb.mapviewer.common.IProgressUpdater;
import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.InvalidArgumentException;
...@@ -124,6 +125,13 @@ public class ModelAnnotator { ...@@ -124,6 +125,13 @@ public class ModelAnnotator {
*/ */
@Autowired @Autowired
private EnsemblAnnotator ensemblAnnotator; private EnsemblAnnotator ensemblAnnotator;
/**
* TAIR annotator.
*/
@Autowired
private TairAnnotator tairAnnotator;
/** /**
* List of all avaliable {@link ElementAnnotator} objects. * List of all avaliable {@link ElementAnnotator} objects.
...@@ -153,6 +161,7 @@ public class ModelAnnotator { ...@@ -153,6 +161,7 @@ public class ModelAnnotator {
addAnnotator(reconAnnotator); addAnnotator(reconAnnotator);
addAnnotator(entrezAnnotator); addAnnotator(entrezAnnotator);
addAnnotator(ensemblAnnotator); addAnnotator(ensemblAnnotator);
addAnnotator(tairAnnotator);
} }
/** /**
......
package lcsb.mapviewer.annotation.services.annotators; package lcsb.mapviewer.annotation.services.annotators;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.kohsuke.rngom.ast.builder.Annotations;
import lcsb.mapviewer.annotation.cache.GeneralCacheInterface; import lcsb.mapviewer.annotation.cache.GeneralCacheInterface;
import lcsb.mapviewer.annotation.cache.SourceNotAvailable; import lcsb.mapviewer.annotation.cache.SourceNotAvailable;
...@@ -47,7 +47,7 @@ public class TairAnnotator extends ElementAnnotator implements IExternalService ...@@ -47,7 +47,7 @@ public class TairAnnotator extends ElementAnnotator implements IExternalService
* Default constructor. * Default constructor.
*/ */
public TairAnnotator() { public TairAnnotator() {
super(TairAnnotator.class, new Class[] { Protein.class, Gene.class, Rna.class }, false); //TODO - check with Simone super(TairAnnotator.class, new Class[] { Protein.class, Gene.class, Rna.class }, false);
} }
@Override @Override
...@@ -75,34 +75,36 @@ public class TairAnnotator extends ElementAnnotator implements IExternalService ...@@ -75,34 +75,36 @@ public class TairAnnotator extends ElementAnnotator implements IExternalService
@Override @Override
public void annotateElement(BioEntity object) throws AnnotatorException { public void annotateElement(BioEntity object) throws AnnotatorException {
if (isAnnotatable(object)) { if (isAnnotatable(object)) {
boolean uniprotFound = false; // boolean uniprotFound = false;
List<MiriamData> mdUniProts = new ArrayList<MiriamData>();
MiriamData mdTair = null; MiriamData mdTair = null;
for (MiriamData md : object.getMiriamData()) { for (MiriamData md : object.getMiriamData()) {
if (md.getDataType().equals(MiriamType.TAIR_LOCUS)) { if (md.getDataType().equals(MiriamType.TAIR_LOCUS)) {
mdTair = md; mdTair = md;
} }
if (md.getDataType().equals(MiriamType.UNIPROT)) { if (md.getDataType().equals(MiriamType.UNIPROT)) {
uniprotFound = true; mdUniProts.add(md);
// uniprotFound = true;
} }
} }
if (mdTair == null || uniprotFound) { if (mdTair == null /*|| uniprotFound*/) {
return; return;
} }
MiriamData mdUniprot = tairToUniprot(mdTair); MiriamData mdUniprot = tairToUniprot(mdTair);
if (mdUniprot != null) { if (mdUniprot != null && mdUniProts.indexOf(mdUniprot) == -1) {
object.addMiriamData(mdUniprot); object.addMiriamData(mdUniprot);
} }
} }
} }
/** /**
* Returns url to TAIR page about TAIR entry. * Returns URL to TAIR page about TAIR entry.
* *
* @param tairId * @param tairId
* tair identifier * TAIR identifier
* @return url to TAIR page about the TAIR entry * @return URL to TAIR page about the TAIR entry
*/ */
private String getTairUrl(String tairId) { private String getTairUrl(String tairId) {
return "http://arabidopsis.org/servlets/TairObject?type=locus&name=" + tairId; return "http://arabidopsis.org/servlets/TairObject?type=locus&name=" + tairId;
...@@ -147,11 +149,11 @@ public class TairAnnotator extends ElementAnnotator implements IExternalService ...@@ -147,11 +149,11 @@ public class TairAnnotator extends ElementAnnotator implements IExternalService
} }
/** /**
* Transform tair identifier into uniprot identifier. * Transform TAIR identifier into uniprot identifier.
* *
* @param tair * @param tair
* {@link MiriamData} with tair identifier * {@link MiriamData} with TAIR identifier
* @return {@link MiriamData} with uniprot identifier * @return {@link MiriamData} with UniProt identifier
* @throws UniprotSearchException * @throws UniprotSearchException
* thrown when there is a problem with accessing external database * thrown when there is a problem with accessing external database
*/ */
...@@ -180,7 +182,6 @@ public class TairAnnotator extends ElementAnnotator implements IExternalService ...@@ -180,7 +182,6 @@ public class TairAnnotator extends ElementAnnotator implements IExternalService
} catch (IOException exception) { } catch (IOException exception) {
throw new AnnotatorException(exception); throw new AnnotatorException(exception);
} }
} }
@Override @Override
......
...@@ -69,6 +69,33 @@ public class TairAnnotatorTest extends AnnotationTestFunctions { ...@@ -69,6 +69,33 @@ public class TairAnnotatorTest extends AnnotationTestFunctions {
} }
} }
@Test
public void testAnnotateExistingUniprot() throws Exception {
try {
Species protein = new GenericProtein("id");
protein.setName("bla");
protein.addMiriamData(new MiriamData(MiriamType.TAIR_LOCUS, "AT1G15950"));
protein.addMiriamData(new MiriamData(MiriamType.UNIPROT, "P32246")); // Human version of the protein
tairAnnotator.annotateElement(protein);
int cntUniProts = 0;
for (MiriamData md : protein.getMiriamData()) {
if (md.getDataType().equals(MiriamType.UNIPROT)) {
cntUniProts++;
}
}
assertTrue("No UNIPROT annotation extracted from TAIR annotator", cntUniProts > 1);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test @Test
public void testAnnotateInvalidTair() throws Exception { public void testAnnotateInvalidTair() throws Exception {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment