Example usage for java.lang String toLowerCase

List of usage examples for java.lang String toLowerCase

Introduction

In this page you can find the example usage for java.lang String toLowerCase.

Prototype

public String toLowerCase() 

Source Link

Document

Converts all of the characters in this String to lower case using the rules of the default locale.

Usage

From source file:GGbot.pkg0.Mainclass.java

public static void main(String[] args)
        throws InterruptedException, TwitterException, DbxException, IOException, Exception {

    String input = "";

    System.out.println("Welcomet to GGbot\nFor more information please take a look at the Read Me\n");

    System.out.println("- Twitter: PlayerName   (flex, returns the latest tweets from a player)\n"
            + "- Facebook: PlayerName  (flex, returns all the information available about a player)\n"
            + "- Note to self: Input   (notflex, create a new text document with your input, and put it in a drop box)\n"
            + "- Translate: Input      (notflex, detects the language of your input and translate it to english)\n"
            + "- Wiki                  (flex, returns the definition of league of legends from wikipedia\n"
            + "- !Players:             (returns the list of the players available in the library (only players from the teams: Cloud9, CLG, and TSM are available at the moment))\n"
            + "- !dropbox:             (returns the link to the dropbox)\n\n" + "Start to chat now!\n");
    while (!input.contains("bye")) {
        System.out.print("<User>");
        Scanner scanner = new Scanner(System.in);
        input = scanner.nextLine();//from ww  w  .  ja  va 2s  . c  o m

        String output = bot.Bot(input.toLowerCase().trim());
        System.out.println("<GGbot>" + WordUtils.wrap(output, 75));
    }

}

From source file:org.eclipse.swt.snippets.SnippetExplorer.java

/**
 * SnippetExplorer main method.//from w ww .j  a  v  a2 s .  c om
 *
 * @param args does not parse any arguments
 */
public static void main(String[] args) throws Exception {
    final String os = System.getProperty("os.name");
    multiDisplaySupport = (os != null && os.toLowerCase().contains("windows"));
    if (canRunCommand("java")) {
        javaCommand = "java";
    } else {
        final String javaHome = System.getProperty("java.home");
        if (javaHome != null) {
            final Path java = Paths.get(javaHome, "bin", "java");
            java.normalize();
            if (canRunCommand(java.toString())) {
                javaCommand = java.toString();
            }
        }
    }

    snippets = loadSnippets();
    snippets.sort((a, b) -> {
        int cmp = Integer.compare(a.snippetNum, b.snippetNum);
        if (cmp == 0) {
            cmp = a.snippetName.compareTo(b.snippetName);
        }
        return cmp;
    });

    new SnippetExplorer().open();
}

From source file:com.sforce.dataset.DatasetUtilMain.java

public static void main(String[] args) {

    printBanner();//w ww . ja v a  2  s .co m

    DatasetUtilParams params = new DatasetUtilParams();

    if (args.length > 0)
        params.server = false;

    System.out.println("");
    System.out.println("DatsetUtils called with {" + args.length + "} Params:");

    for (int i = 0; i < args.length; i++) {
        if ((i & 1) == 0) {
            System.out.print("{" + args[i] + "}");
        } else {
            if (i > 0 && args[i - 1].equalsIgnoreCase("--p"))
                System.out.println(":{*******}");
            else
                System.out.println(":{" + args[i] + "}");
        }

        if (i > 0 && args[i - 1].equalsIgnoreCase("--server")) {
            if (args[i] != null && args[i].trim().equalsIgnoreCase("false"))
                params.server = false;
            else if (args[i] != null && args[i].trim().equalsIgnoreCase("true"))
                params.server = true;
        }
    }
    System.out.println("");

    if (!printlneula(params.server)) {
        System.out.println(
                "You do not have permission to use this software. Please delete it from this computer");
        System.exit(-1);
    }

    String action = null;

    if (args.length >= 2) {
        for (int i = 1; i < args.length; i = i + 2) {
            if (args[i - 1].equalsIgnoreCase("--help") || args[i - 1].equalsIgnoreCase("-help")
                    || args[i - 1].equalsIgnoreCase("help")) {
                printUsage();
            } else if (args[i - 1].equalsIgnoreCase("--u")) {
                params.username = args[i];
            } else if (args[i - 1].equalsIgnoreCase("--p")) {
                params.password = args[i];
            } else if (args[i - 1].equalsIgnoreCase("--sessionId")) {
                params.sessionId = args[i];
            } else if (args[i - 1].equalsIgnoreCase("--token")) {
                params.token = args[i];
            } else if (args[i - 1].equalsIgnoreCase("--endpoint")) {
                params.endpoint = args[i];
            } else if (args[i - 1].equalsIgnoreCase("--action")) {
                action = args[i];
            } else if (args[i - 1].equalsIgnoreCase("--operation")) {
                if (args[i] != null) {
                    if (args[i].equalsIgnoreCase("overwrite")) {
                        params.Operation = args[i];
                    } else if (args[i].equalsIgnoreCase("upsert")) {
                        params.Operation = args[i];
                    } else if (args[i].equalsIgnoreCase("append")) {
                        params.Operation = args[i];
                    } else if (args[i].equalsIgnoreCase("delete")) {
                        params.Operation = args[i];
                    } else {
                        System.out.println("Invalid Operation {" + args[i]
                                + "} Must be Overwrite or Upsert or Append or Delete");
                        System.exit(-1);
                    }
                }
            } else if (args[i - 1].equalsIgnoreCase("--debug")) {
                params.debug = true;
                DatasetUtilConstants.debug = true;
            } else if (args[i - 1].equalsIgnoreCase("--ext")) {
                DatasetUtilConstants.ext = true;
            } else if (args[i - 1].equalsIgnoreCase("--inputFile")) {
                String tmp = args[i];
                if (tmp != null) {
                    File tempFile = new File(tmp);
                    if (tempFile.exists()) {
                        params.inputFile = tempFile.toString();
                    } else {
                        System.out.println("File {" + args[i] + "} does not exist");
                        System.exit(-1);
                    }
                }
            } else if (args[i - 1].equalsIgnoreCase("--dataset")) {
                params.dataset = args[i];
            } else if (args[i - 1].equalsIgnoreCase("--datasetLabel")) {
                params.datasetLabel = args[i];
            } else if (args[i - 1].equalsIgnoreCase("--app")) {
                params.app = args[i];
            } else if (args[i - 1].equalsIgnoreCase("--useBulkAPI")) {
                if (args[i] != null && args[i].trim().equalsIgnoreCase("true"))
                    params.useBulkAPI = true;
            } else if (args[i - 1].equalsIgnoreCase("--uploadFormat")) {
                if (args[i] != null && args[i].trim().equalsIgnoreCase("csv"))
                    params.uploadFormat = "csv";
                else if (args[i] != null && args[i].trim().equalsIgnoreCase("binary"))
                    params.uploadFormat = "binary";
            } else if (args[i - 1].equalsIgnoreCase("--rowLimit")) {
                if (args[i] != null && !args[i].trim().isEmpty())
                    params.rowLimit = (new BigDecimal(args[i].trim())).intValue();
            } else if (args[i - 1].equalsIgnoreCase("--rootObject")) {
                params.rootObject = args[i];
            } else if (args[i - 1].equalsIgnoreCase("--fileEncoding")) {
                params.fileEncoding = args[i];
            } else if (args[i - 1].equalsIgnoreCase("--server")) {
                if (args[i] != null && args[i].trim().equalsIgnoreCase("true"))
                    params.server = true;
                else if (args[i] != null && args[i].trim().equalsIgnoreCase("false"))
                    params.server = false;
            } else if (args[i - 1].equalsIgnoreCase("--codingErrorAction")) {
                if (args[i] != null) {
                    if (args[i].equalsIgnoreCase("IGNORE")) {
                        params.codingErrorAction = CodingErrorAction.IGNORE;
                    } else if (args[i].equalsIgnoreCase("REPORT")) {
                        params.codingErrorAction = CodingErrorAction.REPORT;
                    } else if (args[i].equalsIgnoreCase("REPLACE")) {
                        params.codingErrorAction = CodingErrorAction.REPLACE;
                    }
                }
            } else {
                printUsage();
                System.out.println("\nERROR: Invalid argument: " + args[i - 1]);
                System.exit(-1);
            }
        } //end for

        if (params.username != null) {
            if (params.endpoint == null || params.endpoint.isEmpty()) {
                params.endpoint = DatasetUtilConstants.defaultEndpoint;
            }
        }
    }

    if (params.server) {
        System.out.println();
        System.out.println("\n*******************************************************************************");
        try {
            DatasetUtilServer datasetUtilServer = new DatasetUtilServer();
            datasetUtilServer.init(args, true);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("Server ended, exiting JVM.....");
        System.out.println("*******************************************************************************\n");
        System.out.println("QUITAPP");
        System.exit(0);
    }

    if (params.sessionId == null) {
        if (params.username == null || params.username.trim().isEmpty()) {
            params.username = getInputFromUser("Enter salesforce username: ", true, false);
        }

        if (params.username.equals("-1")) {
            params.sessionId = getInputFromUser("Enter salesforce sessionId: ", true, false);
            params.username = null;
            params.password = null;
        } else {
            if (params.password == null || params.password.trim().isEmpty()) {
                params.password = getInputFromUser("Enter salesforce password: ", true, true);
            }
        }
    }

    if (params.sessionId != null && !params.sessionId.isEmpty()) {
        while (params.endpoint == null || params.endpoint.trim().isEmpty()) {
            params.endpoint = getInputFromUser("Enter salesforce instance url: ", true, false);
            if (params.endpoint == null || params.endpoint.trim().isEmpty())
                System.out.println("\nERROR: endpoint must be specified when sessionId is specified");
        }

        while (params.endpoint.toLowerCase().contains("login.salesforce.com")
                || params.endpoint.toLowerCase().contains("test.salesforce.com")
                || params.endpoint.toLowerCase().contains("test")
                || params.endpoint.toLowerCase().contains("prod")
                || params.endpoint.toLowerCase().contains("sandbox")) {
            System.out.println("\nERROR: endpoint must be the actual serviceURL and not the login url");
            params.endpoint = getInputFromUser("Enter salesforce instance url: ", true, false);
        }
    } else {
        if (params.endpoint == null || params.endpoint.isEmpty()) {
            params.endpoint = getInputFromUser("Enter salesforce instance url (default=prod): ", false, false);
            if (params.endpoint == null || params.endpoint.trim().isEmpty()) {
                params.endpoint = DatasetUtilConstants.defaultEndpoint;
            }
        }
    }

    try {
        if (params.endpoint.equalsIgnoreCase("PROD") || params.endpoint.equalsIgnoreCase("PRODUCTION")) {
            params.endpoint = DatasetUtilConstants.defaultEndpoint;
        } else if (params.endpoint.equalsIgnoreCase("TEST") || params.endpoint.equalsIgnoreCase("SANDBOX")) {
            params.endpoint = DatasetUtilConstants.defaultEndpoint.replace("login", "test");
        }

        URL uri = new URL(params.endpoint);
        String protocol = uri.getProtocol();
        String host = uri.getHost();
        if (protocol == null || !protocol.equalsIgnoreCase("https")) {
            if (host == null || !(host.toLowerCase().endsWith("internal.salesforce.com")
                    || host.toLowerCase().endsWith("localhost"))) {
                System.out.println("\nERROR: Invalid endpoint. UNSUPPORTED_CLIENT: HTTPS Required in endpoint");
                System.exit(-1);
            }
        }

        if (uri.getPath() == null || uri.getPath().isEmpty() || uri.getPath().equals("/")) {
            uri = new URL(uri.getProtocol(), uri.getHost(), uri.getPort(),
                    DatasetUtilConstants.defaultSoapEndPointPath);
        }
        params.endpoint = uri.toString();
    } catch (MalformedURLException e) {
        e.printStackTrace();
        System.out.println("\nERROR: endpoint is not a valid URL");
        System.exit(-1);
    }

    PartnerConnection partnerConnection = null;
    if (params.username != null || params.sessionId != null) {
        try {
            partnerConnection = DatasetUtils.login(0, params.username, params.password, params.token,
                    params.endpoint, params.sessionId, params.debug);
        } catch (ConnectionException e) {
            e.printStackTrace();
            System.exit(-1);
        } catch (MalformedURLException e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    if (args.length == 0 || action == null) {
        //         System.out.println("\n*******************************************************************************");               
        ////         FileListenerUtil.startAllListener(partnerConnection);
        //         try {
        //            Thread.sleep(1000);
        //         } catch (InterruptedException e) {
        //         }
        //         System.out.println("*******************************************************************************\n");   
        //         System.out.println();         

        //         System.out.println("\n*******************************************************************************");               
        //           try {
        //              DatasetUtilServer datasetUtilServer = new DatasetUtilServer();
        //            datasetUtilServer.init(args, false);
        //         } catch (Exception e) {
        //            e.printStackTrace();
        //         }
        //         System.out.println("*******************************************************************************\n");   
        //         System.out.println();         

        while (true) {
            action = getActionFromUser();
            if (action == null || action.isEmpty()) {
                System.exit(-1);
            }
            params = new DatasetUtilParams();
            getRequiredParams(action, partnerConnection, params);
            @SuppressWarnings("unused")
            boolean status = doAction(action, partnerConnection, params);
            //            if(status)
            //            {
            //               if(action.equalsIgnoreCase("load") && params.debug)
            //                  createListener(partnerConnection, params);
            //            }
        }
    } else {
        doAction(action, partnerConnection, params);
    }

}

From source file:DIA_Umpire_Quant.DIA_Umpire_Quant.java

/**
 * @param args the command line arguments
 *///  w  w  w.  j  a v a  2  s  .  c  o m
public static void main(String[] args) throws FileNotFoundException, IOException, Exception {
    System.out.println(
            "=================================================================================================");
    System.out.println("DIA-Umpire quantitation with targeted re-extraction analysis (version: "
            + UmpireInfo.GetInstance().Version + ")");
    if (args.length != 1) {
        System.out.println(
                "command format error, it should be like: java -jar -Xmx10G DIA_Umpire_Quant.jar diaumpire_quant.params");
        return;
    }
    try {
        ConsoleLogger.SetConsoleLogger(Level.INFO);
        ConsoleLogger.SetFileLogger(Level.DEBUG, FilenameUtils.getFullPath(args[0]) + "diaumpire_quant.log");
    } catch (Exception e) {
    }

    try {

        Logger.getRootLogger().info("Version: " + UmpireInfo.GetInstance().Version);
        Logger.getRootLogger().info("Parameter file:" + args[0]);

        BufferedReader reader = new BufferedReader(new FileReader(args[0]));
        String line = "";
        String WorkFolder = "";
        int NoCPUs = 2;

        String UserMod = "";
        String Combined_Prot = "";
        String InternalLibID = "";
        String ExternalLibPath = "";
        String ExternalLibDecoyTag = "DECOY";
        boolean DefaultProtFiltering = true;
        boolean DataSetLevelPepFDR = false;
        float ProbThreshold = 0.99f;
        float ExtProbThreshold = 0.99f;
        float Freq = 0f;
        int TopNPep = 6;
        int TopNFrag = 6;
        float MinFragMz = 200f;
        String FilterWeight = "GW";
        float MinWeight = 0.9f;
        float RTWindow_Int = -1f;
        float RTWindow_Ext = -1f;

        TandemParam tandemPara = new TandemParam(DBSearchParam.SearchInstrumentType.TOF5600);
        HashMap<String, File> AssignFiles = new HashMap<>();
        boolean InternalLibSearch = false;
        boolean ExternalLibSearch = false;

        boolean ExportSaint = false;
        boolean SAINT_MS1 = false;
        boolean SAINT_MS2 = true;

        HashMap<String, String[]> BaitList = new HashMap<>();
        HashMap<String, String> BaitName = new HashMap<>();
        HashMap<String, String[]> ControlList = new HashMap<>();
        HashMap<String, String> ControlName = new HashMap<>();

        //<editor-fold defaultstate="collapsed" desc="Reading parameter file">
        while ((line = reader.readLine()) != null) {
            line = line.trim();
            Logger.getRootLogger().info(line);
            if (!"".equals(line) && !line.startsWith("#")) {
                //System.out.println(line);
                if (line.equals("==File list begin")) {
                    do {
                        line = reader.readLine();
                        line = line.trim();
                        if (line.equals("==File list end")) {
                            continue;
                        } else if (!"".equals(line)) {
                            File newfile = new File(line);
                            if (newfile.exists()) {
                                AssignFiles.put(newfile.getAbsolutePath(), newfile);
                            } else {
                                Logger.getRootLogger().info("File: " + newfile + " does not exist.");
                            }
                        }
                    } while (!line.equals("==File list end"));
                }
                if (line.split("=").length < 2) {
                    continue;
                }
                String type = line.split("=")[0].trim();
                String value = line.split("=")[1].trim();
                switch (type) {
                case "TargetedExtraction": {
                    InternalLibSearch = Boolean.parseBoolean(value);
                    break;
                }
                case "InternalLibSearch": {
                    InternalLibSearch = Boolean.parseBoolean(value);
                    break;
                }
                case "ExternalLibSearch": {
                    ExternalLibSearch = Boolean.parseBoolean(value);
                    break;
                }

                case "Path": {
                    WorkFolder = value;
                    break;
                }
                case "path": {
                    WorkFolder = value;
                    break;
                }
                case "Thread": {
                    NoCPUs = Integer.parseInt(value);
                    break;
                }
                case "Fasta": {
                    tandemPara.FastaPath = value;
                    break;
                }
                case "Combined_Prot": {
                    Combined_Prot = value;
                    break;
                }
                case "DefaultProtFiltering": {
                    DefaultProtFiltering = Boolean.parseBoolean(value);
                    break;
                }
                case "DecoyPrefix": {
                    if (!"".equals(value)) {
                        tandemPara.DecoyPrefix = value;
                    }
                    break;
                }
                case "UserMod": {
                    UserMod = value;
                    break;
                }
                case "ProteinFDR": {
                    tandemPara.ProtFDR = Float.parseFloat(value);
                    break;
                }
                case "PeptideFDR": {
                    tandemPara.PepFDR = Float.parseFloat(value);
                    break;
                }
                case "DataSetLevelPepFDR": {
                    DataSetLevelPepFDR = Boolean.parseBoolean(value);
                    break;
                }
                case "InternalLibID": {
                    InternalLibID = value;
                    break;
                }
                case "ExternalLibPath": {
                    ExternalLibPath = value;
                    break;
                }
                case "ExtProbThreshold": {
                    ExtProbThreshold = Float.parseFloat(value);
                    break;
                }
                case "RTWindow_Int": {
                    RTWindow_Int = Float.parseFloat(value);
                    break;
                }
                case "RTWindow_Ext": {
                    RTWindow_Ext = Float.parseFloat(value);
                    break;
                }
                case "ExternalLibDecoyTag": {
                    ExternalLibDecoyTag = value;
                    if (ExternalLibDecoyTag.endsWith("_")) {
                        ExternalLibDecoyTag = ExternalLibDecoyTag.substring(0,
                                ExternalLibDecoyTag.length() - 1);
                    }
                    break;
                }
                case "ProbThreshold": {
                    ProbThreshold = Float.parseFloat(value);
                    break;
                }
                case "ReSearchProb": {
                    //ReSearchProb = Float.parseFloat(value);
                    break;
                }
                case "FilterWeight": {
                    FilterWeight = value;
                    break;
                }
                case "MinWeight": {
                    MinWeight = Float.parseFloat(value);
                    break;
                }
                case "TopNFrag": {
                    TopNFrag = Integer.parseInt(value);
                    break;
                }
                case "TopNPep": {
                    TopNPep = Integer.parseInt(value);
                    break;
                }
                case "Freq": {
                    Freq = Float.parseFloat(value);
                    break;
                }
                case "MinFragMz": {
                    MinFragMz = Float.parseFloat(value);
                    break;
                }

                //<editor-fold defaultstate="collapsed" desc="SaintOutput">
                case "ExportSaintInput": {
                    ExportSaint = Boolean.parseBoolean(value);
                    break;
                }
                case "QuantitationType": {
                    switch (value) {
                    case "MS1": {
                        SAINT_MS1 = true;
                        SAINT_MS2 = false;
                        break;
                    }
                    case "MS2": {
                        SAINT_MS1 = false;
                        SAINT_MS2 = true;
                        break;
                    }
                    case "BOTH": {
                        SAINT_MS1 = true;
                        SAINT_MS2 = true;
                        break;
                    }
                    }
                    break;
                }
                //                    case "BaitInputFile": {
                //                        SaintBaitFile = value;
                //                        break;
                //                    }
                //                    case "PreyInputFile": {
                //                        SaintPreyFile = value;
                //                        break;
                //                    }
                //                    case "InterationInputFile": {
                //                        SaintInteractionFile = value;
                //                        break;
                //                    }
                default: {
                    if (type.startsWith("BaitName_")) {
                        BaitName.put(type.substring(9), value);
                    }
                    if (type.startsWith("BaitFile_")) {
                        BaitList.put(type.substring(9), value.split("\t"));
                    }
                    if (type.startsWith("ControlName_")) {
                        ControlName.put(type.substring(12), value);
                    }
                    if (type.startsWith("ControlFile_")) {
                        ControlList.put(type.substring(12), value.split("\t"));
                    }
                    break;
                }
                //</editor-fold>                    
                }
            }
        }
        //</editor-fold>

        //Initialize PTM manager using compomics library
        PTMManager.GetInstance();
        if (!UserMod.equals("")) {
            PTMManager.GetInstance().ImportUserMod(UserMod);
        }

        //Check if the fasta file can be found
        if (!new File(tandemPara.FastaPath).exists()) {
            Logger.getRootLogger().info("Fasta file :" + tandemPara.FastaPath
                    + " cannot be found, the process will be terminated, please check.");
            System.exit(1);
        }

        //Check if the prot.xml file can be found
        if (!new File(Combined_Prot).exists()) {
            Logger.getRootLogger().info("ProtXML file: " + Combined_Prot
                    + " cannot be found, the export protein summary table will be empty.");
        }

        LCMSID protID = null;

        //Parse prot.xml and generate protein master list given an FDR 
        if (Combined_Prot != null && !Combined_Prot.equals("")) {
            protID = LCMSID.ReadLCMSIDSerialization(Combined_Prot);
            if (!"".equals(Combined_Prot) && protID == null) {
                protID = new LCMSID(Combined_Prot, tandemPara.DecoyPrefix, tandemPara.FastaPath);
                ProtXMLParser protxmlparser = new ProtXMLParser(protID, Combined_Prot, 0f);
                //Use DIA-Umpire default protein FDR calculation
                if (DefaultProtFiltering) {
                    protID.RemoveLowLocalPWProtein(0.8f);
                    protID.RemoveLowMaxIniProbProtein(0.9f);
                    protID.FilterByProteinDecoyFDRUsingMaxIniProb(tandemPara.DecoyPrefix, tandemPara.ProtFDR);
                } //Get protein FDR calculation without other filtering
                else {
                    protID.FilterByProteinDecoyFDRUsingLocalPW(tandemPara.DecoyPrefix, tandemPara.ProtFDR);
                }
                protID.LoadSequence();
                protID.WriteLCMSIDSerialization(Combined_Prot);
            }
            Logger.getRootLogger().info("Protein No.:" + protID.ProteinList.size());
        }
        HashMap<String, HashMap<String, FragmentPeak>> IDSummaryFragments = new HashMap<>();

        //Generate DIA file list
        ArrayList<DIAPack> FileList = new ArrayList<>();

        File folder = new File(WorkFolder);
        if (!folder.exists()) {
            Logger.getRootLogger().info("The path : " + WorkFolder + " cannot be found.");
            System.exit(1);
        }
        for (final File fileEntry : folder.listFiles()) {
            if (fileEntry.isFile()
                    && (fileEntry.getAbsolutePath().toLowerCase().endsWith(".mzxml")
                            | fileEntry.getAbsolutePath().toLowerCase().endsWith(".mzml"))
                    && !fileEntry.getAbsolutePath().toLowerCase().endsWith("q1.mzxml")
                    && !fileEntry.getAbsolutePath().toLowerCase().endsWith("q2.mzxml")
                    && !fileEntry.getAbsolutePath().toLowerCase().endsWith("q3.mzxml")) {
                AssignFiles.put(fileEntry.getAbsolutePath(), fileEntry);
            }
            if (fileEntry.isDirectory()) {
                for (final File fileEntry2 : fileEntry.listFiles()) {
                    if (fileEntry2.isFile()
                            && (fileEntry2.getAbsolutePath().toLowerCase().endsWith(".mzxml")
                                    | fileEntry2.getAbsolutePath().toLowerCase().endsWith(".mzml"))
                            && !fileEntry2.getAbsolutePath().toLowerCase().endsWith("q1.mzxml")
                            && !fileEntry2.getAbsolutePath().toLowerCase().endsWith("q2.mzxml")
                            && !fileEntry2.getAbsolutePath().toLowerCase().endsWith("q3.mzxml")) {
                        AssignFiles.put(fileEntry2.getAbsolutePath(), fileEntry2);
                    }
                }
            }
        }

        Logger.getRootLogger().info("No. of files assigned :" + AssignFiles.size());
        for (File fileEntry : AssignFiles.values()) {
            Logger.getRootLogger().info(fileEntry.getAbsolutePath());
            String mzXMLFile = fileEntry.getAbsolutePath();
            if (mzXMLFile.toLowerCase().endsWith(".mzxml") | mzXMLFile.toLowerCase().endsWith(".mzml")) {
                DIAPack DiaFile = new DIAPack(mzXMLFile, NoCPUs);
                FileList.add(DiaFile);
                HashMap<String, FragmentPeak> FragMap = new HashMap<>();
                IDSummaryFragments.put(FilenameUtils.getBaseName(mzXMLFile), FragMap);
                Logger.getRootLogger().info(
                        "=================================================================================================");
                Logger.getRootLogger().info("Processing " + mzXMLFile);
                if (!DiaFile.LoadDIASetting()) {
                    Logger.getRootLogger().info("Loading DIA setting failed, job is incomplete");
                    System.exit(1);
                }
                if (!DiaFile.LoadParams()) {
                    Logger.getRootLogger().info("Loading parameters failed, job is incomplete");
                    System.exit(1);
                }
            }
        }

        LCMSID combinePepID = null;
        if (DataSetLevelPepFDR) {
            combinePepID = LCMSID.ReadLCMSIDSerialization(WorkFolder + "combinePepID.SerFS");
            if (combinePepID == null) {
                FDR_DataSetLevel fdr = new FDR_DataSetLevel();
                fdr.GeneratePepIonList(FileList, tandemPara, WorkFolder + "combinePepID.SerFS");
                combinePepID = fdr.combineID;
                combinePepID.WriteLCMSIDSerialization(WorkFolder + "combinePepID.SerFS");
            }
        }

        //process each DIA file for quantification based on untargeted identifications
        for (DIAPack DiaFile : FileList) {
            long time = System.currentTimeMillis();
            Logger.getRootLogger().info("Loading identification results " + DiaFile.Filename + "....");

            //If the LCMSID serialization is found
            if (!DiaFile.ReadSerializedLCMSID()) {
                DiaFile.ParsePepXML(tandemPara, combinePepID);
                DiaFile.BuildStructure();
                if (!DiaFile.MS1FeatureMap.ReadPeakCluster()) {
                    Logger.getRootLogger().info("Loading peak and structure failed, job is incomplete");
                    System.exit(1);
                }
                DiaFile.MS1FeatureMap.ClearMonoisotopicPeakOfCluster();
                //Generate mapping between index of precursor feature and pseudo MS/MS scan index 
                DiaFile.GenerateClusterScanNomapping();
                //Doing quantification
                DiaFile.AssignQuant();
                DiaFile.ClearStructure();
            }
            DiaFile.IDsummary.ReduceMemoryUsage();
            time = System.currentTimeMillis() - time;
            Logger.getRootLogger().info(DiaFile.Filename + " processed time:"
                    + String.format("%d hour, %d min, %d sec", TimeUnit.MILLISECONDS.toHours(time),
                            TimeUnit.MILLISECONDS.toMinutes(time)
                                    - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(time)),
                            TimeUnit.MILLISECONDS.toSeconds(time)
                                    - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(time))));
        }

        //<editor-fold defaultstate="collapsed" desc="Targete re-extraction using internal library">            
        Logger.getRootLogger().info(
                "=================================================================================================");
        if (InternalLibSearch && FileList.size() > 1) {
            Logger.getRootLogger().info("Module C: Targeted extraction using internal library");

            FragmentLibManager libManager = FragmentLibManager.ReadFragmentLibSerialization(WorkFolder,
                    InternalLibID);
            if (libManager == null) {
                Logger.getRootLogger().info("Building internal spectral library");
                libManager = new FragmentLibManager(InternalLibID);
                ArrayList<LCMSID> LCMSIDList = new ArrayList<>();
                for (DIAPack dia : FileList) {
                    LCMSIDList.add(dia.IDsummary);
                }
                libManager.ImportFragLibTopFrag(LCMSIDList, Freq, TopNFrag);
                libManager.WriteFragmentLibSerialization(WorkFolder);
            }
            libManager.ReduceMemoryUsage();

            Logger.getRootLogger()
                    .info("Building retention time prediction model and generate candidate peptide list");
            for (int i = 0; i < FileList.size(); i++) {
                FileList.get(i).IDsummary.ClearMappedPep();
            }
            for (int i = 0; i < FileList.size(); i++) {
                for (int j = i + 1; j < FileList.size(); j++) {
                    RTAlignedPepIonMapping alignment = new RTAlignedPepIonMapping(WorkFolder,
                            FileList.get(i).GetParameter(), FileList.get(i).IDsummary,
                            FileList.get(j).IDsummary);
                    alignment.GenerateModel();
                    alignment.GenerateMappedPepIon();
                }
                FileList.get(i).ExportID();
                FileList.get(i).IDsummary = null;
            }

            Logger.getRootLogger().info("Targeted matching........");
            for (DIAPack diafile : FileList) {
                if (diafile.IDsummary == null) {
                    diafile.ReadSerializedLCMSID();
                }
                if (!diafile.IDsummary.GetMappedPepIonList().isEmpty()) {
                    diafile.UseMappedIon = true;
                    diafile.FilterMappedIonByProb = false;
                    diafile.BuildStructure();
                    diafile.MS1FeatureMap.ReadPeakCluster();
                    diafile.MS1FeatureMap.ClearMonoisotopicPeakOfCluster();
                    diafile.GenerateMassCalibrationRTMap();
                    diafile.TargetedExtractionQuant(false, libManager, 1.1f, RTWindow_Int);
                    diafile.MS1FeatureMap.ClearAllPeaks();
                    diafile.IDsummary.ReduceMemoryUsage();
                    diafile.IDsummary.RemoveLowProbMappedIon(ProbThreshold);
                    diafile.ExportID();
                    Logger.getRootLogger().info("Peptide ions: " + diafile.IDsummary.GetPepIonList().size()
                            + " Mapped ions: " + diafile.IDsummary.GetMappedPepIonList().size());
                    diafile.ClearStructure();
                }
                diafile.IDsummary = null;
                System.gc();
            }
            Logger.getRootLogger().info(
                    "=================================================================================================");
        }
        //</editor-fold>

        //<editor-fold defaultstate="collapsed" desc="Targeted re-extraction using external library">
        //External library search
        if (ExternalLibSearch) {
            Logger.getRootLogger().info("Module C: Targeted extraction using external library");

            //Read exteranl library
            FragmentLibManager ExlibManager = FragmentLibManager.ReadFragmentLibSerialization(WorkFolder,
                    FilenameUtils.getBaseName(ExternalLibPath));
            if (ExlibManager == null) {
                ExlibManager = new FragmentLibManager(FilenameUtils.getBaseName(ExternalLibPath));

                //Import traML file
                ExlibManager.ImportFragLibByTraML(ExternalLibPath, ExternalLibDecoyTag);
                //Check if there are decoy spectra
                ExlibManager.CheckDecoys();
                //ExlibManager.ImportFragLibBySPTXT(ExternalLibPath);
                ExlibManager.WriteFragmentLibSerialization(WorkFolder);
            }
            Logger.getRootLogger()
                    .info("No. of peptide ions in external lib:" + ExlibManager.PeptideFragmentLib.size());
            for (DIAPack diafile : FileList) {
                if (diafile.IDsummary == null) {
                    diafile.ReadSerializedLCMSID();
                }
                //Generate RT mapping
                RTMappingExtLib RTmap = new RTMappingExtLib(diafile.IDsummary, ExlibManager,
                        diafile.GetParameter());
                RTmap.GenerateModel();
                RTmap.GenerateMappedPepIon();

                diafile.BuildStructure();
                diafile.MS1FeatureMap.ReadPeakCluster();
                diafile.GenerateMassCalibrationRTMap();
                //Perform targeted re-extraction
                diafile.TargetedExtractionQuant(false, ExlibManager, ProbThreshold, RTWindow_Ext);
                diafile.MS1FeatureMap.ClearAllPeaks();
                diafile.IDsummary.ReduceMemoryUsage();
                //Remove target IDs below the defined probability threshold
                diafile.IDsummary.RemoveLowProbMappedIon(ExtProbThreshold);
                diafile.ExportID();
                diafile.ClearStructure();
                Logger.getRootLogger().info("Peptide ions: " + diafile.IDsummary.GetPepIonList().size()
                        + " Mapped ions: " + diafile.IDsummary.GetMappedPepIonList().size());
            }
        }
        //</editor-fold>

        //<editor-fold defaultstate="collapsed" desc="Peptide and fragment selection">
        Logger.getRootLogger().info("Peptide and fragment selection across the whole dataset");
        ArrayList<LCMSID> SummaryList = new ArrayList<>();
        for (DIAPack diafile : FileList) {
            if (diafile.IDsummary == null) {
                diafile.ReadSerializedLCMSID();
                diafile.IDsummary.ClearAssignPeakCluster();
                //diafile.IDsummary.ClearPSMs();                    
            }
            if (protID != null) {
                //Generate protein list according to mapping of peptide ions for each DIA file to the master protein list
                diafile.IDsummary.GenerateProteinByRefIDByPepSeq(protID, true);
                diafile.IDsummary.ReMapProPep();
            }
            if ("GW".equals(FilterWeight)) {
                diafile.IDsummary.SetFilterByGroupWeight();
            } else if ("PepW".equals(FilterWeight)) {
                diafile.IDsummary.SetFilterByWeight();
            }
            SummaryList.add(diafile.IDsummary);
        }
        FragmentSelection fragselection = new FragmentSelection(SummaryList);
        fragselection.freqPercent = Freq;
        fragselection.MinFragMZ = MinFragMz;
        fragselection.GeneratePepFragScoreMap();
        fragselection.GenerateTopFragMap(TopNFrag);
        fragselection.GenerateProtPepScoreMap(MinWeight);
        fragselection.GenerateTopPepMap(TopNPep);
        //</editor-fold>

        //<editor-fold defaultstate="collapsed" desc="Writing general reports">                 
        ExportTable export = new ExportTable(WorkFolder, SummaryList, IDSummaryFragments, protID,
                fragselection);
        export.Export(TopNPep, TopNFrag, Freq);
        //</editor-fold>

        //<editor-fold defaultstate="collapsed" desc="//<editor-fold defaultstate="collapsed" desc="Generate SAINT input files">
        if (ExportSaint && protID != null) {
            HashMap<String, DIAPack> Filemap = new HashMap<>();
            for (DIAPack DIAfile : FileList) {
                Filemap.put(DIAfile.GetBaseName(), DIAfile);
            }

            FileWriter baitfile = new FileWriter(WorkFolder + "SAINT_Bait_" + DateTimeTag.GetTag() + ".txt");
            FileWriter preyfile = new FileWriter(WorkFolder + "SAINT_Prey_" + DateTimeTag.GetTag() + ".txt");
            FileWriter interactionfileMS1 = null;
            FileWriter interactionfileMS2 = null;
            if (SAINT_MS1) {
                interactionfileMS1 = new FileWriter(
                        WorkFolder + "SAINT_Interaction_MS1_" + DateTimeTag.GetTag() + ".txt");
            }
            if (SAINT_MS2) {
                interactionfileMS2 = new FileWriter(
                        WorkFolder + "SAINT_Interaction_MS2_" + DateTimeTag.GetTag() + ".txt");
            }
            HashMap<String, String> PreyID = new HashMap<>();

            for (String samplekey : ControlName.keySet()) {
                String name = ControlName.get(samplekey);
                for (String file : ControlList.get(samplekey)) {
                    baitfile.write(FilenameUtils.getBaseName(file) + "\t" + name + "\t" + "C\n");
                    LCMSID IDsummary = Filemap.get(FilenameUtils.getBaseName(file)).IDsummary;
                    if (SAINT_MS1) {
                        SaintOutput(protID, IDsummary, fragselection, interactionfileMS1, file, name, PreyID,
                                1);
                    }
                    if (SAINT_MS2) {
                        SaintOutput(protID, IDsummary, fragselection, interactionfileMS2, file, name, PreyID,
                                2);
                    }
                }
            }
            for (String samplekey : BaitName.keySet()) {
                String name = BaitName.get(samplekey);
                for (String file : BaitList.get(samplekey)) {
                    baitfile.write(FilenameUtils.getBaseName(file) + "\t" + name + "\t" + "T\n");
                    LCMSID IDsummary = Filemap.get(FilenameUtils.getBaseName(file)).IDsummary;
                    if (SAINT_MS1) {
                        SaintOutput(protID, IDsummary, fragselection, interactionfileMS1, file, name, PreyID,
                                1);
                    }
                    if (SAINT_MS2) {
                        SaintOutput(protID, IDsummary, fragselection, interactionfileMS2, file, name, PreyID,
                                2);
                    }
                }
            }
            baitfile.close();
            if (SAINT_MS1) {
                interactionfileMS1.close();
            }
            if (SAINT_MS2) {
                interactionfileMS2.close();
            }
            for (String AccNo : PreyID.keySet()) {
                preyfile.write(AccNo + "\t" + PreyID.get(AccNo) + "\n");
            }
            preyfile.close();
        }

        //</editor-fold>

        Logger.getRootLogger().info("Job done");
        Logger.getRootLogger().info(
                "=================================================================================================");

    } catch (Exception e) {
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(e));
        throw e;
    }
}

From source file:jetbrains.exodus.env.Reflect.java

public static void main(@NotNull final String[] args) throws Exception {
    if (args.length == 0) {
        printUsage();/*from w  ww.jav  a 2  s .c  om*/
        return;
    }
    String envPath = null;
    String envPath2 = null;
    boolean hasOptions = false;
    boolean gatherLogStats = false;
    boolean validateRoots = false;
    boolean traverse = false;
    boolean copy = false;
    boolean traverseAll = false;
    boolean utilizationInfo = false;
    final Set<String> files2Clean = new LinkedHashSet<>();
    for (final String arg : args) {
        if (arg.startsWith("-")) {
            hasOptions = true;
            if ("-ls".equalsIgnoreCase(arg)) {
                gatherLogStats = true;
            } else if ("-r".equalsIgnoreCase(arg)) {
                validateRoots = true;
            } else if ("-t".equalsIgnoreCase(arg)) {
                traverse = true;
            } else if ("-c".equalsIgnoreCase(arg)) {
                copy = true;
            } else if ("-ta".equalsIgnoreCase(arg)) {
                traverseAll = true;
            } else if ("-u".equalsIgnoreCase(arg)) {
                utilizationInfo = true;
            } else if (arg.toLowerCase().startsWith("-cl")) {
                files2Clean.add(arg.substring(2));
            } else {
                printUsage();
                return;
            }
        } else {
            if (envPath == null) {
                envPath = arg;
            } else {
                envPath2 = arg;
                break;
            }
        }
    }
    if (envPath == null || (copy && envPath2 == null)) {
        printUsage();
        return;
    }
    System.out.println("Started investigation of " + envPath);
    final Reflect reflect = new Reflect(new File(envPath));
    if (files2Clean.size() > 0) {
        for (final String file : files2Clean) {
            reflect.cleanFile(file);
        }
    }
    if (!hasOptions) {
        reflect.gatherLogStats();
        reflect.traverse();
    } else {
        List<DatabaseRoot> roots = null;
        if (validateRoots || traverseAll) {
            roots = reflect.roots();
        }
        if (gatherLogStats) {
            reflect.gatherLogStats();
        }
        if (traverse) {
            reflect.traverse();
        }
        if (copy) {
            reflect.copy(new File(envPath2));
        }
        if (utilizationInfo) {
            reflect.spaceInfoFromUtilization();
        }
        if (traverseAll) {
            reflect.traverseAll(roots);
        }
    }
}

From source file:de.mendelson.comm.as2.AS2.java

/**Method to start the server on from the command line*/
public static void main(String args[]) {

    // TODO remove
    cleanup();/* w ww  . j  ava  2  s.  c o  m*/

    String language = null;
    boolean startHTTP = true;
    boolean allowAllClients = false;
    int optind;
    for (optind = 0; optind < args.length; optind++) {
        if (args[optind].toLowerCase().equals("-lang")) {
            language = args[++optind];
        } else if (args[optind].toLowerCase().equals("-nohttpserver")) {
            startHTTP = false;
        } else if (args[optind].toLowerCase().equals("-allowallclients")) {
            allowAllClients = true;
        } else if (args[optind].toLowerCase().equals("-?")) {
            AS2.printUsage();
            System.exit(1);
        } else if (args[optind].toLowerCase().equals("-h")) {
            AS2.printUsage();
            System.exit(1);
        } else if (args[optind].toLowerCase().equals("-help")) {
            AS2.printUsage();
            System.exit(1);
        }
    }
    //load language from preferences
    if (language == null) {
        PreferencesAS2 preferences = new PreferencesAS2();
        language = preferences.get(PreferencesAS2.LANGUAGE);
    }
    if (language != null) {
        if (language.toLowerCase().equals("en")) {
            Locale.setDefault(Locale.ENGLISH);
        } else if (language.toLowerCase().equals("de")) {
            Locale.setDefault(Locale.GERMAN);
        } else if (language.toLowerCase().equals("fr")) {
            Locale.setDefault(Locale.FRENCH);
        } else {
            AS2.printUsage();
            System.out.println();
            System.out.println("Language " + language + " is not supported.");
            System.exit(1);
        }
    }
    Splash splash = new Splash("/de/mendelson/comm/as2/client/Splash.jpg");
    AffineTransform transform = new AffineTransform();
    splash.setTextAntiAliasing(false);
    transform.setToScale(1.0, 1.0);
    splash.addDisplayString(new Font("Verdana", Font.BOLD, 11), 7, 262, AS2ServerVersion.getFullProductName(),
            new Color(0x65, 0xB1, 0x80), transform);
    splash.setVisible(true);
    splash.toFront();
    //start server
    try {
        //register the database drivers for the VM
        Class.forName("org.hsqldb.jdbcDriver");
        //initialize the security provider
        BCCryptoHelper helper = new BCCryptoHelper();
        helper.initialize();
        AS2Server as2Server = new AS2Server(startHTTP, allowAllClients);
        AS2Agent agent = new AS2Agent(as2Server);
    } catch (UpgradeRequiredException e) {
        //an upgrade to HSQLDB 2.x is required, delete the lock file
        Logger.getLogger(AS2Server.SERVER_LOGGER_NAME).warning(e.getMessage());
        JOptionPane.showMessageDialog(null, e.getClass().getName() + ": " + e.getMessage());
        AS2Server.deleteLockFile();
        System.exit(1);
    } catch (Throwable e) {
        if (splash != null) {
            splash.destroy();
        }
        JOptionPane.showMessageDialog(null, e.getMessage());
        System.exit(1);
    }
    //start client
    AS2Gui gui = new AS2Gui(splash, "localhost");
    gui.setVisible(true);
    splash.destroy();
    splash.dispose();
}

From source file:com.github.braully.graph.UtilResultCompare.java

public static void main(String... args) throws Exception {
    Options options = new Options();

    Option input = new Option("i", "input", true, "input file path");
    input.setRequired(false);/*ww w .java2 s  . c  om*/
    options.addOption(input);

    Option output = new Option("o", "output", true, "output file");
    output.setRequired(false);
    options.addOption(output);

    CommandLineParser parser = new DefaultParser();
    HelpFormatter formatter = new HelpFormatter();
    CommandLine cmd;

    try {
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        System.out.println(e.getMessage());
        formatter.printHelp("UtilResult", options);

        System.exit(1);
        return;
    }

    String inputFilePath = cmd.getOptionValue("input");
    if (inputFilePath == null) {
        inputFilePath = "/home/strike/Dropbox/documentos/mestrado/resultado-processamento-grafos/resultado-quartic-ht.txt";

        //            inputFilePath = "/home/strike/Dropbox/documentos/mestrado/resultado-processamento-grafos/resultado-mft-parcial-ht.txt";
        //            inputFilePath = "/home/strike/Dropbox/documentos/mestrado/resultado-processamento-grafos/resultado-highlyirregular-ht.txt";
        //            inputFilePath = "/home/strike/Documentos/grafos-processados/mtf/resultado-ht.txt";
        //            inputFilePath = "/home/strike/Dropbox/documentos/mestrado/resultado-processamento-grafos/resultado-hypo-parcial-ht.txt";
        //            inputFilePath = "/home/strike/Dropbox/documentos/mestrado/resultado-processamento-grafos/resultado-eul-ht.txt";
        //            inputFilePath = "/home/strike/Dropbox/documentos/mestrado/resultado-processamento-grafos/resultado-almhypo-ht.txt";
        //            inputFilePath = "/home/strike/Dropbox/documentos/mestrado/resultado-processamento-grafos/resultado-Almost_hypohamiltonian_graphs_cubic-parcial-ht.txt";
    }
    if (inputFilePath != null) {
        if (inputFilePath.toLowerCase().endsWith(".txt")) {
            processFileTxt(inputFilePath);
        } else if (inputFilePath.toLowerCase().endsWith(".json")) {
            processFileJson(inputFilePath);
        }
    }
}

From source file:com.github.vatbub.tictactoe.view.Main.java

public static void main(String[] args) {
    Common.getInstance().setAppName("tictactoev2");
    FOKLogger.enableLoggingOfUncaughtExceptions();

    try {//from   w  w w  . j  a v  a 2  s  .  c o m
        applicationConfiguration = new Config(new URL(
                "https://raw.githubusercontent.com/vatbub/tictactoe/master/remoteconfig/client.properties"),
                Main.class.getResource("fallbackConfig.properties"), true,
                "tictactoeClientConfigCache.properties", true);
    } catch (IOException e) {
        FOKLogger.log(Main.class.getName(), Level.SEVERE, "Could not read the remote config", e);
    }

    for (String arg : args) {
        if (arg.toLowerCase().matches("mockappversion=.*")) {
            // Set the mock version
            String version = arg.substring(arg.toLowerCase().indexOf('=') + 1);
            Common.getInstance().setMockAppVersion(version);
        } else if (arg.toLowerCase().matches("mockbuildnumber=.*")) {
            // Set the mock build number
            String buildnumber = arg.substring(arg.toLowerCase().indexOf('=') + 1);
            Common.getInstance().setMockBuildNumber(buildnumber);
        } else if (arg.toLowerCase().matches("mockpackaging=.*")) {
            // Set the mock packaging
            String packaging = arg.substring(arg.toLowerCase().indexOf('=') + 1);
            Common.getInstance().setMockPackaging(packaging);
        } else if (arg.toLowerCase().matches("locale=.*")) {
            // set the gui language
            String guiLanguageCode = arg.substring(arg.toLowerCase().indexOf('=') + 1);
            FOKLogger.info(Main.class.getName(), "Setting language: " + guiLanguageCode);
            Locale.setDefault(new Locale(guiLanguageCode));
        }
    }

    launch(args);
}

From source file:hyperheuristics.main.comparisons.ComputeIndicators.java

public static void main(String[] args) throws IOException, InterruptedException {
    int[] numberOfObjectivesArray = new int[] { 2, 4 };

    String[] problems = new String[] { "OO_MyBatis", "OA_AJHsqldb", "OA_AJHotDraw", "OO_BCEL", "OO_JHotDraw",
            "OA_HealthWatcher",
            //                "OA_TollSystems",
            "OO_JBoss" };

    String[] heuristicFunctions = new String[] { LowLevelHeuristic.CHOICE_FUNCTION,
            LowLevelHeuristic.MULTI_ARMED_BANDIT, LowLevelHeuristic.RANDOM };

    String[] algorithms = new String[] { "NSGA-II",
            //            "SPEA2"
    };/*ww w. ja v a2 s  .  c o m*/

    MetricsUtil metricsUtil = new MetricsUtil();
    DecimalFormat decimalFormatter = new DecimalFormat("0.00E0");
    Mean mean = new Mean();
    StandardDeviation standardDeviation = new StandardDeviation();

    InvertedGenerationalDistance igd = new InvertedGenerationalDistance();
    GenerationalDistance gd = new GenerationalDistance();
    Spread spread = new Spread();
    Coverage coverage = new Coverage();

    for (int objectives : numberOfObjectivesArray) {
        try (FileWriter IGDWriter = new FileWriter("experiment/IGD_" + objectives + ".tex");
                FileWriter spreadWriter = new FileWriter("experiment/SPREAD_" + objectives + ".tex");
                FileWriter GDWriter = new FileWriter("experiment/GD_" + objectives + ".tex");
                FileWriter coverageWriter = new FileWriter("experiment/COVERAGE_" + objectives + ".tex")) {

            StringBuilder latexTableBuilder = new StringBuilder();

            latexTableBuilder.append("\\documentclass{paper}\n").append("\n")
                    .append("\\usepackage[T1]{fontenc}\n").append("\\usepackage[latin1]{inputenc}\n")
                    .append("\\usepackage[hidelinks]{hyperref}\n").append("\\usepackage{tabulary}\n")
                    .append("\\usepackage{booktabs}\n").append("\\usepackage{multirow}\n")
                    .append("\\usepackage{amsmath}\n").append("\\usepackage{mathtools}\n")
                    .append("\\usepackage{graphicx}\n").append("\\usepackage{array}\n")
                    .append("\\usepackage[linesnumbered,ruled,inoutnumbered]{algorithm2e}\n")
                    .append("\\usepackage{subfigure}\n").append("\\usepackage[hypcap]{caption}\n")
                    .append("\\usepackage{pdflscape}\n").append("\n").append("\\begin{document}\n").append("\n")
                    .append("\\begin{landscape}\n").append("\n");

            pfKnown: {

                latexTableBuilder.append("\\begin{table}[!htb]\n").append("\t\\centering\n")
                        .append("\t\\def\\arraystretch{1.5}\n")
                        //                        .append("\t\\setlength{\\tabcolsep}{10pt}\n")
                        //                        .append("\t\\fontsize{8pt}{10pt}\\selectfont\n")
                        .append("\t\\caption{INDICATOR found for $PF_{known}$ for ").append(objectives)
                        .append(" objectives}\n").append("\t\\label{tab:INDICATOR ").append(objectives)
                        .append(" objectives}\n").append("\t\\begin{tabulary}{\\linewidth}{c");

                for (String algorithm : algorithms) {
                    latexTableBuilder.append("c");
                    for (String heuristicFunction : heuristicFunctions) {
                        latexTableBuilder.append("c");
                    }
                }

                latexTableBuilder.append("}\n").append("\t\t\\toprule\n").append("\t\t\\textbf{System}");
                for (String algorithm : algorithms) {
                    latexTableBuilder.append(" & \\textbf{").append(algorithm).append("}");
                    for (String heuristicFunction : heuristicFunctions) {
                        latexTableBuilder.append(" & \\textbf{").append(algorithm).append("-")
                                .append(heuristicFunction).append("}");
                    }
                }
                latexTableBuilder.append("\\\\\n").append("\t\t\\midrule\n");

                for (String problem : problems) {

                    NonDominatedSolutionList trueFront = new NonDominatedSolutionList();
                    pfTrueComposing: {
                        for (String algorithm : algorithms) {
                            SolutionSet mecbaFront = metricsUtil.readNonDominatedSolutionSet(
                                    "resultado/" + algorithm.toLowerCase().replaceAll("-", "") + "/" + problem
                                            + "_Comb_" + objectives + "obj/All_FUN_"
                                            + algorithm.toLowerCase().replaceAll("-", "") + "-" + problem);
                            trueFront.addAll(mecbaFront);

                            for (String hyperHeuristic : heuristicFunctions) {
                                SolutionSet front = metricsUtil.readNonDominatedSolutionSet(
                                        "experiment/" + algorithm + "/" + objectives + "objectives/"
                                                + hyperHeuristic + "/" + problem + "/FUN.txt");
                                trueFront.addAll(front);
                            }
                        }
                    }
                    double[][] trueFrontMatrix = trueFront.writeObjectivesToMatrix();

                    HashMap<String, Double> igdMap = new HashMap<>();
                    HashMap<String, Double> gdMap = new HashMap<>();
                    HashMap<String, Double> spreadMap = new HashMap<>();
                    HashMap<String, Double> coverageMap = new HashMap<>();

                    for (String algorithm : algorithms) {
                        double[][] mecbaFront = metricsUtil
                                .readFront("resultado/" + algorithm.toLowerCase().replaceAll("-", "") + "/"
                                        + problem + "_Comb_" + objectives + "obj/All_FUN_"
                                        + algorithm.toLowerCase().replaceAll("-", "") + "-" + problem);
                        igdMap.put(algorithm,
                                igd.invertedGenerationalDistance(mecbaFront, trueFrontMatrix, objectives));
                        gdMap.put(algorithm, gd.generationalDistance(mecbaFront, trueFrontMatrix, objectives));
                        spreadMap.put(algorithm, spread.spread(mecbaFront, trueFrontMatrix, objectives));
                        coverageMap.put(algorithm, coverage.coverage(mecbaFront, trueFrontMatrix));
                        for (String heuristic : heuristicFunctions) {
                            double[][] heuristicFront = metricsUtil.readFront("experiment/" + algorithm + "/"
                                    + objectives + "objectives/" + heuristic + "/" + problem + "/FUN.txt");
                            igdMap.put(algorithm + "-" + heuristic, igd
                                    .invertedGenerationalDistance(heuristicFront, trueFrontMatrix, objectives));
                            gdMap.put(algorithm + "-" + heuristic,
                                    gd.generationalDistance(heuristicFront, trueFrontMatrix, objectives));
                            spreadMap.put(algorithm + "-" + heuristic,
                                    spread.spread(heuristicFront, trueFrontMatrix, objectives));
                            coverageMap.put(algorithm + "-" + heuristic,
                                    coverage.coverage(heuristicFront, trueFrontMatrix));
                        }
                    }

                    latexTableBuilder.append("\t\t").append(problem);

                    String latexTable = latexTableBuilder.toString();

                    latexTableBuilder = new StringBuilder();

                    latexTable = latexTable.replaceAll("O[OA]\\_", "").replaceAll("ChoiceFunction", "CF")
                            .replaceAll("MultiArmedBandit", "MAB");

                    IGDWriter.write(latexTable.replaceAll("INDICATOR", "IGD"));
                    spreadWriter.write(latexTable.replaceAll("INDICATOR", "Spread"));
                    GDWriter.write(latexTable.replaceAll("INDICATOR", "GD"));
                    coverageWriter.write(latexTable.replaceAll("INDICATOR", "Coverage"));

                    String bestHeuristicIGD = "NULL";
                    String bestHeuristicGD = "NULL";
                    String bestHeuristicSpread = "NULL";
                    String bestHeuristicCoverage = "NULL";

                    getBest: {
                        double bestMeanIGD = Double.POSITIVE_INFINITY;
                        double bestMeanGD = Double.POSITIVE_INFINITY;
                        double bestMeanSpread = Double.NEGATIVE_INFINITY;
                        double bestMeanCoverage = Double.NEGATIVE_INFINITY;

                        for (String heuristic : igdMap.keySet()) {
                            double heuristicIGD = igdMap.get(heuristic);
                            double heuristicGD = gdMap.get(heuristic);
                            double heuristicSpread = spreadMap.get(heuristic);
                            double heuristicCoverage = coverageMap.get(heuristic);

                            if (heuristicIGD < bestMeanIGD) {
                                bestMeanIGD = heuristicIGD;
                                bestHeuristicIGD = heuristic;
                            }
                            if (heuristicGD < bestMeanGD) {
                                bestMeanGD = heuristicGD;
                                bestHeuristicGD = heuristic;
                            }
                            if (heuristicSpread > bestMeanSpread) {
                                bestMeanSpread = heuristicSpread;
                                bestHeuristicSpread = heuristic;
                            }
                            if (heuristicCoverage > bestMeanCoverage) {
                                bestMeanCoverage = heuristicCoverage;
                                bestHeuristicCoverage = heuristic;
                            }
                        }
                    }

                    StringBuilder igdBuilder = new StringBuilder();
                    StringBuilder gdBuilder = new StringBuilder();
                    StringBuilder spreadBuilder = new StringBuilder();
                    StringBuilder coverageBuilder = new StringBuilder();

                    String[] newHeuristicFunctions = new String[heuristicFunctions.length * algorithms.length
                            + algorithms.length];
                    fulfillNewHeuristics: {
                        int i = 0;
                        for (String algorithm : algorithms) {
                            newHeuristicFunctions[i++] = algorithm;
                            for (String heuristicFunction : heuristicFunctions) {
                                newHeuristicFunctions[i++] = algorithm + "-" + heuristicFunction;
                            }
                        }
                    }

                    for (String heuristic : newHeuristicFunctions) {
                        igdBuilder.append(" & ");
                        boolean bold = heuristic.equals(bestHeuristicIGD)
                                || igdMap.get(heuristic).equals(igdMap.get(bestHeuristicIGD));
                        if (bold) {
                            igdBuilder.append("\\textbf{");
                        }
                        igdBuilder.append(decimalFormatter.format(igdMap.get(heuristic)));
                        if (bold) {
                            igdBuilder.append("}");
                        }

                        gdBuilder.append(" & ");
                        bold = heuristic.equals(bestHeuristicGD)
                                || gdMap.get(heuristic).equals(gdMap.get(bestHeuristicGD));
                        if (bold) {
                            gdBuilder.append("\\textbf{");
                        }
                        gdBuilder.append(decimalFormatter.format(gdMap.get(heuristic)));
                        if (bold) {
                            gdBuilder.append("}");
                        }

                        spreadBuilder.append(" & ");
                        bold = heuristic.equals(bestHeuristicSpread)
                                || spreadMap.get(heuristic).equals(spreadMap.get(bestHeuristicSpread));
                        if (bold) {
                            spreadBuilder.append("\\textbf{");
                        }
                        spreadBuilder.append(decimalFormatter.format(spreadMap.get(heuristic)));
                        if (bold) {
                            spreadBuilder.append("}");
                        }

                        coverageBuilder.append(" & ");
                        bold = heuristic.equals(bestHeuristicCoverage)
                                || coverageMap.get(heuristic).equals(coverageMap.get(bestHeuristicCoverage));
                        if (bold) {
                            coverageBuilder.append("\\textbf{");
                        }
                        coverageBuilder.append(decimalFormatter.format(coverageMap.get(heuristic)));
                        if (bold) {
                            coverageBuilder.append("}");
                        }
                    }

                    IGDWriter.write(igdBuilder + "\\\\\n");
                    spreadWriter.write(spreadBuilder + "\\\\\n");
                    GDWriter.write(gdBuilder + "\\\\\n");
                    coverageWriter.write(coverageBuilder + "\\\\\n");
                }
                latexTableBuilder = new StringBuilder();

                latexTableBuilder.append("\t\t\\bottomrule\n").append("\t\\end{tabulary}\n")
                        .append("\\end{table}\n\n");
            }

            averages: {

                latexTableBuilder.append("\\begin{table}[!htb]\n").append("\t\\centering\n")
                        .append("\t\\def\\arraystretch{1.5}\n")
                        //                        .append("\t\\setlength{\\tabcolsep}{10pt}\n")
                        //                        .append("\t\\fontsize{8pt}{10pt}\\selectfont\n")
                        .append("\t\\caption{INDICATOR averages found for ").append(objectives)
                        .append(" objectives}\n").append("\t\\label{tab:INDICATOR ").append(objectives)
                        .append(" objectives}\n").append("\t\\begin{tabulary}{\\linewidth}{c");

                for (String algorithm : algorithms) {
                    latexTableBuilder.append("c");
                    for (String heuristicFunction : heuristicFunctions) {
                        latexTableBuilder.append("c");
                    }
                }

                latexTableBuilder.append("}\n").append("\t\t\\toprule\n").append("\t\t\\textbf{System}");
                for (String algorithm : algorithms) {
                    latexTableBuilder.append(" & \\textbf{").append(algorithm).append("}");
                    for (String heuristicFunction : heuristicFunctions) {
                        latexTableBuilder.append(" & \\textbf{").append(algorithm).append("-")
                                .append(heuristicFunction).append("}");
                    }
                }
                latexTableBuilder.append("\\\\\n").append("\t\t\\midrule\n");

                for (String problem : problems) {

                    NonDominatedSolutionList trueFront = new NonDominatedSolutionList();
                    pfTrueComposing: {
                        for (String algorithm : algorithms) {
                            SolutionSet mecbaFront = metricsUtil.readNonDominatedSolutionSet(
                                    "resultado/" + algorithm.toLowerCase().replaceAll("-", "") + "/" + problem
                                            + "_Comb_" + objectives + "obj/All_FUN_"
                                            + algorithm.toLowerCase().replaceAll("-", "") + "-" + problem);
                            trueFront.addAll(mecbaFront);

                            for (String hyperHeuristic : heuristicFunctions) {
                                SolutionSet front = metricsUtil.readNonDominatedSolutionSet(
                                        "experiment/" + algorithm + "/" + objectives + "objectives/"
                                                + hyperHeuristic + "/" + problem + "/FUN.txt");
                                trueFront.addAll(front);
                            }
                        }
                    }
                    double[][] trueFrontMatrix = trueFront.writeObjectivesToMatrix();

                    HashMap<String, double[]> igdMap = new HashMap<>();
                    HashMap<String, double[]> gdMap = new HashMap<>();
                    HashMap<String, double[]> spreadMap = new HashMap<>();
                    HashMap<String, double[]> coverageMap = new HashMap<>();

                    mocaito: {
                        for (String algorithm : algorithms) {
                            double[] mecbaIGDs = new double[EXECUTIONS];
                            double[] mecbaGDs = new double[EXECUTIONS];
                            double[] mecbaSpreads = new double[EXECUTIONS];
                            double[] mecbaCoverages = new double[EXECUTIONS];
                            for (int i = 0; i < EXECUTIONS; i++) {
                                double[][] mecbaFront = metricsUtil.readFront("resultado/"
                                        + algorithm.toLowerCase().replaceAll("-", "") + "/" + problem + "_Comb_"
                                        + objectives + "obj/FUN_" + algorithm.toLowerCase().replaceAll("-", "")
                                        + "-" + problem + "-" + i + ".NaoDominadas");

                                mecbaIGDs[i] = igd.invertedGenerationalDistance(mecbaFront, trueFrontMatrix,
                                        objectives);
                                mecbaGDs[i] = gd.generationalDistance(mecbaFront, trueFrontMatrix, objectives);
                                mecbaSpreads[i] = spread.spread(mecbaFront, trueFrontMatrix, objectives);
                                mecbaCoverages[i] = coverage.coverage(mecbaFront, trueFrontMatrix);
                            }
                            igdMap.put(algorithm, mecbaIGDs);
                            gdMap.put(algorithm, mecbaGDs);
                            spreadMap.put(algorithm, mecbaSpreads);
                            coverageMap.put(algorithm, mecbaCoverages);
                        }
                    }

                    for (String algorithm : algorithms) {
                        for (String heuristic : heuristicFunctions) {
                            double[] hhIGDs = new double[EXECUTIONS];
                            double[] hhGDs = new double[EXECUTIONS];
                            double[] hhSpreads = new double[EXECUTIONS];
                            double[] hhCoverages = new double[EXECUTIONS];
                            for (int i = 0; i < EXECUTIONS; i++) {
                                double[][] hhFront = metricsUtil
                                        .readFront("experiment/" + algorithm + "/" + objectives + "objectives/"
                                                + heuristic + "/" + problem + "/EXECUTION_" + i + "/FUN.txt");

                                hhIGDs[i] = igd.invertedGenerationalDistance(hhFront, trueFrontMatrix,
                                        objectives);
                                hhGDs[i] = gd.generationalDistance(hhFront, trueFrontMatrix, objectives);
                                hhSpreads[i] = spread.spread(hhFront, trueFrontMatrix, objectives);
                                hhCoverages[i] = coverage.coverage(hhFront, trueFrontMatrix);
                            }
                            igdMap.put(algorithm + "-" + heuristic, hhIGDs);
                            gdMap.put(algorithm + "-" + heuristic, hhGDs);
                            spreadMap.put(algorithm + "-" + heuristic, hhSpreads);
                            coverageMap.put(algorithm + "-" + heuristic, hhCoverages);
                        }
                    }

                    HashMap<String, HashMap<String, Boolean>> igdResult = KruskalWallisTest.test(igdMap);
                    HashMap<String, HashMap<String, Boolean>> gdResult = KruskalWallisTest.test(gdMap);
                    HashMap<String, HashMap<String, Boolean>> spreadResult = KruskalWallisTest.test(spreadMap);
                    HashMap<String, HashMap<String, Boolean>> coverageResult = KruskalWallisTest
                            .test(coverageMap);

                    latexTableBuilder.append("\t\t").append(problem);

                    String latexTable = latexTableBuilder.toString();
                    latexTable = latexTable.replaceAll("O[OA]\\_", "").replaceAll("ChoiceFunction", "CF")
                            .replaceAll("MultiArmedBandit", "MAB");

                    IGDWriter.write(latexTable.replaceAll("INDICATOR", "IGD"));
                    spreadWriter.write(latexTable.replaceAll("INDICATOR", "Spread"));
                    GDWriter.write(latexTable.replaceAll("INDICATOR", "GD"));
                    coverageWriter.write(latexTable.replaceAll("INDICATOR", "Coverage"));

                    latexTableBuilder = new StringBuilder();

                    String bestHeuristicIGD = "NULL";
                    String bestHeuristicGD = "NULL";
                    String bestHeuristicSpread = "NULL";
                    String bestHeuristicCoverage = "NULL";

                    getBest: {
                        double bestMeanIGD = Double.POSITIVE_INFINITY;
                        double bestMeanGD = Double.POSITIVE_INFINITY;
                        double bestMeanSpread = Double.NEGATIVE_INFINITY;
                        double bestMeanCoverage = Double.NEGATIVE_INFINITY;

                        for (String heuristic : igdMap.keySet()) {
                            double heuristicMeanIGD = mean.evaluate(igdMap.get(heuristic));
                            double heuristicMeanGD = mean.evaluate(gdMap.get(heuristic));
                            double heuristicMeanSpread = mean.evaluate(spreadMap.get(heuristic));
                            double heuristicMeanCoverage = mean.evaluate(coverageMap.get(heuristic));

                            if (heuristicMeanIGD < bestMeanIGD) {
                                bestMeanIGD = heuristicMeanIGD;
                                bestHeuristicIGD = heuristic;
                            }
                            if (heuristicMeanGD < bestMeanGD) {
                                bestMeanGD = heuristicMeanGD;
                                bestHeuristicGD = heuristic;
                            }
                            if (heuristicMeanSpread > bestMeanSpread) {
                                bestMeanSpread = heuristicMeanSpread;
                                bestHeuristicSpread = heuristic;
                            }
                            if (heuristicMeanCoverage > bestMeanCoverage) {
                                bestMeanCoverage = heuristicMeanCoverage;
                                bestHeuristicCoverage = heuristic;
                            }
                        }
                    }

                    StringBuilder igdBuilder = new StringBuilder();
                    StringBuilder gdBuilder = new StringBuilder();
                    StringBuilder spreadBuilder = new StringBuilder();
                    StringBuilder coverageBuilder = new StringBuilder();

                    String[] newHeuristicFunctions = new String[heuristicFunctions.length * algorithms.length
                            + algorithms.length];
                    fulfillNewHeuristics: {
                        int i = 0;
                        for (String algorithm : algorithms) {
                            newHeuristicFunctions[i++] = algorithm;
                            for (String heuristicFunction : heuristicFunctions) {
                                newHeuristicFunctions[i++] = algorithm + "-" + heuristicFunction;
                            }
                        }
                    }

                    for (String heuristic : newHeuristicFunctions) {
                        igdBuilder.append(" & ");
                        boolean bold = heuristic.equals(bestHeuristicIGD)
                                || !igdResult.get(heuristic).get(bestHeuristicIGD);
                        if (bold) {
                            igdBuilder.append("\\textbf{");
                        }
                        igdBuilder.append(decimalFormatter.format(mean.evaluate(igdMap.get(heuristic))) + " ("
                                + decimalFormatter.format(standardDeviation.evaluate(igdMap.get(heuristic)))
                                + ")");
                        if (bold) {
                            igdBuilder.append("}");
                        }

                        gdBuilder.append(" & ");
                        bold = heuristic.equals(bestHeuristicGD)
                                || !gdResult.get(heuristic).get(bestHeuristicGD);
                        if (bold) {
                            gdBuilder.append("\\textbf{");
                        }
                        gdBuilder.append(decimalFormatter.format(mean.evaluate(gdMap.get(heuristic))) + " ("
                                + decimalFormatter.format(standardDeviation.evaluate(gdMap.get(heuristic)))
                                + ")");
                        if (bold) {
                            gdBuilder.append("}");
                        }

                        spreadBuilder.append(" & ");
                        bold = heuristic.equals(bestHeuristicSpread)
                                || !spreadResult.get(heuristic).get(bestHeuristicSpread);
                        if (bold) {
                            spreadBuilder.append("\\textbf{");
                        }
                        spreadBuilder.append(decimalFormatter.format(mean.evaluate(spreadMap.get(heuristic)))
                                + " ("
                                + decimalFormatter.format(standardDeviation.evaluate(spreadMap.get(heuristic)))
                                + ")");
                        if (bold) {
                            spreadBuilder.append("}");
                        }

                        coverageBuilder.append(" & ");
                        bold = heuristic.equals(bestHeuristicCoverage)
                                || !coverageResult.get(heuristic).get(bestHeuristicCoverage);
                        if (bold) {
                            coverageBuilder.append("\\textbf{");
                        }
                        coverageBuilder
                                .append(decimalFormatter.format(mean.evaluate(coverageMap.get(heuristic))))
                                .append(" (")
                                .append(decimalFormatter
                                        .format(standardDeviation.evaluate(coverageMap.get(heuristic))))
                                .append(")");
                        if (bold) {
                            coverageBuilder.append("}");
                        }
                    }

                    IGDWriter.write(igdBuilder + "\\\\\n");
                    spreadWriter.write(spreadBuilder + "\\\\\n");
                    GDWriter.write(gdBuilder + "\\\\\n");
                    coverageWriter.write(coverageBuilder + "\\\\\n");
                }
                latexTableBuilder.append("\t\t\\bottomrule\n").append("\t\\end{tabulary}\n")
                        .append("\\end{table}\n\n");
            }

            latexTableBuilder.append("\\end{landscape}\n\n").append("\\end{document}");

            String latexTable = latexTableBuilder.toString();

            IGDWriter.write(latexTable);
            spreadWriter.write(latexTable);
            GDWriter.write(latexTable);
            coverageWriter.write(latexTable);
        }
    }
}

From source file:com.hygenics.parser.MainApp.java

/**
 * The entire programs main method.// w  w w.  j  a v a  2 s.c  om
 * 
 * @param args
 */
public static void main(String[] args) {
    final Logger log = LoggerFactory.getLogger(MainApp.class);
    log.info("Starting Parse @ " + Calendar.getInstance().getTime().toString());

    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            ("file:" + System.getProperty("beansfile").trim()));
    log.info("Found beans @ " + System.getProperty("beansfile").trim());
    log.info("Starting");
    ArrayList<String> results = null;

    String activity = null;
    log.info("Obtaining Activities");
    ActivitiesStack stack = (ActivitiesStack) context.getBean("ActivitiesStack");

    // integers keeping track of bean number to pull (e.g. DumpToText0 or
    // DumpToText1)
    // in keeping with the spirit of dumping out data
    int n = 0, srn = 0, mv = 0, cen = 0, pps = 0, sb = 0, kv = 0, cf = 0, zip = 0, bm = 0, dump = 0, kettle = 0,
            execute = 0, transfer = 0, sqls = 0, job = 0, parsepages = 0, getpages = 0, map = 0, js = 0,
            sdump = 0, transforms = 0, execs = 0, gim = 0, ems = 0, jd = 0;

    Pattern p = Pattern.compile("[A-Za-z]+[0-9]+");
    Matcher m;

    // start stack init
    log.info("Stack Initialized with Size of " + stack.getSize() + " @ "
            + Calendar.getInstance().getTime().toString());

    while (stack.getSize() > 0) {
        // pop activity form stack
        activity = stack.Pop();
        log.info("Activities Remaining " + stack.getSize());
        m = p.matcher(activity);

        log.info("\n\nACTIVITY: " + activity + "\n\n");
        if (activity.toLowerCase().contains("manualrepconn")) {
            log.info("Manual Transformation Started @ " + Calendar.getInstance().getTime().toString());
            ManualReplacement mrp = (ManualReplacement) context.getBean("ManualRepConn");
            mrp.run();
            log.info("Manual Transformation Finished @ " + Calendar.getInstance().getTime().toString());
        } else if (activity.toLowerCase().contains("cleanfolder")) {
            log.info("Folder Cleanup Started @ " + Calendar.getInstance().getTime().toString());

            CleanFolder c;
            if (cf == 0 || context.containsBean("CleanFolder")) {
                c = (CleanFolder) ((context.containsBean("CleanFolder")) ? context.getBean("CleanFolder")
                        : context.getBean("CleanFolder" + cf));
            } else {
                c = (CleanFolder) context.getBean("CleanFolder" + cf);
            }
            c.run();
            cf++;
            log.info("File Cleanup Complete @ " + Calendar.getInstance().getTime().toString());
        } else if (activity.toLowerCase().contains("zip")) {

            log.info("Zip File Creation Started @ " + Calendar.getInstance().getTime().toString());

            Archiver a;
            if (zip == 0 || context.containsBean("Zip")) {
                a = (Archiver) ((context.containsBean("Zip")) ? context.getBean("Zip")
                        : context.getBean("Zip" + zip));
            } else {
                a = (Archiver) context.getBean("Zip" + zip);
            }
            a.run();
            zip++;
            log.info("Zip File Creation Complete @ " + Calendar.getInstance().getTime().toString());
        } else if (activity.toLowerCase().contains("transfer")) {
            log.info("File Transfer Started @ " + Calendar.getInstance().getTime().toString());

            Upload u;
            if (transfer == 0 || context.containsBean("FileTransfer")) {
                u = (Upload) ((context.containsBean("FileTransfer")) ? context.getBean("FileTransfer")
                        : context.getBean("FileTransfer" + transfer));
            } else {
                u = (Upload) context.getBean("FileTransfer" + transfer);
            }
            u.run();
            transfer++;
            log.info("File Transfer Complete @ " + Calendar.getInstance().getTime().toString());
        } else if (activity.toLowerCase().contains("droptables")) {
            // drop tables
            log.info("Dropping Tables @ " + Calendar.getInstance().getTime().toString());

            DropTables droptables = (DropTables) context.getBean("DropTables");
            droptables.run();

            droptables = null;
            log.info("Done Dropping Tables @ " + Calendar.getInstance().getTime().toString());
        } else if (activity.toLowerCase().equals("createtables")) {
            // create tables
            log.info("Creating Tables @ " + Calendar.getInstance().getTime().toString());

            CreateTable create = (CreateTable) context.getBean("CreateTables");
            create.run();
            create = null;

            log.info("Done Creating Tables @ " + Calendar.getInstance().getTime().toString());
        } else if (activity.toLowerCase().contains("createtableswithreference")) {
            // create tables
            log.info("Creating Tables @ " + Calendar.getInstance().getTime().toString());

            CreateTablesWithReference create = (CreateTablesWithReference) context
                    .getBean("CreateTablesWithReference");
            create.run();
            create = null;

            log.info("Done Creating Tables @ " + Calendar.getInstance().getTime().toString());
        } else if (activity.toLowerCase().contains("truncate")) {
            // truncate table
            log.info("Truncating @ " + Calendar.getInstance().getTime().toString());
            Truncate truncate = (Truncate) context.getBean("Truncate");
            truncate.truncate();
            truncate = null;
            log.info("Truncated @ " + Calendar.getInstance().getTime().toString());
            Runtime.getRuntime().gc();
            log.info("Free Memory: " + Runtime.getRuntime().freeMemory());
        } else if (activity.toLowerCase().equals("enforce")) {
            // enforce schema
            log.info("Enforcing Schema @" + Calendar.getInstance().getTime().toString());
            ForceConformity ef = (ForceConformity) context.getBean("EnforceStandards");
            ef.run();
            log.info("Done Enforcing Schema @" + Calendar.getInstance().getTime().toString());
            Runtime.getRuntime().gc();
            log.info("Free Memory: " + Runtime.getRuntime().freeMemory());
        } else if (activity.toLowerCase().contains("enforcewithreference")) {
            // enforce schema
            ForceConformityWithReference ef = (ForceConformityWithReference) context
                    .getBean("EnforceStandardsWithReference");
            log.info("Enforcing Schema By Reference @" + Calendar.getInstance().getTime().toString());
            ef.run();
            log.info("Done Enforcing Schema @" + Calendar.getInstance().getTime().toString());
            Runtime.getRuntime().gc();
            log.info("Free Memory: " + Runtime.getRuntime().freeMemory());
        } else if (activity.toLowerCase().trim().equals("repconn")) {
            log.info("Replacing Transformation Connection Information  @"
                    + Calendar.getInstance().getTime().toString());

            RepConn rep = (RepConn) context.getBean("repconn");
            rep.run();

            log.info("Finished Replacing Connection Information  @"
                    + Calendar.getInstance().getTime().toString());
        } else if (activity.toLowerCase().contains("job")) {
            // run a Pentaho job as opposed to a Pentaho Transformation
            log.info("Run Job kjb file @" + Calendar.getInstance().getTime().toString());

            RunJob kjb = null;

            if (m.find()) {
                kjb = (RunJob) context.getBean(activity);
            } else {
                kjb = (RunJob) context.getBean("Job" + job);
            }

            kjb.run();
            kjb = null;
            log.info("Pentaho Job Complete @" + Calendar.getInstance().getTime().toString());
            Runtime.getRuntime().gc();
        } else if (activity.toLowerCase().compareTo("execute") == 0) {
            // Execute a process
            log.info("Executing Process @" + Calendar.getInstance().getTime().toString());

            if (context.containsBean("Execute") && execs == 0) {
                ExecuteProcess proc = (ExecuteProcess) context.getBean(("Execute"));
                proc.Execute();
            } else {
                ExecuteProcess proc = (ExecuteProcess) context.getBean(("Execute" + execute));
                proc.Execute();
            }

            execs++;
            log.info("Pages Obtained @" + Calendar.getInstance().getTime().toString());
            Runtime.getRuntime().gc();
            log.info("Free Memory: " + Runtime.getRuntime().freeMemory());
        } else if (activity.toLowerCase().contains("parsepageswithscala")
                || activity.toLowerCase().contains("parsepagesscala")) {
            //parse pages with scala
            log.info("Parsing Pages with Scala @ " + Calendar.getInstance().getTime().toString());
            ScalaParseDispatcher pds = null;
            if (context.containsBean("ParsePagesScala" + pps)) {
                pds = (ScalaParseDispatcher) context.getBean("ParsePagesScala" + pps);
            } else if (context.containsBean("ParsePagesScala") && pps > 0) {
                pds = (ScalaParseDispatcher) context.getBean("ParsePagesScala");
            }
            pps++;
            pds.run();
            Runtime.getRuntime().gc();
            log.info("Finished Parsing Pages with Scala @ " + Calendar.getInstance().getTime().toString());
        } else if (activity.toLowerCase().contains("parsepages")) {

            // Parse Pages with java
            log.info("Parsing Individual Pages  @" + Calendar.getInstance().getTime().toString());
            if (context.containsBean("ParsePages") && parsepages == 0) {
                ParseDispatcher pd = (ParseDispatcher) context.getBean("ParsePages");
                pd.run();
                pd = null;
            } else {
                ParseDispatcher pd = (ParseDispatcher) context.getBean("ParsePages" + parsepages);
                pd.run();
                pd = null;
            }

            parsepages++;
            log.info("Finished Parsing @" + Calendar.getInstance().getTime().toString());
            Runtime.getRuntime().gc();
            log.info("Free Memory: " + Runtime.getRuntime().freeMemory());
        } else if (activity.toLowerCase().contains("kvparser")) {
            // Parse Pages using the KV Parser
            log.info("Parsing Individual Pages with Key Value Pairs  @"
                    + Calendar.getInstance().getTime().toString());
            if (context.containsBean("KVParser") && parsepages == 0) {
                KVParser pd = (KVParser) context.getBean("KVParser");
                pd.run();
                pd = null;
            } else {
                KVParser pd = (KVParser) context.getBean("KVParser" + kv);
                pd.run();
                pd = null;
            }

            parsepages++;
            log.info("Finished Parsing @" + Calendar.getInstance().getTime().toString());
            Runtime.getRuntime().gc();
            log.info("Free Memory: " + Runtime.getRuntime().freeMemory());
        } else if (activity.toLowerCase().contains("parsewithsoup")) {

            // Parse Pages with Jsoup
            log.info("Parsing Pages with JSoup @ " + Calendar.getInstance().getTime().toString());

            if (context.containsBean("ParseJSoup") && js == 0) {
                ParseJSoup psj = (ParseJSoup) context.getBean("ParseJSoup");
                psj.run();
            } else {
                ParseJSoup psj = (ParseJSoup) context.getBean("ParseJSoup" + Integer.toString(js));
                psj.run();
            }
            js++;
            log.info("Finished Parsing @" + Calendar.getInstance().getTime().toString());
            Runtime.getRuntime().gc();
            log.info("Finished Parsing with JSoup @ " + Calendar.getInstance().getTime().toString());
        } else if (activity.toLowerCase().contains("breakmultiplescala")
                || activity.toLowerCase().contains("breakmultiplewithscala")) {
            log.info("Breaking Records");
            BreakMultipleScala bms = null;
            if (context.containsBean("BreakMultipleScala" + ems)) {
                bms = (BreakMultipleScala) context.getBean("BreakMultipleScala" + sb);
            } else {
                bms = (BreakMultipleScala) context.getBean("BreakMultipleScala");
            }
            bms.run();
            bms = null;
            sb++;
            Runtime.getRuntime().gc();
            System.gc();
            log.info("Free Memory: " + Runtime.getRuntime().freeMemory());
            log.info("Completed Breaking Tasks");
        } else if (activity.toLowerCase().contains("breakmultiple")) {

            // break apart multi-part records
            log.info("Breaking apart Records (BreakMultiple) @" + Calendar.getInstance().getTime().toString());

            if (context.containsBean("BreakMultiple") && bm == 0) {
                BreakMultiple br = (BreakMultiple) context.getBean(("BreakMultiple"));
                br.run();
                br = null;
            } else {
                BreakMultiple br = (BreakMultiple) context.getBean(("BreakMultiple" + Integer.toString(bm)));
                br.run();
                br = null;
            }
            bm++;

            log.info("Finished Breaking Apart Records @" + Calendar.getInstance().getTime().toString());
            log.info("Free Memory: " + Runtime.getRuntime().freeMemory());
        } else if (activity.toLowerCase().compareTo("mapper") == 0) {
            // remap data
            log.info("Mapping Records @" + Calendar.getInstance().getTime().toString());

            if (context.containsBean("Mapper") && map == 0) {
                Mapper mp = (Mapper) context.getBean("Mapper");
                mp.run();
                mp = null;
            } else {
                Mapper mp = (Mapper) context.getBean("Mapper" + Integer.toString(map));
                mp.run();
                mp = null;
            }
            map++;
            log.info("Completed Mapping Records @ " + Calendar.getInstance().getTime().toString());
        } else if (activity.toLowerCase().contains("getimages")) {
            // Get Images in a Separate Step
            log.info("Beggining Image Pull @ " + Calendar.getInstance().getTime().toString());

            if (context.containsBean("getImages") && gim == 0) {
                GetImages gi = (GetImages) context.getBean("getImages");
                gi.run();
                log.info("Image Pull Complete @ " + Calendar.getInstance().getTime().toString());
                gi = null;
            } else {
                GetImages gi = (GetImages) context.getBean("getImages");
                gi.run();
                log.info("Image Pull Complete @ " + Calendar.getInstance().getTime().toString());
                gi = null;
            }
            gim++;
            Runtime.getRuntime().gc();
            System.gc();
            log.info("Free Memory: " + Runtime.getRuntime().freeMemory());

        } else if (activity.toLowerCase().compareTo("sql") == 0) {
            // execute a sql command
            log.info("Executing SQL Query @ " + Calendar.getInstance().getTime().toString());

            if (context.containsBean("SQL") && sqls == 0) {
                ExecuteSQL sql;

                if (m.find()) {
                    sql = (ExecuteSQL) context.getBean(activity);
                } else {
                    sql = (ExecuteSQL) context.getBean("SQL");
                }

                sql.execute();
                sql = null;
            } else {

                ExecuteSQL sql;

                if (m.find()) {
                    sql = (ExecuteSQL) context.getBean(activity);
                } else {
                    sql = (ExecuteSQL) context.getBean("SQL" + sqls);
                }

                sql.execute();
                sql = null;
            }

            sqls++;

            log.info("Finished SQL Query @ " + Calendar.getInstance().getTime().toString());
            Runtime.getRuntime().gc();
            System.gc();
            log.info("Free Memory: " + Runtime.getRuntime().freeMemory());
        } else if (activity.toLowerCase().compareTo("kettle") == 0) {
            // run one or more kettle transformation(s)
            log.info("Beginning Kettle Transformation @ " + Calendar.getInstance().getTime().toString());
            RunTransformation rt = null;

            if (context.containsBean("kettle") && transforms == 0) {
                if (m.find()) {
                    rt = (RunTransformation) context.getBean(activity);
                } else {
                    rt = (RunTransformation) context.getBean(("kettle"));
                }

                rt.run();
                rt = null;
            } else {
                if (m.find()) {
                    rt = (RunTransformation) context.getBean(activity);
                } else {
                    rt = (RunTransformation) context.getBean(("kettle" + kettle));
                }

                rt.run();
                rt = null;
            }
            transforms++;
            log.info("Ending Kettle Transformation @ " + Calendar.getInstance().getTime().toString());
            Runtime.getRuntime().gc();
            System.gc();
            log.info("Free Memory: " + Runtime.getRuntime().freeMemory());
            kettle++;
        } else if (activity.toLowerCase().contains("dumptotext")) {
            // dump to a text file via java
            log.info("Dumping to Text @ " + Calendar.getInstance().getTime().toString());

            DumptoText dtt = null;
            if (m.find()) {
                dtt = (DumptoText) context.getBean(activity);
            } else {
                dtt = (DumptoText) context.getBean("DumpToText" + dump);
            }

            dtt.run();
            dump++;
            log.info("Completed Dump @ " + Calendar.getInstance().getTime().toString());
            dtt = null;
            Runtime.getRuntime().gc();
            System.gc();
            log.info("Free Memory: " + Runtime.getRuntime().freeMemory());
        } else if (activity.toLowerCase().equals("jdump")) {
            log.info("Dumping via JDump @ " + Calendar.getInstance().getTime().toString());
            if (jd == 0 && context.containsBean("JDump")) {
                JDump j = (JDump) context.getBean("JDump");
                jd++;
                j.run();
            } else {
                JDump j = (JDump) context.getBean("JDump" + jd);
                jd++;
                j.run();
            }
            Runtime.getRuntime().gc();
            System.gc();
            log.info("Finished Dumping via JDump @ " + Calendar.getInstance().getTime().toString());
        } else if (activity.toLowerCase().contains("jdumpwithreference")) {
            log.info("Dumping via JDump @ " + Calendar.getInstance().getTime().toString());
            if (jd == 0 && context.containsBean("JDumpWithReference")) {
                JDumpWithReference j = (JDumpWithReference) context.getBean("JDumpWithReference");
                jd++;
                j.run();
            } else {
                JDumpWithReference j = (JDumpWithReference) context.getBean("JDumpWithReference" + jd);
                jd++;
                j.run();
            }
            Runtime.getRuntime().gc();
            System.gc();
            log.info("Finished Dumping via JDump @ " + Calendar.getInstance().getTime().toString());
        } else if (activity.toLowerCase().compareTo("commanddump") == 0) {

            // dump to text using a client side sql COPY TO command
            log.info("Dumping via SQL @ " + Calendar.getInstance().getTime().toString());
            CommandDump d = (CommandDump) context.getBean("dump");
            d.run();
            d = null;
            log.info("Completed Dump @ " + Calendar.getInstance().getTime().toString());
            // most likely not needed by satisfies my paranoia
            Runtime.getRuntime().gc();
            System.gc();
        } else if (activity.toLowerCase().equals("specdump")) {
            // Specified Dump
            log.info("Dumping via Specified Tables, Files, and Attributes @ "
                    + Calendar.getInstance().getTime().toString());

            if (context.containsBean("SpecDump") && sdump == 0) {
                sdump++;
                SpecifiedDump sd = (SpecifiedDump) context.getBean("SpecDump");
                sd.run();
                sd = null;
            } else if (context.containsBean("SpecDump" + Integer.toString(sdump))) {
                SpecifiedDump sd = (SpecifiedDump) context.getBean("SpecDump" + Integer.toString(sdump));
                sd.run();
                sd = null;
            }
            sdump++;
            log.info("Completed Dumping via Specified Tables, Files, and Attributes @ "
                    + Calendar.getInstance().getTime().toString());
        } else if (activity.toLowerCase().contains("specdumpwithreference")) {
            // Specified Dump
            log.info("Dumping via Specified Tables, Files, and Attributes by Reference @ "
                    + Calendar.getInstance().getTime().toString());

            if (context.containsBean("SpecDumpWithReference") && sdump == 0) {
                sdump++;
                SpecDumpWithReference sd = (SpecDumpWithReference) context.getBean("SpecDumpWithReference");
                sd.run();
                sd = null;
            } else if (context.containsBean("SpecDumpWithReference" + Integer.toString(sdump))) {
                SpecDumpWithReference sd = (SpecDumpWithReference) context
                        .getBean("SpecDumpWithReference" + Integer.toString(sdump));
                sd.run();
                sd = null;
            } else {
                log.info("Bean Not Found For " + activity);
            }
            sdump++;
            log.info("Completed Dumping via Specified Tables, Files, and Attributes @ "
                    + Calendar.getInstance().getTime().toString());
        } else if (activity.toLowerCase().compareTo("email") == 0) {
            // email completion notice
            log.info("Sending Notice of Completion @ " + Calendar.getInstance().getTime().toString());

            if (context.containsBean("Email") && ems == 0) {
                Send s = (Send) context.getBean("Email");
                s.run();
                s = null;
            } else {
                Send s = (Send) context.getBean("Email" + Integer.toString(ems));
                s.run();
                s = null;
            }
            ems++;
            Runtime.getRuntime().gc();
            System.gc();
            log.info("Completed Email @ " + Calendar.getInstance().getTime().toString());
            log.info("Free Memory: " + Runtime.getRuntime().freeMemory());
        } else if (activity.toLowerCase().equals("qa")) {
            // perform qa
            log.info("Performing Quality Assurance @ " + Calendar.getInstance().getTime().toString());

            if (context.containsBean("QA")) {
                QualityAssurer qa = (QualityAssurer) context.getBean("QA");
                qa.run();
                qa = null;
            }

            // attempt to hint --> all tasks are really intense so anything
            // is nice
            Runtime.getRuntime().gc();
            System.gc();
            log.info("Completed QA @ " + Calendar.getInstance().getTime().toString());
            log.info("Free Memory: " + Runtime.getRuntime().freeMemory());
        } else if (activity.toLowerCase().equals("notify")) {
            log.info("Running Notification Tasks");
            Notification nt = null;
            if (context.containsBean("Notify" + Integer.toString(n))) {
                nt = (Notification) context.getBean("Notify" + Integer.toString(n));
            } else {
                nt = (Notification) context.getBean("Notify");
            }

            nt.run();
            nt = null;
            n++;

            if (context.containsBean("Email") && ems == 0) {
                Send s = (Send) context.getBean("Email");
                s.run();
                s = null;
            } else if (context.containsBean("Email" + ems)) {
                Send s = (Send) context.getBean("Email" + Integer.toString(ems));
                s.run();
                s = null;
            }

            ems++;
            Runtime.getRuntime().gc();
            System.gc();
            log.info("Free Memory: " + Runtime.getRuntime().freeMemory());
            log.info("Completed Notification Tasks");
        } else if (activity.toLowerCase().contains("move")) {
            log.info("Moving Files @ " + Calendar.getInstance().getTime().toString());

            MoveFile mf = null;
            if (context.containsBean("Move" + Integer.toString(mv))) {
                mf = (MoveFile) context.getBean("Move" + Integer.toString(mv));
            } else {
                mf = (MoveFile) context.getBean("Move");
            }
            mf.run();
            mv++;
            Runtime.getRuntime().gc();
            log.info("Finished Moving Files @ " + Calendar.getInstance().getTime().toString());
        } else if (activity.toLowerCase().contains("numericalcheck")) {
            log.info("Checking Counts");

            NumericalChecker nc = (NumericalChecker) context.getBean("NumericalChecker");
            nc.run();
            Runtime.getRuntime().gc();

            log.info("Finished Checking Counts @ " + Calendar.getInstance().getTime().toString());
        } else if (activity.toLowerCase().contains("runscript")) {
            log.info("Running Script @ " + Calendar.getInstance().getTime().toString());
            RunScript runner = null;
            if (context.containsBean("RunScript" + srn)) {
                runner = (RunScript) context.getBean("RunScript" + srn);
            } else {
                runner = (RunScript) context.getBean("RunScript");
            }
            runner.run();
            srn++;
            Runtime.getRuntime().gc();
            log.info("Finished Running SCript @ " + Calendar.getInstance().getTime().toString());
        } else if (activity.toLowerCase().contains("checkexistance")) {
            log.info("Checking Existance @ " + Calendar.getInstance().getTime().toString());
            ExistanceChecker runner = null;
            if (context.containsBean("CheckExistance" + srn)) {
                runner = (ExistanceChecker) context.getBean("CheckExistance" + cen);
            } else {
                runner = (ExistanceChecker) context.getBean("CheckExistance");
            }
            runner.run();
            cen++;
            Runtime.getRuntime().gc();
            log.info("Finished Checking Existance @ " + Calendar.getInstance().getTime().toString());
        } else {
            log.info("Activity " + activity + " does not exist!");
        }

    }

    log.info("Completed Parse @ " + Calendar.getInstance().getTime().toString());
    context.destroy();
    context.close();
}