// Path: src/main/java/abra/SemiGlobalAligner.java
// static class Result {
// 	Result(int score, int secondBest, int position, int endPosition, String cigar) {
// 		this.score = score;
// 		this.secondBest = secondBest;
// 		this.position = position;
// 		this.endPosition = endPosition;
// 		this.cigar = cigar;
// 	}
// 		
// 	int score;
// 	int secondBest;
// 	int position;
// 	int endPosition;
// 	String cigar;
// 		
// 	public String toString() {
// 		return String.format("score: %d, secondBest: %d, pos: %d, endPos: %d, cigar: %s", score, secondBest, position, endPosition, cigar);
// 	}
// }


import abra.SemiGlobalAligner.Result;
package abra;


public class NativeSemiGlobalAligner {

	private native String align(String seq1, String seq2, int match, int mismatch, int gapOpen, int gapExtend);
	
	private int match = 8;
	private int mismatch = -32;
	private int gapOpen = -48;
	private int gapExtend = -1;
	
	public static final int MAX_CONTIG_LEN = 1998;
	public static final int MAX_REF_LEN = 4998;
	
	public NativeSemiGlobalAligner(int match, int mismatch, int gapOpen, int gapExtend) {
		this.match = match;
		this.mismatch = mismatch;
		this.gapOpen = gapOpen;
		this.gapExtend = gapExtend;
	}
	
	public Result align(String seq1, String seq2) {
		
		if (seq1.length() > MAX_CONTIG_LEN) {
			throw new IllegalArgumentException("Contig too long");
		}
		
		if (seq2.length() > MAX_REF_LEN) {
			throw new IllegalArgumentException("Ref too long");
		}
		
		// Result returned in format score:secondBest:pos:endPos:cigar
		// 789:741:611:734:52M108I71M
		String res = align(seq1, seq2, match, mismatch, gapOpen, gapExtend);
		
		String[] results = res.split(":");
// Path: src/main/java/abra/SemiGlobalAligner.java
// static class Result {
// 	Result(int score, int secondBest, int position, int endPosition, String cigar) {
// 		this.score = score;
// 		this.secondBest = secondBest;
// 		this.position = position;
// 		this.endPosition = endPosition;
// 		this.cigar = cigar;
// 	}
// 		
// 	int score;
// 	int secondBest;
// 	int position;
// 	int endPosition;
// 	String cigar;
// 		
// 	public String toString() {
// 		return String.format("score: %d, secondBest: %d, pos: %d, endPos: %d, cigar: %s", score, secondBest, position, endPosition, cigar);
// 	}
// }


// Path: src/main/java/abra/NativeSemiGlobalAligner.java
import abra.SemiGlobalAligner.Result;

package abra;


public class NativeSemiGlobalAligner {

	private native String align(String seq1, String seq2, int match, int mismatch, int gapOpen, int gapExtend);
	
	private int match = 8;
	private int mismatch = -32;
	private int gapOpen = -48;
	private int gapExtend = -1;
	
	public static final int MAX_CONTIG_LEN = 1998;
	public static final int MAX_REF_LEN = 4998;
	
	public NativeSemiGlobalAligner(int match, int mismatch, int gapOpen, int gapExtend) {
		this.match = match;
		this.mismatch = mismatch;
		this.gapOpen = gapOpen;
		this.gapExtend = gapExtend;
	}
	
	public Result align(String seq1, String seq2) {
		
		if (seq1.length() > MAX_CONTIG_LEN) {
			throw new IllegalArgumentException("Contig too long");
		}
		
		if (seq2.length() > MAX_REF_LEN) {
			throw new IllegalArgumentException("Ref too long");
		}
		
		// Result returned in format score:secondBest:pos:endPos:cigar
		// 789:741:611:734:52M108I71M
		String res = align(seq1, seq2, match, mismatch, gapOpen, gapExtend);
		
		String[] results = res.split(":");
		Result result = new Result(Integer.valueOf(results[0]), Integer.valueOf(results[1]),