9eea470cea664a3efc0b90e0e3bd540af7d937dc
[jalview.git] / src / jalview / util / ProbabilityAnalyserKickstarter.java
1 package jalview.util;
2
3 import java.io.IOException;
4 import java.util.Scanner;
5
6 /**
7  * This class contains the brain of the analyser program, and contains a number
8  * of commands for the processing of data.
9  * 
10  * @author TZVanaalten
11  *
12  */
13
14 public class ProbabilityAnalyserKickstarter
15 {
16
17   public static void main(String[] args)
18           throws IOException, InterruptedException
19   {
20
21     // this does all of the processing
22     HMMProbabilityDistributionAnalyser analyser = new HMMProbabilityDistributionAnalyser();
23
24     boolean running = true;
25     System.out.println("ACTIVATED");
26     while (running)
27     {
28       Scanner keyboard = new Scanner(System.in);
29       String command = keyboard.nextLine();
30
31       Scanner inputScanner = new Scanner(command);
32       // prints family to console. Syntax is printFam <index>
33       if (command.indexOf("printFam") > -1)
34       {
35         inputScanner.next();
36         int index = inputScanner.nextInt();
37         analyser.printFam(index);
38         continue;
39       }
40       // prints HMM to console. Syntax is printHMM <index>
41       if (command.indexOf("printHMM") > -1)
42       {
43
44         inputScanner.next();
45         int index = inputScanner.nextInt();
46         analyser.printHMM(index);
47         continue;
48       }
49       // prints family to file in current folder. Syntax is exportFam <index>.
50       if (command.indexOf("exportFam") > -1)
51       {
52
53         inputScanner.next();
54         int index = inputScanner.nextInt();
55         String location = inputScanner.next();
56         analyser.printFamToFile(index);
57         continue;
58       }
59       // prints HMM to file in current folder. Syntax is exportHMM <index>.
60       if (command.indexOf("exportHMM") > -1)
61       {
62
63         inputScanner.next();
64         int index = inputScanner.nextInt();
65         String location = inputScanner.next();
66         analyser.printHMMToFile(index);
67         continue;
68       }
69       // Processes data. Syntax is run <number of loops> <increments>. The
70       // number loops specifies the number of increments the program will run.
71       // After each increment, the data stored currently in the program is
72       // exported and re-read back into the program. This is to ensure that the
73       // program can be terminated without losing a large quantity of data. The
74       // increment is the number of families read per 'save'.
75       if (command.indexOf("run") > -1)
76       {
77         inputScanner.next();
78
79         int loops = inputScanner.nextInt();
80         int increments = inputScanner.nextInt();
81
82         for (int i = 0; i < loops; i++)
83         {
84           analyser.run(increments);
85         }
86         continue;
87       }
88       // terminates program. Syntax is terminate.
89       if (command.indexOf("terminate") > -1)
90       {
91         running = false;
92         continue;
93       }
94       // clears files in current directory (Only a specific set of files).
95       // Syntax is clear.
96       if (command.indexOf("clear") > -1)
97       {
98         analyser.clear();
99         continue;
100       }
101       // changes current directory. Syntax is cd <directory>
102       if (command.indexOf("cd") > -1)
103       {
104         inputScanner.next();
105         analyser.setFolder(inputScanner.next());
106       }
107       inputScanner.close();
108       continue;
109     }
110
111
112
113
114   }
115
116 }