Examples of CigarOperator


Examples of htsjdk.samtools.CigarOperator

            }
            int length = (cigarBytes[i] - ZERO_BYTE);
            for (++i; isDigit(cigarBytes[i]); ++i) {
                length = (length * 10) + cigarBytes[i] - ZERO_BYTE;
            }
            final CigarOperator operator = CigarOperator.characterToEnum(cigarBytes[i]);
            ret.add(new CigarElement(length, operator));
        }
        return ret;
    }
View Full Code Here

Examples of htsjdk.samtools.CigarOperator

    private List<Integer> consecutiveNonNElements(final List<CigarElement> cigarElements){
        final LinkedList<Integer> results = new LinkedList<>();
        int consecutiveLength = 0;
        for(CigarElement element: cigarElements){
            final CigarOperator op = element.getOperator();
            if(op.equals(CigarOperator.MATCH_OR_MISMATCH) || op.equals(CigarOperator.SOFT_CLIP) || op.equals(CigarOperator.INSERTION)){
                consecutiveLength += element.getLength();
            }
            else if(op.equals(CigarOperator.SKIPPED_REGION))
            {
                if(consecutiveLength != 0){
                    results.addLast(consecutiveLength);
                    consecutiveLength = 0;
                }
View Full Code Here

Examples of htsjdk.samtools.CigarOperator

    **/
    public static boolean isCigarValid(Cigar cigar) {
        if (cigar.isValid(null, -1) == null) {                                                                          // This should take care of most invalid Cigar Strings (picard's "exhaustive" implementation)

            Stack<CigarElement> cigarElementStack = new Stack<CigarElement>();                                          // Stack to invert cigar string to find ending operator
            CigarOperator startingOp = null;
            CigarOperator endingOp = null;

            // check if it doesn't start with deletions
            boolean readHasStarted = false;                                                                             // search the list of elements for the starting operator
            for (CigarElement cigarElement : cigar.getCigarElements()) {
                if (!readHasStarted) {
View Full Code Here

Examples of htsjdk.samtools.CigarOperator

        if ( cigar == null ) throw new IllegalArgumentException("Cigar cannot be null");

        if ( cigar.isEmpty() )
            return false;

        final CigarOperator first = cigar.getCigarElement(0).getOperator();
        final CigarOperator last = cigar.getCigarElement(cigar.numCigarElements()-1).getOperator();
        return first == CigarOperator.D || first == CigarOperator.I || last == CigarOperator.D || last == CigarOperator.I;
    }
View Full Code Here

Examples of htsjdk.samtools.CigarOperator

     */
    private static boolean needsConsolidation(final Cigar c) {
        if ( c.numCigarElements() <= 1 )
            return false; // fast path for empty or single cigar

        CigarOperator lastOp = null;
        for( final CigarElement cur : c.getCigarElements() ) {
            if ( cur.getLength() == 0 || lastOp == cur.getOperator() )
                return true;
            lastOp = cur.getOperator();
        }
View Full Code Here

Examples of htsjdk.samtools.CigarOperator

    public Cigar convertToCigar(boolean negativeStrand) {
        Cigar cigar = new Cigar();
        Iterator<AlignmentMatchSequenceEntry> iterator = negativeStrand ? entries.descendingIterator() : entries.iterator();
        while( iterator.hasNext() ) {
            AlignmentMatchSequenceEntry entry = iterator.next();
            CigarOperator operator;
            switch( entry.getAlignmentState() ) {
                case MATCH_MISMATCH: operator = CigarOperator.MATCH_OR_MISMATCH; break;
                case INSERTION: operator = CigarOperator.INSERTION; break;
                case DELETION: operator = CigarOperator.DELETION; break;
                default: throw new ReviewedGATKException("convertToCigar: cannot process state: " + entry.getAlignmentState());
View Full Code Here

Examples of htsjdk.samtools.CigarOperator

            return false;
        }

        Iterator<CigarElement> elementIterator = c.getCigarElements().iterator();

        CigarOperator firstOp = CigarOperator.H;
        while (elementIterator.hasNext() && (firstOp == CigarOperator.H || firstOp == CigarOperator.S)) {
            CigarOperator op = elementIterator.next().getOperator();

            // No reads with Hard/Soft clips in the middle of the cigar
            if (firstOp != CigarOperator.H && op == CigarOperator.H) {
                    return true;
            }
            firstOp = op;
        }

        // No reads starting with deletions (with or without preceding clips)
        if (firstOp == CigarOperator.D) {
            return true;
        }

        boolean hasMeaningfulElements = (firstOp != CigarOperator.H && firstOp != CigarOperator.S);
        boolean previousElementWasIndel = firstOp == CigarOperator.I;
        CigarOperator lastOp = firstOp;
        CigarOperator previousOp = firstOp;

        while (elementIterator.hasNext()) {
            CigarOperator op = elementIterator.next().getOperator();

            if (op != CigarOperator.S && op != CigarOperator.H) {

                // No reads with Hard/Soft clips in the middle of the cigar
                if (previousOp == CigarOperator.S || previousOp == CigarOperator.H)
                    return true;

                lastOp = op;

                if (!hasMeaningfulElements && op.consumesReadBases()) {
                    hasMeaningfulElements = true;
                }

                if (op == CigarOperator.I || op == CigarOperator.D) {
View Full Code Here

Examples of htsjdk.samtools.CigarOperator

        return new HashMap<Integer, Map<CigarOperator, Long>>();
    }

    public Map<Integer, Map<CigarOperator, Long>> reduce(Map<CigarOperator, ArrayList<Integer>> value, Map<Integer, Map<CigarOperator, Long>> sum) {
        for (Map.Entry<CigarOperator, ArrayList<Integer>> entry : value.entrySet()) {
            CigarOperator op = entry.getKey();
            ArrayList<Integer> positions = entry.getValue();

            for (int p : positions) {
                Map<CigarOperator, Long> operatorCount = sum.get(p);
                if (operatorCount == null) {
View Full Code Here

Examples of htsjdk.samtools.CigarOperator

        Collections.reverse(lce);
        return new SWPairwiseAlignmentResult(AlignmentUtils.consolidateCigar(new Cigar(lce)), alignment_offset);
    }

    protected CigarElement makeElement(final State state, final int length) {
        CigarOperator op = null;
        switch (state) {
            case MATCH: op = CigarOperator.M; break;
            case INSERTION: op = CigarOperator.I; break;
            case DELETION: op = CigarOperator.D; break;
            case CLIP: op = CigarOperator.S; break;
View Full Code Here

Examples of htsjdk.samtools.CigarOperator

                while (iterator.hasNext()) {
                    // state object with the read/offset information
                    final AlignmentStateMachine state = iterator.next();
                    final GATKSAMRecord read = state.getRead();
                    final CigarOperator op = state.getCigarOperator();

                    if (op == CigarOperator.N) // N's are never added to any pileup
                        continue;

                    if (!dontIncludeReadInPileup(read, location.getStart())) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.