import java.util.*; import java.io.*; import java.util.*; /** * Class Interaction is the class that manages the user interaction. * All input parameters are given to class Control * @author Gard Thomassen * @see Invoke * @see Control */ public class Interaction{ Control control; boolean correct = true; String input; BufferedReader stdin; /** * Cosntructor Interaction is used to create an instance of the Control class, * this object is used to store all data from the user in. The object is returned * to class Invoke by the method interact. */ Interaction(){ control = new Control(); try{ stdin = new BufferedReader(new InputStreamReader(System.in)); } catch(Exception e){ System.out.println("Something wrong whiel creating input reader"); System.exit(1); } } /** * Method interact asks the user for the name of the inputfile. * Inputfile are given to the Control class * Method also invokes the two methods that asks the user which consensuses to * search for, and what thresholds to use. * return an instance of the Control class */ public Control interact(){ try{ while(correct) { System.out.println("Enter the name and location of the FASTA formatted file you wish to search"); System.out.println("Type 'q' to exit the program"); input = stdin.readLine(); if(input.equals("q")) System.exit(0); else{ if(control.createSeqIterator(input)) correct = false; else System.out.println("Wrong filename or path to the FASTA formatted file"); } } chooseConsensus(); setThresholds(); } catch(Exception e){ System.out.println("Something went wrong while choosing search parameters"); } return control; }//end interact /** * Method chooseConsensus asks the user which of the consensuses to * search for. User input is stored in an instance of the Control class */ public void chooseConsensus()throws Exception{ System.out.println("Now you will be prompted to choose whether or not to include different consensus sequences in the search"); System.out.println("Type 'q' to exit the program"); System.out.println("Include consensus sequecence to the region recognized by sigma 70, accoring to Pedersen et al. and Ussery (y or n}"); correct = true; while(correct){ input = stdin.readLine(); if(input.equals("q")) System.exit(0); else if(input.equals("y")){ control.consensuses[0] = true; correct = false; } else if(input.equals("n")) correct = false; else System.out.println("Type 'y' or 'n' then press 'ENTER'"); } System.out.println("Include consensus sequecence to the region recognized by sigma 32, accoring to Pedersen et al. and Ussery (y or n)"); correct = true; while(correct){ input = stdin.readLine(); if(input.equals("q")) System.exit(0); else if(input.equals("y")){ control.consensuses[1] = true; correct = false; } else if(input.equals("n")) correct = false; else System.out.println("Type 'y' or 'n' then press 'ENTER'"); } System.out.println("Include consensus sequecence to the region recognized by sigma 54, accoring to Pedersen et al. and Ussery (y or n)"); correct = true; while(correct){ input = stdin.readLine(); if(input.equals("q")) System.exit(0); else if(input.equals("y")){ control.consensuses[2] = true; correct = false; } else if(input.equals("n")) correct = false; else System.out.println("Type 'y' or 'n' then press 'ENTER'"); } System.out.println("Include consensus sequecence to the region recognized by sigma 38, accoring to Pedersen et al. and Ussery (y or n)"); correct = true; while(correct){ input = stdin.readLine(); if(input.equals("q")) System.exit(0); else if(input.equals("y")){ control.consensuses[3] = true; correct = false; } else if(input.equals("n")) correct = false; else System.out.println("Type 'y' or 'n' then press 'ENTER'"); } System.out.println("Include non sigma specific consensus sequecence accoring Lisser and Margalit (y or n)"); correct = true; while(correct){ input = stdin.readLine(); if(input.equals("q")) System.exit(0); else if(input.equals("y")){ control.consensuses[4] = true; correct = false; } else if(input.equals("n")) correct = false; else System.out.println("Type 'y' or 'n' then press 'ENTER'"); } System.out.println("Include consensus sequecence to the region recognized by sigma 70, accoring to regulonDB (y or n)"); correct = true; while(correct){ input = stdin.readLine(); if(input.equals("q")) System.exit(0); else if(input.equals("y")){ control.consensuses[5] = true; correct = false; } else if(input.equals("n")) correct = false; else System.out.println("Type 'y' or 'n' then press 'ENTER'"); } System.out.println("Include consensus sequecence to the region recognized by sigma 32, accoring to Pedersen et al. and Ussery (y or n)"); correct = true; while(correct){ input = stdin.readLine(); if(input.equals("q")) System.exit(0); else if(input.equals("y")){ control.consensuses[6] = true; correct = false; } else if(input.equals("n")) correct = false; else System.out.println("Type 'y' or 'n' then press 'ENTER'"); } System.out.println("Include consensus sequecence to the region recognized by sigma 24, accoring to Pedersen et al. and Ussery (y or n)"); correct = true; while(correct){ input = stdin.readLine(); if(input.equals("q")) System.exit(0); else if(input.equals("y")){ control.consensuses[7] = true; correct = false; } else if(input.equals("n")) correct = false; else System.out.println("Type 'y' or 'n' then press 'ENTER'"); } }//end chooseConsensus /** * Method setThresholds asks the user which thresholds to use accoring to the * consensuses chosen in method chooseConsensus */ private void setThresholds()throws Exception{ int n = 0; double threshold; if(control.consensuses[0]){ correct = true; while(correct){ System.out.println("Type your threshold for the sigma 70 consensus sequence from Pedersen et al. and Ussery"); System.out.println("95 % is recommended , min and max are 87-100, type 'q' to exit"); input = stdin.readLine(); if(input.equals("q")) System.exit(0); threshold = Integer.parseInt(input); if(86 < threshold && threshold <= 100){ control.thresholds[n] = threshold; control.thresholds[n+1] = threshold; n = n+2; correct = false; } else{ System.out.println("Wrong format of threshold value, or value set to low or to high"); } } } if(control.consensuses[1]){ correct = true; while(correct){ System.out.println("Type your threshold for the sigma 32 consensus sequence from Pedersen et al and Ussery"); System.out.println("82 % is recommended , min and max are 75-100, type 'q' to exit"); input = stdin.readLine(); if(input.equals("q")) System.exit(0); threshold = Integer.parseInt(input); if(74 < threshold && threshold <= 100){ control.thresholds[n] = threshold; control.thresholds[n+1] = threshold; n = n+2; correct = false; } else{ System.out.println("Wrong format of threshold value, or value set to low or to high"); } } } if(control.consensuses[2]){ correct = true; while(correct){ System.out.println("Type your threshold for the sigma 54 consensus sequence from Pedersen et al and Ussery"); System.out.println("93 % is recommended , min and max are 85-100, type 'q' to exit"); input = stdin.readLine(); if(input.equals("q")) System.exit(0); threshold = Integer.parseInt(input); if(84 < threshold && threshold <= 100){ control.thresholds[n] = threshold; control.thresholds[n+1] = threshold; n = n+2; correct = false; } else{ System.out.println("Wrong format of threshold value, or value set to low or to high"); } } } if(control.consensuses[3]){ correct = true; while(correct){ System.out.println("Type your threshold for the sigma 38 consensus sequence from Pedersen et al and Ussery"); System.out.println("91 % is recommended , min and max are 80-100, type 'q' to exit"); input = stdin.readLine(); if(input.equals("q")) System.exit(0); threshold = Integer.parseInt(input); if(79 < threshold && threshold <= 100){ control.thresholds[n] = threshold; control.thresholds[n+1] = threshold; n = n+2; correct = false; } else{ System.out.println("Wrong format of threshold value, or value set to low or to high"); } } } if(control.consensuses[4]){ correct = true; while(correct){ System.out.println("Type your threshold for the non sigma specific consensus sequence from Lisser and Margalit"); System.out.println("88 % is recommended , min and max are 77-100, type 'q' to exit"); input = stdin.readLine(); if(input.equals("q")) System.exit(0); threshold = Integer.parseInt(input); if(76 < threshold && threshold <= 100){ control.thresholds[n] = threshold; control.thresholds[n+1] = threshold; n = n+2; correct = false; } else{ System.out.println("Wrong format of threshold value, or value set to low or to high"); } } } if(control.consensuses[5]){ correct = true; while(correct){ System.out.println("Type your threshold for the sigma 70 consensus sequence from the regulon database"); System.out.println("95 % is recommended , min and max are 87-100, type 'q' to exit"); input = stdin.readLine(); if(input.equals("q")) System.exit(0); threshold = Integer.parseInt(input); if(86 < threshold && threshold <= 100){ control.thresholds[n] = threshold; control.thresholds[n+1] = threshold; n = n+2; correct = false; } else{ System.out.println("Wrong format of threshold value, or value set to low or to high"); } } } if(control.consensuses[6]){ correct = true; while(correct){ System.out.println("Type your threshold for the sigma 32 consensus sequence from the regulon database"); System.out.println("83 % is recommended , min and max are 75-100, type 'q' to exit"); input = stdin.readLine(); if(input.equals("q")) System.exit(0); threshold = Integer.parseInt(input); if(74 < threshold && threshold <= 100){ control.thresholds[n] = threshold; control.thresholds[n+1] = threshold; n = n+2; correct = false; } else{ System.out.println("Wrong format of threshold value, or value set to low or to high"); } } } if(control.consensuses[7]){ correct = true; while(correct){ System.out.println("Type your threshold for the sigma 24 consensus sequence from the regulon database"); System.out.println("85 % is recommended , min and max are 75-100, type 'q' to exit"); input = stdin.readLine(); if(input.equals("q")) System.exit(0); threshold = Integer.parseInt(input); if(74 < threshold && threshold <= 100){ control.thresholds[n] = threshold; control.thresholds[n+1] = threshold; n = n+2; correct = false; } else{ System.out.println("Wrong format of threshold value, or value set to low or to high"); } } } }//end setThresholds }//end class