List of usage examples for org.apache.commons.lang ArrayUtils toObject
public static Boolean[] toObject(boolean[] array)
Converts an array of primitive booleans to objects.
From source file:org.apereo.portal.tools.dbloader.DataXmlHandler.java
protected final void doInsert() { if (this.rowData.size() == 0) { this.logger .warn("Found a row with no data for table " + this.currentTable + ", the row will be ignored"); return;//from w w w . j av a 2s . c om } final Map<String, Integer> columnInfo = this.tableColumnInfo.get(this.currentTable); final StringBuilder columns = new StringBuilder(); final StringBuilder parameters = new StringBuilder(); final Object[] values = new Object[this.rowData.size()]; final int[] types = new int[this.rowData.size()]; int index = 0; for (final Iterator<Entry<String, String>> rowIterator = this.rowData.entrySet().iterator(); rowIterator .hasNext();) { final Entry<String, String> row = rowIterator.next(); final String columnName = row.getKey(); columns.append(columnName); parameters.append("?"); values[index] = row.getValue(); types[index] = columnInfo.get(columnName); if (rowIterator.hasNext()) { columns.append(", "); parameters.append(", "); } index++; } final String sql = "INSERT INTO " + this.currentTable + " (" + columns + ") VALUES (" + parameters + ")"; if (this.logger.isInfoEnabled()) { this.logger.info(sql + "\t" + Arrays.asList(values) + "\t" + Arrays.asList(ArrayUtils.toObject(types))); } this.transactionOperations.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { jdbcOperations.update(sql, values, types); } }); }
From source file:org.broadinstitute.gatk.tools.walkers.variantrecalibration.VariantDataManager.java
public void normalizeData() { boolean foundZeroVarianceAnnotation = false; for (int iii = 0; iii < meanVector.length; iii++) { final double theMean = mean(iii, true); final double theSTD = standardDeviation(theMean, iii, true); logger.info(annotationKeys.get(iii) + String.format(": \t mean = %.2f\t standard deviation = %.2f", theMean, theSTD)); if (Double.isNaN(theMean)) { throw new UserException.BadInput("Values for " + annotationKeys.get(iii) + " annotation not detected for ANY training variant in the input callset. VariantAnnotator may be used to add these annotations."); }/*from w w w .j a v a2 s. c o m*/ foundZeroVarianceAnnotation = foundZeroVarianceAnnotation || (theSTD < 1E-5); meanVector[iii] = theMean; varianceVector[iii] = theSTD; for (final VariantDatum datum : data) { // Transform each data point via: (x - mean) / standard deviation datum.annotations[iii] = (datum.isNull[iii] ? 0.1 * Utils.getRandomGenerator().nextGaussian() : (datum.annotations[iii] - theMean) / theSTD); } } if (foundZeroVarianceAnnotation) { throw new UserException.BadInput( "Found annotations with zero variance. They must be excluded before proceeding."); } // trim data by standard deviation threshold and mark failing data for exclusion later for (final VariantDatum datum : data) { boolean remove = false; for (final double val : datum.annotations) { remove = remove || (Math.abs(val) > VRAC.STD_THRESHOLD); } datum.failingSTDThreshold = remove; } // re-order the data by increasing standard deviation so that the results don't depend on the order things were specified on the command line // standard deviation over the training points is used as a simple proxy for information content, perhaps there is a better thing to use here final List<Integer> theOrder = calculateSortOrder(meanVector); annotationKeys = reorderList(annotationKeys, theOrder); varianceVector = ArrayUtils.toPrimitive(reorderArray(ArrayUtils.toObject(varianceVector), theOrder)); meanVector = ArrayUtils.toPrimitive(reorderArray(ArrayUtils.toObject(meanVector), theOrder)); for (final VariantDatum datum : data) { datum.annotations = ArrayUtils .toPrimitive(reorderArray(ArrayUtils.toObject(datum.annotations), theOrder)); datum.isNull = ArrayUtils.toPrimitive(reorderArray(ArrayUtils.toObject(datum.isNull), theOrder)); } logger.info("Annotations are now ordered by their information content: " + annotationKeys.toString()); }
From source file:org.broadinstitute.sting.gatk.walkers.variantrecalibration.VariantDataManager.java
public void normalizeData() { boolean foundZeroVarianceAnnotation = false; for (int iii = 0; iii < meanVector.length; iii++) { final double theMean = mean(iii, true); final double theSTD = standardDeviation(theMean, iii, true); logger.info(annotationKeys.get(iii) + String.format(": \t mean = %.2f\t standard deviation = %.2f", theMean, theSTD)); if (Double.isNaN(theMean)) { throw new UserException.BadInput("Values for " + annotationKeys.get(iii) + " annotation not detected for ANY training variant in the input callset. VariantAnnotator may be used to add these annotations. See " + HelpConstants.forumPost("discussion/49/using-variant-annotator")); }/* w ww. ja v a 2 s. c o m*/ foundZeroVarianceAnnotation = foundZeroVarianceAnnotation || (theSTD < 1E-5); meanVector[iii] = theMean; varianceVector[iii] = theSTD; for (final VariantDatum datum : data) { // Transform each data point via: (x - mean) / standard deviation datum.annotations[iii] = (datum.isNull[iii] ? 0.1 * GenomeAnalysisEngine.getRandomGenerator().nextGaussian() : (datum.annotations[iii] - theMean) / theSTD); } } if (foundZeroVarianceAnnotation) { throw new UserException.BadInput( "Found annotations with zero variance. They must be excluded before proceeding."); } // trim data by standard deviation threshold and mark failing data for exclusion later for (final VariantDatum datum : data) { boolean remove = false; for (final double val : datum.annotations) { remove = remove || (Math.abs(val) > VRAC.STD_THRESHOLD); } datum.failingSTDThreshold = remove; } // re-order the data by increasing standard deviation so that the results don't depend on the order things were specified on the command line // standard deviation over the training points is used as a simple proxy for information content, perhaps there is a better thing to use here final List<Integer> theOrder = calculateSortOrder(meanVector); annotationKeys = reorderList(annotationKeys, theOrder); varianceVector = ArrayUtils.toPrimitive(reorderArray(ArrayUtils.toObject(varianceVector), theOrder)); meanVector = ArrayUtils.toPrimitive(reorderArray(ArrayUtils.toObject(meanVector), theOrder)); for (final VariantDatum datum : data) { datum.annotations = ArrayUtils .toPrimitive(reorderArray(ArrayUtils.toObject(datum.annotations), theOrder)); datum.isNull = ArrayUtils.toPrimitive(reorderArray(ArrayUtils.toObject(datum.isNull), theOrder)); } logger.info("Annotations are now ordered by their information content: " + annotationKeys.toString()); }
From source file:org.carbondata.core.reader.sortindex.CarbonDictionarySortIndexReaderImplTest.java
/** * Test to read the data from dictionary sort index file * * @throws Exception//from w ww . j ava 2 s . c o m */ @Test public void read() throws Exception { deleteStorePath(); CarbonTableIdentifier carbonTableIdentifier = new CarbonTableIdentifier("testSchema", "carbon"); CarbonDictionarySortIndexWriter dictionarySortIndexWriter = new CarbonDictionarySortIndexWriterImpl( carbonTableIdentifier, "Name", hdfsStorePath); List<int[]> expectedData = prepareExpectedData(); List<Integer> sortIndex = Arrays.asList(ArrayUtils.toObject(expectedData.get(0))); List<Integer> invertedSortIndex = Arrays.asList(ArrayUtils.toObject(expectedData.get(1))); dictionarySortIndexWriter.writeSortIndex(sortIndex); dictionarySortIndexWriter.writeInvertedSortIndex(invertedSortIndex); dictionarySortIndexWriter.close(); CarbonDictionarySortIndexReader dictionarySortIndexReader = new CarbonDictionarySortIndexReaderImpl( carbonTableIdentifier, "Name", hdfsStorePath); List<Integer> actualSortIndex = dictionarySortIndexReader.readSortIndex(); List<Integer> actualInvertedSortIndex = dictionarySortIndexReader.readInvertedSortIndex(); for (int i = 0; i < actualSortIndex.size(); i++) { Assert.assertEquals(sortIndex.get(i), actualSortIndex.get(i)); Assert.assertEquals(invertedSortIndex.get(i), actualInvertedSortIndex.get(i)); } }
From source file:org.carbondata.core.writer.sortindex.CarbonDictionarySortIndexWriterImplTest.java
/** * s//from w w w.j a v a2 s.c o m * Method to test the write of sortIndex file. * * @throws Exception */ @Test public void write() throws Exception { String storePath = hdfsStorePath; CarbonTableIdentifier carbonTableIdentifier = new CarbonTableIdentifier("testSchema", "carbon"); CarbonDictionarySortIndexWriter dictionarySortIndexWriter = new CarbonDictionarySortIndexWriterImpl( carbonTableIdentifier, "Name", storePath); List<int[]> indexList = prepareExpectedData(); List<Integer> sortIndex = Arrays.asList(ArrayUtils.toObject(indexList.get(0))); List<Integer> invertedSortIndex = Arrays.asList(ArrayUtils.toObject(indexList.get(1))); dictionarySortIndexWriter.writeSortIndex(sortIndex); dictionarySortIndexWriter.writeInvertedSortIndex(invertedSortIndex); dictionarySortIndexWriter.close(); CarbonDictionarySortIndexReader carbonDictionarySortIndexReader = new CarbonDictionarySortIndexReaderImpl( carbonTableIdentifier, "Name", storePath); List<Integer> actualSortIndex = carbonDictionarySortIndexReader.readSortIndex(); List<Integer> actualInvertedSortIndex = carbonDictionarySortIndexReader.readInvertedSortIndex(); for (int i = 0; i < actualSortIndex.size(); i++) { Assert.assertEquals(sortIndex.get(i), actualSortIndex.get(i)); Assert.assertEquals(invertedSortIndex.get(i), actualInvertedSortIndex.get(i)); } }
From source file:org.cesecore.certificates.certificateprofile.CertificateProfile.java
public void setCVCLongAccessRights(byte[] access) { if (access == null) { data.put(CVCLONGACCESSRIGHTS, null); } else {/* w ww . j a v a 2s. co m*/ // Convert to List<Byte> since byte[] doesn't work with database protection data.put(CVCLONGACCESSRIGHTS, new ArrayList<Byte>(Arrays.asList(ArrayUtils.toObject(access)))); } }
From source file:org.codice.ddf.admin.core.impl.AdminConsoleService.java
private Object sanitizeUIConfiguration(String pid, String configEntryKey, Object configEntryValue) { if (UI_CONFIG_PID.equals(pid) && ("color".equalsIgnoreCase(configEntryKey) || "background".equalsIgnoreCase(configEntryKey)) && (Arrays.stream(ArrayUtils.toObject(String.valueOf(configEntryValue).toCharArray())).parallel() .anyMatch(ILLEGAL_CHARACTER_SET::contains))) { throw loggedException( "Invalid UI Configuration: The color and background properties must only contain a color value"); }// w ww .j a v a 2s . c om return configEntryValue; }
From source file:org.dawnsci.plotting.tools.powderlines.PowderLineTool.java
@Override public void createControl(Composite parent) { this.composite = new Composite(parent, SWT.NONE); composite.setLayout(new FillLayout()); // Add a SashForm to show both the table and the domain specific pane sashForm = new SashForm(composite, SWT.VERTICAL); // Create the table of lines tableCompo = new Composite(sashForm, SWT.NONE); lineTableViewer = new TableViewer(tableCompo, SWT.FULL_SELECTION | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); createColumns(lineTableViewer);//w w w . j a va2 s.c o m lineTableViewer.getTable().setLinesVisible(true); lineTableViewer.getTable().setHeaderVisible(true); // Create the Actions createActions(); // define the content and the provider lineTableViewer.setContentProvider(new IStructuredContentProvider() { @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // TODO Auto-generated method stub } @Override public void dispose() { // TODO Auto-generated method stub } @Override public Object[] getElements(Object inputElement) { return ArrayUtils.toObject(((DoubleDataset) inputElement).getData()); } }); lineTableViewer.setInput(model.getLines()); // The domain specific part of the interface domainCompo = new Composite(sashForm, SWT.NONE); eosCompo = new EoSComposite(domainCompo, SWT.NONE); // maximize the table until told otherwise sashForm.setMaximizedControl(tableCompo); activate(); super.createControl(parent); }
From source file:org.dkpro.tc.evaluation.measures.regression.SpearmanCorrelation.java
public static Map<String, Double> calculate(Id2Outcome id2Outcome) { Map<String, Double> results = new HashMap<String, Double>(); Double[] goldstandard = ArrayUtils.toObject(id2Outcome.getGoldValues()); Double[] prediction = ArrayUtils.toObject(id2Outcome.getPredictions()); results.put(SpearmanCorrelation.class.getSimpleName(), SpearmansRankCorrelation .computeCorrelation(Arrays.asList(goldstandard), Arrays.asList(prediction))); return results; }
From source file:org.dkpro.tc.ml.report.util.ScatterplotRenderer.java
private double getMin(double[] values) { return Collections.min(Arrays.asList(ArrayUtils.toObject(values))); }