예제 #1
0
/** Test that the implementation of clone_union using AVX instructions is
 * equivalent to the straightforward implementation. */
void test_clone_union() {
  for(int i = 0; i < 100; ++i) {
    clone cl1, cl2;
    random_clone(&cl1);
    random_clone(&cl2);
    
    clone cl3, cl4;
    clone_union_straightforward(&cl1, &cl2, &cl3);
    clone_union(&cl1, &cl2, &cl4);
    
    assert(clone_eq(&cl3, &cl4));
  }
}
예제 #2
0
int hivpopulation::write_genotypes(ostream &out, int sample_size, string gt_label, int start, int length){
	if (HIVPOP_VERBOSE) cerr<<"hivpopulation::write_genotypes()...";
	if (HIVPOP_VERBOSE) cerr<<"start = "<<start<<"...";
	if (HIVPOP_VERBOSE) cerr<<"length = "<<length<<"...";

	if (out.bad()){
		cerr<<"hivpopulation::write_genotypes(): BAD OUTPUT FILE!"<<endl;
		return HIVPOP_BADARG;
	}else{
		int gti;
		string temp;
		if (length <= 0)
			length = number_of_loci - start;

		produce_random_sample(sample_size);
		if (sample_size>get_population_size()){
			cerr<<"hivpopulation::write_genotypes(): requested sample size exceeds population size"<<endl;
			return HIVPOP_BADARG;
		}else{
			for (int s=0; s<sample_size; s++){
				gti=random_clone();
				out <<">GT-"<<gt_label<<"_"<<gti<<'\n';
				for (int i =start; i<start+length; i++ ){
					if (population[gti].genotype[i]) out <<'1';
					else out <<'0';
				}
				out<<'\n';
			}
		}
		if (HIVPOP_VERBOSE) cerr<<"...done."<<endl;
		return 0;
	}
}