Package org.broad.igv.util.collections

Examples of org.broad.igv.util.collections.IntArrayList


    **/
    @Ignore
    @Test
    public void compareMemory() throws Exception {

        IntArrayList tmp = makeIntArrayList();
        ArrayList<Integer> tmp2 = makeArrayList();
        long memIntArrList = 0;
        long memArrList = 0;

        for (int ii = 0; ii < size; ii++) {
            memArrList += JavaAgent.getObjectSize(tmp2.get(ii));
            memIntArrList += JavaAgent.getObjectSize(tmp.get(ii));
        }
        assertTrue(memIntArrList < memArrList);

    }
View Full Code Here


    }


    public static IntArrayList makeIntArrayList() {
        IntArrayList list = new IntArrayList();
        for (int i = 0; i < size; i++) {
            list.add(i);
        }
        return list;
    }
View Full Code Here

    public static void tearDownClass() throws Exception {
    }

    @Test
    public void test() {
        IntArrayList al = new IntArrayList(10);

        long t0 = System.currentTimeMillis();
        for (int i = 0; i < NUM_POINTS; i++) {
            al.add(i);
        }
        int[] values = al.toArray();
        assertEquals(NUM_POINTS, values.length);
        assertEquals(2, values[2]);
        System.out.println("IntArrayList time: " + (System.currentTimeMillis() - t0));
    }
View Full Code Here

        System.out.println("IntArrayList time: " + (System.currentTimeMillis() - t0));
    }

    @Test
    public void testAddAll() {
        IntArrayList aList = new IntArrayList(40);
        for(int i=0; i<30; i++) {
            aList.add(i);
        }

        IntArrayList aList2 = new IntArrayList(20);
        for(int i=0; i<20; i++) {
            aList2.add(i);
        }

        aList.addAll(aList2);

        for(int i=0; i<30; i++) {
View Full Code Here

    @Test
    public void testParseStarts() throws Exception {
        GWASParser parser = new GWASParser(new ResourceLocator(TestUtils.DATA_DIR + "gwas/smallp.gwas"), genome);
        GWASData data = parser.parse();
        IntArrayList startLocs = data.getLocations().get("chr6");

        int[] expStarts = {29622220,29623739,29623739};
        for(int ii=0; ii < expStarts.length; ii++){
            assertEquals(expStarts[ii], startLocs.get(ii));
        }

    }
View Full Code Here

        return index;
    }


    public void addLocation(String chr, int location) {
        IntArrayList locList = new IntArrayList(1);
        if (this.locations != null && this.locations.get(chr) != null) {
            locList = this.locations.get(chr);

        }
        locList.add(location);
        this.addLocations(chr, locList);

    }
View Full Code Here

    public void sort(Set<String> unsortedChromosomes) {
        for (String c : unsortedChromosomes) {
            String chr = genome.getChromosomeAlias(c);

            final IntArrayList starts = startLocationsMap.get(chr);
            int sz = starts.size();

            int[] indices = new int[sz];
            for (int i = 0; i < indices.length; i++) {
                indices[i] = i;
            }

            (new ArrayHeapIntSorter()).sort(indices, new IntComparator() {

                public int compare(int arg0, int arg1) {
                    return starts.get(arg0) - starts.get(arg1);
                }
            });


            int[] sortedStarts = reorder(indices, startLocationsMap.get(chr));
            int[] sortedEnds = reorder(indices, endLocationsMap.get(chr));
            float[] sortedData = reorder(indices, dataMap.get(chr));

            startLocationsMap.put(chr, new IntArrayList(sortedStarts));
            endLocationsMap.put(chr, new IntArrayList(sortedEnds));
            dataMap.put(chr, new FloatArrayList(sortedData));
        }

    }
View Full Code Here

        return reorderedValues;
    }


    public void addDataChunk(String chr, IntArrayList starts, IntArrayList ends, FloatArrayList data) {
        IntArrayList startLocations = this.startLocationsMap.get(chr);
        if (startLocations == null) {
            this.startLocationsMap.put(chr, starts);
        } else {
            startLocations.addAll(starts);
        }

        if (ends != null) {
            IntArrayList endLocations = this.endLocationsMap.get(chr);
            if (endLocations == null) {
                this.endLocationsMap.put(chr, ends);
            } else {
                endLocations.addAll(ends);
            }
        }

        FloatArrayList dataArray = this.dataMap.get(chr);
        if (dataArray == null) {
View Full Code Here

        return new String[]{getName()};
    }


    public int[] getStartLocations(String chr) {
        IntArrayList startLocations = this.startLocationsMap.get(chr);
        if (startLocations == null) {
            return null;
        } else {
            return startLocations.toArray();
        }
    }
View Full Code Here

            return startLocations.toArray();
        }
    }

    public int[] getEndLocations(String chr) {
        IntArrayList endLocations = this.endLocationsMap.get(chr);
        if (endLocations == null) {
            return null;
        } else {
            return endLocations.toArray();
        }
    }
View Full Code Here

TOP

Related Classes of org.broad.igv.util.collections.IntArrayList

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.