Example usage for java.util HashMap size

List of usage examples for java.util HashMap size

Introduction

In this page you can find the example usage for java.util HashMap size.

Prototype

int size

To view the source code for java.util HashMap size.

Click Source Link

Document

The number of key-value mappings contained in this map.

Usage

From source file:mujava.cli.genmutes.java

public static void main(String[] args) throws Exception {
    // System.out.println("test");
    genmutesCom jct = new genmutesCom();
    String[] argv = { "-all", "-debug", "Flower" }; // development use, when release,
    // comment out this line
    JCommander jCommander = new JCommander(jct, args);

    // check session name
    if (jct.getParameters().size() > 1) {
        Util.Error("Has more parameters than needed.");
        return;/*from   w ww.j  a  va  2 s.co  m*/
    }

    // set session name
    String sessionName = jct.getParameters().get(0);

    muJavaHomePath = Util.loadConfig();
    // check if debug mode
    if (jct.isDebug()) {
        Util.debug = true;
    }

    // get all existing session name
    File folder = new File(muJavaHomePath);
    // check if the config file has defined the correct folder
    if (!folder.isDirectory()) {
        Util.Error("ERROR: cannot locate the folder specified in mujava.config");
        return;
    }
    File[] listOfFiles = folder.listFiles();
    // null checking
    // check the specified folder has files or not
    if (listOfFiles == null) {
        Util.Error("ERROR: no files in the muJava home folder: " + muJavaHomePath);
        return;
    }
    List<String> fileNameList = new ArrayList<>();
    for (File file : listOfFiles) {
        fileNameList.add(file.getName());
    }

    // check if session is already created.
    if (!fileNameList.contains(sessionName)) {
        Util.Error("Session does not exist.");
        return;

    }

    // get all files in the session
    String[] file_list = new String[1];
    // if(jct.getD())
    // {
    File sessionFolder = new File(muJavaHomePath + "/" + sessionName + "/src");
    File[] listOfFilesInSession = sessionFolder.listFiles();
    file_list = new String[listOfFilesInSession.length];
    for (int i = 0; i < listOfFilesInSession.length; i++) {
        file_list[i] = listOfFilesInSession[i].getName();
    }

    // get all mutation operators selected
    HashMap<String, List<String>> ops = new HashMap<String, List<String>>(); // used
    // for
    // add
    // random
    // percentage
    // and
    // maximum

    String[] paras = new String[] { "1", "0" };
    if (jct.getAll()) // all is selected, add all operators
    {

        // if all is selected, all mutation operators are added
        ops.put("AORB", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("AORS", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("AOIU", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("AOIS", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("AODU", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("AODS", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("ROR", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("COR", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("COD", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("COI", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("SOR", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("LOR", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("LOI", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("LOD", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("ASRS", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("SDL", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("ODL", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("VDL", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("CDL", new ArrayList<String>(Arrays.asList(paras)));
        // ops.put("SDL", jct.getAll());

    } else { // if not all, add selected ops to the list
        if (jct.getAORB()) {
            ops.put("AORB", new ArrayList<String>(Arrays.asList(paras)));
        }
        if (jct.getAORS()) {
            ops.put("AORS", new ArrayList<String>(Arrays.asList(paras)));
        }
        if (jct.getAOIU()) {
            ops.put("AOIU", new ArrayList<String>(Arrays.asList(paras)));
        }
        if (jct.getAOIS()) {
            ops.put("AOIS", new ArrayList<String>(Arrays.asList(paras)));
        }
        if (jct.getAODU()) {
            ops.put("AODU", new ArrayList<String>(Arrays.asList(paras)));
        }
        if (jct.getAODS()) {
            ops.put("AODS", new ArrayList<String>(Arrays.asList(paras)));
        }
        if (jct.getROR()) {
            ops.put("ROR", new ArrayList<String>(Arrays.asList(paras)));
        }
        if (jct.getCOR()) {
            ops.put("COR", new ArrayList<String>(Arrays.asList(paras)));
        }
        if (jct.getCOD()) {
            ops.put("COD", new ArrayList<String>(Arrays.asList(paras)));
        }
        if (jct.getCOI()) {
            ops.put("COI", new ArrayList<String>(Arrays.asList(paras)));
        }
        if (jct.getSOR()) {
            ops.put("SOR", new ArrayList<String>(Arrays.asList(paras)));
        }
        if (jct.getLOR()) {
            ops.put("LOR", new ArrayList<String>(Arrays.asList(paras)));
        }
        if (jct.getLOI()) {
            ops.put("LOI", new ArrayList<String>(Arrays.asList(paras)));
        }
        if (jct.getLOD()) {
            ops.put("LOD", new ArrayList<String>(Arrays.asList(paras)));
        }
        if (jct.getASRS()) {
            ops.put("ASRS", new ArrayList<String>(Arrays.asList(paras)));
        }
        if (jct.getSDL()) {
            ops.put("SDL", new ArrayList<String>(Arrays.asList(paras)));
        }
        if (jct.getVDL()) {
            ops.put("VDL", new ArrayList<String>(Arrays.asList(paras)));
        }
        if (jct.getODL()) {
            ops.put("ODL", new ArrayList<String>(Arrays.asList(paras)));
        }
        if (jct.getCDL()) {
            ops.put("CDL", new ArrayList<String>(Arrays.asList(paras)));
        }
    }

    // add default option "all"
    if (ops.size() == 0) {
        ops.put("AORB", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("AORS", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("AOIU", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("AOIS", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("AODU", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("AODS", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("ROR", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("COR", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("COD", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("COI", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("SOR", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("LOR", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("LOI", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("LOD", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("ASRS", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("SDL", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("ODL", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("VDL", new ArrayList<String>(Arrays.asList(paras)));
        ops.put("CDL", new ArrayList<String>(Arrays.asList(paras)));
    }

    // String[] tradional_ops = ops.toArray(new String[0]);
    // set system
    setJMutationStructureAndSession(sessionName);
    // MutationSystem.setJMutationStructureAndSession(sessionName);
    MutationSystem.recordInheritanceRelation();
    // generate mutants
    generateMutants(file_list, ops);

    //System.exit(0);
}

From source file:DIA_Umpire_Quant.DIA_Umpire_IntLibSearch.java

/**
 * @param args the command line arguments
 *///  w ww  . ja  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 targeted re-extraction analysis using internal library (version: "
            + UmpireInfo.GetInstance().Version + ")");
    if (args.length != 1) {
        System.out.println(
                "command format error, the correct format should be : java -jar -Xmx10G DIA_Umpire_IntLibSearch.jar diaumpire_module.params");
        return;
    }
    try {
        ConsoleLogger.SetConsoleLogger(Level.INFO);
        ConsoleLogger.SetFileLogger(Level.DEBUG,
                FilenameUtils.getFullPath(args[0]) + "diaumpire_intlibsearch.log");
    } catch (Exception e) {
    }

    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 InternalLibID = "";

    float ProbThreshold = 0.99f;
    float RTWindow_Int = -1f;
    float Freq = 0f;
    int TopNFrag = 6;

    TandemParam tandemPara = new TandemParam(DBSearchParam.SearchInstrumentType.TOF5600);
    HashMap<String, File> AssignFiles = 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 "Path": {
                WorkFolder = value;
                break;
            }
            case "path": {
                WorkFolder = value;
                break;
            }
            case "Thread": {
                NoCPUs = Integer.parseInt(value);
                break;
            }

            case "InternalLibID": {
                InternalLibID = value;
                break;
            }

            case "RTWindow_Int": {
                RTWindow_Int = Float.parseFloat(value);
                break;
            }

            case "ProbThreshold": {
                ProbThreshold = Float.parseFloat(value);
                break;
            }
            case "TopNFrag": {
                TopNFrag = Integer.parseInt(value);
                break;
            }
            case "Freq": {
                Freq = Float.parseFloat(value);
                break;
            }
            case "Fasta": {
                tandemPara.FastaPath = value;
                break;
            }
            }
        }
    }
    //</editor-fold>

    //Initialize PTM manager using compomics library
    PTMManager.GetInstance();

    //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);
    }

    //Generate DIA file list
    ArrayList<DIAPack> FileList = new ArrayList<>();
    try {
        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());
        }
        for (File fileEntry : AssignFiles.values()) {
            String mzXMLFile = fileEntry.getAbsolutePath();
            if (mzXMLFile.toLowerCase().endsWith(".mzxml") | mzXMLFile.toLowerCase().endsWith(".mzml")) {
                DIAPack DiaFile = new DIAPack(mzXMLFile, NoCPUs);
                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);
                }
                Logger.getRootLogger().info("Loading identification results " + mzXMLFile + "....");

                //If the serialization file for ID file existed
                if (DiaFile.ReadSerializedLCMSID()) {
                    DiaFile.IDsummary.ReduceMemoryUsage();
                    DiaFile.IDsummary.FastaPath = tandemPara.FastaPath;
                    FileList.add(DiaFile);
                }
            }
        }

        //<editor-fold defaultstate="collapsed" desc="Targete re-extraction using internal library">            
        Logger.getRootLogger().info(
                "=================================================================================================");
        if (FileList.size() > 1) {
            Logger.getRootLogger().info("Targeted re-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, ProbThreshold, 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>

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

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

From source file:DIA_Umpire_Quant.DIA_Umpire_ExtLibSearch.java

/**
 * @param args the command line arguments
 *//*from   w  ww .  j  av a2s .c om*/
public static void main(String[] args) throws FileNotFoundException, IOException, Exception {
    System.out.println(
            "=================================================================================================");
    System.out.println("DIA-Umpire targeted re-extraction analysis using external library (version: "
            + UmpireInfo.GetInstance().Version + ")");
    if (args.length != 1) {
        System.out.println(
                "command format error, the correct format should be: java -jar -Xmx10G DIA_Umpire_ExtLibSearch.jar diaumpire_module.params");
        return;
    }
    try {
        ConsoleLogger.SetConsoleLogger(Level.INFO);
        ConsoleLogger.SetFileLogger(Level.DEBUG,
                FilenameUtils.getFullPath(args[0]) + "diaumpire_extlibsearch.log");
    } catch (Exception e) {
    }

    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 ExternalLibPath = "";
    String ExternalLibDecoyTag = "DECOY";

    float ExtProbThreshold = 0.99f;
    float RTWindow_Ext = -1f;

    TandemParam tandemPara = new TandemParam(DBSearchParam.SearchInstrumentType.TOF5600);
    HashMap<String, File> AssignFiles = 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 "Path": {
                WorkFolder = value;
                break;
            }
            case "path": {
                WorkFolder = value;
                break;
            }
            case "Thread": {
                NoCPUs = Integer.parseInt(value);
                break;
            }
            case "Fasta": {
                tandemPara.FastaPath = value;
                break;
            }
            case "DecoyPrefix": {
                if (!"".equals(value)) {
                    tandemPara.DecoyPrefix = value;
                }
                break;
            }
            case "ExternalLibPath": {
                ExternalLibPath = value;
                break;
            }
            case "ExtProbThreshold": {
                ExtProbThreshold = 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;
            }
            }
        }
    }
    //</editor-fold>

    //Initialize PTM manager using compomics library
    PTMManager.GetInstance();

    //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);
    }

    //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());
    }

    for (File fileEntry : AssignFiles.values()) {
        String mzXMLFile = fileEntry.getAbsolutePath();
        if (mzXMLFile.toLowerCase().endsWith(".mzxml") | mzXMLFile.toLowerCase().endsWith(".mzml")) {
            DIAPack DiaFile = new DIAPack(mzXMLFile, NoCPUs);
            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);
            }
            Logger.getRootLogger().info("Loading identification results " + mzXMLFile + "....");

            //If the serialization file for ID file existed
            if (DiaFile.ReadSerializedLCMSID()) {
                DiaFile.IDsummary.ReduceMemoryUsage();
                DiaFile.IDsummary.FastaPath = tandemPara.FastaPath;
                FileList.add(DiaFile);
            }
        }
    }

    //<editor-fold defaultstate="collapsed" desc="Targeted re-extraction using external library">

    //External library search

    Logger.getRootLogger().info("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, ExtProbThreshold, 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>

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

}

From source file:Main.java

public static boolean isEmptyMap(HashMap map) {
    return (map == null || map.size() <= 0);
}

From source file:Main.java

public static boolean isNotNull(HashMap<?, ?> collection) {
    if (collection != null && collection.size() > 0) {
        return true;
    }/*from   ww w .  j ava  2  s .c  o m*/
    return false;
}

From source file:Main.java

public static HashMap nullIfEmpty(HashMap h) {
    return (h == null ? null : (h.size() == 0 ? null : h));
}

From source file:Main.java

/**
 * Converts a HashMap to a 2d array for JSON Reading
 *
 * @param map/*from w  w w . ja v  a 2s  .  com*/
 *
 * @return an array that can be read in JSON as an array
 */
public static Object[][] HashMapToArray(HashMap map) {
    Object[][] map2D = new Object[map.size()][2];
    Set entries = map.entrySet();
    Iterator entriesIterator = entries.iterator();
    int i = 0;
    while (entriesIterator.hasNext()) {

        Map.Entry mapping = (Map.Entry) entriesIterator.next();
        map2D[i][0] = mapping.getKey();
        map2D[i][1] = mapping.getValue();
        i++;
    }

    return map2D;
}

From source file:Main.java

public static void printDictionary(HashMap<Integer, String> dict) {
    System.out.println("Index\t\tEntry\n---------------------");
    for (int i = 0; i < dict.size(); i++) {
        System.out.println(i + "\t\t" + dict.get(i));
    }/*ww  w  .  j a  v  a  2s  .  co m*/
}

From source file:com.symphony.jirabot.clients.QuandlClient.java

private static String mapToQueryString(HashMap<String, Object> parameters) {
    if (parameters == null || parameters.size() == 0) {
        return "";
    }//from  w  w  w  . j a v a  2  s.  c om

    StringBuilder queryString = new StringBuilder("&");
    for (String key : parameters.keySet()) {
        queryString.append(urlEncodeUTF8(key));
        queryString.append("=");
        queryString.append(urlEncodeUTF8(parameters.get(key).toString()));
        queryString.append("&");
    }

    if (queryString.charAt(queryString.length() - 1) == '&') {
        queryString = queryString.deleteCharAt(queryString.length() - 1);
    }

    return queryString.toString();
}

From source file:com.nridge.core.io.gson.IOJSON.java

/**
 * Writes a JSON field name/value./*from   ww w  .j  ava 2s.  c om*/
 *
 * @param aWriter JSON writer output stream.
 * @param aName Field name.
 * @param aValue Field value.
 *
 * @throws IOException I/O related exception.
 */
public static void writeNameValue(JsonWriter aWriter, String aName, HashMap<String, String> aValue)
        throws IOException {
    if (aValue.size() > 0) {
        aWriter.name(aName).beginObject();
        for (Map.Entry<String, String> featureEntry : aValue.entrySet()) {
            aWriter.name(featureEntry.getKey());
            aWriter.value(featureEntry.getValue());
        }
        aWriter.endObject();
    }
}