Mercurial > repos > rliterman > csp2
comparison 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 |
comparison
equal
deleted
inserted
replaced
67:0e9998148a16 | 68:5028fdace37b |
---|---|
1 package aligner; | |
2 | |
3 import prok.GeneCaller; | |
4 import stream.Read; | |
5 | |
6 public class Alignment implements Comparable<Alignment>{ | |
7 | |
8 public Alignment(Read r_){ | |
9 r=r_; | |
10 } | |
11 | |
12 @Override | |
13 public int compareTo(Alignment o) { | |
14 return id>o.id ? 1 : id<o.id ? -1 : r.length()>o.r.length() ? 1 : r.length()<o.r.length() ? -1 : 0; | |
15 } | |
16 | |
17 public float align(byte[] ref){ | |
18 id=align(r, ref); | |
19 match=r.match; | |
20 start=r.start; | |
21 stop=r.stop; | |
22 return id; | |
23 } | |
24 | |
25 public static float align(Read r, byte[] ref){ | |
26 SingleStateAlignerFlat2 ssa=GeneCaller.getSSA(); | |
27 final int a=0, b=ref.length-1; | |
28 int[] max=ssa.fillUnlimited(r.bases, ref, a, b, 0); | |
29 if(max==null){return 0;} | |
30 | |
31 final int rows=max[0]; | |
32 final int maxCol=max[1]; | |
33 final int maxState=max[2]; | |
34 | |
35 //returns {score, bestRefStart, bestRefStop} | |
36 //padded: {score, bestRefStart, bestRefStop, padLeft, padRight}; | |
37 int[] score=ssa.score(r.bases, ref, a, b, rows, maxCol, maxState); | |
38 int rstart=score[1]; | |
39 int rstop=score[2]; | |
40 r.start=rstart; | |
41 r.stop=rstop; | |
42 | |
43 byte[] match=ssa.traceback(r.bases, ref, a, b, rows, maxCol, maxState); | |
44 float id=Read.identity(match); | |
45 return id; | |
46 } | |
47 | |
48 public final Read r; | |
49 public float id=-1; | |
50 public byte[] match; | |
51 public int start; | |
52 public int stop; | |
53 | |
54 } |