JAL-3750 parse protocol before checking if argument to -open can be opened as a file
[jalview.git] / src / jalview / bin / Jalview.java
index 186d143..613cc02 100755 (executable)
  */
 package jalview.bin;
 
+import jalview.ext.so.SequenceOntology;
+import jalview.gui.AlignFrame;
+import jalview.gui.Desktop;
+import jalview.gui.PromptUserConfig;
+import jalview.io.AppletFormatAdapter;
+import jalview.io.BioJsHTMLOutput;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
+import jalview.io.FileFormatException;
+import jalview.io.FileFormatI;
+import jalview.io.FileFormats;
+import jalview.io.FileLoader;
+import jalview.io.HtmlSvgOutput;
+import jalview.io.IdentifyFile;
+import jalview.io.NewickFile;
+import jalview.io.gff.SequenceOntologyFactory;
+import jalview.schemes.ColourSchemeI;
+import jalview.schemes.ColourSchemeProperty;
+import jalview.util.MessageManager;
+import jalview.util.Platform;
+import jalview.ws.jws2.Jws2Discoverer;
+
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileOutputStream;
@@ -429,7 +451,11 @@ public class Jalview
       }
       System.out.println("CMD [-open " + file + "] executed successfully!");
 
-      if (!file.startsWith("http://"))
+      
+
+      protocol = AppletFormatAdapter.checkProtocol(file);
+      
+      if (protocol == DataSourceType.FILE)
       {
         if (!(new File(file)).exists())
         {
@@ -441,8 +467,6 @@ public class Jalview
         }
       }
 
-      protocol = AppletFormatAdapter.checkProtocol(file);
-
       try
       {
         format = new IdentifyFile().identify(file, protocol);
@@ -626,18 +650,34 @@ public class Jalview
             af.createEPS(outputFile);
             continue;
           }
-
-          if (af.saveAlignment(file, format))
-          {
-            System.out.println("Written alignment in " + format
-                    + " format to " + file);
+          FileFormatI outFormat=null;
+          try {
+            outFormat = FileFormats.getInstance().forName(outputFormat);
+          } catch (Exception formatP) {
+            System.out.println("Couldn't parse "+outFormat+" as a valid Jalview format string.");
           }
-          else
+          if (outFormat != null)
           {
-            System.out.println("Error writing file " + file + " in "
-                    + format + " format!!");
+            if (!outFormat.isWritable())
+            {
+              System.out.println(
+                      "This version of Jalview does not support alignment export as "
+                              + outputFormat);
+            }
+            else
+            {
+              if (af.saveAlignment(file, outFormat))
+              {
+                System.out.println("Written alignment in " + format
+                        + " format to " + file);
+              }
+              else
+              {
+                System.out.println("Error writing file " + file + " in "
+                        + format + " format!!");
+              }
+            }
           }
-
         }
 
         while (aparser.getSize() > 0)
@@ -817,27 +857,22 @@ public class Jalview
 
   private static boolean setCrossPlatformLookAndFeel()
   {
-    boolean set = false;
-    try
-    {
-      UIManager.setLookAndFeel(
-              UIManager.getCrossPlatformLookAndFeelClassName());
-      set = true;
-    } catch (Exception ex)
-    {
-      Cache.log.error("Unexpected Look and Feel Exception");
-      Cache.log.error(ex.getMessage());
-      Cache.log.debug(Cache.getStackTraceString(ex));
-    }
-    return set;
+    return setGenericLookAndFeel(false);
   }
 
   private static boolean setSystemLookAndFeel()
   {
+    return setGenericLookAndFeel(true);
+  }
+
+  private static boolean setGenericLookAndFeel(boolean system)
+  {
     boolean set = false;
     try
     {
-      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+      UIManager.setLookAndFeel(
+              system ? UIManager.getSystemLookAndFeelClassName()
+                      : UIManager.getCrossPlatformLookAndFeelClassName());
       set = true;
     } catch (Exception ex)
     {
@@ -961,6 +996,8 @@ public class Jalview
                     + "-jabaws URL\tSpecify URL for Jabaws services (e.g. for a local installation).\n"
                     + "-fetchfrom nickname\tQuery nickname for features for the alignments and display them.\n"
                     + "-groovy FILE\tExecute groovy script in FILE, after all other arguments have been processed (if FILE is the text 'STDIN' then the file will be read from STDIN)\n"
+                    + "-jvmmempc=PERCENT\tOnly available with standalone executable jar or jalview.bin.Launcher. Limit maximum heap size (memory) to PERCENT% of total physical memory detected. This defaults to 90 if total physical memory can be detected. See https://www.jalview.org/help/html/memory.html for more details.\n"
+                    + "-jvmmemmax=MAXMEMORY\tOnly available with standalone executable jar or jalview.bin.Launcher. Limit maximum heap size (memory) to MAXMEMORY. MAXMEMORY can be specified in bytes, kilobytes(k), megabytes(m), gigabytes(g) or if you're lucky enough, terabytes(t). This defaults to 32g if total physical memory can be detected, or to 8g if total physical memory cannot be detected. See https://www.jalview.org/help/html/memory.html for more details.\n"
                     + "\n~Read documentation in Application or visit http://www.jalview.org for description of Features and Annotations file~\n\n");
   }