List of usage examples for java.util List removeAll
boolean removeAll(Collection<?> c);
From source file:gov.nih.nci.ncicb.tcga.dcc.qclive.loader.bamloader.BAMValidator.java
public void validate(final BamXmlResultSet bamXmlResultSet, final BamContext bamContext) { if (bamXmlResultSet != null) { final List<BamXmlResult> bamXmlResultList = bamXmlResultSet.getBamXmlResultList(); if (bamXmlResultList != null && bamXmlResultList.size() > 0) { HashSet<BamXmlResult> blackList = new HashSet<BamXmlResult>(); for (final BamXmlResult bamXmlResult : bamXmlResultList) { validateDisease(bamXmlResult, blackList, bamContext); validateAliquotUuid(bamXmlResult, blackList, bamContext); validateFiles(bamXmlResult, blackList, bamContext); validateAnalyteCode(bamXmlResult, blackList, bamContext); validateCenter(bamXmlResult, blackList, bamContext); }//from www .ja va2 s . co m bamXmlResultList.removeAll(blackList); } else { bamContext.addError(PROCESS, "BAM Data is empty."); } } else { bamContext.addError(PROCESS, "No BAM Data found."); } }
From source file:edu.cmu.tetrad.sem.GeneralizedSemEstimator.java
/** * Maximizes likelihood equation by equation. Assumes the equations are recursive and that * each has exactly one error term.//from ww w . ja va 2 s . c o m */ public GeneralizedSemIm estimate(GeneralizedSemPm pm, DataSet data) { StringBuilder builder = new StringBuilder(); NumberFormat nf = new DecimalFormat("0.0000000"); GeneralizedSemIm estIm = new GeneralizedSemIm(pm); List<Node> nodes = pm.getGraph().getNodes(); nodes.removeAll(pm.getErrorNodes()); MyContext context = new MyContext(); List<List<Double>> allResiduals = new ArrayList<>(); List<RealDistribution> allDistributions = new ArrayList<>(); for (int index = 0; index < nodes.size(); index++) { Node node = nodes.get(index); List<String> parameters = new ArrayList<>(pm.getReferencedParameters(node)); Node error = pm.getErrorNode(node); parameters.addAll(pm.getReferencedParameters(error)); LikelihoodFittingFunction2 likelihoodFittingfunction = new LikelihoodFittingFunction2(index, pm, parameters, nodes, data, context); double[] values = new double[parameters.size()]; for (int j = 0; j < parameters.size(); j++) { String parameter = parameters.get(j); Expression parameterEstimationInitializationExpression = pm .getParameterEstimationInitializationExpression(parameter); values[j] = parameterEstimationInitializationExpression.evaluate(new MyContext()); } double[] point = optimize(likelihoodFittingfunction, values, 1); for (int j = 0; j < parameters.size(); j++) { estIm.setParameterValue(parameters.get(j), point[j]); } List<Double> residuals = likelihoodFittingfunction.getResiduals(); allResiduals.add(residuals); RealDistribution distribution = likelihoodFittingfunction.getDistribution(); allDistributions.add(distribution); GeneralAndersonDarlingTest test = new GeneralAndersonDarlingTest(residuals, distribution); builder.append("\nEquation: " + node + " := " + estIm.getNodeSubstitutedString(node)); builder.append("\n\twhere " + pm.getErrorNode(node) + " ~ " + estIm.getNodeSubstitutedString(pm.getErrorNode(node))); builder.append("\nAnderson Darling A^2* for this equation = " + test.getASquaredStar() + "\n"); } List<String> parameters = new ArrayList<>(); double[] values = new double[parameters.size()]; for (int i = 0; i < parameters.size(); i++) { values[i] = estIm.getParameterValue(parameters.get(i)); } LikelihoodFittingFunction likelihoodFittingFunction = new LikelihoodFittingFunction(pm, parameters, nodes, data, context); optimize(likelihoodFittingFunction, values, 1); StringBuilder builder2 = new StringBuilder(); builder2.append("Report:\n"); MultiGeneralAndersonDarlingTest test = new MultiGeneralAndersonDarlingTest(allResiduals, allDistributions); builder2.append("\nModel A^2* (Anderson Darling) = " + test.getASquaredStar() + "\n"); builder2.append(builder); this.report = builder2.toString(); return estIm; }
From source file:org.openmrs.module.hospitalcore.web.controller.department.DepartmentConceptFormController.java
@RequestMapping(method = RequestMethod.GET) public String firstView( @ModelAttribute("departmentConceptCommand") DepartmentConceptCommand departmentConceptCommand, @RequestParam(value = "dId", required = false) Integer id, Model model) { PatientDashboardService dashboardService = Context.getService(PatientDashboardService.class); List<Department> listDepartment = dashboardService.listDepartment(false); model.addAttribute("listDepartment", listDepartment); if (id != null) { //Department department = dashboardService.getDepartmentById(id); List<DepartmentConcept> listDiagnosisDepartment = dashboardService.listByDepartment(id, DepartmentConcept.TYPES[0]); List<DepartmentConcept> listProcedureDepartment = dashboardService.listByDepartment(id, DepartmentConcept.TYPES[1]); List<Concept> diagnosisList = dashboardService.searchDiagnosis(null); Collections.sort(diagnosisList, new ConceptComparator()); //model.addAttribute("listDiagnosis", diagnosis); List<Concept> procedures = dashboardService.searchProcedure(null); Collections.sort(procedures, new ConceptComparator()); List<Concept> listC = new ArrayList<Concept>(); if (CollectionUtils.isNotEmpty(listDiagnosisDepartment)) { for (DepartmentConcept c : listDiagnosisDepartment) { listC.add(c.getConcept()); }// w ww .j a v a 2 s . c om } diagnosisList.removeAll(listC); listC = new ArrayList<Concept>(); if (CollectionUtils.isNotEmpty(listProcedureDepartment)) { for (DepartmentConcept c : listProcedureDepartment) { listC.add(c.getConcept()); } } procedures.removeAll(listC); //List all department model.addAttribute("listProcedures", procedures); model.addAttribute("diagnosisList", diagnosisList); model.addAttribute("dId", id); model.addAttribute("listDiagnosisDepartment", listDiagnosisDepartment); model.addAttribute("listProcedureDepartment", listProcedureDepartment); } return "/module/hospitalcore/department/departmentConcept"; }
From source file:org.saiku.web.rest.resources.BasicTagRepositoryResource.java
@POST @Produces({ "application/json" }) @Path("/{cubeIdentifier}/{tagname}") public SaikuTag saveTag(@PathParam("tagname") String tagName, @PathParam("cubeIdentifier") String cubeIdentifier, @FormParam("queryname") String queryName, @FormParam("positions") String positions) { try {/*from w ww . j a va 2 s.co m*/ List<List<Integer>> cellPositions = new ArrayList<List<Integer>>(); for (String position : positions.split(",")) { String[] ps = position.split(":"); List<Integer> cellPosition = new ArrayList<Integer>(); for (String p : ps) { Integer pInt = Integer.parseInt(p); cellPosition.add(pInt); } cellPositions.add(cellPosition); } SaikuTag t = olapQueryService.createTag(queryName, tagName, cellPositions); if (repo != null) { List<SaikuTag> tags = getSavedTags(cubeIdentifier); if (!cubeIdentifier.endsWith(".tag")) { cubeIdentifier += ".tag"; } List<SaikuTag> remove = new ArrayList<SaikuTag>(); for (SaikuTag tag : tags) { if (tag.getName().equals(tagName)) { remove.add(tag); } } tags.removeAll(remove); tags.add(t); ObjectMapper om = new ObjectMapper(); om.setVisibilityChecker(om.getVisibilityChecker().withFieldVisibility(Visibility.ANY)); String uri = repo.getName().getPath(); if (!uri.endsWith("" + File.separatorChar)) { uri += File.separatorChar; } File tagFile = new File(uri + URLDecoder.decode(cubeIdentifier, "UTF-8")); if (tagFile.exists()) { tagFile.delete(); } else { tagFile.createNewFile(); } om.writeValue(tagFile, tags); return t; } } catch (Exception e) { log.error("Cannot add tag " + tagName + " for query (" + queryName + ")", e); } return null; }
From source file:com.redhat.rhn.common.localization.LocalizationService.java
/** * Get a SortedMap containing NAME/CODE value pairs. The reason we key the * Map based on the NAME is that we desire to maintain a localized sort * order based on the display value and not the code. * * <pre>/* ww w. j a va 2s . com*/ * {name=Spain, code=ES} * {name=Sri Lanka, code=LK} * {name=Sudan, code=SD} * {name=Suriname, code=SR, } * etc ... * </pre> * * @return SortedMap sorted map of available countries. */ public SortedMap<String, String> availableCountries() { List<String> validCountries = new LinkedList<String>(Arrays.asList(Locale.getISOCountries())); String[] excluded = Config.get().getStringArray(ConfigDefaults.WEB_EXCLUDED_COUNTRIES); if (excluded != null) { validCountries.removeAll(new LinkedList<String>(Arrays.asList(excluded))); } SortedMap<String, String> ret = new TreeMap<String, String>(); for (Iterator<String> iter = validCountries.iterator(); iter.hasNext();) { String isoCountry = iter.next(); ret.put(this.getMessage(isoCountry), isoCountry); } return ret; }
From source file:fr.paris.lutece.portal.web.admin.AdminMenuJspBean.java
/** * Returns an array that contains all feature groups corresponding to the user * * @param user The Admin user//from w w w .j ava 2s. c om * @return An array of FeatureGroup objects */ private List<FeatureGroup> getFeatureGroupsList(AdminUser user) { // structure that will be returned ArrayList<FeatureGroup> aOutFeatureGroupList = new ArrayList<FeatureGroup>(); // get the list of user's features Map<String, Right> featuresMap = user.getRights(); List<Right> features = new ArrayList<Right>(featuresMap.values()); List<Right> rightsToDelete = new ArrayList<Right>(); //delete features which have a null URL : these features does not have to be displayed in the menu for (Right right : features) { if (right.getUrl() == null) { rightsToDelete.add(right); } } features.removeAll(rightsToDelete); Collections.sort(features); // for each group, load the features for (FeatureGroup featureGroup : FeatureGroupHome.getFeatureGroupsList()) { ArrayList<Right> aLeftFeatures = new ArrayList<Right>(); for (Right right : features) { right.setLocale(user.getLocale()); right.setIconUrl(getFeatureIcon(right)); String strFeatureGroup = right.getFeatureGroup(); if (featureGroup.getId().equalsIgnoreCase(strFeatureGroup)) { featureGroup.addFeature(right); } else { aLeftFeatures.add(right); } } if (!featureGroup.isEmpty()) { featureGroup.setLocale(user.getLocale()); aOutFeatureGroupList.add(featureGroup); } features = aLeftFeatures; } // add the features with no group to the last group if (aOutFeatureGroupList.size() > 0) { FeatureGroup lastFeatureGroup = aOutFeatureGroupList.get(aOutFeatureGroupList.size() - 1); for (Right right : features) { lastFeatureGroup.addFeature(right); // FIXME ???? itFeatures.remove( ); } } return aOutFeatureGroupList; }
From source file:com.evolveum.midpoint.model.impl.validator.ResourceValidatorImpl.java
private void checkMissingReactions(ResourceValidationContext ctx, ItemPath path, ObjectSynchronizationType objectSync, Map<SynchronizationSituationType, Integer> counts, Collection<SynchronizationSituationType> situations) { List<SynchronizationSituationType> missing = new ArrayList<>(situations); missing.removeAll(counts.keySet()); if (!missing.isEmpty()) { ctx.validationResult.add(Issue.Severity.INFO, CAT_SYNCHRONIZATION, C_NO_REACTION, getString(ctx.bundle, CLASS_DOT + C_NO_REACTION, getName(objectSync), format(missing)), ctx.resourceRef, path);// w w w . j a va2 s. co m } }
From source file:au.org.ala.delta.intkey.model.SortingUtils.java
/** * Determines best order and separating power of all characters in the * supplied context's dataset/*from www. ja v a 2 s . c om*/ * * @param context * the application's global state * @return a map of characters to their separating powers. The best order of * the characters can be obtained by getting the keyset of the * supplied map */ public static LinkedHashMap<au.org.ala.delta.model.Character, Double> doOrdering(IntkeyContext context, OrderingType orderingType, Item taxonToSeparate) { LinkedHashMap<Character, Double> retMap = new LinkedHashMap<Character, Double>(); IntkeyDataset dataset = context.getDataset(); List<Character> allCharacters = dataset.getCharactersAsList(); final double[] suVals = new double[allCharacters.size()]; double[] sepVals = new double[allCharacters.size()]; double[] charCosts = new double[allCharacters.size()]; for (Character ch : allCharacters) { double charCost = Math.pow(context.getRBase(), 5.0 - Math.min(10.0, ch.getReliability())); charCosts[ch.getCharacterId() - 1] = charCost; } double varw = (1 - context.getVaryWeight()) / Math.max(context.getVaryWeight(), 0.01); // Build list of available characters List<Character> availableCharacters = new ArrayList<Character>(context.getAvailableCharacters()); Collections.sort(availableCharacters); List<Character> ignoredCharacters = new ArrayList<Character>(); for (Character ch : availableCharacters) { // TODO ignore EXACT characters that have been eliminated???? // Ignore character if its reliability is zero if (ch.getReliability() == 0) { ignoredCharacters.add(ch); } // Ignore character if it is a text character if (ch instanceof TextCharacter) { ignoredCharacters.add(ch); } // Ignore real characters if there are no key states // for real characters if (ch instanceof RealCharacter && !context.getDataset().realCharacterKeyStateBoundariesPresent()) { ignoredCharacters.add(ch); } } availableCharacters.removeAll(ignoredCharacters); if (availableCharacters.isEmpty()) { // no available characters, so just return an empty map. return retMap; } // Build list of remaining taxa int numAvailableTaxa = 0; // Put includedTaxa and eliminated taxa into hash sets to speed up // membership lookup Set<Item> includedTaxa = new HashSet<Item>(context.getIncludedTaxa()); Set<Item> eliminatedTaxa = new HashSet<Item>(context.getEliminatedTaxa()); Map<Item, Boolean> taxaAvailability = new HashMap<Item, Boolean>(); for (Item taxon : dataset.getItemsAsList()) { boolean ignore = false; if (eliminatedTaxa.contains(taxon)) { ignore = true; } // skip if taxon is not included if (!includedTaxa.contains(taxon)) { ignore = true; } // TODO skip if there are EXACT characters and this taxon has // been eliminated if (ignore) { taxaAvailability.put(taxon, false); } else { numAvailableTaxa++; taxaAvailability.put(taxon, true); } } if (numAvailableTaxa == 0) { // no taxa are available - return empty map return retMap; } // sort available characters by reliability (descending) Collections.sort(availableCharacters, new ReliabilityComparator()); // minimum cost - this will always be the cost of the available // character with the greatest reliability double cmin = charCosts[availableCharacters.get(0).getCharacterId() - 1]; List<Character> unsuitableCharacters = new ArrayList<Character>(); for (Character ch : availableCharacters) { int sumNumTaxaInSubgroups = 0; double sumSubgroupsFrequencies = 0; int numSubgroupsSameSizeAsOriginalGroup = 0; double sup0 = 0; // theoretical partition component of sup. double dupf = 0; // arbitrary intra-taxon variability component of // sup. double sep = 0; // separating power of the character double sup = 0; // total partition component of su. sup = sup0 + // dupf double su = 0; // character suitability // NOTE: to simplify the algorithm, all characters are treated as // multistate characters. Integer and real // characters are converted into multistate representations. // Determine the total available states for each character int totalNumStates = 0; if (ch instanceof MultiStateCharacter) { totalNumStates = ((MultiStateCharacter) ch).getNumberOfStates(); } else if (ch instanceof IntegerCharacter) { // for an integer character, 1 state for each value between // the minimum and // maximum (inclusive), 1 state for all values below the // minimum, and 1 state for // all values above the maximum IntegerCharacter intChar = (IntegerCharacter) ch; totalNumStates = intChar.getMaximumValue() - intChar.getMinimumValue() + 3; } else if (ch instanceof RealCharacter) { // the real character's key state boundaries are used to convert // a real value into a // multistate value (see below). The total number of possible // states is equal to the number of // key state boundaries. totalNumStates = ((RealCharacter) ch).getKeyStateBoundaries().size(); } else { throw new RuntimeException("Invalid character type " + ch.toString()); } // number of taxa in character subgroups int[] subgroupsNumTaxa = new int[totalNumStates]; // frequency of character subgroups double[] subgroupFrequencies = new double[totalNumStates]; List<Attribute> charAttributes = dataset.getAllAttributesForCharacter(ch.getCharacterId()); // examine taxon to be diagnosed or separated first boolean[] taxonToSeparateStatePresence = new boolean[totalNumStates]; int ndgSum = 1; if (orderingType == OrderingType.SEPARATE || orderingType == OrderingType.DIAGNOSE) { Attribute attr = charAttributes.get(taxonToSeparate.getItemNumber() - 1); if (attr.isUnknown() && attr.isInapplicable()) { unsuitableCharacters.add(ch); continue; } taxonToSeparateStatePresence = getStatePresenceForAttribute(attr, totalNumStates, orderingType, context.getDiagType()).getFirst(); } for (Attribute attr : charAttributes) { Item taxon = attr.getItem(); // Skip any attributes that pertain to taxa that are not // available if (!taxaAvailability.get(taxon)) { continue; } Pair<boolean[], Integer> statePresencePair = getStatePresenceForAttribute(attr, totalNumStates, orderingType, context.getDiagType()); boolean[] statePresence = statePresencePair.getFirst(); int numStatesPresent = statePresencePair.getSecond(); if (orderingType == OrderingType.BEST) { // work out size of character subgroups. for (int i = 0; i < totalNumStates; i++) { if (statePresence[i] == true) { subgroupsNumTaxa[i]++; // frequency of items with current state of current // character double stateFrequency = 1.0 / (double) numStatesPresent; stateFrequency += subgroupFrequencies[i]; subgroupFrequencies[i] = stateFrequency; } } } else { for (int i = 0; i < totalNumStates; i++) { if (statePresence[i] == true) { subgroupsNumTaxa[i]++; } } if (!taxon.equals(taxonToSeparate)) { for (int i = 0; i < totalNumStates; i++) { if (statePresence[i] && taxonToSeparateStatePresence[i]) { ndgSum++; break; } } } } } if (orderingType == OrderingType.BEST) { // total number of non-empty character subgroups int totalNumSubgroups = 0; // work out sum of subgroup sizes and frequencies for (int i = 0; i < totalNumStates; i++) { sumNumTaxaInSubgroups += subgroupsNumTaxa[i]; sumSubgroupsFrequencies += subgroupFrequencies[i]; if (subgroupsNumTaxa[i] > 0) { totalNumSubgroups++; } } for (int i = 0; i < totalNumStates; i++) { int numTaxaInSubgroup = subgroupsNumTaxa[i]; if (numTaxaInSubgroup == sumNumTaxaInSubgroups) { // character is unsuitable if it divides the characters // into a // single // subgroup unsuitableCharacters.add(ch); continue; } else { if (numTaxaInSubgroup == numAvailableTaxa) { numSubgroupsSameSizeAsOriginalGroup++; } if (subgroupsNumTaxa[i] > 0) { sup0 += (subgroupFrequencies[i] * log2(subgroupsNumTaxa[i])); } } } boolean isControllingChar = !ch.getDependentCharacters().isEmpty(); // TODO what is this test for??? if (!isControllingChar && (totalNumSubgroups == numSubgroupsSameSizeAsOriginalGroup || (sumNumTaxaInSubgroups > numAvailableTaxa && numSubgroupsSameSizeAsOriginalGroup == totalNumStates))) { unsuitableCharacters.add(ch); continue; } sup0 = sup0 / sumSubgroupsFrequencies; if (numAvailableTaxa > 1 && sumNumTaxaInSubgroups > numAvailableTaxa) { dupf = varw * (1 + 100 * numSubgroupsSameSizeAsOriginalGroup) * (sumNumTaxaInSubgroups - numAvailableTaxa) * ((numAvailableTaxa + 8) / (numAvailableTaxa * log2(numAvailableTaxa))); } else { dupf = 0; } sep = -sup0 + log2(numAvailableTaxa); // handle rounding errors if (Math.abs(sep) <= minimumSeparatingPower) { sep = 0.0; } // don't display controlling characters with 0 separation if (isControllingChar && sep == 0) { unsuitableCharacters.add(ch); continue; } sup = sup0 + dupf; } else { // SEPARATE or DIAGNOSE // total number of non-empty character subgroups int totalNumSubgroups = 0; for (int i = 0; i < totalNumStates; i++) { sumNumTaxaInSubgroups += subgroupsNumTaxa[i]; if (subgroupsNumTaxa[i] > 0) { totalNumSubgroups++; } } for (int i = 0; i < totalNumStates; i++) { int numTaxaInSubgroup = subgroupsNumTaxa[i]; // character is unsuitable if it divides the characters into // a // single // subgroup if (numTaxaInSubgroup == sumNumTaxaInSubgroups) { unsuitableCharacters.add(ch); continue; } else { if (numTaxaInSubgroup == numAvailableTaxa) { numSubgroupsSameSizeAsOriginalGroup++; } } } // TODO what is this test for??? if (orderingType == OrderingType.DIAGNOSE && (totalNumSubgroups == numSubgroupsSameSizeAsOriginalGroup || (sumNumTaxaInSubgroups > numAvailableTaxa && numSubgroupsSameSizeAsOriginalGroup == totalNumStates))) { unsuitableCharacters.add(ch); continue; } sup0 = log2(ndgSum); sep = -sup0 + log2(numAvailableTaxa); // handle rounding errors if (Math.abs(sep) <= minimumSeparatingPower) { sep = 0.0; } // for DIAGNOSE, characters with zero separation are ignored if (sep <= 0.0 && orderingType == OrderingType.DIAGNOSE) { unsuitableCharacters.add(ch); continue; } sup = sup0; } su = charCosts[ch.getCharacterId() - 1] + cmin * sup; sepVals[ch.getCharacterId() - 1] = sep; suVals[ch.getCharacterId() - 1] = su; } availableCharacters.removeAll(unsuitableCharacters); List<Character> sortedChars = new ArrayList<Character>(availableCharacters); Collections.sort(sortedChars, new Comparator<Character>() { @Override public int compare(Character c1, Character c2) { double suValC1 = suVals[c1.getCharacterId() - 1]; double suValC2 = suVals[c2.getCharacterId() - 1]; if (suValC1 == suValC2) { return Integer.valueOf(c1.getCharacterId()).compareTo(Integer.valueOf(c2.getCharacterId())); } else { return Double.valueOf(suValC1).compareTo(Double.valueOf(suValC2)); } } }); for (Character ch : sortedChars) { retMap.put(ch, sepVals[ch.getCharacterId() - 1]); } return retMap; }
From source file:com.opengamma.component.factory.livedata.PriorityResolvingCombiningLiveDataServerComponentFactory.java
/** * Builds the list of server infos.// w w w . j a va 2 s .c o m * * @return the server list, not null */ protected List<ComponentInfo> buildInfoList() { List<ComponentInfo> infos = Lists.newArrayList(); infos.add(getServer1()); infos.add(getServer2()); infos.add(getServer3()); infos.add(getServer4()); infos.add(getServer5()); infos.add(getServer6()); infos.removeAll(Collections.singleton(null)); return infos; }
From source file:cn.guoyukun.spring.jpa.plugin.web.controller.BaseTreeableController.java
@RequestMapping(value = "tree", method = RequestMethod.GET) @PageableDefaults(sort = { "parentIds=asc", "weight=asc" }) public String tree(HttpServletRequest request, @RequestParam(value = "searchName", required = false) String searchName, @RequestParam(value = "async", required = false, defaultValue = "false") boolean async, Searchable searchable, Model model) { if (permissionList != null) { permissionList.assertHasViewPermission(); }//from w ww. j ava 2s. c o m List<M> models = null; if (!StringUtils.isEmpty(searchName)) { searchable.addSearchParam("name_like", searchName); models = baseService.findAllByName(searchable, null); if (!async) { //? ?? searchable.removeSearchFilter("name_like"); List<M> children = baseService.findChildren(models, searchable); models.removeAll(children); models.addAll(children); } else { //?? } } else { if (!async) { //? ?? models = baseService.findAllWithSort(searchable); } else { //?? models = baseService.findRootAndChild(searchable); } } model.addAttribute("trees", convertToZtreeList(request.getContextPath(), models, async, true)); return viewName("tree"); }