Example usage for java.lang Float MIN_VALUE

List of usage examples for java.lang Float MIN_VALUE

Introduction

In this page you can find the example usage for java.lang Float MIN_VALUE.

Prototype

float MIN_VALUE

To view the source code for java.lang Float MIN_VALUE.

Click Source Link

Document

A constant holding the smallest positive nonzero value of type float , 2-149.

Usage

From source file:edu.fullerton.viewerplugin.SpectrumPlot.java

@Override
public void setParameters(Map<String, String[]> parameterMap) {
    this.parameterMap = parameterMap;
    String[] t;/*from w w  w . ja  v  a2  s  .  c  o m*/
    t = parameterMap.get("window");
    String it = t != null && t.length > 0 ? t[0] : "";

    if (it.isEmpty() || it.equalsIgnoreCase("none")) {
        window = Window.NONE;
    } else if (it.equalsIgnoreCase("hanning")) {
        window = Window.HANNING;
    } else if (it.equalsIgnoreCase("flattop")) {
        window = Window.FLATTOP;
    } else {
        window = Window.HANNING;
    }

    t = parameterMap.get("scaling");
    it = t != null && t.length > 0 ? t[0] : "";
    if (it.equalsIgnoreCase("Amplitude spectrum")) {
        pwrScale = Scaling.AS;
    } else if (it.equalsIgnoreCase("Amplitude spectral density")) {
        pwrScale = Scaling.ASD;
    } else if (it.equalsIgnoreCase("Power specturm")) {
        pwrScale = Scaling.PS;
    } else if (it.equalsIgnoreCase("Power spectral density")) {
        pwrScale = Scaling.PSD;
    }

    t = parameterMap.get("sp_linethickness");
    if (t == null || !t[0].trim().matches("^\\d+$")) {
        lineThickness = 2;
    } else {
        lineThickness = Integer.parseInt(t[0]);
    }

    t = parameterMap.get("secperfft");
    if (t == null) {
        secperfft = 1;
    } else if (t[0].matches("[\\d\\.]+")) {
        this.secperfft = (float) Double.parseDouble(t[0]);
    } else {
        vpage.add("Invalid entry for seconds per fft, using 1");
    }

    t = parameterMap.get("fftoverlap");
    if (t == null) {
        overlap = secperfft / 2;
    } else if (t[0].matches("[\\d\\.]+")) {
        double tmp = Double.parseDouble(t[0]);
        if (tmp >= 0 && tmp < 1) {
            this.overlap = (float) (tmp * secperfft);
        } else {
            vpage.add("Invalid entry for overlap, using 0.5");
            overlap = secperfft / 2;
        }
    } else {
        vpage.add("Invalid entry for overlap, using 0.5");
        overlap = secperfft / 2;
    }

    t = parameterMap.get("fmin");
    if (t == null) {
        fmin = Float.MIN_VALUE;
    } else if (t[0].matches("[\\d\\.]+")) {
        fmin = (float) Double.parseDouble(t[0]);
    } else {
        fmin = Float.MIN_VALUE;
    }

    t = parameterMap.get("fmax");
    if (t == null) {
        fmax = Float.MAX_VALUE;
    } else if (t[0].matches("[\\d\\.]+")) {
        fmax = (float) Double.parseDouble(t[0]);
    } else {
        fmax = Float.MAX_VALUE;
    }
    t = parameterMap.get("sp_logx");
    logXaxis = t != null;

    t = parameterMap.get("sp_logy");
    logYaxis = t != null;
}

From source file:org.broad.igv.track.TrackMenuUtils.java

public static JMenuItem getDataRangeItem(final Collection<Track> selectedTracks) {
    JMenuItem item = new JMenuItem("Set Data Range...");

    item.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            if (selectedTracks.size() > 0) {
                // Create a datarange that spans the extent of prev tracks range
                float mid = 0;
                float min = Float.MAX_VALUE;
                float max = Float.MIN_VALUE;
                boolean drawBaseline = false;
                for (Track t : selectedTracks) {
                    DataRange dr = t.getDataRange();
                    min = Math.min(min, dr.getMinimum());
                    max = Math.max(max, dr.getMaximum());
                    mid += dr.getBaseline();
                }/*  w w  w.j  a  v a2s.  c o  m*/
                mid /= selectedTracks.size();
                if (mid < min) {
                    mid = min;
                } else if (mid > max) {
                    min = max;
                }

                DataRange prevAxisDefinition = new DataRange(min, mid, max, drawBaseline);
                DataRangeDialog dlg = new DataRangeDialog(IGV.getMainFrame(), prevAxisDefinition);
                dlg.setVisible(true);
                if (!dlg.isCanceled()) {
                    min = Math.min(dlg.getMax(), dlg.getMin());
                    max = Math.max(dlg.getMin(), dlg.getMax());
                    mid = dlg.getBase();
                    mid = Math.max(min, Math.min(mid, max));

                    DataRange axisDefinition = new DataRange(dlg.getMin(), dlg.getBase(), dlg.getMax());

                    for (Track track : selectedTracks) {
                        track.setDataRange(axisDefinition);
                        if (track instanceof DataTrack) {
                            ((DataTrack) track).setAutoscale(false);
                        }
                    }
                    IGV.getInstance().repaint();
                }

            }
        }
    });
    return item;
}

From source file:com.milaboratory.core.alignment.KMapper.java

/**
 * Performs an alignment for a part of the target sequence.
 *
 * <p>This methods is thread-safe and can be concurrently used by several threads if no new sequences added after
 * its first invocation.</p>/*from  w  ww.j  a v a  2 s. c om*/
 *
 * @param sequence target sequence
 * @param from     first nucleotide to align (inclusive)
 * @param to       last nucleotide to align (exclusive)
 * @return a list of hits found in the target sequence
 */
public KMappingResult align(NucleotideSequence sequence, int from, int to) {
    ensureBuilt();

    ArrayList<KMappingHit> result = new ArrayList<>();

    if (to - from <= kValue)
        return new KMappingResult(null, result);

    IntArrayList seedPositions = new IntArrayList((to - from) / minDistance + 2);
    int seedPosition = from;
    seedPositions.add(seedPosition);

    Well19937c random = RandomUtil.getThreadLocalRandom();

    while ((seedPosition += random.nextInt(maxDistance + 1 - minDistance) + minDistance) < to - kValue)
        seedPositions.add(seedPosition);

    //if (seedPositions.get(seedPositions.size() - 1) != to - kValue)
    seedPositions.add(to - kValue);

    int[] seeds = new int[seedPositions.size()];

    int kmer;
    IntArrayList[] candidates = new IntArrayList[sequencesInBase];

    //Building candidates arrays (seed)
    int id, offset;
    for (int i = 0; i < seeds.length; ++i) {
        kmer = 0;
        for (int j = seedPositions.get(i); j < seedPositions.get(i) + kValue; ++j)
            kmer = kmer << 2 | sequence.codeAt(j);

        seeds[i] = kmer;
        if (base[kmer].length == 0)
            continue;

        for (int record : base[kmer]) {
            id = record >>> bitsForOffset;
            offset = record & offsetMask;

            if (candidates[id] == null)
                candidates[id] = new IntArrayList();

            candidates[id].add((seedPositions.get(i) - offset) << (32 - bitsForOffset) | i);
        }
    }

    //Selecting best candidates (vote)
    //int resultId = 0;
    Info info = new Info();
    int cFrom, cTo, siFrom, siTo;
    int maxRawScore = 0, j, i;
    double preScore;
    double maxScore = Float.MIN_VALUE;
    for (i = candidates.length - 1; i >= 0; --i) {
        //TODO reconsider conditions:
        if (candidates[i] != null && candidates[i].size() >= ((minAlignmentLength - kValue + 1) / maxDistance)
                && candidates[i].size() * matchScore >= maxScore * relativeMinScore) {

            //Sorting (important)
            candidates[i].sort();
            //Calculating best score and offset values
            getScoreFromOffsets(candidates[i], info);

            //Theoretical range of target and reference sequence intersection
            cFrom = max(info.offset, from);
            cTo = min(info.offset + refLength[i], to) - kValue;

            //Calculating number of seeds in this range
            siTo = siFrom = -1;
            for (j = seedPositions.size() - 1; j >= 0; --j)
                if ((seedPosition = seedPositions.get(j)) <= cTo) {
                    if (siTo == -1)
                        siTo = j + 1;
                    if (seedPosition < cFrom) {
                        siFrom = j + 1;
                        break;
                    }
                }

            //If siFrom not set, first seed is inside the range of target and
            //reference sequence intersection
            if (siFrom == -1)
                siFrom = 0;

            //Calculating score without penalty
            preScore = matchScore * info.score; //+ max(siTo - siFrom - info.score, 0) * mismatchScore;

            //Selecting candidates
            if (preScore >= absoluteMinScore) {
                result.add(new KMappingHit(info.offset, i, (float) preScore, siFrom, siTo));

                if (maxRawScore < info.score)
                    maxRawScore = info.score;

                if (maxScore < preScore)
                    maxScore = preScore;
            }
        }
    }

    int c, seedIndex, seedIndexMask = (0xFFFFFFFF >>> (bitsForOffset)), offsetDelta, currentSeedPosition, prev;
    float score;

    KMappingHit hit;
    maxScore = 0.0;
    for (j = result.size() - 1; j >= 0; --j) {
        hit = result.get(j);

        //Fulfilling the seed positions array
        //getting seed positions in intersection of target and reference sequences
        hit.seedOffsets = new int[hit.to - hit.from];
        Arrays.fill(hit.seedOffsets, SEED_NOT_FOUND_OFFSET);
        for (int k = candidates[hit.id].size() - 1; k >= 0; --k) {
            //  offset value | seed index
            c = candidates[hit.id].get(k);
            seedIndex = c & seedIndexMask;

            //filling seed position array with actual positions of seeds inside intersection
            if (seedIndex >= result.get(j).from && seedIndex < result.get(j).to) {
                seedIndex -= hit.from;
                offsetDelta = abs((c >> (32 - bitsForOffset)) - hit.offset);

                //check if offset difference is less than max allowed and better seed position is found
                if (offsetDelta <= maxIndels && (hit.seedOffsets[seedIndex] == SEED_NOT_FOUND_OFFSET
                        || abs(hit.seedOffsets[seedIndex] - hit.offset) > offsetDelta))
                    hit.seedOffsets[seedIndex] = (c >> (32 - bitsForOffset));
            }
        }

        //Previous seed position
        prev = -1;
        c = -1;
        for (i = hit.seedOffsets.length - 1; i >= 0; --i)
            if (hit.seedOffsets[i] != SEED_NOT_FOUND_OFFSET) {
                if (c != -1)
                    //check for situation like: seedsOffset = [25,25,25,25,  28  ,25]
                    //we have to remove such offsets because it's most likely wrong mapping
                    //c - most left index, prev - middle index and i - right most index
                    //but we iterate in reverse direction
                    if (hit.seedOffsets[c] != hit.seedOffsets[prev]
                            && hit.seedOffsets[prev] != hit.seedOffsets[i]
                            && ((hit.seedOffsets[c] < hit.seedOffsets[prev]) != (hit.seedOffsets[prev] < hit.seedOffsets[i]))) {
                        hit.seedOffsets[prev] = SEED_NOT_FOUND_OFFSET;
                        prev = -1;
                    }
                c = prev;
                prev = i;
            }

        //Calculating score
        score = 0.0f;
        for (int off : hit.seedOffsets)
            if (off != SEED_NOT_FOUND_OFFSET)
                score += matchScore;
            else
                score += mismatchPenalty;

        //Floating bounds reward
        if (floatingLeftBound) {
            prev = -1;
            for (i = 0; i < hit.seedOffsets.length; ++i)
                if (hit.seedOffsets[i] != SEED_NOT_FOUND_OFFSET) {
                    if (prev == -1) {
                        prev = i;
                        continue;
                    }

                    //Calculating score gain for deleting first kMer
                    if (matchScore + abs(hit.seedOffsets[i] - hit.seedOffsets[prev]) * offsetShiftPenalty
                            + (i - prev - 1) * mismatchPenalty <= 0.0f) {
                        //Bad kMer
                        hit.seedOffsets[prev] = SEED_NOT_FOUND_OFFSET;
                        prev = i;
                        continue;
                    }

                    score -= prev * mismatchPenalty;
                    break;
                }
        }

        //Floating bounds reward
        if (floatingRightBound) {
            prev = -1;
            for (i = hit.seedOffsets.length - 1; i >= 0; --i)
                if (hit.seedOffsets[i] != SEED_NOT_FOUND_OFFSET) {
                    if (prev == -1) {
                        prev = i;
                        continue;
                    }

                    //Calculating score gain for deleting first kMer
                    if (matchScore + abs(hit.seedOffsets[i] - hit.seedOffsets[prev]) * offsetShiftPenalty
                            + (prev - 1 - i) * mismatchPenalty <= 0.0f) {
                        //Bad kMer
                        hit.seedOffsets[prev] = SEED_NOT_FOUND_OFFSET;
                        prev = i;
                        continue;
                    }

                    score -= (hit.seedOffsets.length - 1 - prev) * mismatchPenalty;
                }
        }

        c = -1;
        prev = -1;
        //totalIndels = 0;
        for (i = hit.seedOffsets.length - 1; i >= 0; --i) {
            if (hit.seedOffsets[i] != SEED_NOT_FOUND_OFFSET) {
                currentSeedPosition = seedPositions.get(i + hit.from) - hit.seedOffsets[i];
                if (c == -1) {
                    c = currentSeedPosition;
                    prev = i;
                } else if (c <= currentSeedPosition)
                    //Removing paradoxical kMer offsets
                    hit.seedOffsets[i] = SEED_NOT_FOUND_OFFSET;
                else {
                    //totalIndels += abs(hit.seedOffsets[i] - hit.seedOffsets[prev]);
                    score += abs(hit.seedOffsets[i] - hit.seedOffsets[prev]) * offsetShiftPenalty;
                    c = currentSeedPosition;
                    prev = i;
                }
            }
        }

        hit.score = score;

        if (score < absoluteMinScore)
            result.remove(j);

        if (maxScore < score)
            maxScore = score;

        //if (totalIndels > maxIndels * 2) {
        //    result.remove(j);
        //}
    }

    //Removing candidates with score < maxScore * hitsRange
    maxScore *= relativeMinScore;
    for (j = result.size() - 1; j >= 0; --j) {
        hit = result.get(j);
        if (hit.score < maxScore)
            result.remove(j);
    }

    //Removing seed conflicts

    return new KMappingResult(seedPositions, result);
}

From source file:net.ymate.platform.commons.lang.TreeObject.java

/**
 * 
 *
 * @param f
 */
public TreeObject(Float f) {
    _object = f != null ? f.floatValue() : Float.MIN_VALUE;
    _type = TYPE_FLOAT;
}

From source file:pipeline.misc_util.Utils.java

private static float max(Object o) {
    if (o instanceof float[]) {
        float the_max = Float.MIN_VALUE;
        float[] fa = (float[]) o;
        for (float element : fa) {
            if (element > the_max)
                the_max = element;//from   w ww . ja  v a 2 s  . co m
        }
        return the_max;
    } else if (o instanceof short[]) {
        int the_max = Integer.MIN_VALUE;
        short[] fa = (short[]) o;
        for (short element : fa) {
            if ((element & 0xffff) > the_max)
                the_max = (element & 0xffff);
        }
        return the_max;
    } else if (o instanceof byte[]) {
        int the_max = Integer.MIN_VALUE;
        byte[] fa = (byte[]) o;
        for (byte element : fa) {
            if ((element & 0xff) > the_max)
                the_max = (element & 0xff);
        }
        return the_max;
    } else
        throw new RuntimeException("Pixel type not handled in max");
}

From source file:org.kaaproject.kaa.demo.powerplant.fragment.DashboardFragment.java

private void prepareLineChart(View rootView, List<DataReport> data) {
    lineChart = (LineChartView) rootView.findViewById(R.id.lineChart);

    TextView yAxisView = (TextView) rootView.findViewById(R.id.lineChartYAxisText);
    TextView xAxisView = (TextView) rootView.findViewById(R.id.lineChartXAxisText);

    // yAxisView.setBackgroundColor(CHART_BACKROUND_COLOR);
    yAxisView.setTextColor(LINE_CHART_AXIS_TEXT_COLOR);
    yAxisView.setTextSize(TypedValue.COMPLEX_UNIT_SP, LINE_CHART_AXIS_TEXT_SIZE);
    yAxisView.setText(Y_AXIS_LABEL);/*from  www  . j  a  v  a 2 s .  co  m*/

    // xAxisView.setBackgroundColor(CHART_BACKROUND_COLOR);
    xAxisView.setTextColor(LINE_CHART_AXIS_TEXT_COLOR);
    xAxisView.setTextSize(TypedValue.COMPLEX_UNIT_SP, LINE_CHART_AXIS_TEXT_SIZE);
    xAxisView.setText(X_AXIS_LABEL);

    // lineChart.setBackgroundColor(CHART_BACKROUND_COLOR);
    lineChart.getChartRenderer().setMinViewportXValue((float) 0);
    lineChart.getChartRenderer().setMaxViewportXValue((float) POINTS_COUNT);

    List<PointValue> values = new ArrayList<PointValue>();

    float maxValue = Float.MIN_VALUE;
    float minValue = Float.MAX_VALUE;
    int startPos = POINTS_COUNT - data.size() + 1;
    float latestValue = 0.0f;
    for (int i = 0; i < data.size(); i++) {
        if (i == 148) {
            System.out.println();
        }
        int pos = startPos + i;
        float value = 0.0f;
        for (DataPoint dp : data.get(i).getDataPoints()) {
            value += convertVoltage(dp.getVoltage());
        }
        values.add(new PointValue(pos, value));
        minValue = Math.min(minValue, value);
        maxValue = Math.max(maxValue, value);
        latestValue = value;
    }
    for (int i = 0; i < FUTURE_POINTS_COUNT; i++) {
        values.add(new PointValue(POINTS_COUNT + i + 1, latestValue));
    }

    lineChart.getChartRenderer().setMinViewportYValue(MIN_VOLTAGE);
    lineChart.getChartRenderer().setMaxViewportYValue((MAX_VOLTAGE * MAX_PANEL_PER_ZONE * NUM_ZONES) / 1000);

    // In most cased you can call data model methods in builder-pattern-like
    // manner.
    line = new Line(values).setColor(LINE_CHART_LINE_COLOR).setCubic(LINE_CHART_IS_CUBIC).setHasLabels(false)
            .setHasPoints(false).setFilled(true).setAreaTransparency(AREA_TRANSPARENCY);
    List<Line> lines = new ArrayList<Line>();
    lines.add(line);

    final LineChartData lineChartData = new LineChartData();
    lineChartData.setLines(lines);

    Axis axisX = new Axis();
    Axis axisY = new Axis().setHasLines(true);

    axisX.setTextSize(LINE_CHART_AXIS_SIZE);
    axisX.setTextColor(LINE_CHART_AXIS_COLOR);
    axisY.setTextSize(LINE_CHART_AXIS_SIZE);
    axisY.setTextColor(LINE_CHART_AXIS_COLOR);

    // This is the right way to show axis labels but has some issues with
    // layout
    final Calendar calendar = new GregorianCalendar();
    final SimpleDateFormat ft = new SimpleDateFormat("hh:mm:ss a ____________", Locale.US);

    axisX.setAutoGenerated(true);
    axisX.setFormatter(new AxisValueFormatter() {

        @Override
        public int formatValueForManualAxis(char[] formattedValue, AxisValue axisValue) {
            return format(calendar, ft, formattedValue, axisValue.getValue());
        }

        @Override
        public int formatValueForAutoGeneratedAxis(char[] formattedValue, float value, int autoDecimalDigits) {
            return format(calendar, ft, formattedValue, value);
        }

        private int format(final Calendar calendar, final SimpleDateFormat ft, char[] formattedValue,
                float value) {
            long time = System.currentTimeMillis();
            calendar.setTimeInMillis(time);
            String formatedValue = null;
            if ((int) value == POINTS_COUNT) {
                formatedValue = ft.format(calendar.getTime());
            } else {
                int delta = POINTS_COUNT - (int) value;
                if (delta % INTERVAL_FOR_HORIZONTAL_AXIS == 0 && delta > INTERVAL_FOR_HORIZONTAL_AXIS) {
                    formatedValue = "- " + (delta / 2);
                }
            }
            if (formatedValue == null) {
                return 0;
            } else {
                char[] data = formatedValue.toCharArray();
                for (int i = 0; i < data.length; i++) {
                    formattedValue[formattedValue.length - data.length + i] = data[i];
                }
                return data.length;
            }
        }
    });

    lineChartData.setAxisXBottom(axisX);
    lineChartData.setAxisYLeft(axisY);

    lineChart.setLineChartData(lineChartData);
}

From source file:org.apache.nutch.crawl.CrawlDbReader.java

private TreeMap<String, Writable> processStatJobHelper(String crawlDb, Configuration config, boolean sort)
        throws IOException, InterruptedException, ClassNotFoundException {
    Path tmpFolder = new Path(crawlDb, "stat_tmp" + System.currentTimeMillis());

    Job job = NutchJob.getInstance(config);
    config = job.getConfiguration();//from ww w.  j  ava 2 s .c  o  m
    job.setJobName("stats " + crawlDb);
    config.setBoolean("db.reader.stats.sort", sort);

    FileInputFormat.addInputPath(job, new Path(crawlDb, CrawlDb.CURRENT_NAME));
    job.setInputFormatClass(SequenceFileInputFormat.class);

    job.setJarByClass(CrawlDbReader.class);
    job.setMapperClass(CrawlDbStatMapper.class);
    job.setCombinerClass(CrawlDbStatReducer.class);
    job.setReducerClass(CrawlDbStatReducer.class);

    FileOutputFormat.setOutputPath(job, tmpFolder);
    job.setOutputFormatClass(SequenceFileOutputFormat.class);
    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(NutchWritable.class);

    // https://issues.apache.org/jira/browse/NUTCH-1029
    config.setBoolean("mapreduce.fileoutputcommitter.marksuccessfuljobs", false);
    FileSystem fileSystem = tmpFolder.getFileSystem(config);
    try {
        boolean success = job.waitForCompletion(true);
        if (!success) {
            String message = "CrawlDbReader job did not succeed, job status:" + job.getStatus().getState()
                    + ", reason: " + job.getStatus().getFailureInfo();
            LOG.error(message);
            fileSystem.delete(tmpFolder, true);
            throw new RuntimeException(message);
        }
    } catch (IOException | InterruptedException | ClassNotFoundException e) {
        LOG.error(StringUtils.stringifyException(e));
        fileSystem.delete(tmpFolder, true);
        throw e;
    }

    // reading the result
    SequenceFile.Reader[] readers = SegmentReaderUtil.getReaders(tmpFolder, config);

    Text key = new Text();
    NutchWritable value = new NutchWritable();

    TreeMap<String, Writable> stats = new TreeMap<>();
    for (int i = 0; i < readers.length; i++) {
        SequenceFile.Reader reader = readers[i];
        while (reader.next(key, value)) {
            String k = key.toString();
            Writable val = stats.get(k);
            if (val == null) {
                stats.put(k, value.get());
                continue;
            }
            if (k.equals("sc")) {
                float min = Float.MAX_VALUE;
                float max = Float.MIN_VALUE;
                if (stats.containsKey("scn")) {
                    min = ((FloatWritable) stats.get("scn")).get();
                } else {
                    min = ((FloatWritable) stats.get("sc")).get();
                }
                if (stats.containsKey("scx")) {
                    max = ((FloatWritable) stats.get("scx")).get();
                } else {
                    max = ((FloatWritable) stats.get("sc")).get();
                }
                float fvalue = ((FloatWritable) value.get()).get();
                if (min > fvalue) {
                    min = fvalue;
                }
                if (max < fvalue) {
                    max = fvalue;
                }
                stats.put("scn", new FloatWritable(min));
                stats.put("scx", new FloatWritable(max));
            } else if (k.equals("ft") || k.equals("fi")) {
                long min = Long.MAX_VALUE;
                long max = Long.MIN_VALUE;
                String minKey = k + "n";
                String maxKey = k + "x";
                if (stats.containsKey(minKey)) {
                    min = ((LongWritable) stats.get(minKey)).get();
                } else if (stats.containsKey(k)) {
                    min = ((LongWritable) stats.get(k)).get();
                }
                if (stats.containsKey(maxKey)) {
                    max = ((LongWritable) stats.get(maxKey)).get();
                } else if (stats.containsKey(k)) {
                    max = ((LongWritable) stats.get(k)).get();
                }
                long lvalue = ((LongWritable) value.get()).get();
                if (min > lvalue) {
                    min = lvalue;
                }
                if (max < lvalue) {
                    max = lvalue;
                }
                stats.put(k + "n", new LongWritable(min));
                stats.put(k + "x", new LongWritable(max));
            } else if (k.equals("sct")) {
                FloatWritable fvalue = (FloatWritable) value.get();
                ((FloatWritable) val).set(((FloatWritable) val).get() + fvalue.get());
            } else if (k.equals("scd")) {
                MergingDigest tdigest = null;
                MergingDigest tdig = MergingDigest
                        .fromBytes(ByteBuffer.wrap(((BytesWritable) value.get()).getBytes()));
                if (val instanceof BytesWritable) {
                    tdigest = MergingDigest.fromBytes(ByteBuffer.wrap(((BytesWritable) val).getBytes()));
                    tdigest.add(tdig);
                } else {
                    tdigest = tdig;
                }
                ByteBuffer tdigestBytes = ByteBuffer.allocate(tdigest.smallByteSize());
                tdigest.asSmallBytes(tdigestBytes);
                stats.put(k, new BytesWritable(tdigestBytes.array()));
            } else {
                LongWritable lvalue = (LongWritable) value.get();
                ((LongWritable) val).set(((LongWritable) val).get() + lvalue.get());
            }
        }
        reader.close();
    }
    // remove score, fetch interval, and fetch time
    // (used for min/max calculation)
    stats.remove("sc");
    stats.remove("fi");
    stats.remove("ft");
    // removing the tmp folder
    fileSystem.delete(tmpFolder, true);
    return stats;
}

From source file:MSUmpire.LCMSPeakStructure.LCMSPeakMS1.java

public void RemoveContaminantPeaks(float proportion) {
    Logger.getRootLogger().info("Removing peak clusters whose m/z appear more than " + proportion * 100
            + "% chromatography. No. of peak clusters : " + PeakClusters.size());
    float minmz = Float.MAX_VALUE;
    float maxmz = Float.MIN_VALUE;
    float minrt = Float.MAX_VALUE;
    float maxrt = Float.MIN_VALUE;
    for (PeakCluster peak : PeakClusters) {
        if (peak.TargetMz() > maxmz) {
            maxmz = peak.TargetMz();//from w ww.j a va2s.  c  o  m
        }
        if (peak.TargetMz() < minmz) {
            minmz = peak.TargetMz();
        }
        if (peak.endRT > maxrt) {
            maxrt = peak.endRT;
        }
        if (peak.startRT < minrt) {
            minrt = peak.startRT;
        }
    }
    HashMap<Integer, ArrayList<PeakCluster>> map = new HashMap<>();

    float[] MzBin = new float[(int) Math.ceil((maxmz - minmz) * 10) + 1];
    for (PeakCluster peak : PeakClusters) {
        int binkey = (int) Math.ceil((peak.TargetMz() - minmz) * 10);
        MzBin[binkey] += peak.endRT - peak.startRT;
        if (!map.containsKey(binkey)) {
            map.put(binkey, new ArrayList<PeakCluster>());
        }
        map.get(binkey).add(peak);
    }
    float threshold = proportion * (maxrt - minrt);
    for (int i = 0; i < MzBin.length; i++) {
        if (MzBin[i] > threshold) {
            for (PeakCluster peakCluster : map.get(i)) {
                PeakClusters.remove(peakCluster);
                //Logger.getRootLogger().debug("Removing the cluster m/z: "+ peakCluster.TargetMz()+", StartRT: "+ peakCluster.startRT +", EndRT: "+peakCluster.endRT);
            }
        }
    }
    Logger.getRootLogger().info("Remaining peak clusters : " + PeakClusters.size());
}

From source file:net.sf.json.TestJSONObject.java

public void testFromBean_use_wrappers() {
    JSONObject json = JSONObject.fromObject(Boolean.TRUE);
    assertTrue(json.isEmpty());/*from w ww .  java 2  s  . c om*/
    json = JSONObject.fromObject(new Byte(Byte.MIN_VALUE));
    assertTrue(json.isEmpty());
    json = JSONObject.fromObject(new Short(Short.MIN_VALUE));
    assertTrue(json.isEmpty());
    json = JSONObject.fromObject(new Integer(Integer.MIN_VALUE));
    assertTrue(json.isEmpty());
    json = JSONObject.fromObject(new Long(Long.MIN_VALUE));
    assertTrue(json.isEmpty());
    json = JSONObject.fromObject(new Float(Float.MIN_VALUE));
    assertTrue(json.isEmpty());
    json = JSONObject.fromObject(new Double(Double.MIN_VALUE));
    assertTrue(json.isEmpty());
    json = JSONObject.fromObject(new Character('A'));
    assertTrue(json.isEmpty());
}

From source file:pipeline.misc_util.Utils.java

public static float getMax(IPluginIOStack source) {
    if (source == null) {
        Utils.log("Source stack in null in getStackMax", LogLevel.WARNING);
        return 0;
    }/*from ww w .  ja  v a 2 s . c o  m*/
    float max = Float.MIN_VALUE;
    for (int i = 0; i < source.getDimensions().depth; i++) {
        float sliceMax = (max(source.getPixels(i)));
        if (sliceMax > max)
            max = sliceMax;
    }
    return max;
}