Skip to content
Snippets Groups Projects

cazy issues

Merged Piotr Gawron requested to merge devel_15.1.x into master
2 files
+ 29
13
Compare changes
  • Side-by-side
  • Inline
Files
2
package lcsb.mapviewer.annotation.services.annotators;
import java.io.IOException;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -12,15 +16,23 @@ import org.springframework.stereotype.Service;
import lcsb.mapviewer.annotation.cache.GeneralCacheInterface;
import lcsb.mapviewer.annotation.cache.WebPageDownloader;
import lcsb.mapviewer.annotation.services.*;
import lcsb.mapviewer.annotation.services.ExternalServiceStatus;
import lcsb.mapviewer.annotation.services.ExternalServiceStatusType;
import lcsb.mapviewer.annotation.services.IExternalService;
import lcsb.mapviewer.annotation.services.WrongResponseCodeIOException;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.model.LogMarker;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.species.*;
import lcsb.mapviewer.model.user.annotator.*;
import lcsb.mapviewer.model.map.species.Gene;
import lcsb.mapviewer.model.map.species.GenericProtein;
import lcsb.mapviewer.model.map.species.Protein;
import lcsb.mapviewer.model.map.species.Rna;
import lcsb.mapviewer.model.user.annotator.AnnotatorData;
import lcsb.mapviewer.model.user.annotator.AnnotatorInputParameter;
import lcsb.mapviewer.model.user.annotator.AnnotatorOutputParameter;
/**
* This is a class that implements a backend to CAZy.
@@ -120,7 +132,7 @@ public class CazyAnnotator extends ElementAnnotator implements IExternalService
@Override
public MiriamData getExampleValidAnnotation() {
return new MiriamData(MiriamType.UNIPROT, "Q9SG95");
return new MiriamData(MiriamType.UNIPROT, "Q00012");
}
/**
@@ -143,7 +155,7 @@ public class CazyAnnotator extends ElementAnnotator implements IExternalService
* @return CAZy family identifier found on the page
*/
private Collection<MiriamData> parseCazy(String pageContent) {
Collection<MiriamData> result = new HashSet<MiriamData>();
Collection<MiriamData> result = new HashSet<>();
Matcher m = cazyIdMatcher.matcher(pageContent);
if (m.find()) {
result.add(new MiriamData(MiriamType.CAZY, m.group(1)));
@@ -176,12 +188,16 @@ public class CazyAnnotator extends ElementAnnotator implements IExternalService
if (collection.size() > 0) {
return collection.iterator().next();
} else {
marker.getEntry().setType(ProjectLogEntryType.INVALID_IDENTIFIER);
if (marker != null) {
marker.getEntry().setType(ProjectLogEntryType.INVALID_IDENTIFIER);
}
logger.warn(marker, "Cannot find CAZy data for UniProt id: " + uniprot.getResource());
return null;
}
} catch (WrongResponseCodeIOException exception) {
marker.getEntry().setType(ProjectLogEntryType.OTHER);
if (marker != null) {
marker.getEntry().setType(ProjectLogEntryType.OTHER);
}
logger.warn(marker, "Wrong response code when retrieving CAZy data for UniProt id: " + uniprot.getResource());
return null;
} catch (IOException exception) {
Loading