JAL-4047 JAL-4948 show count of each dbref authority and 'first' reference
[jalview.git] / src / jalview / viewmodel / seqfeatures / IdColumns.java
index 2f113f2..a938d63 100644 (file)
@@ -8,6 +8,7 @@ import java.util.Vector;
 
 import jalview.api.DBRefEntryI;
 import jalview.datamodel.AlignmentI;
+import jalview.datamodel.DBRefEntry;
 import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 import jalview.datamodel.features.SequenceFeaturesI;
@@ -90,9 +91,12 @@ public class IdColumns
           updateListForFeature(sf);
         }
       }
-      for (DBRefEntryI dbr : seq.getDBRefs())
+      if (seq.getDBRefs() != null)
       {
-        updateListForDbxref(dbr);
+        for (DBRefEntryI dbr : seq.getDBRefs())
+        {
+          updateListForDbxref(dbr);
+        }
       }
     }
   }
@@ -148,13 +152,14 @@ public class IdColumns
     ColumnCell cell = null;
     if (col != null)
     {
+      SequenceI dseq = seq;
+      while (dseq.getDatasetSequence() != null)
+      {
+        dseq = dseq.getDatasetSequence();
+      }
       if (col == STRUCTURES_NUM)
       {
-        while (seq.getDatasetSequence() != null)
-        {
-          seq = seq.getDatasetSequence();
-        }
-        Vector pdbE = seq.getAllPDBEntries();
+        Vector pdbE = dseq.getAllPDBEntries();
         if (pdbE == null)
         {
           return null;
@@ -163,15 +168,15 @@ public class IdColumns
       }
       if (col.featureTypeName != null)
       {
-        List<SequenceFeature> np = seq.getFeatures()
+        List<SequenceFeature> np = dseq.getFeatures()
                 .getNonPositionalFeatures(col.featureTypeName);
         if (np != null)
         {
           for (SequenceFeature npfeat : np)
           {
             // nb deal with multiplicities!
-            if (col.featureGroupName != null && npfeat.featureGroup != null
-                    && npfeat.featureGroup.equals(col.featureGroupName))
+            if (col.featureGroupName == null || (npfeat.featureGroup != null
+                    && npfeat.featureGroup.equals(col.featureGroupName)))
             {
               Color fg = Color.black;
               Color bg = Color.white;
@@ -183,14 +188,26 @@ public class IdColumns
       }
       if (col.DbRefName != null)
       {
-        for (DBRefEntryI dbr : seq.getDBRefs())
+        List<DBRefEntryI> refs = new ArrayList<DBRefEntryI>();
+        for (DBRefEntryI dbr : dseq.getDBRefs())
         {
           if (dbr.getSource().equals(col.DbRefName))
           {
-            return new ColumnCell(dbr.getAccessionId(), Color.black,
-                    Color.white);
+            refs.add(dbr);
           }
         }
+        if (refs.size()==0)
+        {
+          return null;
+        }
+        StringBuilder dbr = new StringBuilder();
+        dbr.append(refs.size());
+        for (DBRefEntryI ref : refs)
+        {
+          dbr.append(" "+ref.getAccessionId());
+        }
+        return new ColumnCell(dbr.toString(), Color.black, Color.white);
+
       }
     }
     // no value for this sequence in given column