X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2Fxdb%2Fembl%2FEmblFile.java;h=8a32c130c9230c6ac7a4e4e5fa52700200fda18a;hb=88515cdb74e4603a40c8c1dca14107b5ca503e04;hp=2129054f95bfbff7912ef32007e915a7a289f860;hpb=d62b90cb6effb7b380e5f7d590691dd884b024cf;p=jalview.git diff --git a/src/jalview/datamodel/xdb/embl/EmblFile.java b/src/jalview/datamodel/xdb/embl/EmblFile.java index 2129054..8a32c13 100644 --- a/src/jalview/datamodel/xdb/embl/EmblFile.java +++ b/src/jalview/datamodel/xdb/embl/EmblFile.java @@ -20,6 +20,9 @@ */ package jalview.datamodel.xdb.embl; +import jalview.datamodel.DBRefEntry; +import jalview.ws.dbsources.Uniprot; + import java.io.File; import java.io.FileReader; import java.io.PrintWriter; @@ -43,6 +46,8 @@ public class EmblFile Vector errors; + String text; + /** * @return the entries */ @@ -116,8 +121,8 @@ public class EmblFile try { // uncomment to DEBUG EMBLFile reading - if (jalview.bin.Cache.getDefault( - jalview.bin.Cache.CASTORLOGLEVEL, "debug") + if (jalview.bin.Cache + .getDefault(jalview.bin.Cache.CASTORLOGLEVEL, "debug") .equalsIgnoreCase("DEBUG")) { unmar.setDebug(jalview.bin.Cache.log.isDebugEnabled()); @@ -130,6 +135,8 @@ public class EmblFile unmar.setMapping(map); unmar.setLogWriter(new PrintWriter(System.out)); record = (EmblFile) unmar.unmarshal(file); + + canonicaliseDbRefs(record); } catch (Exception e) { e.printStackTrace(System.err); @@ -138,4 +145,59 @@ public class EmblFile return record; } + + /** + * Change blank version to "0" in any DBRefEntry, to ensure consistent + * comparison with other DBRefEntry in Jalview + * + * @param record + * @see Uniprot#getDbVersion + */ + static void canonicaliseDbRefs(EmblFile record) + { + if (record.getEntries() == null) + { + return; + } + for (EmblEntry entry : record.getEntries()) + { + if (entry.getDbRefs() != null) + { + for (DBRefEntry dbref : entry.getDbRefs()) + { + if ("".equals(dbref.getVersion())) + { + dbref.setVersion("0"); + } + } + } + + if (entry.getFeatures() != null) + { + for (EmblFeature feature : entry.getFeatures()) + { + if (feature.getDbRefs() != null) + { + for (DBRefEntry dbref : feature.getDbRefs()) + { + if ("".equals(dbref.getVersion())) + { + dbref.setVersion("0"); + } + } + } + } + } + } + } + + public String getText() + { + return text; + } + + public void setText(String text) + { + this.text = text; + } }