| 1 | package driver; |
| 2 | |
| 3 | import dna.ChromosomeArray; |
| 4 | import shared.Tools; |
| 5 | |
| 6 | public class CompareSequences { |
| 7 | |
| 8 | public static void main(String[] args){ |
| 9 | |
| 10 | ChromosomeArray cha1=ChromosomeArray.read(args[0]); |
| 11 | ChromosomeArray cha2=ChromosomeArray.read(args[1]); |
| 12 | |
| 13 | long different=0; |
| 14 | long same=0; |
| 15 | long nToBase=0; |
| 16 | long baseToN=0; |
| 17 | long caseDifferent=0; |
| 18 | long toUpper=0; |
| 19 | long toLower=0; |
| 20 | long difLen=cha2.maxIndex-cha1.maxIndex; |
| 21 | |
| 22 | int lim=cha2.maxIndex>cha1.maxIndex ? cha1.maxIndex : cha2.maxIndex; |
| 23 | |
| 24 | for(int i=0; i<lim; i++){ |
| 25 | char a=(char) cha1.get(i); |
| 26 | char b=(char) cha2.get(i); |
| 27 | if(a==b){ |
| 28 | same++; |
| 29 | }else{ |
| 30 | different++; |
| 31 | if(a=='N' && b!='N'){ |
| 32 | nToBase++; |
| 33 | }else if(a!='N' && b=='N'){ |
| 34 | baseToN++; |
| 35 | } |
| 36 | |
| 37 | if(Tools.toLowerCase(a)==Tools.toLowerCase(b)){ |
| 38 | caseDifferent++; |
| 39 | if(a==Tools.toLowerCase(a)){ |
| 40 | toUpper++; |
| 41 | }else{ |
| 42 | toLower++; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | same+=caseDifferent; |
| 50 | different-=caseDifferent; |
| 51 | |
| 52 | System.out.println("Length Difference: "+difLen); |
| 53 | System.out.println("Same bases: "+same); |
| 54 | System.out.println("Different bases: "+different+" ("+(100f*different/(float)(different+same))+"%)"); |
| 55 | System.out.println("Base-to-N: "+baseToN); |
| 56 | System.out.println("N-To-Base: "+nToBase); |
| 57 | System.out.println("Changed case: "+caseDifferent); |
| 58 | System.out.println("toUpperCase: "+toUpper); |
| 59 | System.out.println("toLowerCase: "+toLower); |
| 60 | |
| 61 | } |
| 62 | |
| 63 | } |