3 import java.io.IOException;
4 import java.util.Scanner;
7 * This class contains the brain of the analyser program, and contains a number
8 * of commands for the processing of data.
14 public class ProbabilityAnalyserKickstarter
17 public static void main(String[] args)
18 throws IOException, InterruptedException
21 // this does all of the processing
22 HMMProbabilityDistributionAnalyser analyser = new HMMProbabilityDistributionAnalyser();
24 boolean running = true;
25 System.out.println("ACTIVATED");
28 Scanner keyboard = new Scanner(System.in);
29 String command = keyboard.nextLine();
31 Scanner inputScanner = new Scanner(command);
32 // prints family to console. Syntax is printFam <index>
33 if (command.indexOf("printFam") > -1)
38 int index = inputScanner.nextInt();
39 analyser.printFam(index);
43 System.out.println("Command failed");
47 // prints HMM to console. Syntax is printHMM <index>
48 if (command.indexOf("printHMM") > -1)
53 int index = inputScanner.nextInt();
54 analyser.printHMM(index);
58 System.out.println("Command failed");
61 // prints family to file in current folder. Syntax is exportFam <index>.
62 if (command.indexOf("exportFam") > -1)
67 int index = inputScanner.nextInt();
68 String location = inputScanner.next();
69 analyser.exportFam(index, location);
73 System.out.println("Command failed");
76 // prints HMM to file in current folder. Syntax is exportHMM <index>.
77 if (command.indexOf("exportHMM") > -1)
82 int index = inputScanner.nextInt();
83 String location = inputScanner.next();
84 analyser.exportHMM(index, location);
88 System.out.println("Command failed");
91 // Processes data. Syntax is run <number of loops> <increments>. The
92 // number loops specifies the number of increments the program will run.
93 // After each increment, the data stored currently in the program is
94 // exported and re-read back into the program. This is to ensure that the
95 // program can be terminated without losing a large quantity of data. The
96 // increment is the number of families read per 'save'.
97 if (command.indexOf("run") > -1 && !(command.indexOf("ToEnd") > -1))
104 int loops = inputScanner.nextInt();
105 int increments = inputScanner.nextInt();
106 boolean keepRaw = inputScanner.nextBoolean();
108 for (int i = 0; i < loops; i++)
110 analyser.run(increments, keepRaw);
111 System.out.println("Saved");
113 System.out.println("Task completed");
115 } catch (Exception e)
117 System.out.println("Command failed");
121 if ((command.indexOf("runToEnd") > -1))
127 boolean keepRaw = inputScanner.nextBoolean();
128 boolean forClans = inputScanner.nextBoolean();
129 analyser.runToEnd(keepRaw, forClans);
130 System.out.println("Task completed");
131 } catch (Exception e)
133 System.out.println("Command failed");
137 // terminates program. Syntax is terminate.
138 if (command.indexOf("terminate") > -1)
143 // clears files in current directory (Only a specific set of files).
145 if (command.indexOf("clear") > -1)
150 // changes current directory. Syntax is cd <directory>
151 if (command.indexOf("cd") > -1)
156 analyser.setFolder(inputScanner.next());
157 } catch (Exception e)
159 System.out.println("Command failed");
165 if (command.indexOf("getFamName") > -1)
170 System.out.println(analyser.getFamilyName(inputScanner.nextInt()));
172 } catch (Exception e)
174 System.out.println("Command failed");
178 if (command.indexOf("sortIntoClans") > -1)
181 analyser.sortIntoClans(inputScanner.next());
185 if (command.indexOf("setFamilies") > -1)
188 analyser.setFamilies(inputScanner.next());
193 if (command.indexOf("setHMMs") > -1)
196 analyser.setHmms(inputScanner.next());
201 if (command.indexOf("alignWithinClans") > -1)
204 String export = inputScanner.next();
205 String clans = inputScanner.next();
206 analyser.alignWithinClan(export, clans);
211 System.out.println("Unrecognised command");