List of usage examples for java.util Map values
Collection<V> values();
From source file:edu.msu.cme.rdp.graph.utils.ContigMerger.java
private static List<MergedContig> mergeAllContigs(Map<String, Sequence> leftContigs, Map<String, Sequence> rightContigs, String kmer, String gene, ProfileHMM hmm) { List<MergedContig> ret = new ArrayList(); int k = kmer.length(); for (Sequence leftContig : leftContigs.values()) { String leftSeq = leftContig.getSeqString(); leftSeq = leftSeq.substring(0, leftSeq.length() - k); for (Sequence rightContig : rightContigs.values()) { String seq = leftSeq + rightContig.getSeqString(); MergedContig mergedContig = new MergedContig(); if (hmm.getAlphabet() == SequenceType.Protein) { mergedContig.nuclSeq = seq; seq = mergedContig.protSeq = ProteinUtils.getInstance().translateToProtein(seq, true, 11); } else if (hmm.getAlphabet() == SequenceType.Nucleotide) { mergedContig.nuclSeq = seq; } else { throw new IllegalStateException("Cannot handle hmm alpha " + hmm.getAlphabet()); }/* ww w .j av a2s . c om*/ mergedContig.score = ForwardScorer.scoreSequence(hmm, seq); mergedContig.leftContig = leftContig.getSeqName(); mergedContig.rightContig = rightContig.getSeqName(); mergedContig.length = seq.length(); mergedContig.gene = gene; ret.add(mergedContig); } } return ret; }
From source file:it.unibas.spicy.model.mapping.operators.GenerateCandidateSTTGDs.java
public static List<SetAlias> findVariablesInPaths(List<VariablePathExpression> pathExpressions) { Map<SetAlias, SetAlias> map = new HashMap<SetAlias, SetAlias>(); for (VariablePathExpression pathExpression : pathExpressions) { SetAlias pathVariable = pathExpression.getStartingVariable(); map.put(pathVariable, pathVariable); }//from ww w . j a v a2 s.c o m List<SetAlias> result = new ArrayList<SetAlias>(map.values()); Collections.sort(result); return result; }
From source file:com.sunchenbin.store.feilong.core.util.MapUtil.java
/** * map,keys,? value ?.//from w w w .j a v a 2 s. c om * * @param <K> * the key type * @param <T> * the generic type * @param map * map * @param keys * key * @return keys key ? map ,null * @see java.util.Collection#toArray() * @see java.util.Arrays#sort(Object[]) */ @SuppressWarnings("unchecked") public static <K, T extends Number> T getMinValue(Map<K, T> map, K[] keys) { Map<K, T> subMap = getSubMap(map, keys); if (null == subMap) { return null; } Collection<T> values = subMap.values(); Object[] array = values.toArray(); Arrays.sort(array); return (T) array[0]; }
From source file:ca.sfu.federation.utils.IContextUtils.java
public static Map<String, INamed> getDependancies(Map<String, INamed> ElementMap) { // init/*from w w w .ja v a2s. c o m*/ LinkedHashMap<String, INamed> results = new LinkedHashMap<String, INamed>(); HashSet dependancies = new HashSet(); // scenario dependancies come from contextual object references Iterator iter = ElementMap.values().iterator(); while (iter.hasNext()) { INamed named = (INamed) iter.next(); dependancies.add(named.getContext()); } // convert set to map iter = dependancies.iterator(); while (iter.hasNext()) { INamed named = (INamed) iter.next(); results.put(named.getName(), named); } // return result return results; }
From source file:Maps.java
public static <K, V> Map<K, V> put(Map<K, V> map, K key, V value) { switch (map.size()) { case 0:/*from ww w . jav a2s . c o m*/ // Empty -> Singleton return Collections.singletonMap(key, value); case 1: { if (map.containsKey(key)) { return create(key, value); } // Singleton -> HashMap Map<K, V> result = new HashMap<K, V>(); result.put(map.keySet().iterator().next(), map.values().iterator().next()); result.put(key, value); return result; } default: // HashMap map.put(key, value); return map; } }
From source file:org.oncoblocks.centromere.web.controller.RequestUtils.java
/** * Inspects a {@link Model} class and returns all of the available and acceptable query parameter * definitions, as a map of parameter names and {@link QueryParameterDescriptor} objects. * // w w w . j a va 2s .c o m * @param model * @return */ public static Map<String, QueryParameterDescriptor> getAvailableQueryParameters(Class<? extends Model<?>> model, boolean recursive) { Map<String, QueryParameterDescriptor> paramMap = new HashMap<>(); for (Field field : model.getDeclaredFields()) { String fieldName = field.getName(); Class<?> type = field.getType(); if (Collection.class.isAssignableFrom(field.getType())) { ParameterizedType parameterizedType = (ParameterizedType) field.getGenericType(); type = (Class<?>) parameterizedType.getActualTypeArguments()[0]; } if (field.isAnnotationPresent(Ignored.class)) { continue; } else { paramMap.put(fieldName, new QueryParameterDescriptor(fieldName, fieldName, type, Evaluation.EQUALS)); } if (field.isAnnotationPresent(ForeignKey.class)) { if (!recursive) continue; ForeignKey foreignKey = field.getAnnotation(ForeignKey.class); String relField = !"".equals(foreignKey.rel()) ? foreignKey.rel() : fieldName; Map<String, QueryParameterDescriptor> foreignModelMap = getAvailableQueryParameters( foreignKey.model(), false); for (QueryParameterDescriptor descriptor : foreignModelMap.values()) { String newParamName = relField + "." + descriptor.getParamName(); descriptor.setParamName(newParamName); paramMap.put(newParamName, descriptor); } } if (field.isAnnotationPresent(Aliases.class)) { Aliases aliases = field.getAnnotation(Aliases.class); for (Alias alias : aliases.value()) { paramMap.put(alias.value(), new QueryParameterDescriptor(alias.value(), alias.fieldName().equals("") ? fieldName : alias.fieldName(), type, alias.evaluation())); } } else if (field.isAnnotationPresent(Alias.class)) { Alias alias = field.getAnnotation(Alias.class); paramMap.put(alias.value(), new QueryParameterDescriptor(alias.value(), alias.fieldName().equals("") ? fieldName : alias.fieldName(), type, alias.evaluation())); } } return paramMap; }
From source file:org.zenoss.zep.impl.PluginServiceImpl.java
/** * Sorts plug-ins in the order of their dependencies, so all dependencies * come before the plug-in which depends on them. * * @param <T>/*from w w w. j a va 2 s .c om*/ * The type of {@link EventPlugin}. * @param plugins * Map of plug-ins keyed by the plug-in ID. * @return A sorted list of plug-ins in order based on their dependencies. */ static <T extends EventPlugin> List<T> sortPluginsByDependencies(Map<String, T> plugins) { List<T> sorted = new ArrayList<T>(plugins.size()); Map<String, T> mutablePlugins = new HashMap<String, T>(plugins); while (!mutablePlugins.isEmpty()) { for (Iterator<T> it = mutablePlugins.values().iterator(); it.hasNext();) { T plugin = it.next(); boolean allDependenciesResolved = true; final Set<String> pluginDependencies = plugin.getDependencies(); if (pluginDependencies != null) { for (String dep : pluginDependencies) { T depPlugin = mutablePlugins.get(dep); if (depPlugin != null) { allDependenciesResolved = false; break; } } } if (allDependenciesResolved) { sorted.add(plugin); it.remove(); } } } return sorted; }
From source file:eu.itesla_project.modules.rules.CheckSecurityTool.java
private static void writeCsv2(Map<String, Map<SecurityIndexId, SecurityRuleCheckStatus>> checkStatusPerBaseCase, Path outputCsvFile) throws IOException { Objects.requireNonNull(outputCsvFile); Set<SecurityIndexId> securityIndexIds = new LinkedHashSet<>(); for (Map<SecurityIndexId, SecurityRuleCheckStatus> checkStatus : checkStatusPerBaseCase.values()) { securityIndexIds.addAll(checkStatus.keySet()); }/* www . j a va 2 s . co m*/ try (BufferedWriter writer = Files.newBufferedWriter(outputCsvFile, StandardCharsets.UTF_8)) { writer.write("Base case"); for (SecurityIndexId securityIndexId : securityIndexIds) { writer.write(CSV_SEPARATOR); writer.write(securityIndexId.toString()); } writer.newLine(); for (Map.Entry<String, Map<SecurityIndexId, SecurityRuleCheckStatus>> entry : checkStatusPerBaseCase .entrySet()) { String baseCaseName = entry.getKey(); writer.write(baseCaseName); Map<SecurityIndexId, SecurityRuleCheckStatus> checkStatus = entry.getValue(); for (SecurityIndexId securityIndexId : securityIndexIds) { writer.write(CSV_SEPARATOR); SecurityRuleCheckStatus status = checkStatus.get(securityIndexId); writer.write(status.name()); } writer.newLine(); } } }
From source file:playground.johannes.socialnets.GraphStatistics.java
/** * @deprecated//from w w w . j a va 2 s.co m */ public static double averagePathLength(Graph g) { Map values = edu.uci.ics.jung.statistics.GraphStatistics.averageDistances(g); double sum = 0; for (Object d : values.values()) { sum += (Double) d; } return sum / (double) values.size(); }
From source file:org.matsim.contrib.drt.analysis.DynModeTripsAnalyser.java
public static double getTotalDistance(Map<Id<Vehicle>, double[]> vehicleDistances) { DescriptiveStatistics driven = new DescriptiveStatistics(); for (double[] dist : vehicleDistances.values()) { driven.addValue(dist[0]);/*from ww w . ja v a2s. c o m*/ } return driven.getSum(); }