// Path: src/main/java/abra/SAMRecordUtils.java
// public static class ReadBlock {
// 	private int readPos;
// 	private int refPos;
// 	private int length;
// 	private CigarElement elem;
// 		
// 	public ReadBlock(int readPos, int refPos, int length, CigarElement elem) {
// 		this.readPos = readPos;
// 		this.refPos = refPos;
// 		this.length = length;
// 		this.elem = elem;
// 	}
// 
// 	public int getReadPos() {
// 		return readPos;
// 	}
// 
// 	public int getRefPos() {
// 		return refPos;
// 	}
// 
// 	public int getLength() {
// 		return length;
// 	}
// 		
// 	public CigarElement getCigarElement() {
// 		return elem;
// 	}
// }


import htsjdk.samtools.CigarElement;
import htsjdk.samtools.CigarOperator;
import htsjdk.samtools.SAMRecord;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import abra.SAMRecordUtils.ReadBlock;
							elems.get(0).getOperator() == CigarOperator.M && 
							elems.get(2).getOperator() == CigarOperator.M &&
							(elems.get(1).getOperator() == CigarOperator.D || elems.get(1).getOperator() == CigarOperator.I)) {
							
							String insertBases = null;
							char type = '0';
							
							if (elems.get(1).getOperator() == CigarOperator.D) {
								type = 'D';
							} else if (elems.get(1).getOperator() == CigarOperator.I) {
								type = 'I';
								int start = elems.get(0).getLength();
								int stop =  start + elems.get(1).getLength();
								insertBases = read.getReadString().substring(start, stop);
							}
							
							int refStart = read.getAlignmentStart() + elems.get(0).getLength();
							
							// Require indel start to be within region
							if (refStart >= region.getStart() && refStart <= region.getEnd()) {
								Indel indel = new Indel(type, read.getReferenceName(), refStart, elems.get(1).getLength(), insertBases, elems.get(0).getLength(), SAMRecordUtils.sumBaseQuals(read));
								if (indels.containsKey(indel)) {
									indels.get(indel).addReadPosition(elems.get(0).getLength(), SAMRecordUtils.sumBaseQuals(read));
								} else {
									indels.put(indel, indel);
								}
							}
						} else if(SAMRecordUtils.getNumGaps(read) > 1) {
							// Handle read containing multiple indels (create single contig)
							List<Indel> indelComponents = new ArrayList<Indel>();
// Path: src/main/java/abra/SAMRecordUtils.java
// public static class ReadBlock {
// 	private int readPos;
// 	private int refPos;
// 	private int length;
// 	private CigarElement elem;
// 		
// 	public ReadBlock(int readPos, int refPos, int length, CigarElement elem) {
// 		this.readPos = readPos;
// 		this.refPos = refPos;
// 		this.length = length;
// 		this.elem = elem;
// 	}
// 
// 	public int getReadPos() {
// 		return readPos;
// 	}
// 
// 	public int getRefPos() {
// 		return refPos;
// 	}
// 
// 	public int getLength() {
// 		return length;
// 	}
// 		
// 	public CigarElement getCigarElement() {
// 		return elem;
// 	}
// }


// Path: src/main/java/abra/AltContigGenerator.java
import htsjdk.samtools.CigarElement;
import htsjdk.samtools.CigarOperator;
import htsjdk.samtools.SAMRecord;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import abra.SAMRecordUtils.ReadBlock;

							elems.get(0).getOperator() == CigarOperator.M && 
							elems.get(2).getOperator() == CigarOperator.M &&
							(elems.get(1).getOperator() == CigarOperator.D || elems.get(1).getOperator() == CigarOperator.I)) {
							
							String insertBases = null;
							char type = '0';
							
							if (elems.get(1).getOperator() == CigarOperator.D) {
								type = 'D';
							} else if (elems.get(1).getOperator() == CigarOperator.I) {
								type = 'I';
								int start = elems.get(0).getLength();
								int stop =  start + elems.get(1).getLength();
								insertBases = read.getReadString().substring(start, stop);
							}
							
							int refStart = read.getAlignmentStart() + elems.get(0).getLength();
							
							// Require indel start to be within region
							if (refStart >= region.getStart() && refStart <= region.getEnd()) {
								Indel indel = new Indel(type, read.getReferenceName(), refStart, elems.get(1).getLength(), insertBases, elems.get(0).getLength(), SAMRecordUtils.sumBaseQuals(read));
								if (indels.containsKey(indel)) {
									indels.get(indel).addReadPosition(elems.get(0).getLength(), SAMRecordUtils.sumBaseQuals(read));
								} else {
									indels.put(indel, indel);
								}
							}
						} else if(SAMRecordUtils.getNumGaps(read) > 1) {
							// Handle read containing multiple indels (create single contig)
							List<Indel> indelComponents = new ArrayList<Indel>();
							List<ReadBlock> readBlocks = SAMRecordUtils.getReadBlocks(read.getCigar(), read.getAlignmentStart());