jpayne@68: package fun; jpayne@68: jpayne@68: import java.util.HashSet; jpayne@68: import java.util.Random; jpayne@68: jpayne@68: import dna.AminoAcid; jpayne@68: jpayne@68: public class ProbShared2 { jpayne@68: jpayne@68: public static void main(String args[]){ jpayne@68: int k=Integer.parseInt(args[0]); jpayne@68: int len1=Integer.parseInt(args[1]); jpayne@68: int len2=Integer.parseInt(args[2]); jpayne@68: int rounds=Integer.parseInt(args[3]); jpayne@68: jpayne@68: System.out.println("Probability: "+simulate(k, len1, len2, rounds)); jpayne@68: } jpayne@68: jpayne@68: static double simulate(int k, int len1, int len2, int rounds){ jpayne@68: int successes=0; jpayne@68: final HashSet set=new HashSet(); jpayne@68: for(int i=0; i set){ jpayne@68: set.clear(); jpayne@68: jpayne@68: final int shift=2*k; jpayne@68: final long mask=(shift>63 ? -1L : ~((-1L)<=k){ jpayne@68: set.add(kmer); jpayne@68: } jpayne@68: } jpayne@68: jpayne@68: bases=randomSequence(len1); jpayne@68: jpayne@68: for(int i=0; i=k){ jpayne@68: if(set.contains(kmer)){return 1;} jpayne@68: } jpayne@68: } jpayne@68: return 0; jpayne@68: } jpayne@68: jpayne@68: static byte[] randomSequence(int len){ jpayne@68: byte[] array=new byte[len]; jpayne@68: for(int i=0; i