JAL-2716 fix to reset choice parameter on Revert
[jalview.git] / src / jalview / util / ProbabilityAnalyserKickstarter.java
index 9eea470..59c0a9f 100644 (file)
@@ -32,39 +32,61 @@ public class ProbabilityAnalyserKickstarter
       // prints family to console. Syntax is printFam <index>
       if (command.indexOf("printFam") > -1)
       {
-        inputScanner.next();
-        int index = inputScanner.nextInt();
-        analyser.printFam(index);
-        continue;
+        try
+        {
+          inputScanner.next();
+          int index = inputScanner.nextInt();
+          analyser.printFam(index);
+          continue;
+        } catch (Exception e)
+        {
+          System.out.println("Command failed");
+        }
+
       }
       // prints HMM to console. Syntax is printHMM <index>
       if (command.indexOf("printHMM") > -1)
       {
-
+        try
+        {
         inputScanner.next();
         int index = inputScanner.nextInt();
         analyser.printHMM(index);
         continue;
+        } catch (Exception e)
+        {
+          System.out.println("Command failed");
+        }
       }
       // prints family to file in current folder. Syntax is exportFam <index>.
       if (command.indexOf("exportFam") > -1)
       {
-
+        try
+        {
         inputScanner.next();
         int index = inputScanner.nextInt();
-        String location = inputScanner.next();
-        analyser.printFamToFile(index);
+          String location = inputScanner.next();
+          analyser.exportFam(index, location);
         continue;
+        } catch (Exception e)
+        {
+          System.out.println("Command failed");
+        }
       }
       // prints HMM to file in current folder. Syntax is exportHMM <index>.
       if (command.indexOf("exportHMM") > -1)
       {
-
+        try
+        {
         inputScanner.next();
         int index = inputScanner.nextInt();
-        String location = inputScanner.next();
-        analyser.printHMMToFile(index);
+          String location = inputScanner.next();
+          analyser.exportHMM(index, location);
         continue;
+        } catch (Exception e)
+        {
+          System.out.println("Command failed");
+        }
       }
       // Processes data. Syntax is run <number of loops> <increments>. The
       // number loops specifies the number of increments the program will run.
@@ -72,16 +94,45 @@ public class ProbabilityAnalyserKickstarter
       // exported and re-read back into the program. This is to ensure that the
       // program can be terminated without losing a large quantity of data. The
       // increment is the number of families read per 'save'.
-      if (command.indexOf("run") > -1)
+      if (command.indexOf("run") > -1 && !(command.indexOf("ToEnd") > -1))
       {
+        try
+        {
+
         inputScanner.next();
 
         int loops = inputScanner.nextInt();
         int increments = inputScanner.nextInt();
+        boolean keepRaw = inputScanner.nextBoolean();
 
         for (int i = 0; i < loops; i++)
         {
-          analyser.run(increments);
+          analyser.run(increments, keepRaw);
+          System.out.println("Saved");
+        }
+        System.out.println("Task completed");
+        continue;
+        } catch (Exception e)
+        {
+          System.out.println("Command failed");
+        }
+        continue;
+      }
+      if ((command.indexOf("runToEnd") > -1))
+      {
+        try
+        {
+
+          inputScanner.next();
+          int minCount = inputScanner.nextInt();
+          int maxCount = inputScanner.nextInt();
+          boolean keepRaw = inputScanner.nextBoolean();
+          boolean forClans = inputScanner.nextBoolean();
+          analyser.runToEnd(minCount, maxCount, keepRaw, forClans);
+          System.out.println("Task completed");
+        } catch (Exception e)
+        {
+          System.out.println("Command failed");
         }
         continue;
       }
@@ -101,11 +152,65 @@ public class ProbabilityAnalyserKickstarter
       // changes current directory. Syntax is cd <directory>
       if (command.indexOf("cd") > -1)
       {
+        try
+        {
         inputScanner.next();
         analyser.setFolder(inputScanner.next());
+        } catch (Exception e)
+        {
+          System.out.println("Command failed");
+
+        }
+        continue;
       }
-      inputScanner.close();
-      continue;
+
+      if (command.indexOf("getFamName") > -1)
+      {
+        try
+        {
+        inputScanner.next();
+        System.out.println(analyser.getFamilyName(inputScanner.nextInt()));
+
+        } catch (Exception e)
+        {
+          System.out.println("Command failed");
+        }
+        continue;
+      }
+      if (command.indexOf("sortIntoClans") > -1)
+      {
+        inputScanner.next();
+        analyser.sortIntoClans(inputScanner.next());
+          continue;
+
+      }
+      if (command.indexOf("setFamilies") > -1)
+      {
+        inputScanner.next();
+        analyser.setFamilies(inputScanner.next());
+        continue;
+
+      }
+
+      if (command.indexOf("setHMMs") > -1)
+      {
+        inputScanner.next();
+        analyser.setHmms(inputScanner.next());
+        continue;
+
+      }
+
+      if (command.indexOf("alignWithinClans") > -1)
+      {
+        inputScanner.next();
+        String export = inputScanner.next();
+        String clans = inputScanner.next();
+        analyser.alignWithinClan(export, clans);
+        continue;
+
+      }
+
+      System.out.println("Unrecognised command");
     }