JAL-3863 passing test to verify a uniprot accession with canonical flag set is transf...
authorJim Procter <j.procter@dundee.ac.uk>
Fri, 3 Sep 2021 15:45:16 +0000 (16:45 +0100)
committerJim Procter <j.procter@dundee.ac.uk>
Fri, 3 Sep 2021 15:45:16 +0000 (16:45 +0100)
src/jalview/api/DBRefEntryI.java
src/jalview/datamodel/DBRefEntry.java
test/jalview/datamodel/SequenceTest.java
test/jalview/ws/seqfetcher/DbRefFetcherTest.java

index 672d6b4..ed6358e 100644 (file)
@@ -112,4 +112,6 @@ public interface DBRefEntryI
    *         associated sequence object
    */
   public boolean isPrimaryCandidate();
+
+  public boolean isCanonical();
 }
index ae06650..b6cae62 100755 (executable)
@@ -113,7 +113,7 @@ public class DBRefEntry implements DBRefEntryI
                     : new String(entry.getVersion())),
             (entry.getAccessionId() == null ? ""
                     : new String(entry.getAccessionId())),
-            (entry.getMap() == null ? null : new Mapping(entry.getMap())));
+            (entry.getMap() == null ? null : new Mapping(entry.getMap())),entry.isCanonical());
   }
 
   @Override
index 129d7b3..5ae7dd9 100644 (file)
@@ -2175,4 +2175,15 @@ public class SequenceTest
     assertEquals(0, seq.firstResidueOutsideIterator(cs.iterator()));
 
   }
+  @Test(groups= {"Functional"})
+  public void testTransferAnnotation() {
+    Sequence origSeq = new Sequence("MYSEQ","THISISASEQ");
+    Sequence toSeq = new Sequence("MYSEQ","THISISASEQ");
+    origSeq.addDBRef(new DBRefEntry("UNIPROT", "0", "Q12345", null, true));
+    toSeq.transferAnnotation(origSeq, null);
+    assertTrue(toSeq.getDBRefs().size()>0);
+    
+    assertTrue(toSeq.getDBRefs().get(0).isCanonical());
+    
+  }
 }
index a7e5806..914520f 100644 (file)
@@ -30,10 +30,12 @@ import jalview.datamodel.AlignmentI;
 import jalview.datamodel.DBRefEntry;
 import jalview.datamodel.DBRefSource;
 import jalview.datamodel.FeatureProperties;
+import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 import jalview.gui.JvOptionPane;
 import jalview.util.DBRefUtils;
+import jalview.ws.DBRefFetcher;
 import jalview.ws.SequenceFetcher;
 import jalview.ws.dbsources.Pdb;
 import jalview.ws.dbsources.Uniprot;
@@ -77,6 +79,26 @@ public class DbRefFetcherTest
   {
   }
 
+  @Test(groups= {"Network"})
+  public void checkUniprotCanonicalFlagSet()
+  {
+    // TODO - mock this  - for moment it is a live request.
+    SequenceI uniprotSeq = new Sequence("FER1_SPIOL",
+            "MAATTTTMMGMATTFVPKPQAPPMMAALPSNTGRSLFGLKTGSRGGRMTMAAYKVTLVTPTGNVEFQCPDDV"
+            + "YILDAAEEEGIDLPYSCRAGSCSSCAGKLKTGSLNQDDQSFLDDDQIDEGWVLTCAAYPVSDVTIETHKEEE"
+            + "LTA");
+    DBRefFetcher dbr = new DBRefFetcher(new SequenceI[] { uniprotSeq });
+    dbr.fetchDBRefs(true);
+    List<DBRefEntry> primRefs = uniprotSeq.getPrimaryDBRefs();
+    assertNotNull(primRefs);
+    assertTrue(primRefs.size()>0);
+    boolean canonicalUp=false;
+    for (DBRefEntry ref:primRefs) {
+      assertEquals(DBRefSource.UNIPROT, ref.getCanonicalSourceName());
+      canonicalUp |= ref.isCanonical();
+    }
+    assertTrue("No Canonical Uniprot reference detected", canonicalUp);
+  }
   /**
    * Tests that standard protein database sources include Uniprot (as the first)
    * and also PDB. (Additional sources are dependent on availability of DAS