Merge branch 'patch/JAL-2197_jpredforjnets' into develop
[jalview.git] / src / jalview / bin / JalviewLite.java
index 96c8a97..de011ea 100644 (file)
@@ -38,6 +38,7 @@ import jalview.datamodel.SequenceI;
 import jalview.io.AnnotationFile;
 import jalview.io.AppletFormatAdapter;
 import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
 import jalview.io.FileFormatI;
 import jalview.io.FileParse;
 import jalview.io.IdentifyFile;
@@ -469,17 +470,11 @@ public class JalviewLite extends Applet implements
         SequenceI rs = sel.getSequenceAt(0);
         start = rs.findIndex(start);
         end = rs.findIndex(end);
-        if (csel != null)
-        {
-          List<Integer> cs = csel.getSelected();
-          // note - the following actually clears cs as well, since
-          // csel.getSelected returns a reference. Need to check if we need to
-          // have a concurrentModification exception thrown here
-          csel.clear();
-          for (Integer selectedCol : cs)
-          {
-            csel.addElement(rs.findIndex(selectedCol));
-          }
+        List<Integer> cs = new ArrayList<Integer>(csel.getSelected());
+        csel.clear();
+        for (Integer selectedCol : cs)
+        {
+          csel.addElement(rs.findIndex(selectedCol));
         }
       }
       sel.setStartRes(start);
@@ -522,21 +517,23 @@ public class JalviewLite extends Applet implements
   {
     try
     {
+      FileFormatI theFormat = FileFormat.valueOf(format);
       boolean seqlimits = suffix.equalsIgnoreCase(TRUE);
       if (alf.viewport.getSelectionGroup() != null)
       {
         // JBPNote: getSelectionAsNewSequence behaviour has changed - this
         // method now returns a full copy of sequence data
         // TODO consider using getSequenceSelection instead here
-        String reply = new AppletFormatAdapter().formatSequences(format,
+        String reply = new AppletFormatAdapter().formatSequences(theFormat,
                 new Alignment(alf.viewport.getSelectionAsNewSequence()),
                 seqlimits);
         return reply;
       }
-    } catch (Exception ex)
+    } catch (IllegalArgumentException ex)
     {
       ex.printStackTrace();
-      return "Error retrieving alignment in " + format + " format. ";
+      return "Error retrieving alignment, possibly invalid format specifier: "
+              + format;
     }
     return "";
   }
@@ -718,13 +715,15 @@ public class JalviewLite extends Applet implements
     {
       boolean seqlimits = suffix.equalsIgnoreCase(TRUE);
 
-      String reply = new AppletFormatAdapter().formatSequences(format,
+      FileFormatI theFormat = FileFormat.valueOf(format);
+      String reply = new AppletFormatAdapter().formatSequences(theFormat,
               alf.viewport.getAlignment(), seqlimits);
       return reply;
-    } catch (Exception ex)
+    } catch (IllegalArgumentException ex)
     {
       ex.printStackTrace();
-      return "Error retrieving alignment in " + format + " format. ";
+      return "Error retrieving alignment, possibly invalid format specifier: "
+              + format;
     }
   }
 
@@ -2256,6 +2255,11 @@ public class JalviewLite extends Applet implements
     {
       boolean result = false;
       String param = applet.getParameter("jnetfile");
+      if (param == null)
+      {
+        // jnet became jpred around 2016
+        param = applet.getParameter("jpredfile");
+      }
       if (param != null)
       {
         try