X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2Fxdb%2Fembl%2FEmblFile.java;h=8a32c130c9230c6ac7a4e4e5fa52700200fda18a;hb=88515cdb74e4603a40c8c1dca14107b5ca503e04;hp=54aab8bae651de0d8b9e7ceaaf3da0b77029d716;hpb=c19d2a91ca05e052e3408bf5852d88eb5d0608f1;p=jalview.git diff --git a/src/jalview/datamodel/xdb/embl/EmblFile.java b/src/jalview/datamodel/xdb/embl/EmblFile.java index 54aab8b..8a32c13 100644 --- a/src/jalview/datamodel/xdb/embl/EmblFile.java +++ b/src/jalview/datamodel/xdb/embl/EmblFile.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2) - * Copyright (C) 2015 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -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,9 @@ 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()); } @@ -129,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); @@ -137,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; + } }