// Path: src/main/java/abra/SAMRecordWrapper.java
// static class Span {
// 	int start;
// 	int end;
// 		
// 	public Span(int start, int end) {
// 		this.start = start;
// 		this.end = end;
// 	}
// 
// 	@Override
// 	public int hashCode() {
// 		final int prime = 31;
// 		int result = 1;
// 		result = prime * result + end;
// 		result = prime * result + start;
// 		return result;
// 	}
// 
// 	@Override
// 	public boolean equals(Object obj) {
// 		if (this == obj)
// 			return true;
// 		if (obj == null)
// 			return false;
// 		if (getClass() != obj.getClass())
// 			return false;
// 		Span other = (Span) obj;
// 		if (end != other.end)
// 			return false;
// 		if (start != other.start)
// 			return false;
// 		return true;
// 	}
// }


import java.util.ArrayList;
import java.util.List;
import abra.SAMRecordWrapper.Span;
import htsjdk.samtools.SAMFileHeader;
import htsjdk.samtools.SAMRecord;

	public void setKmer(int kmer) {
		this.kmerSize = kmer;
	}
	
	public static int findFirstOverlappingRegion(SAMFileHeader samHeader, SAMRecordWrapper read, int readStart, int readEnd, List<Feature> regions, int start) {
		if (start < 0) {
			start = 0;
		}

		for (int idx=start; idx<regions.size(); idx++) {
			Feature region = regions.get(idx);
			if ( (read.getSamRecord().getReferenceIndex() < samHeader.getSequenceDictionary().getSequenceIndex(region.getSeqname())) ||
				 (read.getSamRecord().getReferenceName().equals(region.getSeqname()) && readStart < region.getStart()) ) {
				
				// This read is in between regions
				// TODO: adjust start region here
				return -1;
			} else if (region.overlaps(read.getSamRecord().getReferenceName(), readStart, readEnd)) {
				return idx;
			}
		}
		
		// This read is beyond all regions
		return -1;
	}
	
	public static List<Integer> findAllOverlappingRegions(SAMFileHeader samHeader, SAMRecordWrapper read, List<Feature> regions, int start) {
		List<Integer> overlappingRegions = new ArrayList<Integer>();
		
// Path: src/main/java/abra/SAMRecordWrapper.java
// static class Span {
// 	int start;
// 	int end;
// 		
// 	public Span(int start, int end) {
// 		this.start = start;
// 		this.end = end;
// 	}
// 
// 	@Override
// 	public int hashCode() {
// 		final int prime = 31;
// 		int result = 1;
// 		result = prime * result + end;
// 		result = prime * result + start;
// 		return result;
// 	}
// 
// 	@Override
// 	public boolean equals(Object obj) {
// 		if (this == obj)
// 			return true;
// 		if (obj == null)
// 			return false;
// 		if (getClass() != obj.getClass())
// 			return false;
// 		Span other = (Span) obj;
// 		if (end != other.end)
// 			return false;
// 		if (start != other.start)
// 			return false;
// 		return true;
// 	}
// }


// Path: src/main/java/abra/Feature.java
import java.util.ArrayList;
import java.util.List;
import abra.SAMRecordWrapper.Span;
import htsjdk.samtools.SAMFileHeader;
import htsjdk.samtools.SAMRecord;


	public void setKmer(int kmer) {
		this.kmerSize = kmer;
	}
	
	public static int findFirstOverlappingRegion(SAMFileHeader samHeader, SAMRecordWrapper read, int readStart, int readEnd, List<Feature> regions, int start) {
		if (start < 0) {
			start = 0;
		}

		for (int idx=start; idx<regions.size(); idx++) {
			Feature region = regions.get(idx);
			if ( (read.getSamRecord().getReferenceIndex() < samHeader.getSequenceDictionary().getSequenceIndex(region.getSeqname())) ||
				 (read.getSamRecord().getReferenceName().equals(region.getSeqname()) && readStart < region.getStart()) ) {
				
				// This read is in between regions
				// TODO: adjust start region here
				return -1;
			} else if (region.overlaps(read.getSamRecord().getReferenceName(), readStart, readEnd)) {
				return idx;
			}
		}
		
		// This read is beyond all regions
		return -1;
	}
	
	public static List<Integer> findAllOverlappingRegions(SAMFileHeader samHeader, SAMRecordWrapper read, List<Feature> regions, int start) {
		List<Integer> overlappingRegions = new ArrayList<Integer>();
		
		for (Span span : read.getSpanningRegions()) {