Package com.googlecode.gaal.data.api

Examples of com.googlecode.gaal.data.api.IntSequence


    }

    @Test
    public void testSubSequence() {
        // sequence [2, 3, 4]
        IntSequence s = sequence.subSequence(1, 3);
        assertEquals("[3, 4]", s.toString());
    }
View Full Code Here


    }

    @Test
    public void testReverse() {
        // sequence [2, 3, 4]
        IntSequence reverse = sequence.reverse();
        assertEquals("[4, 3, 2]", reverse.toString());
    }
View Full Code Here

        assertEquals("[4, 3, 2]", reverse.toString());
    }

    @Test
    public void testReverseGetIntInt() {
        IntSequence reverse = sequence.reverse();
        // s [4, 3, 2]
        assertTrue(reverse.get(0, -1) == 4);
        assertTrue(reverse.get(1, -1) == 3);
        assertTrue(reverse.get(2, -1) == 2);
        assertTrue(reverse.get(3, -1) == -1);
    }
View Full Code Here

        assertTrue(reverse.get(3, -1) == -1);
    }

    @Test
    public void testReverseGetInt() {
        IntSequence reverse = sequence.reverse();
        // s [4, 3, 2]
        assertTrue(reverse.get(0) == 4);
        assertTrue(reverse.get(1) == 3);
        assertTrue(reverse.get(2) == 2);
        Exception exception = null;
        try {
            reverse.get(3);
        } catch (IndexOutOfBoundsException ex) {
            exception = ex;
        }
        assertTrue(exception != null);
        assertTrue(exception.getMessage().equals("3"));
View Full Code Here

        assertTrue(exception.getMessage().equals("3"));
    }

    @Test
    public void testReverseSubSequence() {
        IntSequence reverse = sequence.reverse();
        // s [4, 3, 2]
        IntSequence s = reverse.subSequence(1, 3);
        assertEquals("[3, 2]", s.toString());
    }
View Full Code Here

        // equality
        System.out.printf("%s=%s\n", sequence, sequence);
        assertTrue(sequence.compareTo(sequence) == 0);
        assertTrue(sequence.equals(new ArraySequence(new int[] { 2, 3, 4 })));
        // a bigger sequence
        IntSequence bigger = new ArraySequence(new int[] { 2, 3, 5 });
        System.out.printf("%s<%s\n", sequence, bigger);
        assertTrue(sequence.compareTo(bigger) < 0);
        System.out.printf("%s>%s\n", bigger, sequence);
        assertTrue(bigger.compareTo(sequence) > 0);
        // a smaller sequence
        IntSequence smaller = new ArraySequence(new int[] { 1, 2, 3 });
        System.out.printf("%s>%s\n", sequence, smaller);
        assertTrue(sequence.compareTo(smaller) > 0);
        System.out.printf("%s<%s\n", smaller, sequence);
        assertTrue(smaller.compareTo(sequence) < 0);
        // a shorter sequence
        IntSequence shorter = new ArraySequence(new int[] { 2, 3 });
        System.out.printf("%s>%s\n", sequence, shorter);
        assertTrue(sequence.compareTo(shorter) > 0);
        System.out.printf("%s<%s\n", shorter, sequence);
        assertTrue(shorter.compareTo(sequence) < 0);
        // a longer sequence
        IntSequence longer = new ArraySequence(new int[] { 2, 3, 4, 5 });
        System.out.printf("%s<%s\n", sequence, longer);
        assertTrue(sequence.compareTo(longer) < 0);
        System.out.printf("%s>%s\n", longer, sequence);
        assertTrue(longer.compareTo(sequence) > 0);

    }
View Full Code Here

            if (!interval.isTerminal()) {
                if ((distinctBwtSet.contains(interval) && maximalSet.contains(interval)) != isSupermaximal(interval)) {
                    System.err.printf("%s - got:%s, expected:%s\n", interval, distinctBwtSet.contains(interval),
                            isSupermaximal(interval));
                    int[] suffixTable = lst.getSuffixTable();
                    IntSequence sequence = corpus.sequence();
                    for (int i = interval.left(); i <= interval.right(); i++) {
                        System.err.print(corpus.toToken(sequence.get(suffixTable[i] - 1, sequence.size() - 1)) + " ");
                    }
                    System.err.println();
                    fail("supermaximality mismatch");
                }
            }
View Full Code Here

            if (!interval.isTerminal()) {
                if (singletonBwtSet.contains(interval) != isBwtSingleton(interval)) {
                    System.err.printf("%s - got:%s, expected:%s\n", interval, singletonBwtSet.contains(interval),
                            isBwtSingleton(interval));
                    int[] suffixTable = lst.getSuffixTable();
                    IntSequence sequence = corpus.sequence();
                    for (int i = interval.left(); i <= interval.right(); i++) {
                        System.err.print(corpus.toToken(sequence.get(suffixTable[i] - 1, sequence.size() - 1)) + " ");
                    }
                    System.err.println();
                    fail("bwt singleton mismatch");
                }
            }
View Full Code Here

    }

    private boolean isSupermaximal(Interval interval) {
        if (!isMaximal(interval))
            return false;
        IntSequence sequence = lst.getSequence();
        int[] suffixTable = lst.getSuffixTable();
        int left = interval.left();
        int right = interval.right();

        for (int i = left; i <= right; i++) {
            for (int j = left; j <= right; j++) {
                if (i != j) {
                    int iLoc = suffixTable[i];
                    int jLoc = suffixTable[j];
                    int iSym = sequence.get(iLoc - 1, sequence.size() - 1);
                    int jSym = sequence.get(jLoc - 1, sequence.size() - 1);
                    if (iSym == jSym) {
                        return false;
                    }
                }
            }
View Full Code Here

        }
        return true;
    }

    private boolean isBwtSingleton(Interval interval) {
        IntSequence sequence = lst.getSequence();
        int[] suffixTable = lst.getSuffixTable();
        int prev = -1;
        for (int i = interval.left(); i <= interval.right(); i++) {
            int sym = sequence.get(suffixTable[i] - 1, sequence.size() - 1);
            if (prev != -1 && sym != prev) {
                return false;
            }
            prev = sym;
        }
View Full Code Here

TOP

Related Classes of com.googlecode.gaal.data.api.IntSequence

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.