List of usage examples for java.util Set retainAll
boolean retainAll(Collection<?> c);
From source file:edu.cornell.med.icb.geo.tools.MicroarrayTrainEvaluate.java
public static Table filterColumnsForTask(final Table source, final List<Set<String>> labelValueGroups, final String identifierColumnName, Set<String> reduction) throws TypeMismatchException, InvalidColumnException { final Table result = source.copy(); // 1. filter out columns were label is not defined. final Set<String> keepSet = new HashSet<String>(); for (final Set<String> labelGroup : labelValueGroups) { // if label value is in a label group, keep this column keepSet.addAll(labelGroup);/*from ww w . j a va 2 s .co m*/ } keepSet.add(identifierColumnName); // keep only those samples also in reduction: reduction.add(identifierColumnName); keepSet.retainAll(reduction); filterColumns(result, keepSet); return result; }
From source file:ubic.BAMSandAllen.MatrixPairs.LiteratureSpaceMatrixPair.java
public LiteratureSpaceMatrixPair(boolean logDistance) throws Exception { // only ABA has space coordinates super(Nomenclature.ABA); try {//www .ja va2s . c o m AllenAtlasAnnotationLoader spaceLoader = new AllenAtlasAnnotationLoader(); String matrixAname = "EuclidianDistance"; AdjacencyCompute adjacencyCompute = null; if (logDistance) { adjacencyCompute = new LogEuclidAdjacency(); matrixAname = "Log" + matrixAname; } else { adjacencyCompute = new EuclidAdjacency(); } matrixA = new ABAMSDataMatrix(spaceLoader.getCenterMatrix(), matrixAname, adjacencyCompute); StructureCatalogLoader loader = new StructureCatalogLoader(); Set<String> leafs = loader.getLeafs(); leafs.retainAll(matrixA.getColNames()); // just the leafs matrixA = matrixA.retainColumns(leafs); } catch (Exception e) { e.printStackTrace(); System.exit(1); } }
From source file:KnowledgeBooksNlpGenerateRdfPropertiesFromWebPages.java
private float score_mapset(Set<String> set_1, Set<String> set_2) { set_1.retainAll(set_2); // replace contents of set_1 with intersection of set_1 and set_2 return set_1.size(); }
From source file:org.wso2.carbon.registry.search.services.utils.AdvancedSearchResultsBeanPopulator.java
private static String[] getQueryResult(Registry configSystemRegistry, UserRegistry registry, String[][] propertyNameValues) throws Exception { AdvancedResourceQuery query = new AdvancedResourceQuery(); Map<String, String> customValues = new HashMap<String, String>(); for (String[] propertyNameValue : propertyNameValues) { if (propertyNameValue[0].equals("resourcePath")) { query.setResourceName(propertyNameValue[1]); } else if (propertyNameValue[0].equals("author")) { query.setAuthorName(propertyNameValue[1]); } else if (propertyNameValue[0].equals("updater")) { query.setUpdaterName(propertyNameValue[1]); } else if (propertyNameValue[0].equals("createdAfter")) { query.setCreatedAfter(CommonUtil.computeDate(propertyNameValue[1])); } else if (propertyNameValue[0].equals("createdBefore")) { query.setCreatedBefore(addOneDay(CommonUtil.computeDate(propertyNameValue[1]))); } else if (propertyNameValue[0].equals("updatedAfter")) { query.setUpdatedAfter(CommonUtil.computeDate(propertyNameValue[1])); } else if (propertyNameValue[0].equals("updatedBefore")) { query.setUpdatedBefore(addOneDay(CommonUtil.computeDate(propertyNameValue[1]))); } else if (propertyNameValue[0].equals("commentWords")) { query.setCommentWords(propertyNameValue[1]); } else if (propertyNameValue[0].equals("associationType")) { query.setAssociationType(propertyNameValue[1]); } else if (propertyNameValue[0].equals("associationDest")) { query.setAssociationDest(propertyNameValue[1]); } else if (propertyNameValue[0].equals("tags")) { query.setTags(propertyNameValue[1]); } else if (propertyNameValue[0].equals("propertyName")) { query.setPropertyName(propertyNameValue[1]); } else if (propertyNameValue[0].equals("leftPropertyValue")) { query.setLeftPropertyValue(propertyNameValue[1]); } else if (propertyNameValue[0].equals("rightPropertyValue")) { query.setRightPropertyValue(propertyNameValue[1]); } else if (propertyNameValue[0].equals("propertyValue")) { query.setRightPropertyValue(propertyNameValue[1]); query.setRightOp("eq"); } else if (propertyNameValue[0].equals("authorNameNegate")) { query.setAuthorNameNegate(propertyNameValue[1]); } else if (propertyNameValue[0].equals("updaterNameNegate")) { query.setUpdaterNameNegate(propertyNameValue[1]); } else if (propertyNameValue[0].equals("createdRangeNegate")) { query.setCreatedRangeNegate(propertyNameValue[1]); } else if (propertyNameValue[0].equals("updatedRangeNegate")) { query.setUpdatedRangeNegate(propertyNameValue[1]); } else if (propertyNameValue[0].equals("leftOp")) { query.setLeftOp(propertyNameValue[1]); } else if (propertyNameValue[0].equals("rightOp")) { query.setRightOp(propertyNameValue[1]); } else if (propertyNameValue[0].equals("content")) { query.setContent(propertyNameValue[1]); } else if (propertyNameValue[0].equals("mediaType")) { query.setMediaType(propertyNameValue[1]); } else if (propertyNameValue[0].equals("mediaTypeNegate")) { query.setMediaTypeNegate(propertyNameValue[1]); } else {/*from w w w . j a v a 2 s .c o m*/ customValues.put(propertyNameValue[0], propertyNameValue[1]); } } boolean first = true, noCustomSearch = true; Set<String> s = new HashSet<String>(); for (Map.Entry<String, String> entry : customValues.entrySet()) { if (!entry.getValue().equals("")) { Map<String, String> temp = new HashMap<String, String>(); temp.put(entry.getKey(), entry.getValue()); query.setCustomSearchValues(temp); Resource qResults = query.execute(configSystemRegistry, registry); if (((String[]) qResults.getContent()).length > 0) { if (first) { s.addAll(Arrays.asList((String[]) qResults.getContent())); first = false; } else { s.retainAll(Arrays.asList((String[]) qResults.getContent())); } } else { s.clear(); return new String[0]; } noCustomSearch = false; } } if (noCustomSearch) { query.setCustomSearchValues(customValues); Resource qResults = query.execute(configSystemRegistry, registry); return (String[]) qResults.getContent(); } String[] ret = new String[s.size()]; ret = s.toArray(ret); return ret; }
From source file:ubic.BAMSandAllen.Top50Analyze.java
public Set<String> getSharedGenes(OntClass a, OntClass b) { Set<String> result = getTop50Genes(a); result.retainAll(getTop50Genes(b)); return result; }
From source file:edu.cornell.mannlib.vitro.webapp.modelaccess.ontmodels.JoinedOntModelCache.java
public JoinedOntModelCache(OntModelCache primary, OntModelCache secondary) { this.primary = primary; this.secondary = secondary; Set<String> duplicateNames = new HashSet<>(primary.getModelNames()); duplicateNames.retainAll(secondary.getModelNames()); if (!duplicateNames.isEmpty()) { log.warn("These model names appear in both caches: " + duplicateNames); }/*from w w w . j av a 2 s . c o m*/ }
From source file:org.eel.kitchen.jsonschema.syntax.SyntaxValidator.java
/** * Validate one schema// www .j a v a 2 s .com * * @param messages the list of messages to fill in the event of a failure * @param schema the schema to analyze */ public void validate(final List<Message> messages, final JsonNode schema) { if (!schema.isObject()) { final Message message = Domain.SYNTAX.newMessage().setKeyword("N/A") .setMessage("illegal JSON Schema: not an object").addInfo("found", NodeType.getNodeType(schema)) .build(); messages.add(message); return; } final Set<String> keywords = JacksonUtils.fieldNames(schema); keywords.retainAll(checkers.keySet()); Message.Builder msg; SyntaxChecker checker; for (final String keyword : keywords) { msg = Domain.SYNTAX.newMessage().setKeyword(keyword); checker = checkers.get(keyword); checker.checkSyntax(msg, messages, schema); } }
From source file:net.recommenders.rival.evaluation.statistics.StandardError.java
/** * Implements equation (8.13) from "Elementary Statistics: A Problem Solving * Approach 4th Edition", Andrew L. Comrey, Howard B. Lee * * @return the standard error as the ratio of the standard deviation divided * by the sqrt(number of users) of the distribution of difference scores. *///from www . j a v a 2s. c om public double getStandardError() { Set<V> overlap = new HashSet<V>(baselineMetricPerDimension.keySet()); overlap.retainAll(testMetricPerDimension.keySet()); // paired or matched samples --> analyse distribution of difference scores SummaryStatistics differences = new SummaryStatistics(); for (V key : overlap) { double diff = baselineMetricPerDimension.get(key) - testMetricPerDimension.get(key); differences.addValue(diff); } double e = differences.getStandardDeviation() / Math.sqrt(differences.getN()); return e; }
From source file:se.uu.it.cs.recsys.constraint.builder.ScheduleDomainBuilder.java
/** * For period 1 to 6. Periods 5, 6 are considered to have same domain as 1, * 2 respectively./*from w ww. j a va 2s .c o m*/ * * @param interestedCourseIdSet * @param periodsInfo * @return SetDomain for the 6 study periods */ public Map<Integer, SetDomain> createScheduleSetDomainsFor(Set<Integer> interestedCourseIdSet, Set<CourseSchedule> periodsInfo) { return getStartPeriodAndIdSetMapping(periodsInfo).entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, entry -> { Set<Integer> planedCourseIdSet = entry.getValue(); planedCourseIdSet.retainAll(interestedCourseIdSet);//get intersection return planedCourseIdSet.isEmpty() ? SetDomain.emptyDomain : DomainBuilder.createDomain(planedCourseIdSet); })); }
From source file:com.opengamma.integration.tool.marketdata.HtsSyncTool.java
private Set<String> filterClassifiers(Set<String> srcMasterClassifiers, Set<String> destMasterClassifiers) { Set<String> commonComponentNames = Sets.newLinkedHashSet(); commonComponentNames.addAll(srcMasterClassifiers); commonComponentNames.retainAll(destMasterClassifiers); if (getCommandLine().hasOption("classifiers")) { List<String> classifiersList = Arrays.asList(getCommandLine().getOptionValues("classifiers")); Set<String> classifiers = Sets.newHashSet(); classifiers.addAll(classifiersList); classifiers.removeAll(classifiers); if (classifiers.size() > 0) { System.err.println("Couldn't find classifiers: " + classifiers.toString() + ", skipping those"); }/*from ww w .j av a 2 s . c o m*/ classifiers.clear(); classifiers.addAll(classifiersList); commonComponentNames.retainAll(classifiers); } return commonComponentNames; }