/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package oligo3; import java.io.File; import java.util.Arrays; import java.io.IOException; import java.io.BufferedReader; import java.io.FilenameFilter; import java.io.InputStreamReader; import java.lang.management.ManagementFactory; /** * * @author rli */ public class RunJob { public static String[] files; public static String s = ""; public static void getStdInput() { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); do { System.out.print("Proceed to run ? [y/b/n]: "); try { s = br.readLine().trim(); } catch (IOException e) { System.err.println("Error: " + e.getMessage()); } if (s.equalsIgnoreCase("n")) { System.out.println(""); System.exit(1); } } while (!s.matches("[byBY]")); if (s.equalsIgnoreCase("b")) { System.out.println("\nPlease type bg to run in the background."); Process pr = null; String p = ""; try { p = ManagementFactory.getRuntimeMXBean().getName(); p = p.substring(0, p.indexOf('@')); } catch (Exception e) { System.err.println("Error: " + e.getMessage()); } try { pr = Runtime.getRuntime().exec("kill -STOP " + p); } catch (IOException e) { System.err.println("Error: " + e.getMessage()); } try { pr.waitFor(); } catch (InterruptedException e) { System.err.println("Error: " + e.getMessage()); } } } public static void runSelectedJob() throws IOException { // Transform start codons into Java regex-usable Params.ORF_start_codons = Params.ORF_start_codons.toUpperCase().replace(",","|"); // Selectively execute the program switch(Params.input_file_mode) { case 1: // Get a list of files from parameter file or command line. files = Params.input_genes_file.split(","); break; case 2: // Get a list of files from a list file in data directory. if (InputFile.OpenOkay(Params.input_files_dir, Params.input_genes_file)) { files = InputFile.getArray(); } break; case 3: // Get a list of files from a directory in this case. File d = new File(Params.input_files_dir); files = d.list(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".ffn"); }}); Arrays.sort(files); break; } } }