Debian Codegraph @

current/var2/VarKey.java

raw symbols SCIP
1 package var2;
2
3 //This class is not currently thought to be used
4 /** Allows simpler hashing, without complete alleles. */
5 public class VarKey implements Comparable<VarKey> {
6
7 public static VarKey toVarKey(Var v){
8 if(v.type==Var.INS){
9 return new VarKey(v.scafnum, v.start, v.allele.length, v.type, v.allele[0]);
10 }else if(v.type==Var.DEL){
11 return new VarKey(v.scafnum, v.start, v.reflen(), v.type, 0);
12 }
13 return new VarKey(v.scafnum, v.start, v.reflen(), v.type, v.allele[0]);
14 }
15
16 public VarKey(int scafNum_, int start_, int length_, int type_, int allele_){
17 scafNum=scafNum_;
18 start=start_;
19 length=length_;
20 type=type_;
21 allele=allele_;
22 }
23
24 @Override
25 public int hashCode(){
26 return scafNum^Integer.rotateLeft(start, 4)^Integer.rotateRight(start, 18)^Integer.rotateLeft(type, 8)^Integer.rotateLeft(allele, 12);
27 }
28
29 @Override
30 public boolean equals(Object b){
31 return equals((VarKey)b);
32 }
33
34 public boolean equals(VarKey b){
35 if(b==null){return false;}
36 return scafNum==b.scafNum && start==b.start && length==b.length && type==b.type && allele==b.allele;
37 }
38
39 @Override
40 public int compareTo(VarKey b){
41 if(b==null){return -1;}
42 if(scafNum!=b.scafNum){return scafNum-b.scafNum;}
43 if(start!=b.start){return start-b.start;}
44 if(length!=b.length){return length-b.length;}
45 if(type!=b.type){return type-b.type;}
46 if(allele!=b.allele){return allele-b.allele;}
47 return 0;
48 }
49
50 int scafNum;
51 int start;
52 int length;
53 int type;
54 //0 for DEL, otherwise first letter of allele
55 int allele;
56 }