enricher) {
this.interactorBaseEnricher.setCvTermEnricher(enricher);
- if (getProteinEnricher() != null){
+ if (getProteinEnricher() != null) {
getProteinEnricher().setCvTermEnricher(enricher);
}
- if (getPolymerBaseEnricher() != null){
+ if (getPolymerBaseEnricher() != null) {
getPolymerBaseEnricher().setCvTermEnricher(enricher);
}
- if (getGeneEnricher() != null){
+ if (getGeneEnricher() != null) {
getGeneEnricher().setCvTermEnricher(enricher);
}
- if (getBioactiveEntityEnricher() != null){
+ if (getBioactiveEntityEnricher() != null) {
getBioactiveEntityEnricher().setCvTermEnricher(enricher);
}
- if (getComplexEnricher() != null){
+ if (getComplexEnricher() != null) {
getComplexEnricher().setCvTermEnricher(enricher);
}
- if (getInteractorPoolEnricher() != null){
+ if (getInteractorPoolEnricher() != null) {
getInteractorPoolEnricher().setCvTermEnricher(enricher);
}
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void setOrganismEnricher(OrganismEnricher enricher) {
this.interactorBaseEnricher.setOrganismEnricher(enricher);
- if (getProteinEnricher() != null){
+ if (getProteinEnricher() != null) {
getProteinEnricher().setOrganismEnricher(enricher);
}
- if (getPolymerBaseEnricher() != null){
+ if (getPolymerBaseEnricher() != null) {
getPolymerBaseEnricher().setOrganismEnricher(enricher);
}
- if (getGeneEnricher() != null){
+ if (getGeneEnricher() != null) {
getGeneEnricher().setOrganismEnricher(enricher);
}
- if (getBioactiveEntityEnricher() != null){
+ if (getBioactiveEntityEnricher() != null) {
getBioactiveEntityEnricher().setOrganismEnricher(enricher);
}
- if (getComplexEnricher() != null){
+ if (getComplexEnricher() != null) {
getComplexEnricher().setOrganismEnricher(enricher);
}
- if (getInteractorPoolEnricher() != null){
+ if (getInteractorPoolEnricher() != null) {
getInteractorPoolEnricher().setOrganismEnricher(enricher);
}
}
diff --git a/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/impl/full/FullNucleicAcidEnricher.java b/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/impl/full/FullNucleicAcidEnricher.java
new file mode 100644
index 0000000000..7ef5f20353
--- /dev/null
+++ b/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/impl/full/FullNucleicAcidEnricher.java
@@ -0,0 +1,51 @@
+package psidev.psi.mi.jami.enricher.impl.full;
+
+import psidev.psi.mi.jami.bridges.fetcher.GeneFetcher;
+import psidev.psi.mi.jami.bridges.fetcher.NucleicAcidFetcher;
+import psidev.psi.mi.jami.enricher.impl.minimal.MinimalGeneEnricher;
+import psidev.psi.mi.jami.enricher.impl.minimal.MinimalNucleicAcidEnricher;
+import psidev.psi.mi.jami.enricher.listener.NucleicAcidEnricherListener;
+import psidev.psi.mi.jami.enricher.listener.ProteinEnricherListener;
+import psidev.psi.mi.jami.model.NucleicAcid;
+import psidev.psi.mi.jami.model.Protein;
+
+/**
+ * A full enricher for genes.
+ *
+ * See description of full enrichment in AbstractInteractorEnricher.
+ *
+ * The GeneFetcher is required for enriching genes.
+ *
+ * @author Gabriel Aldam (galdam@ebi.ac.uk)
+ * @since 04/09/13
+
+ */
+public class FullNucleicAcidEnricher extends MinimalNucleicAcidEnricher {
+
+ /**
+ * Constructor for FullGeneEnricher.
+ *
+ * @param fetcher a {@link GeneFetcher} object.
+ */
+ public FullNucleicAcidEnricher(NucleicAcidFetcher fetcher) {
+ super(fetcher);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected boolean isFullEnrichment() {
+ return true;
+ }
+
+ @Override
+ protected void processOtherProperties(NucleicAcid objectToEnrich, NucleicAcid fetched) {
+
+ // sequence
+ if (objectToEnrich.getSequence() == null && fetched.getSequence() != null){
+ objectToEnrich.setSequence(fetched.getSequence());
+ if (getListener() instanceof NucleicAcidEnricherListener){
+ ((NucleicAcidEnricherListener)getListener()).onSequenceUpdate(objectToEnrich, null);
+ }
+ }
+ }
+}
diff --git a/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/impl/full/FullNucleicAcidUpdater.java b/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/impl/full/FullNucleicAcidUpdater.java
new file mode 100644
index 0000000000..60441c2c4c
--- /dev/null
+++ b/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/impl/full/FullNucleicAcidUpdater.java
@@ -0,0 +1,53 @@
+package psidev.psi.mi.jami.enricher.impl.full;
+
+import psidev.psi.mi.jami.bridges.fetcher.GeneFetcher;
+import psidev.psi.mi.jami.bridges.fetcher.NucleicAcidFetcher;
+import psidev.psi.mi.jami.enricher.impl.minimal.MinimalGeneUpdater;
+import psidev.psi.mi.jami.enricher.impl.minimal.MinimalNucleicAcidUpdater;
+import psidev.psi.mi.jami.enricher.listener.NucleicAcidEnricherListener;
+import psidev.psi.mi.jami.enricher.listener.ProteinEnricherListener;
+import psidev.psi.mi.jami.model.NucleicAcid;
+import psidev.psi.mi.jami.model.Protein;
+
+/**
+ * A full updater for genes.
+ *
+ * See description of full update in AbstractInteractorEnricher.
+ *
+ * The GeneFetcher is required for enriching genes.
+ *
+ * @author Gabriel Aldam (galdam@ebi.ac.uk)
+ * @since 04/09/13
+
+ */
+public class FullNucleicAcidUpdater extends MinimalNucleicAcidUpdater {
+
+ /**
+ * Constructor for FullGeneUpdater.
+ *
+ * @param fetcher a {@link GeneFetcher} object.
+ */
+ public FullNucleicAcidUpdater(NucleicAcidFetcher fetcher) {
+ super(fetcher);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected boolean isFullEnrichment() {
+ return true;
+ }
+
+ @Override
+ protected void processOtherProperties(NucleicAcid toEnrich, NucleicAcid fetched) {
+
+ // sequence
+ if ((fetched.getSequence() != null && !fetched.getSequence().equalsIgnoreCase(toEnrich.getSequence())
+ || (fetched.getSequence() == null && toEnrich.getSequence() != null))){
+ String oldSeq = toEnrich.getSequence();
+ toEnrich.setSequence(fetched.getSequence());
+ if (getListener() instanceof NucleicAcidEnricherListener){
+ ((NucleicAcidEnricherListener)getListener()).onSequenceUpdate(toEnrich, oldSeq);
+ }
+ }
+ }
+}
diff --git a/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/impl/minimal/MinimalGeneEnricher.java b/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/impl/minimal/MinimalGeneEnricher.java
index 58edd432c9..93dbc5199b 100644
--- a/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/impl/minimal/MinimalGeneEnricher.java
+++ b/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/impl/minimal/MinimalGeneEnricher.java
@@ -2,6 +2,7 @@
import psidev.psi.mi.jami.bridges.exception.BridgeFailedException;
import psidev.psi.mi.jami.bridges.fetcher.GeneFetcher;
+import psidev.psi.mi.jami.bridges.fetcher.InteractorFetcher;
import psidev.psi.mi.jami.enricher.exception.EnricherException;
import psidev.psi.mi.jami.enricher.impl.AbstractInteractorEnricher;
import psidev.psi.mi.jami.enricher.listener.EnrichmentStatus;
@@ -14,17 +15,26 @@
/**
* A basic minimal enricher for genes.
- *
+ *
* See description of minimal enrichment in AbstractInteractorEnricher.
- *
+ *
* The GeneFetcher is required for enriching genes.
*
* @author Gabriel Aldam (galdam@ebi.ac.uk)
* @since 04/09/13
-
*/
public class MinimalGeneEnricher extends AbstractInteractorEnricher {
+ protected GeneFetcher ensemblFetcher;
+
+ public GeneFetcher getEnsemblFetcher() {
+ return ensemblFetcher == null ? getInteractorFetcher() : ensemblFetcher;
+ }
+
+ public void setEnsemblFetcher(GeneFetcher ensemblFetcher) {
+ this.ensemblFetcher = ensemblFetcher;
+ }
+
/**
* Constructor for MinimalGeneEnricher.
*
@@ -32,127 +42,135 @@ public class MinimalGeneEnricher extends AbstractInteractorEnricher {
*/
public MinimalGeneEnricher(GeneFetcher fetcher) {
super(fetcher);
- if (fetcher == null){
- throw new IllegalArgumentException("The gene enricher needs a non null fetcher");
- }
+ if (fetcher == null) throw new IllegalArgumentException("The gene enricher needs a non null fetcher");
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
@Override
public GeneFetcher getInteractorFetcher() {
- return (GeneFetcher)super.getInteractorFetcher();
+ return (GeneFetcher) super.getInteractorFetcher();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
@Override
public Gene find(Gene geneToEnrich) throws EnricherException {
int taxid = -3;
- if(geneToEnrich.getOrganism() != null) {
+ if (geneToEnrich.getOrganism() != null) {
taxid = geneToEnrich.getOrganism().getTaxId();
}
Gene geneFetched = null;
- if(geneToEnrich.getEnsembl() != null)
- geneFetched = fetchGeneByIdentifier(geneToEnrich, geneToEnrich.getEnsembl() , taxid);
+ if (geneToEnrich.getEnsembl() != null)
+ geneFetched = fetchGeneByIdentifier(getEnsemblFetcher(), geneToEnrich, geneToEnrich.getEnsembl(), taxid);
- if(geneFetched == null && geneToEnrich.getRefseq() != null)
- geneFetched = fetchGeneByIdentifier(geneToEnrich, geneToEnrich.getRefseq() , taxid);
+ if (geneFetched == null && geneToEnrich.getRefseq() != null)
+ geneFetched = fetchGeneByIdentifier(getInteractorFetcher(), geneToEnrich, geneToEnrich.getRefseq(), taxid);
- if(geneFetched == null && geneToEnrich.getEnsemblGenome() != null)
- geneFetched = fetchGeneByIdentifier(geneToEnrich, geneToEnrich.getEnsemblGenome() , taxid);
+ if (geneFetched == null && geneToEnrich.getEnsemblGenome() != null)
+ geneFetched = fetchGeneByIdentifier(getInteractorFetcher(), geneToEnrich, geneToEnrich.getEnsemblGenome(), taxid);
return geneFetched;
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
@Override
- protected void onEnrichedVersionNotFound(Gene objectToEnrich) throws EnricherException{
- if(getListener() != null)
+ protected void onEnrichedVersionNotFound(Gene objectToEnrich) throws EnricherException {
+ if (getListener() != null)
getListener().onEnrichmentComplete(
- objectToEnrich , EnrichmentStatus.FAILED ,
- "Could not fetch a gene with the provided identifier [" + objectToEnrich.getPreferredIdentifier() + "].");
+ objectToEnrich, EnrichmentStatus.FAILED,
+ "Could not fetch a gene with the provided identifier [" + objectToEnrich.getPreferredIdentifier() + "].");
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
@Override
protected boolean isFullEnrichment() {
return false;
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
@Override
protected void onCompletedEnrichment(Gene objectToEnrich) {
- if(getListener() != null)
+ if (getListener() != null)
getListener().onEnrichmentComplete(
- objectToEnrich , EnrichmentStatus.SUCCESS , "The gene [" + objectToEnrich.getPreferredIdentifier() + "] has been successfully enriched.");
+ objectToEnrich, EnrichmentStatus.SUCCESS, "The gene [" + objectToEnrich.getPreferredIdentifier() + "] has been successfully enriched.");
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
@Override
- protected void onInteractorCheckFailure(Gene objectToEnrich, Gene fetchedObject) throws EnricherException{
- if(getListener() != null)
+ protected void onInteractorCheckFailure(Gene objectToEnrich, Gene fetchedObject) throws EnricherException {
+ if (getListener() != null)
getListener().onEnrichmentComplete(
- objectToEnrich , EnrichmentStatus.FAILED , "Cannot enrich the gene [" + objectToEnrich.getPreferredIdentifier() + "] because the interactor type is not a gene type or we have a mismatch between the gene taxid to enrich and the fetched gene taxid.");
+ objectToEnrich, EnrichmentStatus.FAILED, "Cannot enrich the gene [" + objectToEnrich.getPreferredIdentifier() + "] because the interactor type is not a gene type or we have a mismatch between the gene taxid to enrich and the fetched gene taxid.");
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
@Override
- protected boolean canEnrichInteractor(Gene entityToEnrich, Gene fetchedEntity) throws EnricherException{
- if (fetchedEntity == null){
+ protected boolean canEnrichInteractor(Gene entityToEnrich, Gene fetchedEntity) throws EnricherException {
+ if (fetchedEntity == null) {
onEnrichedVersionNotFound(entityToEnrich);
return false;
}
// if the interactor type is not a valid bioactive entity interactor type, we cannot enrich
if (entityToEnrich.getInteractorType() != null &&
!CvTermUtils.isCvTerm(entityToEnrich.getInteractorType(), Gene.GENE_MI, Gene.GENE)
- && !CvTermUtils.isCvTerm(entityToEnrich.getInteractorType(), Interactor.UNKNOWN_INTERACTOR_MI, Interactor.UNKNOWN_INTERACTOR)){
+ && !CvTermUtils.isCvTerm(entityToEnrich.getInteractorType(), Interactor.UNKNOWN_INTERACTOR_MI, Interactor.UNKNOWN_INTERACTOR)) {
return false;
}
// if the organism is different, we cannot enrich
if (entityToEnrich.getOrganism() != null && fetchedEntity.getOrganism() != null &&
- !OrganismTaxIdComparator.areEquals(entityToEnrich.getOrganism(), fetchedEntity.getOrganism())){
+ !OrganismTaxIdComparator.areEquals(entityToEnrich.getOrganism(), fetchedEntity.getOrganism())) {
return false;
}
return true;
}
- private Gene fetchGeneByIdentifier(Gene gene, String identifier , int taxid) throws EnricherException {
+ private Gene fetchGeneByIdentifier(GeneFetcher fetcher, Gene gene, String identifier, int taxid) throws EnricherException {
Collection results;
try {
- results = getInteractorFetcher().fetchByIdentifier(identifier, taxid);
- if(results.size() == 1){
+ results = fetcher.fetchByIdentifier(identifier, taxid);
+ if (results.size() == 1) {
return results.iterator().next();
- }
- else if (!results.isEmpty()){
- if (getListener() != null){
+ } else if (!results.isEmpty()) {
+ if (getListener() != null) {
getListener().onEnrichmentError(gene, "The identifier [" + identifier + "] and taxid " + taxid + " can match " +
- results.size() + " genes and it is not possible to enrich with multiple entries", new EnricherException("Multiple gene entries found for " + identifier + " and taxid " + taxid));
+ results.size() + " genes and it is not possible to enrich with multiple entries", new EnricherException("Multiple gene entries found for " + identifier + " and taxid " + taxid));
}
return null;
- }
- else{
+ } else {
return null;
}
} catch (BridgeFailedException e) {
int index = 0;
- while(index < getRetryCount()){
+ while (index < getRetryCount()) {
try {
- results = getInteractorFetcher().fetchByIdentifier(identifier, taxid);
- if(results.size() == 1){
+ results = fetcher.fetchByIdentifier(identifier, taxid);
+ if (results.size() == 1) {
return results.iterator().next();
- }
- else if (!results.isEmpty()){
- if (getListener() != null){
+ } else if (!results.isEmpty()) {
+ if (getListener() != null) {
getListener().onEnrichmentError(gene, "The identifier [" + identifier + "] and taxid " + taxid + " can match " +
results.size() + " genes and it is not possible to enrich with multiple entries", new EnricherException("Multiple gene entries found for [" + identifier + "] and taxid " + taxid));
}
return null;
- }
- else{
+ } else {
return null;
}
} catch (BridgeFailedException ee) {
@@ -160,7 +178,7 @@ else if (!results.isEmpty()){
index++;
}
}
- throw new EnricherException("Retried "+getRetryCount()+" times to connect to the gene fetcher", e);
+ throw new EnricherException("Retried " + getRetryCount() + " times to connect to the gene fetcher", e);
}
}
}
diff --git a/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/impl/minimal/MinimalGeneUpdater.java b/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/impl/minimal/MinimalGeneUpdater.java
index 65f415217e..9eb3178985 100644
--- a/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/impl/minimal/MinimalGeneUpdater.java
+++ b/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/impl/minimal/MinimalGeneUpdater.java
@@ -1,6 +1,7 @@
package psidev.psi.mi.jami.enricher.impl.minimal;
import psidev.psi.mi.jami.bridges.fetcher.GeneFetcher;
+import psidev.psi.mi.jami.bridges.fetcher.NucleicAcidFetcher;
import psidev.psi.mi.jami.enricher.impl.AbstractInteractorEnricher;
import psidev.psi.mi.jami.enricher.impl.AbstractInteractorUpdater;
import psidev.psi.mi.jami.model.Gene;
@@ -18,6 +19,15 @@
*/
public class MinimalGeneUpdater extends AbstractInteractorUpdater {
+ public GeneFetcher getEnsemblFetcher() {
+ return ((MinimalGeneEnricher) getInteractorEnricher()).getEnsemblFetcher();
+ }
+
+ public void setEnsemblFetcher(GeneFetcher ensemblFetcher) {
+ ((MinimalGeneEnricher) getInteractorEnricher()).setEnsemblFetcher(ensemblFetcher);
+ }
+
+
/**
* Constructor for MinimalGeneUpdater.
*
diff --git a/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/impl/minimal/MinimalNucleicAcidEnricher.java b/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/impl/minimal/MinimalNucleicAcidEnricher.java
new file mode 100644
index 0000000000..55307b0642
--- /dev/null
+++ b/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/impl/minimal/MinimalNucleicAcidEnricher.java
@@ -0,0 +1,179 @@
+package psidev.psi.mi.jami.enricher.impl.minimal;
+
+import psidev.psi.mi.jami.bridges.exception.BridgeFailedException;
+import psidev.psi.mi.jami.bridges.fetcher.NucleicAcidFetcher;
+import psidev.psi.mi.jami.enricher.exception.EnricherException;
+import psidev.psi.mi.jami.enricher.impl.AbstractInteractorEnricher;
+import psidev.psi.mi.jami.enricher.listener.EnrichmentStatus;
+import psidev.psi.mi.jami.model.Interactor;
+import psidev.psi.mi.jami.model.NucleicAcid;
+import psidev.psi.mi.jami.model.Xref;
+import psidev.psi.mi.jami.utils.CvTermUtils;
+import psidev.psi.mi.jami.utils.comparator.organism.OrganismTaxIdComparator;
+
+import java.util.Collection;
+
+/**
+ * A basic minimal enricher for nucleic acids.
+ *
+ * See description of minimal enrichment in AbstractInteractorEnricher.
+ *
+ * The NucleicAcidFetcher is required for enriching nucleic acids.
+ * The EnsemblNucleicAcidFetcher is required for enriching ensembl identifiers
+ *
+ * @author Gabriel Aldam (galdam@ebi.ac.uk)
+ * @since 04/09/13
+ */
+public class MinimalNucleicAcidEnricher extends AbstractInteractorEnricher {
+
+ public static final String RNA_CENTRAL_MI = "MI:1357";
+ public static final String RNA_CENTRAL = "RNACentral";
+ public static final String ENSEMBL_MI = "MI:0476";
+ public static final String ENSEMBL = "ensembl";
+ protected NucleicAcidFetcher ensemblFetcher;
+
+ public NucleicAcidFetcher getEnsemblFetcher() {
+ return ensemblFetcher == null ? getInteractorFetcher() : ensemblFetcher;
+ }
+
+ public void setEnsemblFetcher(NucleicAcidFetcher ensemblFetcher) {
+ this.ensemblFetcher = ensemblFetcher;
+ }
+
+ /**
+ * Constructor for MinimalNucleicAcidEnricher.
+ *
+ * @param fetcher a {@link NucleicAcidFetcher} object.
+ */
+ public MinimalNucleicAcidEnricher(NucleicAcidFetcher fetcher) {
+ super(fetcher);
+ if (fetcher == null) throw new IllegalArgumentException("The nucleic acid enricher needs a non null fetcher");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NucleicAcidFetcher getInteractorFetcher() {
+ return (NucleicAcidFetcher) super.getInteractorFetcher();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NucleicAcid find(NucleicAcid objectToEnrich) throws EnricherException {
+ Xref id = objectToEnrich.getPreferredIdentifier();
+ if (CvTermUtils.isCvTerm(id.getDatabase(), RNA_CENTRAL_MI, RNA_CENTRAL)) {
+ return fetchNAByIdentifier(getInteractorFetcher(), objectToEnrich, id.getId());
+ } else if (CvTermUtils.isCvTerm(id.getDatabase(), ENSEMBL_MI, ENSEMBL)) {
+ return fetchNAByIdentifier(getEnsemblFetcher(), objectToEnrich, id.getId());
+ }
+ return null;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void onEnrichedVersionNotFound(NucleicAcid objectToEnrich) throws EnricherException {
+ if (getListener() != null)
+ getListener().onEnrichmentComplete(
+ objectToEnrich, EnrichmentStatus.FAILED,
+ "Could not fetch a nucleic acid with the provided identifier [" + objectToEnrich.getPreferredIdentifier() + "].");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isFullEnrichment() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void onCompletedEnrichment(NucleicAcid objectToEnrich) {
+ if (getListener() != null)
+ getListener().onEnrichmentComplete(
+ objectToEnrich, EnrichmentStatus.SUCCESS, "The nucleic acid [" + objectToEnrich.getPreferredIdentifier() + "] has been successfully enriched.");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void onInteractorCheckFailure(NucleicAcid objectToEnrich, NucleicAcid fetchedObject) throws EnricherException {
+ if (getListener() != null)
+ getListener().onEnrichmentComplete(
+ objectToEnrich, EnrichmentStatus.FAILED, "Cannot enrich the nucleic acid [" + objectToEnrich.getPreferredIdentifier() + "] because the interactor type is not a nucleic acid type or we have a mismatch between the nucleic acid taxid to enrich and the fetched nucleic acid taxid.");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean canEnrichInteractor(NucleicAcid entityToEnrich, NucleicAcid fetchedEntity) throws EnricherException {
+ if (fetchedEntity == null) {
+ onEnrichedVersionNotFound(entityToEnrich);
+ return false;
+ }
+ // if the interactor type is not a valid bioactive entity interactor type, we cannot enrich
+ if (entityToEnrich.getInteractorType() != null &&
+ !CvTermUtils.isCvTerm(entityToEnrich.getInteractorType(), NucleicAcid.NULCEIC_ACID_MI, NucleicAcid.NULCEIC_ACID)
+ && !CvTermUtils.isCvTerm(entityToEnrich.getInteractorType(), Interactor.UNKNOWN_INTERACTOR_MI, Interactor.UNKNOWN_INTERACTOR)) {
+ return false;
+ }
+
+ // if the organism is different, we cannot enrich
+ if (entityToEnrich.getOrganism() != null && fetchedEntity.getOrganism() != null &&
+ !OrganismTaxIdComparator.areEquals(entityToEnrich.getOrganism(), fetchedEntity.getOrganism())) {
+ return false;
+ }
+
+ return true;
+ }
+
+ private NucleicAcid fetchNAByIdentifier(NucleicAcidFetcher fetcher, NucleicAcid nucleicAcid, String identifier) throws EnricherException {
+ Collection results;
+ try {
+ results = fetcher.fetchByIdentifier(identifier);
+ if (results.size() == 1) {
+ return results.iterator().next();
+ } else if (!results.isEmpty()) {
+ if (getListener() != null) {
+ getListener().onEnrichmentError(nucleicAcid, "The identifier [" + identifier + "] can match " +
+ results.size() + " nucleic acids and it is not possible to enrich with multiple entries", new EnricherException("Multiple nucleicAcid entries found for " + identifier));
+ }
+ return null;
+ } else {
+ return null;
+ }
+ } catch (BridgeFailedException e) {
+ int index = 0;
+ while (index < getRetryCount()) {
+ try {
+ results = fetcher.fetchByIdentifier(identifier);
+ if (results.size() == 1) {
+ return results.iterator().next();
+ } else if (!results.isEmpty()) {
+ if (getListener() != null) {
+ getListener().onEnrichmentError(nucleicAcid, "The identifier [" + identifier + "] can match " +
+ results.size() + " nucleic acids and it is not possible to enrich with multiple entries", new EnricherException("Multiple nucleicAcid entries found for [" + identifier + "]"));
+ }
+ return null;
+ } else {
+ return null;
+ }
+ } catch (BridgeFailedException ee) {
+ ee.printStackTrace();
+ index++;
+ }
+ }
+ throw new EnricherException("Retried " + getRetryCount() + " times to connect to the nucleicAcid fetcher", e);
+ }
+ }
+}
diff --git a/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/impl/minimal/MinimalNucleicAcidUpdater.java b/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/impl/minimal/MinimalNucleicAcidUpdater.java
new file mode 100644
index 0000000000..0e68e005d8
--- /dev/null
+++ b/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/impl/minimal/MinimalNucleicAcidUpdater.java
@@ -0,0 +1,48 @@
+package psidev.psi.mi.jami.enricher.impl.minimal;
+
+import psidev.psi.mi.jami.bridges.fetcher.NucleicAcidFetcher;
+import psidev.psi.mi.jami.enricher.impl.AbstractInteractorEnricher;
+import psidev.psi.mi.jami.enricher.impl.AbstractInteractorUpdater;
+import psidev.psi.mi.jami.model.Gene;
+import psidev.psi.mi.jami.model.NucleicAcid;
+
+/**
+ * A basic minimal updater for nucleic acids.
+ *
+ * See description of minimal update in AbstractInteractorUpdater.
+ *
+ * The NucleicAcidFetcher is required for enriching nucleic acids.
+ * The EnsemblNucleicAcidFetcher is required for enriching ensembl identifiers
+ *
+ * @author Gabriel Aldam (galdam@ebi.ac.uk)
+ * @since 04/09/13
+
+ */
+public class MinimalNucleicAcidUpdater extends AbstractInteractorUpdater {
+
+ public NucleicAcidFetcher getEnsemblFetcher() {
+ return ((MinimalNucleicAcidEnricher) getInteractorEnricher()).getEnsemblFetcher();
+ }
+
+ public void setEnsemblFetcher(NucleicAcidFetcher ensemblFetcher) {
+ ((MinimalNucleicAcidEnricher) getInteractorEnricher()).setEnsemblFetcher(ensemblFetcher);
+ }
+
+ /**
+ * Constructor for MinimalGeneUpdater.
+ *
+ * @param fetcher a {@link psidev.psi.mi.jami.bridges.fetcher.GeneFetcher} object.
+ */
+ public MinimalNucleicAcidUpdater(NucleicAcidFetcher fetcher) {
+ super(new MinimalNucleicAcidEnricher(fetcher));
+ }
+
+ /**
+ * Constructor for MinimalGeneUpdater.
+ *
+ * @param interactorEnricher a {@link psidev.psi.mi.jami.enricher.impl.AbstractInteractorEnricher} object.
+ */
+ protected MinimalNucleicAcidUpdater(AbstractInteractorEnricher interactorEnricher) {
+ super(interactorEnricher);
+ }
+}
diff --git a/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/listener/NucleicAcidEnricherListener.java b/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/listener/NucleicAcidEnricherListener.java
new file mode 100644
index 0000000000..7c91e988ff
--- /dev/null
+++ b/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/listener/NucleicAcidEnricherListener.java
@@ -0,0 +1,13 @@
+package psidev.psi.mi.jami.enricher.listener;
+
+import psidev.psi.mi.jami.model.NucleicAcid;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @author Gabriel Aldam (galdam@ebi.ac.uk)
+ * @since 03/09/13
+
+ */
+public interface NucleicAcidEnricherListener extends PolymerEnricherListener {
+}
diff --git a/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/listener/impl/writer/NucleicAcidEnricherStatisticsWriter.java b/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/listener/impl/writer/NucleicAcidEnricherStatisticsWriter.java
new file mode 100644
index 0000000000..f14b3b6b9c
--- /dev/null
+++ b/jami-enricher/src/main/java/psidev/psi/mi/jami/enricher/listener/impl/writer/NucleicAcidEnricherStatisticsWriter.java
@@ -0,0 +1,64 @@
+package psidev.psi.mi.jami.enricher.listener.impl.writer;
+
+import psidev.psi.mi.jami.enricher.listener.NucleicAcidEnricherListener;
+import psidev.psi.mi.jami.model.NucleicAcid;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Created with IntelliJ IDEA.
+ *
+ * @author Gabriel Aldam (galdam@ebi.ac.uk)
+ * @since 03/09/13
+
+ */
+public class NucleicAcidEnricherStatisticsWriter
+ extends PolymerEnricherStatisticsWriter
+ implements NucleicAcidEnricherListener {
+
+
+ /** Constant FILE_NAME="NucleicAcid"
*/
+ public static final String FILE_NAME = "NucleicAcid";
+
+ /**
+ * Uses the known name of the JamiObject type as the seed to generate names for the success an failure log files.
+ *
+ * @throws IOException Thrown if a problem is encountered with file location.
+ */
+ public NucleicAcidEnricherStatisticsWriter() throws IOException {
+ super(FILE_NAME);
+ }
+
+ /**
+ * Creates the files from the provided seed file name with 'success' and 'failure' appended.
+ *
+ * @param fileName The seed to base the names of the files on.
+ * @throws IOException Thrown if a problem is encountered with file location.
+ */
+ public NucleicAcidEnricherStatisticsWriter(String fileName) throws IOException {
+ super(fileName);
+ }
+
+ /**
+ * Uses the provided names to create the files for successful and failed enrichment logging.
+ *
+ * @param successFileName The exact name for the file to log successful enrichments in
+ * @param failureFileName The exact name for the file to log failed enrichments in
+ * @throws IOException Thrown if a problem is encountered with file location.
+ */
+ public NucleicAcidEnricherStatisticsWriter(String successFileName, String failureFileName) throws IOException {
+ super(successFileName, failureFileName);
+ }
+
+ /**
+ * Uses the exact files provided to log successful and failed enrichments.
+ *
+ * @param successFile The file to log successful enrichments in
+ * @param failureFile The file to log failed enrichments in.
+ * @throws IOException Thrown if a problem is encountered with file location.
+ */
+ public NucleicAcidEnricherStatisticsWriter(File successFile, File failureFile) throws IOException {
+ super(successFile, failureFile);
+ }
+}
diff --git a/jami-enricher/src/test/java/psidev/psi/mi/jami/enricher/impl/FullNucleicAcidEnricherTest.java b/jami-enricher/src/test/java/psidev/psi/mi/jami/enricher/impl/FullNucleicAcidEnricherTest.java
new file mode 100644
index 0000000000..3ae65b92de
--- /dev/null
+++ b/jami-enricher/src/test/java/psidev/psi/mi/jami/enricher/impl/FullNucleicAcidEnricherTest.java
@@ -0,0 +1,100 @@
+package psidev.psi.mi.jami.enricher.impl;
+
+import org.junit.Before;
+import org.junit.Test;
+import psidev.psi.mi.jami.bridges.fetcher.mock.MockNucleicAcidFetcher;
+import psidev.psi.mi.jami.enricher.exception.EnricherException;
+import psidev.psi.mi.jami.enricher.impl.full.FullNucleicAcidEnricher;
+import psidev.psi.mi.jami.model.CvTerm;
+import psidev.psi.mi.jami.model.NucleicAcid;
+import psidev.psi.mi.jami.model.impl.DefaultNucleicAcid;
+import psidev.psi.mi.jami.model.impl.DefaultOrganism;
+import psidev.psi.mi.jami.model.impl.DefaultXref;
+import psidev.psi.mi.jami.utils.CvTermUtils;
+
+import java.util.List;
+
+import static junit.framework.Assert.*;
+
+/**
+ * Unit tests for MinimalProteinEnricher
+ *
+ * @author Gabriel Aldam (galdam@ebi.ac.uk)
+ * @since 23/05/13
+ */
+
+public class FullNucleicAcidEnricherTest {
+
+ private FullNucleicAcidEnricher enricher;
+ private MockNucleicAcidFetcher mockNucleicAcidFetcher;
+ private MockNucleicAcidFetcher mockEnsemblNucleicAcidFetcher;
+
+ private static final String TEST_SHORTNAME = "test shortName";
+ private static final String TEST_FULLNAME = "test fullName";
+ private static final String TEST_FULLNAME_ENSEMBL = "test fullName ENSEMBL";
+ private static final String TEST_AC_FULL = "URS000055C986_4896";
+ private static final String TEST_AC_ENSEMBL = "ENST00000652534";
+ private static final String TEST_SEQUENCE = "GATTACA";
+ private static final int TEST_ORGANISM_ID = 1234;
+ private static final String TEST_ORGANISM_COMMON = "Common";
+ private static final String TEST_ORGANISM_SCIENTIFIC = "Scientific";
+ private DefaultXref rnaCentralId;
+ private DefaultXref ensemblId;
+
+ @Before
+ public void initialiseFetcherAndEnricher() {
+ mockNucleicAcidFetcher = new MockNucleicAcidFetcher();
+ mockEnsemblNucleicAcidFetcher = new MockNucleicAcidFetcher();
+
+ enricher = new FullNucleicAcidEnricher(mockNucleicAcidFetcher);
+ enricher.setEnsemblFetcher(mockEnsemblNucleicAcidFetcher);
+
+ CvTerm identity = CvTermUtils.createIdentityQualifier();
+ CvTerm rnaCentral = CvTermUtils.createRNACentralDatabase();
+
+
+ NucleicAcid fullNucleicAcid = new DefaultNucleicAcid(TEST_SHORTNAME, TEST_FULLNAME);
+ rnaCentralId = new DefaultXref(rnaCentral, TEST_AC_FULL, identity);
+ fullNucleicAcid.getIdentifiers().add(rnaCentralId);
+ fullNucleicAcid.setSequence(TEST_SEQUENCE);
+ fullNucleicAcid.setOrganism(new DefaultOrganism(TEST_ORGANISM_ID, TEST_ORGANISM_COMMON, TEST_ORGANISM_SCIENTIFIC));
+ mockNucleicAcidFetcher.addEntry(TEST_AC_FULL, List.of(fullNucleicAcid));
+
+ NucleicAcid ensemblTranscript = new DefaultNucleicAcid(TEST_SHORTNAME, TEST_FULLNAME_ENSEMBL);
+ CvTerm ensembl = CvTermUtils.createEnsemblDatabase();
+ ensemblId = new DefaultXref(ensembl, TEST_AC_ENSEMBL, identity);
+ ensemblTranscript.getIdentifiers().add(ensemblId);
+ mockEnsemblNucleicAcidFetcher.addEntry(TEST_AC_ENSEMBL, List.of(ensemblTranscript));
+ }
+
+ @Test
+ public void test_correct_fetcher_used() throws EnricherException {
+ NucleicAcid rnaCentral = new DefaultNucleicAcid(TEST_SHORTNAME);
+ rnaCentral.getIdentifiers().add(rnaCentralId);
+ assertNull(rnaCentral.getFullName());
+
+ this.enricher.enrich(rnaCentral);
+
+ assertFalse(rnaCentral.getFullName().endsWith("ENSEMBL"));
+
+ NucleicAcid ensembl = new DefaultNucleicAcid(TEST_SHORTNAME);
+ ensembl.getIdentifiers().add(ensemblId);
+ assertNull(ensembl.getFullName());
+
+ this.enricher.enrich(ensembl);
+
+ assertTrue(ensembl.getFullName().endsWith("ENSEMBL"));
+ }
+
+ @Test
+ public void test_sequence_added() throws EnricherException {
+ NucleicAcid rnaCentral = new DefaultNucleicAcid(TEST_SHORTNAME);
+ rnaCentral.getIdentifiers().add(rnaCentralId);
+ assertNull(rnaCentral.getSequence());
+
+ this.enricher.enrich(rnaCentral);
+
+ assertEquals(TEST_SEQUENCE, rnaCentral.getSequence());
+ }
+
+}
diff --git a/jami-enricher/src/test/java/psidev/psi/mi/jami/enricher/impl/MinimalGeneEnricherTest.java b/jami-enricher/src/test/java/psidev/psi/mi/jami/enricher/impl/MinimalGeneEnricherTest.java
index 4a4a7a0683..1a4d69a67e 100644
--- a/jami-enricher/src/test/java/psidev/psi/mi/jami/enricher/impl/MinimalGeneEnricherTest.java
+++ b/jami-enricher/src/test/java/psidev/psi/mi/jami/enricher/impl/MinimalGeneEnricherTest.java
@@ -20,6 +20,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import static junit.framework.Assert.*;
@@ -33,6 +34,7 @@
public class MinimalGeneEnricherTest {
private MinimalGeneEnricher geneEnricher;
+ private MockGeneFetcher mockEnsemblGeneFetcher;
private MockGeneFetcher mockGeneFetcher;
Gene persistentGene;
@@ -42,30 +44,40 @@ public class MinimalGeneEnricherTest {
private static final String TEST_OLD_FULLNAME = "test old fullName";
private static final String TEST_AC_CUSTOM_GENE = "ENSG00000139617";
private static final String TEST_SHORTNAME = "test shortName";
+ private static final String TEST_SHORTNAME_REF_SEQ = TEST_SHORTNAME + " : RefSeq";
private static final String TEST_FULLNAME = "test fullName";
+ private static final String TEST_FULLNAME_REF_SEQ = TEST_FULLNAME + " : RefSeq";
private static final String TEST_AC_FULL_GENE = "ENSG00000139618";
private static final String TEST_AC_HALF_GENE = "ENSG00000139616";
+ private static final String TEST_AC_REF_SEQ = "NM_058074.4";
private static final int TEST_ORGANISM_ID = 1234;
private static final String TEST_ORGANISM_COMMON = "Common";
private static final String TEST_ORGANISM_SCIENTIFIC = "Scientific";
@Before
public void initialiseFetcherAndEnricher() {
+ mockEnsemblGeneFetcher = new MockGeneFetcher();
mockGeneFetcher = new MockGeneFetcher();
geneEnricher = new MinimalGeneEnricher(mockGeneFetcher);
+ geneEnricher.setEnsemblFetcher(mockEnsemblGeneFetcher);
+
+ Organism organism = new DefaultOrganism(TEST_ORGANISM_ID, TEST_ORGANISM_COMMON, TEST_ORGANISM_SCIENTIFIC);
Gene fullGene = new DefaultGene(TEST_SHORTNAME, TEST_FULLNAME);
fullGene.setEnsembl(TEST_AC_FULL_GENE);
- fullGene.setOrganism(new DefaultOrganism(TEST_ORGANISM_ID, TEST_ORGANISM_COMMON, TEST_ORGANISM_SCIENTIFIC));
- Collection fullGeneList = new ArrayList();
- fullGeneList.add(fullGene);
- mockGeneFetcher.addEntry(TEST_AC_FULL_GENE, fullGeneList);
+ fullGene.setOrganism(organism);
+ mockEnsemblGeneFetcher.addEntry(TEST_AC_FULL_GENE, List.of(fullGene));
Gene halfGene = new DefaultGene(TEST_SHORTNAME);
halfGene.setEnsembl(TEST_AC_HALF_GENE);
Collection halfGeneList = new ArrayList();
halfGeneList.add(halfGene);
- mockGeneFetcher.addEntry(TEST_AC_HALF_GENE, halfGeneList);
+ mockEnsemblGeneFetcher.addEntry(TEST_AC_HALF_GENE, halfGeneList);
+
+ Gene fullGeneRefSeq = new DefaultGene(TEST_SHORTNAME_REF_SEQ, TEST_FULLNAME_REF_SEQ);
+ fullGene.setEnsembl(TEST_AC_REF_SEQ);
+ fullGene.setOrganism(organism);
+ mockGeneFetcher.addEntry(TEST_AC_REF_SEQ, List.of(fullGeneRefSeq));
persistentGene = null;
persistentInt = 0;
@@ -366,7 +378,7 @@ public void test_organism_conflict_between_organism_TAXIDs_stops_enrichment() th
customGene.setOrganism(new DefaultOrganism(9898));
Collection customList = new ArrayList();
customList.add(customGene);
- mockGeneFetcher.addEntry(TEST_AC_CUSTOM_GENE, customList);
+ mockEnsemblGeneFetcher.addEntry(TEST_AC_CUSTOM_GENE, customList);
persistentGene = new DefaultGene(TEST_OLD_SHORTNAME, TEST_OLD_FULLNAME);
persistentGene.setEnsembl(TEST_AC_CUSTOM_GENE);
@@ -487,7 +499,7 @@ public void test_organism_and_interactorType_conflicts_both_reported() throws En
customGene.setOrganism(new DefaultOrganism(9898));
Collection customList = new ArrayList();
customList.add(customGene);
- mockGeneFetcher.addEntry(TEST_AC_CUSTOM_GENE, customList);
+ mockEnsemblGeneFetcher.addEntry(TEST_AC_CUSTOM_GENE, customList);
persistentGene = new DefaultGene(TEST_OLD_SHORTNAME, TEST_OLD_FULLNAME);
persistentGene.setEnsembl(TEST_AC_CUSTOM_GENE);
@@ -847,7 +859,7 @@ public void test_shortName_not_enriched_if_not_null() throws EnricherException {
customGene.setEnsembl(TEST_AC_CUSTOM_GENE);
Collection customList = new ArrayList();
customList.add(customGene);
- mockGeneFetcher.addEntry(TEST_AC_CUSTOM_GENE, customList);
+ mockEnsemblGeneFetcher.addEntry(TEST_AC_CUSTOM_GENE, customList);
assertNotNull(persistentGene.getShortName());
assertEquals(TEST_OLD_SHORTNAME, persistentGene.getShortName());
@@ -967,7 +979,7 @@ public void test_fullName_enriched_if_null() throws EnricherException {
Collection customList = new ArrayList();
customList.add(customGene);
- mockGeneFetcher.addEntry(TEST_AC_CUSTOM_GENE, customList);
+ mockEnsemblGeneFetcher.addEntry(TEST_AC_CUSTOM_GENE, customList);
assertNull(persistentGene.getFullName());
@@ -1087,7 +1099,7 @@ public void test_fullName_not_enriched_if_not_null() throws EnricherException {
customGene.setEnsembl(TEST_AC_CUSTOM_GENE);
Collection customList = new ArrayList();
customList.add(customGene);
- mockGeneFetcher.addEntry(TEST_AC_CUSTOM_GENE, customList);
+ mockEnsemblGeneFetcher.addEntry(TEST_AC_CUSTOM_GENE, customList);
assertNotNull(persistentGene.getFullName());
assertEquals(TEST_OLD_FULLNAME, persistentGene.getFullName());
@@ -1210,7 +1222,7 @@ public void test_identifiers_enriched() throws EnricherException {
Collection customList = new ArrayList();
customList.add(customGene);
- mockGeneFetcher.addEntry(TEST_AC_CUSTOM_GENE, customList);
+ mockEnsemblGeneFetcher.addEntry(TEST_AC_CUSTOM_GENE, customList);
assertEquals(2, persistentGene.getIdentifiers().size());
@@ -1354,7 +1366,7 @@ public void test_aliases_enriched() throws EnricherException {
Collection customList = new ArrayList();
customList.add(customGene);
- mockGeneFetcher.addEntry(TEST_AC_CUSTOM_GENE, customList);
+ mockEnsemblGeneFetcher.addEntry(TEST_AC_CUSTOM_GENE, customList);
assertEquals(1, persistentGene.getAliases().size());
@@ -1497,7 +1509,7 @@ public void test_xrefs_enriched() throws EnricherException {
Collection customList = new ArrayList();
customList.add(customGene);
- mockGeneFetcher.addEntry(TEST_AC_CUSTOM_GENE, customList);
+ mockEnsemblGeneFetcher.addEntry(TEST_AC_CUSTOM_GENE, customList);
assertEquals(1, persistentGene.getXrefs().size());
@@ -1626,5 +1638,26 @@ public void test_set_organism_if_null() throws EnricherException {
// TODO onRefseqUpdate, onGeneNameUpdate
+ // == Fetcher ====================================================================================
+ @Test
+ public void test_correct_fetcher_used() throws EnricherException {
+ Gene gene_ref_seq = new DefaultGene(TEST_SHORTNAME_REF_SEQ);
+ gene_ref_seq.setRefseq(TEST_AC_REF_SEQ);
+ assertNull(gene_ref_seq.getFullName());
+
+ this.geneEnricher.enrich(gene_ref_seq);
+
+ assertTrue(gene_ref_seq.getFullName().endsWith("RefSeq"));
+
+ Gene gene_ensembl = new DefaultGene(TEST_SHORTNAME);
+ gene_ensembl.setEnsembl(TEST_AC_FULL_GENE);
+ assertNull(gene_ensembl.getFullName());
+
+ this.geneEnricher.enrich(gene_ensembl);
+
+ assertFalse(gene_ensembl.getFullName().endsWith("RefSeq"));
+ }
+
+
}
diff --git a/jami-enricher/src/test/java/psidev/psi/mi/jami/enricher/impl/MinimalNucleicAcidEnricherTest.java b/jami-enricher/src/test/java/psidev/psi/mi/jami/enricher/impl/MinimalNucleicAcidEnricherTest.java
new file mode 100644
index 0000000000..8e52837145
--- /dev/null
+++ b/jami-enricher/src/test/java/psidev/psi/mi/jami/enricher/impl/MinimalNucleicAcidEnricherTest.java
@@ -0,0 +1,100 @@
+package psidev.psi.mi.jami.enricher.impl;
+
+import org.junit.Before;
+import org.junit.Test;
+import psidev.psi.mi.jami.bridges.fetcher.mock.MockNucleicAcidFetcher;
+import psidev.psi.mi.jami.enricher.exception.EnricherException;
+import psidev.psi.mi.jami.enricher.impl.minimal.MinimalNucleicAcidEnricher;
+import psidev.psi.mi.jami.model.*;
+import psidev.psi.mi.jami.model.impl.DefaultNucleicAcid;
+import psidev.psi.mi.jami.model.impl.DefaultOrganism;
+import psidev.psi.mi.jami.model.impl.DefaultXref;
+import psidev.psi.mi.jami.utils.CvTermUtils;
+
+import java.util.List;
+
+import static junit.framework.Assert.*;
+
+/**
+ * Unit tests for MinimalProteinEnricher
+ *
+ * @author Gabriel Aldam (galdam@ebi.ac.uk)
+ * @since 23/05/13
+ */
+
+public class MinimalNucleicAcidEnricherTest {
+
+ private MinimalNucleicAcidEnricher enricher;
+ private MockNucleicAcidFetcher mockNucleicAcidFetcher;
+ private MockNucleicAcidFetcher mockEnsemblNucleicAcidFetcher;
+
+ private static final String TEST_SHORTNAME = "test shortName";
+ private static final String TEST_FULLNAME = "test fullName";
+ private static final String TEST_FULLNAME_ENSEMBL = "test fullName ENSEMBL";
+ private static final String TEST_AC_FULL = "URS000055C986_4896";
+ private static final String TEST_AC_ENSEMBL = "ENST00000652534";
+ private static final String TEST_SEQUENCE = "GATTACA";
+ private static final int TEST_ORGANISM_ID = 1234;
+ private static final String TEST_ORGANISM_COMMON = "Common";
+ private static final String TEST_ORGANISM_SCIENTIFIC = "Scientific";
+ private DefaultXref rnaCentralId;
+ private DefaultXref ensemblId;
+
+ @Before
+ public void initialiseFetcherAndEnricher() {
+ mockNucleicAcidFetcher = new MockNucleicAcidFetcher();
+ mockEnsemblNucleicAcidFetcher = new MockNucleicAcidFetcher();
+
+ enricher = new MinimalNucleicAcidEnricher(mockNucleicAcidFetcher);
+ enricher.setEnsemblFetcher(mockEnsemblNucleicAcidFetcher);
+
+ CvTerm identity = CvTermUtils.createIdentityQualifier();
+ CvTerm rnaCentral = CvTermUtils.createRNACentralDatabase();
+
+
+ NucleicAcid fullNucleicAcid = new DefaultNucleicAcid(TEST_SHORTNAME, TEST_FULLNAME);
+ rnaCentralId = new DefaultXref(rnaCentral, TEST_AC_FULL, identity);
+ fullNucleicAcid.getIdentifiers().add(rnaCentralId);
+ fullNucleicAcid.setSequence(TEST_SEQUENCE);
+ fullNucleicAcid.setOrganism(new DefaultOrganism(TEST_ORGANISM_ID, TEST_ORGANISM_COMMON, TEST_ORGANISM_SCIENTIFIC));
+ mockNucleicAcidFetcher.addEntry(TEST_AC_FULL, List.of(fullNucleicAcid));
+
+ NucleicAcid ensemblTranscript = new DefaultNucleicAcid(TEST_SHORTNAME, TEST_FULLNAME_ENSEMBL);
+ CvTerm ensembl = CvTermUtils.createEnsemblDatabase();
+ ensemblId = new DefaultXref(ensembl, TEST_AC_ENSEMBL, identity);
+ ensemblTranscript.getIdentifiers().add(ensemblId);
+ mockEnsemblNucleicAcidFetcher.addEntry(TEST_AC_ENSEMBL, List.of(ensemblTranscript));
+ }
+
+ @Test
+ public void test_correct_fetcher_used() throws EnricherException {
+ NucleicAcid rnaCentral = new DefaultNucleicAcid(TEST_SHORTNAME);
+ rnaCentral.getIdentifiers().add(rnaCentralId);
+ assertNull(rnaCentral.getFullName());
+
+ this.enricher.enrich(rnaCentral);
+
+ assertFalse(rnaCentral.getFullName().endsWith("ENSEMBL"));
+
+ NucleicAcid ensembl = new DefaultNucleicAcid(TEST_SHORTNAME);
+ ensembl.getIdentifiers().add(ensemblId);
+ assertNull(ensembl.getFullName());
+
+ this.enricher.enrich(ensembl);
+
+ assertTrue(ensembl.getFullName().endsWith("ENSEMBL"));
+ }
+
+ @Test
+ public void test_sequence_not_added() throws EnricherException {
+ NucleicAcid rnaCentral = new DefaultNucleicAcid(TEST_SHORTNAME);
+ rnaCentral.getIdentifiers().add(rnaCentralId);
+ assertNull(rnaCentral.getSequence());
+
+ this.enricher.enrich(rnaCentral);
+
+ assertNull(rnaCentral.getSequence());
+
+ }
+
+}
diff --git a/jami-examples/pom.xml b/jami-examples/pom.xml
index 7d28340c6e..9b2e5b3f15 100644
--- a/jami-examples/pom.xml
+++ b/jami-examples/pom.xml
@@ -4,7 +4,7 @@
psidev.psi.mi.jami
psi-jami
- 3.4.1
+ 3.5.0
jami-examples
diff --git a/jami-html/pom.xml b/jami-html/pom.xml
index 20fc22702e..f3e8b50204 100644
--- a/jami-html/pom.xml
+++ b/jami-html/pom.xml
@@ -4,7 +4,7 @@
psidev.psi.mi.jami
psi-jami
- 3.4.1
+ 3.5.0
jami-html
diff --git a/jami-imex-updater/pom.xml b/jami-imex-updater/pom.xml
index 9cd1508990..a1bfa9e451 100644
--- a/jami-imex-updater/pom.xml
+++ b/jami-imex-updater/pom.xml
@@ -4,7 +4,7 @@
psidev.psi.mi.jami
psi-jami
- 3.4.1
+ 3.5.0
jami-imex-updater
diff --git a/jami-interactionviewer-json/pom.xml b/jami-interactionviewer-json/pom.xml
index 0760e18016..88e8857130 100644
--- a/jami-interactionviewer-json/pom.xml
+++ b/jami-interactionviewer-json/pom.xml
@@ -4,7 +4,7 @@
psidev.psi.mi.jami
psi-jami
- 3.4.1
+ 3.5.0
jami-interactionviewer-json
diff --git a/jami-mitab/pom.xml b/jami-mitab/pom.xml
index 15a4bca52d..4c2d825503 100644
--- a/jami-mitab/pom.xml
+++ b/jami-mitab/pom.xml
@@ -4,7 +4,7 @@
psidev.psi.mi.jami
psi-jami
- 3.4.1
+ 3.5.0
jami-mitab
diff --git a/jami-xml/pom.xml b/jami-xml/pom.xml
index a7aac3668c..2944308f87 100644
--- a/jami-xml/pom.xml
+++ b/jami-xml/pom.xml
@@ -4,7 +4,7 @@
psidev.psi.mi.jami
psi-jami
- 3.4.1
+ 3.5.0
jami-xml
diff --git a/pom.xml b/pom.xml
index c1f52adf61..aef8aa372d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
psidev.psi.mi.jami
psi-jami
- 3.4.1
+ 3.5.0
pom
PSI :: JAMI - Java framework for molecular interactions
@@ -15,9 +15,9 @@
UTF-8
4.3.30.RELEASE
- 2.1.0
+ 2.1.1
2.14-SNAPSHOT
- 1.2.4
+ 1.1.2
2.4
1.4.197
@@ -167,11 +167,6 @@
nexus-ebi-snapshot-repo
https://www.ebi.ac.uk/Tools/maven/repos/content/groups/ebi-snapshots/
-
- ebiUniprotPublic
- ebi-uniprot-public
- https://www.ebi.ac.uk/uniprot/artifactory/public
-