X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2Fxdb%2Fembl%2FEmblFile.java;h=69870b693e97811322bdfd7cb1b4d31d05f6f21f;hb=c9df9ff2328d948b50aecced66df5f0b57edac82;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..69870b6 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; @@ -116,9 +119,8 @@ public class EmblFile try { // uncomment to DEBUG EMBLFile reading - if (jalview.bin.Cache.getDefault( - jalview.bin.Cache.CASTORLOGLEVEL, "debug") - .equalsIgnoreCase("DEBUG")) + if (jalview.bin.Cache.getDefault(jalview.bin.Cache.CASTORLOGLEVEL, + "debug").equalsIgnoreCase("DEBUG")) { unmar.setDebug(jalview.bin.Cache.log.isDebugEnabled()); } @@ -130,6 +132,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 +142,45 @@ 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) + { + 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"); + } + } + } + } + } + } + } }