/** * @param rec the SAM record * @return number of cigar elements (number + operator) in the mate cigar string. */ public static int getMateCigarLength(final SAMRecord rec) { final Cigar mateCigar = getMateCigar(rec); return (mateCigar != null) ? mateCigar.numCigarElements() : 0; }
/** * This method is preferred over getCigar().getNumElements(), because for BAMRecord it may be faster. * @return number of cigar elements (number + operator) in the cigar string. */ public int getCigarLength() { return getCigar().numCigarElements(); }
/** * This method is preferred over getCigar().getNumElements(), because for BAMRecord it may be faster. * @return number of cigar elements (number + operator) in the cigar string. */ public int getCigarLength() { return getCigar().numCigarElements(); }
/** * This method is preferred over getCigar().getNumElements(), because for BAMRecord it may be faster. * @return number of cigar elements (number + operator) in the cigar string. */ public int getCigarLength() { return getCigar().numCigarElements(); }
/** * @param rec the SAM record * @return number of cigar elements (number + operator) in the mate cigar string. */ public static int getMateCigarLength(final SAMRecord rec) { final Cigar mateCigar = getMateCigar(rec); return (mateCigar != null) ? mateCigar.numCigarElements() : 0; }
/** * @param rec the SAM record * @return number of cigar elements (number + operator) in the mate cigar string. */ public static int getMateCigarLength(final SAMRecord rec) { final Cigar mateCigar = getMateCigar(rec); return (mateCigar != null) ? mateCigar.numCigarElements() : 0; }
/** * @param rec the SAM record * @return number of cigar elements (number + operator) in the mate cigar string. */ public static int getMateCigarLength(final SAMRecord rec) { final Cigar mateCigar = getMateCigar(rec); return (mateCigar != null) ? mateCigar.numCigarElements() : 0; }
/** returns the last cigar element */ public CigarElement getLastCigarElement() { return isEmpty() ? null : this.cigarElements.get(this.numCigarElements() - 1 ); }
/** returns the last cigar element */ public CigarElement getLastCigarElement() { return isEmpty() ? null : this.cigarElements.get(this.numCigarElements() - 1 ); }
static CigarOperator getCigarOperator(Cigar cigar, int ci) { CigarOperator operator = cigar.getCigarElement(ci).getOperator(); // Treat insertions at the edge as soft-clipping if ((ci == 0 || ci == cigar.numCigarElements() - 1) && operator == CigarOperator.I) { operator = CigarOperator.S; } return operator; }
protected static Cigar unclipCigar(Cigar cigar) { ArrayList<CigarElement> elements = new ArrayList<CigarElement>(cigar.numCigarElements()); for ( CigarElement ce : cigar.getCigarElements() ) { if ( !isClipOperator(ce.getOperator()) ) elements.add(ce); } return new Cigar(elements); }
public void setCigar(Cigar cigar) { if (CIGAR < 0) throw new RuntimeException("Premature setting of cigar."); writeUShort(cigar.numCigarElements(), CIGAR_LEN); final int[] binaryCigar = encodeBinaryCigar(cigar); int at = CIGAR; for (final int cigarElement : binaryCigar) { // Assumption that this will fit into an integer, despite the fact // that it is specced as a uint. writeInt(cigarElement, at); at += 4; } BASES = at; }
@Requires({"read != null", "read.getAlignmentStart() != -1", "read.getCigar() != null"}) public AlignmentStateMachine(final GATKSAMRecord read) { this.read = read; this.cigar = read.getCigar(); this.nCigarElements = cigar.numCigarElements(); initializeAsLeftEdge(); }
public LIBS_position(final SAMRecord read) { this.read = read; numOperators = read.getCigar().numCigarElements(); }
/** * Does cigar start or end with a deletion operation? * * @param cigar a non-null cigar to test * @return true if the first or last operator of cigar is a D */ public static boolean startsOrEndsWithInsertionOrDeletion(final Cigar cigar) { 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; }
/** * Skip the insertions and deletions that are right after or before introns (they indicate of aligner problem) * @param cigar cigar of the read * @param ci current index of element in cigar * @return true if cigar operator must be skipped, false if not */ private static boolean skipIndelNextToIntron(Cigar cigar, int ci) { if ((cigar.numCigarElements() > ci && cigar.getCigarElement(ci + 1).getOperator() == CigarOperator.N) || (ci > 1 && cigar.getCigarElement(ci - 1).getOperator() == CigarOperator.N)) { return true; } return false; }
/** * Checks to see if the provided Cigar could be considered the "sentinel cigar" that indicates * that the actual cigar is too long for the BAM spec and should be taken from the CG tag. This * was introduced in SAM v1.6. */ static boolean isSentinelCigar(final Cigar cigar, final int readLength) { // There's an implicit assumption here there readLength == length of read in cigar, unless readLength==0 return cigar.numCigarElements() == 2 && cigar.getCigarElement(1).getOperator() == CigarOperator.N && cigar.getCigarElement(0).getOperator() == CigarOperator.S && (cigar.getCigarElement(0).getLength() == readLength || readLength == 0) ; }
/** * Checks to see if the provided Cigar could be considered the "sentinel cigar" that indicates * that the actual cigar is too long for the BAM spec and should be taken from the CG tag. This * was introduced in SAM v1.6. */ static boolean isSentinelCigar(final Cigar cigar, final int readLength) { // There's an implicit assumption here there readLength == length of read in cigar, unless readLength==0 return cigar.numCigarElements() == 2 && cigar.getCigarElement(1).getOperator() == CigarOperator.N && cigar.getCigarElement(0).getOperator() == CigarOperator.S && (cigar.getCigarElement(0).getLength() == readLength || readLength == 0) ; }
protected static Cigar reclipCigar(Cigar cigar, SAMRecord read) { ArrayList<CigarElement> elements = new ArrayList<CigarElement>(); int i = 0; int n = read.getCigar().numCigarElements(); while ( i < n && isClipOperator(read.getCigar().getCigarElement(i).getOperator()) ) elements.add(read.getCigar().getCigarElement(i++)); elements.addAll(cigar.getCigarElements()); i++; while ( i < n && !isClipOperator(read.getCigar().getCigarElement(i).getOperator()) ) i++; while ( i < n && isClipOperator(read.getCigar().getCigarElement(i).getOperator()) ) elements.add(read.getCigar().getCigarElement(i++)); return new Cigar(elements); }
public Integer map(ReferenceContext ref, GATKSAMRecord read, RefMetaDataTracker metaDataTracker) { // we can not deal with screwy records if ( read.getReadUnmappedFlag() || read.getCigar().numCigarElements() == 0 ) { emit(read); return 0; } // move existing indels (for 1 indel reads only) to leftmost position within identical sequence int numBlocks = AlignmentUtils.getNumAlignmentBlocks(read); if ( numBlocks == 2 ) { Cigar newCigar = AlignmentUtils.leftAlignIndel(IndelRealigner.unclipCigar(read.getCigar()), ref.getBases(), read.getReadBases(), 0, 0, true); newCigar = IndelRealigner.reclipCigar(newCigar, read); read.setCigar(newCigar); } emit(read); return 1; }