Example usage for java.util HashMap get

List of usage examples for java.util HashMap get

Introduction

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

Prototype

public V get(Object key) 

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:lineage.LineageEngine.java

/**
 * The main pipeline for reconstructing the cell lineage trees
 */// www.jav a  2 s  .c  o m
public static void buildLineage(Args args) {

    // 1. load SNV data
    SNVDataStore db = new SNVDataStore(args.inputFileName, args.clustersFileName, args.normalSampleId);

    // 2. get the SNVs partitioned by group tag and create the appropriate SNV group objects
    HashMap<String, ArrayList<SNVEntry>> snvsByTag = db.getSomaticGroups();
    ArrayList<SNVGroup> groups = new ArrayList<SNVGroup>();
    for (String groupTag : snvsByTag.keySet()) {
        groups.add(new SNVGroup(groupTag, snvsByTag.get(groupTag), db.isRobustGroup(groupTag)));
    }
    if (groups.size() == 0) {
        logger.warning("All SNV groups have been filtered out.");
        return;
    }

    // 3. cluster SNVs in each group
    AAFClusterer clusterer = new AAFClusterer();
    for (SNVGroup group : groups) {
        if (args.clustersFileName == null) {
            Cluster[] clusters = clusterer.clusterSubPopulations(group, ClusteringAlgorithms.EM, 1);
            logger.fine("Clustering results for group: " + group.getTag());
            for (Cluster c : clusters) {
                logger.fine(c.toString());
            }
            group.setSubPopulations(clusters);
        } else {
            ArrayList<Cluster> groupClusters = db.getClusters().get(group.getTag());
            group.subPopulations = new Cluster[groupClusters.size()];
            group.subPopulations = groupClusters.toArray(group.subPopulations);
        }
    }

    // 4. construct the constraint network
    PHYNetwork constrNetwork = new PHYNetwork(groups, db.getNumSamples());
    logger.fine(constrNetwork.toString());

    // 5. find all the lineage trees that pass the VAF constraints
    ArrayList<PHYTree> spanningTrees = constrNetwork.getLineageTrees();
    logger.info("Found " + spanningTrees.size() + " valid tree(s)");

    if (spanningTrees.size() == 0) {
        logger.info("Adjusting the network...");
        // if no valid trees were found, fix the network 
        // remove group nodes that are not robust, complete edges
        int delta = 0;
        do {
            int numNodes = constrNetwork.numNodes;
            constrNetwork = constrNetwork.fixNetwork();
            spanningTrees = constrNetwork.getLineageTrees();
            delta = numNodes - constrNetwork.numNodes;
        } while ((delta != 0) && (spanningTrees.size() <= 0));
        if (spanningTrees.size() <= 0) {
            Parameters.ALL_EDGES = true;
            constrNetwork = new PHYNetwork(groups, db.getNumSamples());
            spanningTrees = constrNetwork.getLineageTrees();
        }
        logger.info("Found " + spanningTrees.size() + " valid trees after network adjustments");
    }

    // 6. evaluate/rank the trees
    if (spanningTrees.size() > 0) {
        constrNetwork.evaluateLineageTrees();
        logger.fine("Top tree\nError score: " + spanningTrees.get(0).getErrorScore());
        logger.fine(spanningTrees.get(0).toString());
    }

    // 7. result visualization
    if (args.showNetwork) {
        constrNetwork.displayNetwork();
    }
    if (spanningTrees.size() > 0) {
        for (int i = 0; i < args.numShow; i++) {
            if (spanningTrees.size() > i) {
                constrNetwork.displayTree(spanningTrees.get(i), db.getSampleNames(), null, null);
            } else {
                break;
            }
        }
        // 8. persistent storage
        if (args.numSave > 0) {
            writeTreesToTxtFile(constrNetwork, spanningTrees, db.getSampleNames(), args);
        }
    }
}

From source file:com.bigtobster.pgnextractalt.commands.TestCommandContext.java

/**
 * Builds a command string up from a basic command plus a Hash Map of Option, Argument value pairs to get "command [--&lt;option&gt; &lt;
 * arg&gt;]*"/* w  w w.  j  a v  a  2  s.  c om*/
 *
 * @param command         The base command
 * @param optionValuesMap The hash map of Option, Argument pairs
 * @return The fully constructed command
 */
static String buildCommand(final String command, final HashMap<String, String> optionValuesMap) {
    final StringBuilder newCommandBuilder = new StringBuilder(50);
    newCommandBuilder.append(command);
    if (optionValuesMap != null) {
        for (final String key : optionValuesMap.keySet()) {
            newCommandBuilder.append(" --");
            newCommandBuilder.append(key);
            newCommandBuilder.append(TestContext.SPACE);
            newCommandBuilder.append(optionValuesMap.get(key));
        }
    }
    return newCommandBuilder.toString();
}

From source file:com.cssweb.quote.util.StockInfo.java

public static String getStockName(int begin, int end, int type) {
    StringBuffer sb = new StringBuffer();
    List<HashMap<String, String>> l = getStockListByType(type);
    int t = l.size();
    for (int i = (begin); i <= (end < t ? end : t); i++) {
        HashMap<String, String> h = l.get(i - 1);
        sb.append(h.get("stockname"));
        if (i != end)
            sb.append(",");
    }//from w  w w.j a  va 2s .co m
    return sb.toString();
}

From source file:com.cssweb.quote.util.StockInfo.java

public static String getStockCode(int begin, int end, int type, String exchange) {
    StringBuffer sb = new StringBuffer();
    List<HashMap<String, String>> l = getStockListByType(type, exchange);
    int t = l.size();
    for (int i = (begin); i <= (end < t ? end : t); i++) {
        HashMap<String, String> h = l.get(i - 1);
        sb.append(h.get("stockcode"));
        if (i != end)
            sb.append(",");
    }/*from w  w w.j a  v a2 s .  co  m*/
    return sb.toString();
}

From source file:com.cssweb.quote.util.StockInfo.java

public static String getStockName(int begin, int end, int type, String exchange) {
    StringBuffer sb = new StringBuffer();
    List<HashMap<String, String>> l = getStockListByType(type, exchange);
    int t = l.size();
    for (int i = (begin); i <= (end < t ? end : t); i++) {
        HashMap<String, String> h = l.get(i - 1);
        sb.append(h.get("stockname"));
        if (i != end)
            sb.append(",");
    }//from w w  w  .  j a v a2  s . co m
    return sb.toString();
}

From source file:de.unileipzig.ub.indexer.App.java

public static String getTimestamp(String line) throws IOException {
    final HashMap record = sharedMapper.readValue(line, HashMap.class);
    final HashMap meta = (HashMap) record.get("meta");
    final String timestamp = meta.get("timestamp").toString();
    return timestamp;
}

From source file:com.cssweb.quote.util.StockInfo.java

/**
 * ?????//from   w  w w. java 2  s  .c om
 * @param begin
 * @param end
 * @return
 */
public static String getStockInfo(int begin, int end, int type) {
    StringBuffer sb = new StringBuffer();
    List<HashMap<String, String>> l = getStockListByType(type);
    int t = l.size();
    for (int i = (begin); i <= (end < t ? end : t); i++) {
        HashMap<String, String> h = l.get(i - 1);
        sb.append(h.get("exchange"));
        sb.append(h.get("stockcode"));
        if (i != end)
            sb.append(",");
    }
    return sb.toString();
}

From source file:com.cssweb.quote.util.StockInfo.java

/**
 * ?????// w  w  w  . j a va2 s  . c o  m
 * ??
 * @param begin
 * @param end
 * @return
 */
public static String getStockInfo(int begin, int end, int type, String exchange) {
    StringBuffer sb = new StringBuffer();
    List<HashMap<String, String>> l = getStockListByType(type, exchange);
    int t = l.size();
    for (int i = (begin); i <= (end < t ? end : t); i++) {
        HashMap<String, String> h = l.get(i - 1);
        sb.append(h.get("exchange"));
        sb.append(h.get("stockcode"));
        if (i != end)
            sb.append(",");
    }
    return sb.toString();
}

From source file:eionet.util.SecurityUtil.java

/**
 *
 * @param usr/*from ww w .  j a  v a 2  s.  c  om*/
 * @param aclPath
 * @param prm
 * @return
 * @throws Exception
 */
public static boolean hasChildPerm(String usr, String aclPath, String prm) throws Exception {
    HashMap acls = AccessController.getAcls();
    Iterator aclNames = acls.keySet().iterator();
    AccessControlListIF acl;
    while (aclNames.hasNext()) {
        String aclName = (String) aclNames.next();
        if (aclName.startsWith(aclPath)) {
            acl = (AccessControlListIF) acls.get(aclName);
            if (acl.checkPermission(usr, prm)) {
                return true;
            }
        }
    }

    return false;
}

From source file:com.icesoft.faces.facelets.D2DFaceletViewHandler.java

/**
 * Make a list of every UIComponent that has a duplicate id, as found
 * in the duplicateIds parameter./*from   w w w  . ja  v a2s .c  o m*/
 *
 * @param comp               UIComponent to recurse down through, searching for
 *                           duplicate ids.
 * @param duplicateIds2comps HashMap< String id, ArrayList<UIComponent> >
 *                           save every UIComponent with one of the
 *                           duplicate ids, so we can list them all
 * @param duplicateIds       ArrayList<String id> duplicate ids encountered
 *                           before
 */
private static void compileDuplicateComponentIds(UIComponent comp, HashMap duplicateIds2comps,
        ArrayList duplicateIds) {
    String id = comp.getId();
    if (id != null && duplicateIds.contains(id)) {
        ArrayList duplicateComps = (ArrayList) duplicateIds2comps.get(id);
        if (duplicateComps == null) {
            duplicateComps = new ArrayList();
            duplicateIds2comps.put(id, duplicateComps);
        }
        duplicateComps.add(comp);
    }
    Iterator children = comp.getFacetsAndChildren();
    while (children.hasNext()) {
        UIComponent child = (UIComponent) children.next();
        compileDuplicateComponentIds(child, duplicateIds2comps, duplicateIds);
    }
}