1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
package pacbio;
import shared.Shared;
import stream.SiteScore;
import stream.SiteScoreR;
/**
* @author Brian Bushnell
* @date Jul 24, 2012
*
*/
public class SiteR {
public SiteR(SiteScoreR ssr){
this(ssr.start, ssr.stop, ssr.chrom, ssr.strand, ssr.numericID, ssr.pairnum);
}
public SiteR(int start_, int stop_, int chrom, byte strand, long numericID, int pairnum){
start=start_;
stop=stop_;
if((pairnum&1)==0){
idPairnum=numericID;
}else{
idPairnum=-numericID;
}
if(strand==Shared.PLUS){
chromStrand=chrom;
}else{
chromStrand=-chrom;
}
assert(chrom==chrom());
assert(strand==strand());
assert(numericID==numericID());
assert(pairnum==pairNum());
}
public boolean equals(SiteScore other){
if(other.start!=start){return false;}
if(other.stop!=stop){return false;}
if(other.chrom!=chrom()){return false;}
if(other.strand!=strand()){return false;}
return true;
}
public boolean equals(SiteScoreR other){
if(other.start!=start){return false;}
if(other.stop!=stop){return false;}
if(other.chrom!=chrom()){return false;}
if(other.strand!=strand()){return false;}
return true;
}
public StringBuilder toTextRecursive(StringBuilder sb){
if(sb==null){sb=new StringBuilder();}else{sb.append(" ");}
sb.append("("+toText()+")");
if(next!=null){next.toTextRecursive(sb);}
return sb;
}
public StringBuilder toText(){
StringBuilder sb=new StringBuilder();
sb.append(start).append(',');
sb.append(stop).append(',');
sb.append(chrom()).append(',');
sb.append(strand()).append(',');
sb.append(numericID()).append(',');
sb.append(pairNum());
return sb;
}
@Override
public String toString(){
return toText().toString();
}
public final int start;
public final int stop;
public final int chromStrand;
public final long idPairnum;
public SiteR next;
public long numericID(){return idPairnum>=0 ? idPairnum : -idPairnum;}
public int pairNum(){return idPairnum>=0 ? 0 : 1;}
public int chrom(){return chromStrand>=0 ? chromStrand : -chromStrand;}
public byte strand(){return chromStrand>=0 ? (byte)0 : (byte)1;};
public int listLength(){
int i=1;
SiteR sr=this;
while(sr.next!=null){
sr=sr.next;
i++;
}
return i;
}
}
|