value bv_CAML_copy( value vbv ) { CAMLparam1(vbv); CAMLlocal1(res); bv_alloc_val(res,bv_copy(Vect_val(vbv),1)); CAMLreturn(res); }
value bv_CAML_inter( value vbv1, value vbv2 ) { CAMLparam2( vbv1, vbv2 ); CAMLlocal1( vres ); vect *res, *bv1, *bv2; bv1 = Vect_val(vbv1); bv2 = Vect_val(vbv2); res = bv_copy(bv1,0); bv_alloc_val(vres,res); bv_inter(res, bv1, bv2); CAMLreturn(vres); }
BITVEC *reads_not_in_set(CJOB *settings, char *sfafname, char *fbvfname, READSET *set) { char *sbvfname = get_bvfname_from_one_fafname(settings, sfafname); int i = 0; BITVEC *sbv = bv_read_from_file(sbvfname); BITVEC *diff = bv_create(sbv->num_bits); int j = 0; for(j = 0; j < set->num_files; j++) { if(j != i) { char *isbvfname = get_bvfname_of_index_and_search(settings, set->filenames[j], set->filenames[i]); BITVEC *isbv = bv_copy(bv_read_from_file(isbvfname)); bv_ior(diff, isbv); } } bv_inot(diff); bv_iand(diff, sbv); return diff; }
value bv_CAML_fitch_median2( value vbv1, value vbv2 ) { CAMLparam2( vbv1, vbv2 ); CAMLlocal2( vres,vbv0 ); long cost; vect *bv0,*bv1,*bv2; bv1 = Vect_val( vbv1 ); bv2 = Vect_val( vbv2 ); bv0 = bv_copy( bv1,0 ); bv_alloc_val(vbv0,bv0); cost = bv_fitch( bv0, bv1, bv2 ); vres = caml_alloc(2,0); Store_field( vres, 0, vbv0 ); Store_field( vres, 1, Val_int(cost) ); CAMLreturn( vres ); }
BITVEC *reads_elsewhere_in_set(CJOB *settings, READSET *set, int i) { char *sbvfname = get_bvfname_from_one_fafname(settings, set->filenames[i]); BITVEC *sbv = bv_read_from_file(sbvfname); BITVEC *others = bv_create(sbv->num_bits); int j = 0; for(j = 0; j < set->num_files; j++) { if(j != i) { char *isbvfname = get_bvfname_of_index_and_search(settings, set->filenames[j], set->filenames[i]); BITVEC *isbv = bv_copy(bv_read_from_file(isbvfname)); bv_ior(others, isbv); } } bv_iand(others, sbv); bv_destroy(sbv); free(sbvfname); return others; }