Package net.sf.picard.util

Examples of net.sf.picard.util.Interval


        SAMFileReader samReader = new SAMFileReader(bam, bam_index);
        String chr_id = "chr1";
        int start = 1;
        int end = 20;
//        int end = 247199724;
        Interval interval = new Interval(chr_id, start, end);
        IntervalList il = new IntervalList(samReader.getFileHeader());
        il.add(interval);
       
        SamLocusIterator sli = new SamLocusIterator(samReader, il, true);
View Full Code Here


    public void setAvgSeqQWindow(double avgSeqQWindow) {
        this.avgSeqQWindow = avgSeqQWindow;
    }

    public void setDeletionInfo(SAMFileReader samReader, ArrayList overlappedAreaList) {
        Interval interval = new Interval(getChr(), getWindowStart(), getWindowEnd());
        IntervalList il = new IntervalList(samReader.getFileHeader());
        il.add(interval);

        ArrayList locusList = new ArrayList();
View Full Code Here

    }

    public void putRegion(int startPos, int endPos, String seqName, boolean positiveStranded) {
        // unique feature name
        String featureName = "region" + ++regionCount;
        overlapDetector.addLhs( new Feature(featureName, positiveStranded), new Interval(seqName, startPos, endPos));
        sequenceNames.add(seqName);
    }
View Full Code Here

        overlapDetector.addLhs( new Feature(featureName, positiveStranded), new Interval(seqName, startPos, endPos));
        sequenceNames.add(seqName);
    }

    public boolean overlaps(int readStart, int readEnd, String seqName) {
        Collection<Feature> overlaps = overlapDetector.getOverlaps(new Interval(seqName, readStart, readEnd));

        return overlaps.size() > 0;
    }
View Full Code Here

        return overlaps.size() > 0;
    }

    public OverlapResult overlaps(int readStart, int readEnd, String seqName, boolean forwardStrandExpected) {
        Collection<Feature> overlaps = overlapDetector.getOverlaps(new Interval(seqName, readStart, readEnd));

        Iterator<Feature> it = overlaps.iterator();

        int numStrandMatches = 0;
        int numMatches = 0;
View Full Code Here

                    }
                }

                for (int i = 0; i < breakCoords.length; i+=2) {
                    String chrName = gene.getSequence();
                    Interval intronInterval = new Interval(chrName, breakCoords[i], breakCoords[i+1]);
                    numIntrons++;
                    intronIntervalTreeMap.put(intronInterval, numIntrons);
                    junctionLocationMap.put(chrName, breakCoords[i],breakCoords[i+1]);
                }
View Full Code Here

        int posInRead = 0;
        for (CigarElement cigarElement : cigarElements) {
            int length = cigarElement.getLength();

            if ( cigarElement.getOperator().equals(CigarOperator.M)  ) {
                intervals.add(new Interval(chrName, offset, offset + length - 1, strand, "" ));
                posInRead += length;
            }

            if (cigarElement.getOperator().equals(CigarOperator.I) ||
                    cigarElement.getOperator().equals(CigarOperator.EQ) ||
View Full Code Here

    Interval interval;
    Map<String,String> attributes;

    public GenomicFeature(String seqName, int start, int end, boolean isNegative, String featureName ) {
        interval = new Interval(seqName, start, end, isNegative, featureName);
        attributes = new HashMap<String, String>();
    }
View Full Code Here

    /* concatenates intersecting intervals */
    private static Interval concatenateIntervals(Interval i1, Interval i2) {
        int start =  Math.min(i1.getStart(),i2.getStart());
        int end = Math.max(i1.getEnd(), i2.getEnd());
        return new Interval(i1.getSequence(), start,end, i1.isPositiveStrand(), i1.getName());
    }
View Full Code Here

    public void addRegion(GenomicFeature r, String featureName) {

            boolean featureStrand = r.isPositiveStrand();

            Interval newInterval = new Interval(r.getSequenceName(), r.getStart(), r.getEnd(), r.isPositiveStrand(), featureName);
            List<Interval> toRemove = new ArrayList<Interval>();

            //DEBUG
            /*if (featureName.equals("ENSG00000214827") && (r.getStart() == 154292309 || r.getStart() == 154292241)  ) {
                System.out.println("It's something new here!");
            }*/

            if (featureIntervalMap.containsKey(featureName)) {
                Collection<Interval> intervals = featureIntervalMap.get(featureName);
                for (Interval interval: intervals ) {
                    if (newInterval.intersects(interval) || newInterval.abuts(interval)) {
                        if (newInterval.getStart() == interval.getStart() && newInterval.getEnd() == interval.getEnd()) {
                            // equal interval is already present for this feature
                            return;
                        }
                        newInterval = concatenateIntervals(newInterval, interval);
                        toRemove.add(interval);
                    }
                }

                intervals.removeAll(toRemove);

            }

            // If we removed intervals from featureIntervalMap, then need to update the intervalTree accordingly
            for (Interval iv : toRemove) {
                IntervalTree.Node<Set<Feature>> redundantInterval = intervalTree.find(iv.getStart(), iv.getEnd());
                Set<Feature> features = redundantInterval.getValue();
                removeFeatureByName(featureName, features);
                if (features.isEmpty()) {
                    intervalTree.remove(iv.getStart(), iv.getEnd());
                }
            }

            IntervalTree.Node<Set<Feature>> dublicateInterval = intervalTree.find(newInterval.getStart(), newInterval.getEnd());
            if (dublicateInterval != null ) {
                Set<Feature> intervalFeatures = dublicateInterval.getValue();
                intervalFeatures.add(new Feature(featureName, featureStrand) );
            } else {
                Set<Feature> intervalFeatures = new HashSet<Feature>();
                intervalFeatures.add(new Feature(featureName, featureStrand));
                intervalTree.put(newInterval.getStart(), newInterval.getEnd(), intervalFeatures);
            }
            featureIntervalMap.put(featureName, newInterval);



View Full Code Here

TOP

Related Classes of net.sf.picard.util.Interval

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.