Mercurial > repos > rliterman > csp2
annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/opt/bbmap-39.01-1/current/aligner/Alignment.java @ 68:5028fdace37b
planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author | jpayne |
---|---|
date | Tue, 18 Mar 2025 16:23:26 -0400 |
parents | |
children |
rev | line source |
---|---|
jpayne@68 | 1 package aligner; |
jpayne@68 | 2 |
jpayne@68 | 3 import prok.GeneCaller; |
jpayne@68 | 4 import stream.Read; |
jpayne@68 | 5 |
jpayne@68 | 6 public class Alignment implements Comparable<Alignment>{ |
jpayne@68 | 7 |
jpayne@68 | 8 public Alignment(Read r_){ |
jpayne@68 | 9 r=r_; |
jpayne@68 | 10 } |
jpayne@68 | 11 |
jpayne@68 | 12 @Override |
jpayne@68 | 13 public int compareTo(Alignment o) { |
jpayne@68 | 14 return id>o.id ? 1 : id<o.id ? -1 : r.length()>o.r.length() ? 1 : r.length()<o.r.length() ? -1 : 0; |
jpayne@68 | 15 } |
jpayne@68 | 16 |
jpayne@68 | 17 public float align(byte[] ref){ |
jpayne@68 | 18 id=align(r, ref); |
jpayne@68 | 19 match=r.match; |
jpayne@68 | 20 start=r.start; |
jpayne@68 | 21 stop=r.stop; |
jpayne@68 | 22 return id; |
jpayne@68 | 23 } |
jpayne@68 | 24 |
jpayne@68 | 25 public static float align(Read r, byte[] ref){ |
jpayne@68 | 26 SingleStateAlignerFlat2 ssa=GeneCaller.getSSA(); |
jpayne@68 | 27 final int a=0, b=ref.length-1; |
jpayne@68 | 28 int[] max=ssa.fillUnlimited(r.bases, ref, a, b, 0); |
jpayne@68 | 29 if(max==null){return 0;} |
jpayne@68 | 30 |
jpayne@68 | 31 final int rows=max[0]; |
jpayne@68 | 32 final int maxCol=max[1]; |
jpayne@68 | 33 final int maxState=max[2]; |
jpayne@68 | 34 |
jpayne@68 | 35 //returns {score, bestRefStart, bestRefStop} |
jpayne@68 | 36 //padded: {score, bestRefStart, bestRefStop, padLeft, padRight}; |
jpayne@68 | 37 int[] score=ssa.score(r.bases, ref, a, b, rows, maxCol, maxState); |
jpayne@68 | 38 int rstart=score[1]; |
jpayne@68 | 39 int rstop=score[2]; |
jpayne@68 | 40 r.start=rstart; |
jpayne@68 | 41 r.stop=rstop; |
jpayne@68 | 42 |
jpayne@68 | 43 byte[] match=ssa.traceback(r.bases, ref, a, b, rows, maxCol, maxState); |
jpayne@68 | 44 float id=Read.identity(match); |
jpayne@68 | 45 return id; |
jpayne@68 | 46 } |
jpayne@68 | 47 |
jpayne@68 | 48 public final Read r; |
jpayne@68 | 49 public float id=-1; |
jpayne@68 | 50 public byte[] match; |
jpayne@68 | 51 public int start; |
jpayne@68 | 52 public int stop; |
jpayne@68 | 53 |
jpayne@68 | 54 } |