JAL-4308 reduce number of refs to 5, always have canonical reference first.
[jalview.git] / src / jalview / io / SequenceAnnotationReport.java
index 7fc04e1..0a1172c 100644 (file)
  */
 package jalview.io;
 
-import java.util.Locale;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Comparator;
 import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
-import com.google.common.collect.Lists;
-
 import jalview.api.FeatureColourI;
 import jalview.datamodel.DBRefEntry;
 import jalview.datamodel.DBRefSource;
@@ -58,7 +55,7 @@ public class SequenceAnnotationReport
 
   private static final int MAX_REFS_PER_SOURCE = 4;
 
-  private static final int MAX_SOURCES = 40;
+  private static final int MAX_SOURCES = 5;
 
   private static String linkImageURL;
 
@@ -82,10 +79,19 @@ public class SequenceAnnotationReport
       {
         return 1;
       }
+      
       String s1 = ref1.getSource();
       String s2 = ref2.getSource();
       boolean s1Primary = DBRefSource.isPrimarySource(s1);
       boolean s2Primary = DBRefSource.isPrimarySource(s2);
+      if (ref1.isCanonical() && !ref2.isCanonical())
+      {
+        return -1;
+      }
+      if (!ref1.isCanonical() && ref2.isCanonical())
+      {
+        return 1;
+      }
       if (s1Primary && !s2Primary)
       {
         return -1;
@@ -426,7 +432,7 @@ public class SequenceAnnotationReport
             }
           } catch (Exception x)
           {
-            System.err.println(
+            jalview.bin.Console.errPrintln(
                     "problem when creating links from " + urlstring);
             x.printStackTrace();
           }
@@ -449,7 +455,7 @@ public class SequenceAnnotationReport
     UrlLink urlLink = new UrlLink(link);
     if (!urlLink.isValid())
     {
-      System.err.println(urlLink.getInvalidMessage());
+      jalview.bin.Console.errPrintln(urlLink.getInvalidMessage());
       return null;
     }
 
@@ -539,7 +545,7 @@ public class SequenceAnnotationReport
   protected int appendDbRefs(final StringBuilder sb, SequenceI ds,
           boolean summary)
   {
-    List<DBRefEntry> dbrefs,dbrefset = ds.getDBRefs();
+    List<DBRefEntry> dbrefs, dbrefset = ds.getDBRefs();
 
     if (dbrefset == null)
     {
@@ -549,9 +555,9 @@ public class SequenceAnnotationReport
     // PATCH for JAL-3980 defensive copy
 
     dbrefs = new ArrayList<DBRefEntry>();
-    
+
     dbrefs.addAll(dbrefset);
-    
+
     // note this sorts the refs held on the sequence!
     dbrefs.sort(comparator);
     boolean ellipsis = false;