Package org.broad.igv.util.index

Examples of org.broad.igv.util.index.IntervalTree


        return intervalTrees.keySet();
    }

    public IntervalTree getIntervalTree(String chr) {

        IntervalTree iv = intervalTrees.get(chr);
        if(iv == null) {
            iv = intervalTrees.get("*"); // To support legacy MAF indeces, files are split by chromosome
        }
        return iv;
    }
View Full Code Here


        intervalTrees.put(s, iv);
    }

    public void insertInterval(String lastChr, int intervalStart, int intervalEnd, long value) {
        IntervalTree iv = intervalTrees.get(lastChr);
        if (iv == null) {
            iv = new IntervalTree();
            intervalTrees.put(lastChr, iv);
        }
        iv.insert(new Interval(intervalStart, intervalEnd, value));
    }
View Full Code Here

                        break;
                    }
                    index.species.add(line.trim());
                }

                IntervalTree iv = null;
                while ((line = br.readLine()) != null) {
                    if (line.trim().length() == 0) continue;
                    if (line.startsWith("#chr=")) {
                        String chr = ParsingUtils.EQ_PATTERN.split(line)[1];
                        iv = new IntervalTree();
                        index.putIntervalTree(chr, iv);
                    } else if (iv != null) {
                        String[] info = Globals.tabPattern.split(line);
                        int start = Integer.parseInt(info[0]);
                        int end = Integer.parseInt(info[1]) + start;
                        long offset = Long.parseLong(info[2]);
                        iv.insert(new Interval(start, end, offset));
                    } else {
                        // log.info("Skipping line " + line);
                    }
                }

            } else {
                // A "legacy" index, created for Broad hosted files that are separated by chromosome.
                // Every alignment is indexed, which is overkill.  Below we lump them into blocks of 50.
                IntervalTree iv = new IntervalTree();
                int l = 0;
                int intervalStart = 0;
                int intervalEnd = 0;
                long lastOffset = 0;
                while ((line = br.readLine()) != null) {
                    String[] info = Globals.tabPattern.split(line);
                    int start = Integer.parseInt(info[0]);
                    intervalEnd = Integer.parseInt(info[1]) + start;
                    if (l % 50 == 0) {
                        iv.insert(new Interval(intervalStart, intervalEnd, lastOffset));
                        intervalStart = intervalEnd;
                        lastOffset = Long.parseLong(info[2]);
                    }
                    l++;
                }

                if(intervalEnd > intervalStart) {
                    iv.insert(new Interval(intervalStart, intervalEnd, lastOffset));
                }

                index.putIntervalTree("*", iv);
            }
        } finally {
View Full Code Here

            pw.println("#endSpecies");

            Collection<String> chrList = index.getChromosomes();
            for (String chr : chrList) {
                pw.println("#chr=" + chr);
                IntervalTree tree = index.getIntervalTree(chr);
                Collection<Interval> intervals = tree.getIntervals();
                for (Interval node : intervals) {
                    pw.print(String.valueOf(node.getLow()));
                    pw.print("\t");
                    pw.print(String.valueOf(node.getHigh() - node.getLow()));
                    pw.print("\t");
View Full Code Here

    }

    @Override
    public List<MultipleAlignmentBlock> loadAlignments(String chr, int start, int end) throws IOException {

        IntervalTree ivTree = index.getIntervalTree(chr);
        if (ivTree == null) return null;

        List<Interval> intervals = ivTree.findOverlapping(start, end);
        if (intervals.isEmpty()) {
            return null;
        }

View Full Code Here

TOP

Related Classes of org.broad.igv.util.index.IntervalTree

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.