From: Jim Procter Date: Fri, 20 Jan 2023 20:48:43 +0000 (+0000) Subject: JAL-2353 primary ref candidates that should be promoted should preserve original... X-Git-Tag: Release_2_11_2_6~5^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fpatch%2FRelease_2_11_2_6_Branch;p=jalview.git JAL-2353 primary ref candidates that should be promoted should preserve original version string --- diff --git a/src/jalview/util/DBRefUtils.java b/src/jalview/util/DBRefUtils.java index 5337852..e17a336 100755 --- a/src/jalview/util/DBRefUtils.java +++ b/src/jalview/util/DBRefUtils.java @@ -20,13 +20,12 @@ */ package jalview.util; -import java.util.Locale; - import java.util.ArrayList; import java.util.BitSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import com.stevesoft.pat.Regex; @@ -805,7 +804,7 @@ public class DBRefUtils } // and promote - not that version must be non-null here, // as p must have passed isPrimaryCandidate() - cand.setVersion(p.getVersion() + " (promoted)"); + cand.setVersion(cand.getVersion() + " (promoted)"); bsSelect.clear(ic); // selfs.remove(cand); // toPromote.add(cand); diff --git a/src/jalview/ws/dbsources/Uniprot.java b/src/jalview/ws/dbsources/Uniprot.java index 286fc36..c9db7f2 100644 --- a/src/jalview/ws/dbsources/Uniprot.java +++ b/src/jalview/ws/dbsources/Uniprot.java @@ -193,7 +193,7 @@ public class Uniprot extends DbSourceProxyImpl SequenceI sequence = new Sequence(id, seqString); sequence.setDescription(getUniprotEntryDescription(entry)); - + final String uniprotRecordVersion = "" + entry.getVersion(); /* * add a 'self' DBRefEntry for each accession */ @@ -202,8 +202,8 @@ public class Uniprot extends DbSourceProxyImpl boolean canonical = true; for (String accessionId : entry.getAccession()) { - DBRefEntry dbRef = new DBRefEntry(DBRefSource.UNIPROT, dbVersion, - accessionId, null, canonical); + DBRefEntry dbRef = new DBRefEntry(DBRefSource.UNIPROT, + uniprotRecordVersion, accessionId, null, canonical); canonical = false; dbRefs.add(dbRef); } @@ -241,8 +241,11 @@ public class Uniprot extends DbSourceProxyImpl // remove version String[] vrs = cdsId.split("\\."); String version = vrs.length > 1 ? vrs[1] - : DBRefSource.UNIPROT + ":" + dbVersion; + : DBRefSource.UNIPROT + ":" + uniprotRecordVersion; dbr = new DBRefEntry(DBRefSource.EMBLCDS, version, vrs[0]); + // TODO: process VARIANT features to allow EMBLCDS record's product to + // match Uniprot + dbr.setCanonical(true); dbRefs.add(dbr); } } @@ -252,7 +255,7 @@ public class Uniprot extends DbSourceProxyImpl // remove version String[] vrs = dbref.getId().split("\\."); String version = vrs.length > 1 ? vrs[1] - : DBRefSource.UNIPROT + ":" + dbVersion; + : DBRefSource.UNIPROT + ":" + uniprotRecordVersion; dbr.setAccessionId(vrs[0]); dbr.setVersion(version); /* @@ -270,7 +273,7 @@ public class Uniprot extends DbSourceProxyImpl // remove version String[] cdsVrs = cdsId.split("\\."); String cdsVersion = cdsVrs.length > 1 ? cdsVrs[1] - : DBRefSource.UNIPROT + ":" + dbVersion; + : DBRefSource.UNIPROT + ":" + uniprotRecordVersion; dbr = new DBRefEntry(DBRefSource.ENSEMBL, DBRefSource.UNIPROT + ":" + cdsVersion, cdsVrs[0]); dbRefs.add(dbr); diff --git a/test/jalview/ws/dbsources/UniprotTest.java b/test/jalview/ws/dbsources/UniprotTest.java index a7eedf1..176cddc 100644 --- a/test/jalview/ws/dbsources/UniprotTest.java +++ b/test/jalview/ws/dbsources/UniprotTest.java @@ -224,14 +224,22 @@ public class UniprotTest res = DBRefUtils.searchRefsForSource(seq.getDBRefs(), DBRefSource.UNIPROT); assertEquals(2, res.size()); - res = DBRefUtils.searchRefs(seq.getDBRefs(), "AAK85932"); - assertEquals(1, res.size()); - assertTrue("1".equals(res.get(0).getVersion())); /* * NB this test fragile - relies on ordering being preserved */ assertTrue(res.get(0).isCanonical()); assertFalse(res.get(1).isCanonical()); + + // check version is preserved for EMBLCDS + res = DBRefUtils.searchRefs(seq.getDBRefs(), "AAK85932"); + assertEquals(1, res.size()); + // Ideally we would expect AAK85932.1 -> AAK85932 + // assertTrue("1".equals(res.get(0).getVersion())); + // but it also passes through DBrefUtils.ensurePrimaries which adds + // (promoted) to the version string + // FIXME: Jim needs to specify what (promoted) means !! - or perhaps we just + // ignore it ! + assertEquals("1 (promoted)", (res.get(0).getVersion())); } /**