// Path: src/main/java/abra/Logger.java
// enum Level { TRACE, DEBUG, INFO, WARN, ERROR };


import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import abra.Logger.Level;
import htsjdk.samtools.Cigar;
import htsjdk.samtools.CigarElement;
import htsjdk.samtools.CigarOperator;
import htsjdk.samtools.SAMFileWriter;
import htsjdk.samtools.SAMFileWriterFactory;
import htsjdk.samtools.SAMRecord;
import htsjdk.samtools.SamReader;
import htsjdk.samtools.TextCigarCodec;
					Cigar subCigar = new Cigar(Arrays.asList(prev, elem, next));
					String subSeq = seq.substring(readOffset, readOffset+subCigar.getReadLength());
					Cigar newCigar = shiftIndelsLeft(refStart + refOffset, refStart + refOffset + subCigar.getReferenceLength(),
							chromosome, subCigar, subSeq, c2r);
					
					//TODO: Merge abutting indels if applicable
					elems.set(i-1, newCigar.getCigarElement(0));
					elems.set(i, newCigar.getCigarElement(1));
					if (newCigar.getCigarElements().size() == 3) {
						elems.set(i+1, newCigar.getCigarElement(2));
					} else {
						elems.remove(i+1);
						elemSize -= 1;
					}
				}
			}
			
			mergeAbuttingElements(elems);
			return new Cigar(elems);
		} catch (RuntimeException e) {
			e.printStackTrace();
			Logger.error("Error on: " + refStart + ", " + refEnd + "," + chromosome + ", " + cigar + ", " + seq);
			throw e;
		}
	}
	
	// Merge neighboring Cigar elements of same type
	// mutates input
	private void mergeAbuttingElements(List<CigarElement> elems) {
		int origSize = elems.size();
// Path: src/main/java/abra/Logger.java
// enum Level { TRACE, DEBUG, INFO, WARN, ERROR };


// Path: src/main/java/abra/IndelShifter.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import abra.Logger.Level;
import htsjdk.samtools.Cigar;
import htsjdk.samtools.CigarElement;
import htsjdk.samtools.CigarOperator;
import htsjdk.samtools.SAMFileWriter;
import htsjdk.samtools.SAMFileWriterFactory;
import htsjdk.samtools.SAMRecord;
import htsjdk.samtools.SamReader;
import htsjdk.samtools.TextCigarCodec;

					Cigar subCigar = new Cigar(Arrays.asList(prev, elem, next));
					String subSeq = seq.substring(readOffset, readOffset+subCigar.getReadLength());
					Cigar newCigar = shiftIndelsLeft(refStart + refOffset, refStart + refOffset + subCigar.getReferenceLength(),
							chromosome, subCigar, subSeq, c2r);
					
					//TODO: Merge abutting indels if applicable
					elems.set(i-1, newCigar.getCigarElement(0));
					elems.set(i, newCigar.getCigarElement(1));
					if (newCigar.getCigarElements().size() == 3) {
						elems.set(i+1, newCigar.getCigarElement(2));
					} else {
						elems.remove(i+1);
						elemSize -= 1;
					}
				}
			}
			
			mergeAbuttingElements(elems);
			return new Cigar(elems);
		} catch (RuntimeException e) {
			e.printStackTrace();
			Logger.error("Error on: " + refStart + ", " + refEnd + "," + chromosome + ", " + cigar + ", " + seq);
			throw e;
		}
	}
	
	// Merge neighboring Cigar elements of same type
	// mutates input
	private void mergeAbuttingElements(List<CigarElement> elems) {
		int origSize = elems.size();
		List<CigarElement> orig = Logger.LEVEL == Level.TRACE ? new ArrayList<CigarElement>(elems) : null;