# Class CigarUtil

java.lang.Object
htsjdk.samtools.util.CigarUtil

public class CigarUtil extends Object

## Constructor Summary

Constructors
Constructor
Description
`CigarUtil()`

## Method Summary

Modifier and Type
Method
Description
`static Cigar`
`addClippedBasesToEndsOfCigar(Cigar cigar, boolean negativeStrand, int threePrimeEnd, int fivePrimeEnd, CigarOperator clippingOperator)`
Adds additional soft-clipped bases at the 3' and/or 5' end of the cigar.
`static Cigar`
`addSoftClippedBasesToEndsOfCigar(Cigar cigar, boolean negativeStrand, int threePrimeEnd, int fivePrimeEnd)`
Adds additional soft-clipped bases at the 3' and/or 5' end of the cigar.
`static char[]`
`cigarArrayFromElements(List<CigarElement> cigar)`
`static char[]`
`cigarArrayFromString(String cigar)`
`static String`
`cigarStringFromArray(char[] cigar)`
`static void`
`clip3PrimeEndOfRead(SAMRecord rec, int clipFrom, CigarOperator clippingOperator)`
Adds a soft- or hard-clip, based on `clipFrom` and `clippingOperator`, to the SAM record's existing cigar and, for negative strands, also adjusts the SAM record's start position.
`static List<CigarElement>`
`clipEndOfRead(int clipFrom, List<CigarElement> oldCigar, CigarOperator clippingOperator)`
Adjust the cigar based on adapter clipping.
`static void`
`softClip3PrimeEndOfRead(SAMRecord rec, int clipFrom)`
Adjust the cigar of `rec` based on adapter clipping using soft-clipping
`static List<CigarElement>`
`softClipEndOfRead(int clipFrom, List<CigarElement> oldCigar)`
Adjust the cigar based on adapter clipping

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### CigarUtil

public CigarUtil()

## Method Details

### clipEndOfRead

public static List<CigarElement> clipEndOfRead(int clipFrom, List<CigarElement> oldCigar, CigarOperator clippingOperator)
Adjust the cigar based on adapter clipping. TODO: If there is hard clipping at the end of the input CIGAR, it is lost. It should not be. *

Parameters:
  `clipFrom` - 1-based position where the clipping starts
  `oldCigar` - The existing unclipped cigar
  `clippingOperator` - Type of clipping to use, either soft or hard. If non-clipping operator is used an exception is thrown
Returns:
  New adjusted list of cigar elements

### softClipEndOfRead

public static List<CigarElement> softClipEndOfRead(int clipFrom, List<CigarElement> oldCigar)
Adjust the cigar based on adapter clipping

Parameters:
  `clipFrom` - 1-based position where the clipping starts
  `oldCigar` - The existing unclipped cigar
Returns:
  New adjusted list of cigar elements

### softClip3PrimeEndOfRead

public static void softClip3PrimeEndOfRead(SAMRecord rec, int clipFrom)
Adjust the cigar of `rec` based on adapter clipping using soft-clipping

Parameters:
  `clipFrom` - 1-based position where the soft-clipping starts

### clip3PrimeEndOfRead

public static void clip3PrimeEndOfRead(SAMRecord rec, int clipFrom, CigarOperator clippingOperator)
Adds a soft- or hard-clip, based on `clipFrom` and `clippingOperator`, to the SAM record's existing cigar and, for negative strands, also adjusts the SAM record's start position. If clipping changes the number of unclipped bases, the the NM, MD, and UQ tags will be invalidated. Clips the end of the read as the read came off the sequencer.

Parameters:
  `rec` - SAMRecord to clip
  `clipFrom` - Position to clip from
  `clippingOperator` - Type of clipping to use, either soft or hard. If non-clipping operator is used an exception is thrown

### addClippedBasesToEndsOfCigar

public static Cigar addClippedBasesToEndsOfCigar(Cigar cigar, boolean negativeStrand, int threePrimeEnd, int fivePrimeEnd, CigarOperator clippingOperator)
Adds additional soft-clipped bases at the 3' and/or 5' end of the cigar. Does not change the existing cigar except to merge the newly added soft-clipped bases if the element at the end of the cigar being modified is also a soft-clip.

Parameters:
  `cigar` - The cigar on which to base the new cigar
  `negativeStrand` - Whether the read is on the negative strand
  `threePrimeEnd` - number of soft-clipped bases to add to the 3' end of the read
  `fivePrimeEnd` - number of soft-clipped bases to add to the 5' end of the read
  `clippingOperator` - Type of clipping to use, either soft or hard. If non-clipping operator is used an exception is thrown

### addSoftClippedBasesToEndsOfCigar

public static Cigar addSoftClippedBasesToEndsOfCigar(Cigar cigar, boolean negativeStrand, int threePrimeEnd, int fivePrimeEnd)
Adds additional soft-clipped bases at the 3' and/or 5' end of the cigar. Does not change the existing cigar except to merge the newly added soft-clipped bases if the element at the end of the cigar being modified is also a soft-clip.

Parameters:
  `cigar` - The cigar on which to base the new cigar
  `negativeStrand` - Whether the read is on the negative strand
  `threePrimeEnd` - number of soft-clipped bases to add to the 3' end of the read
  `fivePrimeEnd` - number of soft-clipped bases to add to the 5' end of the read
Returns:
  New cigar with additional soft-clipped bases

### cigarArrayFromElements

public static char[] cigarArrayFromElements(List<CigarElement> cigar)

### cigarArrayFromString

public static char[] cigarArrayFromString(String cigar)

### cigarStringFromArray

public static String cigarStringFromArray(char[] cigar)