| 1 | package driver; |
| 2 | |
| 3 | import dna.ChromosomeArray; |
| 4 | import dna.Data; |
| 5 | |
| 6 | public class CompareReferenceGenomes { |
| 7 | |
| 8 | public static void main(String[] args){ |
| 9 | compareGenomes(args[0], args[1]); |
| 10 | } |
| 11 | |
| 12 | public static void compareGenomes(String pattern1, String pattern2){ |
| 13 | for(byte chrom=1; chrom<=25; chrom++){ |
| 14 | System.out.println("Comparing chromosome "+chrom); |
| 15 | String fname1=pattern1.replace("#", ""+chrom); |
| 16 | String fname2=pattern2.replace("#", ""+chrom); |
| 17 | ChromosomeArray cha=ChromosomeArray.read(fname1); |
| 18 | ChromosomeArray chb=ChromosomeArray.read(fname2); |
| 19 | boolean result=compare(cha, chb); |
| 20 | System.out.println("..."+(result ? "identical." : "different.")); |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | public static boolean compare(ChromosomeArray cha, ChromosomeArray chb){ |
| 25 | boolean equal=true; |
| 26 | if(cha.minIndex!=chb.minIndex || cha.maxIndex!=chb.maxIndex){ |
| 27 | System.out.println("Index mismatch in chrom "+cha.chromosome+":\n" + |
| 28 | "("+cha.minIndex+" - "+cha.maxIndex+") vs ("+chb.minIndex+" - "+chb.maxIndex+")"); |
| 29 | equal=false; |
| 30 | } |
| 31 | int start=Data.max(cha.minIndex, chb.minIndex); |
| 32 | int stop=Data.min(cha.maxIndex, chb.maxIndex); |
| 33 | |
| 34 | for(int i=start; i<=stop; i++){ |
| 35 | byte a=cha.get(i); |
| 36 | byte b=chb.get(i); |
| 37 | if(a!=b){ |
| 38 | System.out.println(((char)cha.chromosome)+"\t"+i+"\t"+((char)a)+" "+((char)b)); |
| 39 | equal=false; |
| 40 | } |
| 41 | } |
| 42 | return equal; |
| 43 | |
| 44 | } |
| 45 | |
| 46 | } |