*/
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;
unmar.setMapping(map);
unmar.setLogWriter(new PrintWriter(System.out));
record = (EmblFile) unmar.unmarshal(file);
+
+ canonicaliseDbRefs(record);
} catch (Exception e)
{
e.printStackTrace(System.err);
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");
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
+ "<description>Chicken LDH-A mRNA for lactate dehydrogenase A chain (EC 1.1.1.27)</description>"
+ "<keyword>L-lactate dehydrogenase</keyword><keyword>chutney</keyword>"
+ "<dbreference db=\"EuropePMC\" primary=\"PMC1460223\" secondary=\"9649548\" />"
+ + "<dbreference db=\"MD5\" primary=\"d3b68\" />"
+ "<feature name=\"CDS\"><dbreference db=\"GOA\" primary=\"P00340\" secondary=\"2.1\" /><dbreference db=\"InterPro\" primary=\"IPR001236\" />"
+ "<qualifier name=\"note\"><value>L-lactate dehydrogenase A-chain</value><value>pickle</value></qualifier>"
+ "<qualifier name=\"translation\"><value>MSLKDHLIHN</value><evidence>Keith</evidence></qualifier>"
/*
* dbrefs
*/
- assertEquals(1, entry.getDbRefs().size());
+ assertEquals(2, entry.getDbRefs().size());
DBRefEntry dbref = entry.getDbRefs().get(0);
assertEquals("EuropePMC", dbref.getSource());
assertEquals("PMC1460223", dbref.getAccessionId());
assertEquals("9649548", dbref.getVersion());
+ dbref = entry.getDbRefs().get(1);
+ assertEquals("MD5", dbref.getSource());
+ assertEquals("d3b68", dbref.getAccessionId());
+ // blank version has been converted to "0"
+ assertEquals("0", dbref.getVersion());
/*
* sequence features
dbref = ef.getDbRefs().get(1);
assertEquals("InterPro", dbref.getSource());
assertEquals("IPR001236", dbref.getAccessionId());
- assertEquals("", dbref.getVersion());
+ // blank version converted to "0":
+ assertEquals("0", dbref.getVersion());
assertEquals(2, ef.getQualifiers().size());
// feature qualifiers
assertEquals("mRNA", seq.getType());
assertEquals("2", seq.getVersion());
assertEquals("GTGACG", seq.getSequence());
+
+ /*
+ * getSequence() converts empty DBRefEntry.version to "0"
+ */
+ assertEquals("0", entry.getDbRefs().get(1).getVersion());
+ assertEquals("0", entry.getFeatures().get(0).getDbRefs().get(1)
+ .getVersion());
}
}