X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2Fxdb%2Fembl%2FEmblFile.java;h=1dd854a4bd2906ace8441e04724adf322182ffd9;hb=a25f31a9140c9764baf76ec1c2ede98c1e3e52f9;hp=e0b5ede32fc0788d99d92fa96f67be791d965d0f;hpb=4d7f98a6dd54d9863ba449ec79dcd95d25ed863d;p=jalview.git diff --git a/src/jalview/datamodel/xdb/embl/EmblFile.java b/src/jalview/datamodel/xdb/embl/EmblFile.java index e0b5ede..1dd854a 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 */ @@ -129,6 +134,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); @@ -137,4 +144,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; + } }