Example usage for java.lang Integer MIN_VALUE

List of usage examples for java.lang Integer MIN_VALUE

Introduction

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

Prototype

int MIN_VALUE

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

Click Source Link

Document

A constant holding the minimum value an int can have, -231.

Usage

From source file:de.thkwalter.et.pulsmuster.SchaltwinkelRaumzeigermodulation.java

/**
 * Diese Methode bildet den Einsprungpunkt in die Berechnung der Schaltwinkel. 
 * /*from  ww  w  .j av a 2 s .com*/
 * @param args Die Kommandozeilenparameter. Das Programm muss mit genau einem Kommandozeilenparameter aufgerufen werden, 
 * nmlich mit der Pulszahl.
 */
public static void main(String[] args) {
    // Falls das Programm nicht mit genau einem Parameter gestartet wurde, wird eine Fehlermeldung ausgegeben.
    if (args == null || args.length != 1) {
        System.out.println(
                "Das Programm muss mit genau einem Parameter gestartet werden, nmlich mit der Pulszahl!");
    }

    // Falls das Programm mit genau einem Programm gestartet wurde, ...
    else {
        // Das erste Kommandozeilenargument wird in die Pulszahl umgewandelt.
        int pulszahl = Integer.MIN_VALUE;
        try {
            pulszahl = Integer.parseInt(args[0]);
        } catch (NumberFormatException e) {
            System.out.println("Der Parameter muss eine ");
        }

        if (pulszahl < 0) {
            System.out.println("Der Parameter");
        }

        else {
            // Die Schaltwinkel werden berechnet.
            SchaltwinkelRaumzeigermodulation schaltwinkelRaumzeigermodulation = new SchaltwinkelRaumzeigermodulation(
                    pulszahl);

            // Die berechneten Schaltwinkel werden gelesen und auf der Kommandozeile ausgegeben.
            for (double schaltwinkel : schaltwinkelRaumzeigermodulation.getSchaltwinkel()) {
                System.out.println(schaltwinkel);
            }
        }
    }
}

From source file:com.yobidrive.diskmap.buckets.BucketFNVHash.java

public static void main(String[] args) {
    // need to pass Ethernet address; can either use real one (shown here)
    EthernetAddress nic = EthernetAddress.fromInterface();
    // or bogus which would be gotten with: EthernetAddress.constructMulticastAddress()
    TimeBasedGenerator uuidGenerator = Generators.timeBasedGenerator(nic);
    // also: we don't specify synchronizer, getting an intra-JVM syncer; there is
    // also external file-locking-based synchronizer if multiple JVMs run JUG

    int numIterations = 4096 * 16 * 24;
    int numBuckets = 4096 * 16 * 2;
    ;//w  w w . jav  a 2  s  . co  m
    int[] buckets = new int[numBuckets];
    BucketFNVHash hash = new BucketFNVHash(numBuckets);
    long smallest = Integer.MAX_VALUE;
    long biggest = Integer.MIN_VALUE;
    int collisionsI = 0;
    int collisions6 = 0;
    int collisions2 = 0;
    int collisions3 = 0;
    int collisions4 = 0;
    int collisions5 = 0;
    long smallestI = Integer.MAX_VALUE;
    long biggestI = Integer.MIN_VALUE;
    int counter = 0;
    int maxCols = 0;

    for (int i = 0; i < numIterations; i++) {
        String key = uuidGenerator.generate().toString();
        long valVoldemort = Math.abs(hash.hashVoldemort(key.getBytes()));
        if (valVoldemort < smallest)
            smallest = valVoldemort;
        if (valVoldemort > biggest)
            biggest = valVoldemort;

        long partition = valVoldemort % 16; // 16 partitions
        if (partition == 7) {
            counter++; // 1 more in partition
            int val = (int) hash.hash(key.getBytes());
            if (val < smallestI)
                smallestI = val;
            if (val > biggestI)
                biggestI = val;
            buckets[val]++;
            if (buckets[val] > maxCols)
                maxCols = buckets[val];
            if (buckets[val] > 1) {
                collisionsI++;
            }
            if (buckets[val] == 2) {
                collisions2++;
            }
            if (buckets[val] == 3) {
                collisions3++;
            }
            if (buckets[val] == 4) {
                collisions4++;
            }
            if (buckets[val] == 5) {
                collisions5++;
            }
            if (buckets[val] > 5) {
                collisions6++;
            }
        }

    }

    System.out.println("Smallest=" + smallest + ", Biggest=" + biggest + ", SmallestI=" + smallestI
            + ", BiggestI=" + biggestI + "/" + numBuckets + ", Partition rate="
            + ((float) counter / numIterations * 100) + "% (target 6,25%), Collision rate="
            + ((float) collisionsI * 100 / counter) + "%, Fill rate" + ((float) counter / numBuckets * 100)
            + ", Max cols=" + (maxCols - 1));
    System.out.println("Chains 2:" + ((float) collisions2 * 100 / collisionsI) + ", 3:"
            + ((float) collisions3 * 100 / collisionsI) + ", 4:" + ((float) collisions4 * 100 / collisionsI)
            + ", 5:" + ((float) collisions5 * 100 / collisionsI) + ", 6:"
            + ((float) collisions6 * 100 / collisionsI));
}

From source file:edu.msu.cme.rdp.probematch.cli.SliceToPrimer.java

public static void main(String[] args) throws Exception {
    //args = "--fedit-dist 4 --redit-dist=4 -k --max-length=400 --min-length=280 -o java_sliced_edit4.fasta TGCGAYCCSAARGCBGACTC ATSGCCATCATYTCRCCGGA /scratch/fishjord/tae_kwon_primer_match/all_genomes.fasta".split(" ");
    PatternBitMask64[] fprimers;/*from  ww w .j av  a  2  s  .co  m*/
    String[] fprimerStrs, rprimerStrs;
    PatternBitMask64[] rprimers;

    FastaWriter seqOut;
    PrintStream statsOut;

    int fEdit = 3;
    int rEdit = 3;
    int minLength = Integer.MIN_VALUE;
    int maxLength = Integer.MAX_VALUE;
    boolean allowAmbiguities = true;
    boolean keepPrimers = false;

    SequenceReader inSeqs;

    try {

        CommandLine line = new PosixParser().parse(options, args);

        if (line.hasOption("edit-dist")) {
            fEdit = rEdit = Integer.parseInt(line.getOptionValue("edit-dist"));

            if (line.hasOption("redit-dist") || line.hasOption("fedit-dist")) {
                throw new Exception("edit-dist, [fedit-dist, redit-dist] are mutually exclusive");
            }
        }

        if (line.hasOption("fedit-dist")) {
            fEdit = Integer.parseInt(line.getOptionValue("fedit-dist"));
        }

        if (line.hasOption("no-ambiguities")) {
            allowAmbiguities = false;
        }

        if (line.hasOption("keep-primers")) {
            keepPrimers = true;
        }

        if (line.hasOption("redit-dist")) {
            rEdit = Integer.parseInt(line.getOptionValue("redit-dist"));
        }

        if (line.hasOption("seq-out")) {
            seqOut = new FastaWriter(new File(line.getOptionValue("seq-out")));
        } else {
            throw new Exception("Must specify seq-out");
        }

        if (line.hasOption("stats-out")) {
            statsOut = new PrintStream(new File(line.getOptionValue("stats-out")));
        } else {
            statsOut = System.out;
        }

        if (line.hasOption("min-length")) {
            minLength = Integer.parseInt(line.getOptionValue("min-length"));
        }

        if (line.hasOption("max-length")) {
            maxLength = Integer.parseInt(line.getOptionValue("max-length"));
        }

        args = line.getArgs();

        if (args.length != 3) {
            throw new Exception("Unexpected number of command line arguments");
        }

        fprimers = translateStringPrimers(args[0].split(","), allowAmbiguities, false);
        fprimerStrs = args[0].split(",");
        rprimers = translateStringPrimers(args[1].split(","), allowAmbiguities, true);
        rprimerStrs = args[1].split(",");
        inSeqs = new SequenceReader(new File(args[2]));

    } catch (Exception e) {
        new HelpFormatter().printHelp("SliceToPrimer [options] <f,p,r,i,m,e,r> <r,p,r,i,m,e,r> <in_seq_file>",
                options);
        System.err.println("ERROR: " + e.getMessage());
        return;
    }

    Sequence seq;

    statsOut.println(
            "orig_seqid\tsliced_seqid\tfprimer\tstart\tend\tscore\trprimer\tstart\tend\tscore\tlength");

    ScoringMatrix sccoringMatrix = ScoringMatrix.getDefaultNuclMatrix();

    DPMAligner[] faligners = new DPMAligner[fprimers.length];
    for (int index = 0; index < faligners.length; index++) {
        faligners[index] = new DPMAligner(fprimerStrs[index], Integer.MAX_VALUE);
    }

    try {
        while ((seq = inSeqs.readNextSequence()) != null) {
            Set<PrimerMatch> fprimerMatches = new HashSet();
            Set<PrimerMatch> rprimerMatches = new HashSet();

            for (int index = 0; index < fprimers.length; index++) {
                PatternBitMask64 primer = fprimers[index];

                for (BitVector64Match r : BitVector64.process(seq.getSeqString().toCharArray(), primer, fEdit)
                        .getResults()) {
                    PrimerMatch match = new PrimerMatch();
                    match.start = r.getPosition() - (primer.getPatternLength() + r.getScore());
                    match.end = r.getPosition();
                    match.score = r.getScore();
                    match.primerIndex = index;
                    fprimerMatches.add(match);
                }
            }

            for (int index = 0; index < rprimers.length; index++) {
                PatternBitMask64 primer = rprimers[index];

                for (BitVector64Match r : BitVector64.process(seq.getSeqString().toCharArray(), primer, rEdit)
                        .getResults()) {
                    PrimerMatch match = new PrimerMatch();
                    match.start = r.getPosition() - (primer.getPatternLength() + r.getScore());
                    match.end = r.getPosition();
                    match.score = r.getScore();
                    match.primerIndex = index;
                    rprimerMatches.add(match);
                }
            }

            if (fprimerMatches.isEmpty() || rprimerMatches.isEmpty()) {
                statsOut.println(seq.getSeqName() + "\tEither/or no forward/reverse primer hits");
                continue;
            }
            for (PrimerMatch fmatch : fprimerMatches) {
                PrimerMatch bestReverse = null;
                int bestScore = Integer.MAX_VALUE;
                for (PrimerMatch rmatch : rprimerMatches) {
                    if (rmatch.start > fmatch.end && rmatch.start - fmatch.end < bestScore) {
                        bestReverse = rmatch;
                        bestScore = rmatch.start - fmatch.end;
                    }
                }

                if (bestReverse == null) {
                    statsOut.println(seq.getSeqName() + "\tNo reverse primer before " + fmatch.end);
                    continue;
                }

                String slicedSeq = null;
                if (keepPrimers) {
                    slicedSeq = seq.getSeqString().substring(fmatch.start, bestReverse.end);
                } else {
                    slicedSeq = seq.getSeqString().substring(fmatch.end, bestReverse.start);
                }

                String seqid = seq.getSeqName() + "_" + fmatch.primerIndex + "_" + fmatch.start;
                if (slicedSeq.length() > minLength && slicedSeq.length() < maxLength) {
                    seqOut.writeSeq(seqid, "", slicedSeq);
                }

                DPMAlignment seqs = faligners[fmatch.primerIndex]
                        .align(seq.getSeqString().substring(fmatch.start, fmatch.end));
                System.err.println(">" + seqid);
                System.err.println(fprimerStrs[fmatch.primerIndex]);
                System.err.println(seq.getSeqString().substring(fmatch.start, fmatch.end));
                System.err.println();
                System.err.println(seqs.getAlignedMatchFragment());
                System.err.println(seqs.getAlignedProbe());

                System.err.println();

                statsOut.println(seq.getSeqName() + "\t" + seqid + "\t" + fmatch.primerIndex + "\t"
                        + fmatch.start + "\t" + fmatch.end + "\t" + fmatch.score + "\t"
                        + bestReverse.primerIndex + "\t" + bestReverse.start + "\t" + bestReverse.end + "\t"
                        + bestReverse.score + "\t" + slicedSeq.length());
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        statsOut.close();
        seqOut.close();
    }
}

From source file:Main.java

public static int longToInt(long l) {
    if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) {
        throw new IllegalArgumentException(l + " cannot be cast to int without changing its value.");
    }//from w w w . j a  v  a2  s  .c o  m
    return (int) l;
}

From source file:Main.java

public static int max(Iterable<Integer> c) {
    int a = Integer.MIN_VALUE;
    for (Integer integer : c) {
        a = Math.max(a, integer);
    }/* w w w . j a  v  a 2s. com*/
    return a;
}

From source file:Main.java

public static int getMax(int[] arr) {
    int max = Integer.MIN_VALUE;

    for (int i = 0; i < arr.length; i++) {
        if (arr[i] > max)
            max = arr[i];/*from   w ww .ja v a2s. c o  m*/
    }

    return max;
}

From source file:Main.java

static public boolean isIncreasing(int A[]) {
    int lastId = Integer.MIN_VALUE;
    for (int i = 0; i < A.length; i++) {
        if (A[i] <= lastId) {
            return false;
        }/*from  ww  w  . j  av  a 2 s.c  o  m*/
        lastId = A[i];
    }
    return true;
}

From source file:Main.java

public static int addAndCheck(int x, int y) {
    long s = (long) x + (long) y;
    if (s < Integer.MIN_VALUE || s > Integer.MAX_VALUE) {
        throw new ArithmeticException("overflow: add");
    }//  ww w  .j  a  v  a2s .c o m
    return (int) s;
}

From source file:Main.java

private static int getMax(int... vals) {
    int max = Integer.MIN_VALUE;
    for (int i : vals)
        if (i > max)
            max = i;/* w  ww  . jav a 2  s  .c o  m*/
    return max;
}

From source file:Main.java

public static int max(int[] x, int length) {
    int m = Integer.MIN_VALUE;
    for (int i = 0; i < length; i++)
        if (x[i] > m)
            m = x[i];/* w  w w . j  a v a 2  s .  c  o  m*/
    return m;
}