path = new Path<>(path, graph.getEdge(v7,postV));
// Construct the actual cigar string implied by the test path
Cigar expectedCigar = new Cigar();
if( offRefBeginning ) {
expectedCigar.add(new CigarElement(preAltOption.length(), CigarOperator.I));
}
expectedCigar.add(new CigarElement(preRef.length(), CigarOperator.M));
// first bubble
if( refBubbleLength > altBubbleLength ) {
expectedCigar.add(new CigarElement(refBubbleLength - altBubbleLength, CigarOperator.D));
expectedCigar.add(new CigarElement(altBubbleLength,CigarOperator.M));
} else if ( refBubbleLength < altBubbleLength ) {
expectedCigar.add(new CigarElement(refBubbleLength,CigarOperator.M));
expectedCigar.add(new CigarElement(altBubbleLength - refBubbleLength,CigarOperator.I));
} else {
expectedCigar.add(new CigarElement(refBubbleLength, CigarOperator.M));
}
expectedCigar.add(new CigarElement(midRef1.length(), CigarOperator.M));
// second bubble is ref path
expectedCigar.add(new CigarElement(refBubbleLength, CigarOperator.M));
expectedCigar.add(new CigarElement(midRef2.length(), CigarOperator.M));
// third bubble
if( refBubbleLength > altBubbleLength ) {
expectedCigar.add(new CigarElement(refBubbleLength - altBubbleLength, CigarOperator.D));
expectedCigar.add(new CigarElement(altBubbleLength,CigarOperator.M));
} else if ( refBubbleLength < altBubbleLength ) {
expectedCigar.add(new CigarElement(refBubbleLength,CigarOperator.M));
expectedCigar.add(new CigarElement(altBubbleLength - refBubbleLength,CigarOperator.I));
} else {
expectedCigar.add(new CigarElement(refBubbleLength, CigarOperator.M));
}
expectedCigar.add(new CigarElement(postRef.length(), CigarOperator.M));
if( offRefEnding ) {
expectedCigar.add(new CigarElement(postAltOption.length(), CigarOperator.I));
}
Assert.assertEquals(path.calculateCigar(ref.getBytes()).toString(),
AlignmentUtils.consolidateCigar(expectedCigar).toString(),
"Cigar string mismatch: ref = " + ref + " alt " + new String(path.getBases()));