JAL-2106 increased coverage for testGetPrimaryDbRefs
[jalview.git] / src / jalview / datamodel / Sequence.java
index ec8aa81..b50e5af 100755 (executable)
@@ -28,6 +28,7 @@ import jalview.util.StringUtils;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.List;
 import java.util.Vector;
@@ -59,8 +60,6 @@ public class Sequence extends ASequence implements SequenceI
 
   String vamsasId;
 
-  DBRefEntryI sourceDBRef;
-
   DBRefEntry[] dbrefs;
 
   RNA rna;
@@ -307,8 +306,9 @@ public class Sequence extends ASequence implements SequenceI
               && datasetSequence.getSequenceFeatures() != null
               && datasetSequence.getSequenceFeatures().length > 0)
       {
-        System.err
-              .println("Warning: JAL-2046 side effect ? Possible implementation error: overwriting dataset sequence features by setting sequence features on alignment");
+        new Exception(
+                "Warning: JAL-2046 side effect ? Possible implementation error: overwriting dataset sequence features by setting sequence features on alignment")
+                .printStackTrace();
       }
       datasetSequence.setSequenceFeatures(features);
     }
@@ -1423,12 +1423,12 @@ public class Sequence extends ASequence implements SequenceI
     }
     if (dbrefs==null || dbrefs.length==0)
     {
-      return Arrays.asList(new DBRefEntry[0]);
+      return Collections.emptyList();
     }
     synchronized (dbrefs)
     {
       List<DBRefEntry> primaries = new ArrayList<DBRefEntry>();
-      DBRefEntry tmp[] = new DBRefEntry[1], res[] = null;
+      DBRefEntry[] tmp = new DBRefEntry[1];
       for (DBRefEntry ref : dbrefs)
       {
         if (!ref.isPrimary())
@@ -1449,7 +1449,13 @@ public class Sequence extends ASequence implements SequenceI
                 DBRefUtils.getCanonicalName(ref.getSource())))
         {
           // PDB dbrefs imply there should be a PDBEntry associated
-          if (getPDBEntry(ref.getAccessionId()) != null)
+          // TODO: tighten PDB dbrefs
+          // formally imply Jalview has actually downloaded and
+          // parsed the pdb file. That means there should be a cached file
+          // handle on the PDBEntry, and a real mapping between sequence and
+          // extracted sequence from PDB file
+          PDBEntry pdbentry = getPDBEntry(ref.getAccessionId());
+          if (pdbentry != null && pdbentry.getFile() != null)
           {
             primaries.add(ref);
           }
@@ -1457,7 +1463,7 @@ public class Sequence extends ASequence implements SequenceI
         }
         // check standard protein or dna sources
         tmp[0] = ref;
-        res = DBRefUtils.selectDbRefs(!isProtein(), tmp);
+        DBRefEntry[] res = DBRefUtils.selectDbRefs(!isProtein(), tmp);
         if (res != null && res[0] == tmp[0])
         {
           primaries.add(ref);