package sort; import dna.AminoAcid; import shared.Tools; import stream.Read; /** * Sorts similarly to Clumpify * @author Brian Bushnell * @date Oct 5, 2022 * */ public final class ReadComparatorClump extends ReadComparator { private ReadComparatorClump(){} @Override public int compare(Read a, Read b) { int x=compareInner(a, b); if(x==0){x=compareInner(a.mate, b.mate);} if(x==0){x=a.id.compareTo(b.id);} return ascending*x; } private static int compareInner(Read a, Read b) { if(a==b){return 0;} if(a==null){return 1;} if(b==null){return -1;} if(a.numericID!=b.numericID){return a.numericID>b.numericID ? 1 : -1;} if(a.strand()!=b.strand()){return a.strand()-b.strand();} if(a.start!=b.start){return a.start-b.start;} return 0; } /** Finds the global maximum, forward and reverse */ public static final long set(Read r){ if(r.length()>>2)|(x2<=k){ final long kmax=Tools.max(kmer, rkmer); final long code=Tools.hash64shift(kmax); if(code>topCode){ topKmer=kmax; topCode=code; topStrand=(kmax==kmer ? 0 : 1); topStop=i; } } } if(topCode==Long.MIN_VALUE){ return setShort(r); } r.numericID=topKmer; r.setStrand(topStrand); r.start=topStop; return topKmer; } /** Generates a key when the read is shorter than k */ public static final long setShort(Read r){ final byte[] bases=r.bases; final int max=Tools.min(bases.length, k); long kmer=0; long rkmer=0; for(int i=0; i>>2)|(x2<0 && k<=32) : k; // // shift=2*k; // shift2=shift-2; // mask=(shift>63 ? -1L : ~((-1L)<63 ? -1L : ~((-1L)<