JAL-2353 primary ref candidates that should be promoted should preserve original... patch/Release_2_11_2_6_Branch
authorJim Procter <j.procter@dundee.ac.uk>
Fri, 20 Jan 2023 20:48:43 +0000 (20:48 +0000)
committerJim Procter <j.procter@dundee.ac.uk>
Fri, 20 Jan 2023 20:48:43 +0000 (20:48 +0000)
src/jalview/util/DBRefUtils.java
src/jalview/ws/dbsources/Uniprot.java
test/jalview/ws/dbsources/UniprotTest.java

index 5337852..e17a336 100755 (executable)
  */
 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);
index 286fc36..c9db7f2 100644 (file)
@@ -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);
index a7eedf1..176cddc 100644 (file)
@@ -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()));
   }
 
   /**