Пример #1
0
int invdist_circular_nomem(struct genome_struct *g1, struct genome_struct *g2,
                           int num_genes)
{
    int offset;

    offset = calculate_offset(g1, g2, num_genes);

    return (invdist_noncircular_nomem(g1, g2, offset, num_genes));
}
Пример #2
0
/* Added by Lauren to take in Ocaml values. 
 Returns the inversion distance between gene1 and gene2.
 gene1-- the first genome
 gene2-- the 2nd genome
 num-- the number of gene in each genome (i.e., the length of gene1;
 the length of both must be the same)
 circular-- an int that's positive if genome are circular */
value grappa_CAML_cmp_inv_dis(value c_gene1, value c_gene2, 
				      value c_num_gen, value c_circular) {
    CAMLparam4(c_gene1, c_gene2, c_num_gen, c_circular); 
    int num_gene, distance, circ/*, num_chromosome*/;
    struct genome_struct *g1, *g2;
    g1 = (struct genome_struct *) Data_custom_val (c_gene1);
    g2 = (struct genome_struct *) Data_custom_val (c_gene2);
    num_gene = Int_val (c_num_gen);
    circ = Int_val (c_circular);
    int deli_num1 = g1->deli_num;
    int deli_num2 = g2->deli_num;
  /*  fprintf(stdout,"grappa, c_cmp_inv_dis with deli_num1=%d, deli_num2=%d \n",
            deli_num1, deli_num2);
    fflush(stdout);
    int i;
        fprintf(stdout,"g1 = {");
        for(i=0;i<num_gene;i++)
        { 
            fprintf(stdout,"%d,",g1->genes[i]);
        }
        fprintf(stdout,"} ; g2 = { ");
        for(i=0;i<num_gene;i++)
        { 
            fprintf(stdout,"%d,",g2->genes[i]);
        }fprintf(stdout," }\n");
        fflush(stdout); */
    if ((deli_num1>1)||(deli_num2>1)) //deal with multichromosome input
    {
        distance = mgr_invdist(g1->genes,g2->genes,num_gene,g1->delimiters,g2->delimiters,deli_num1,deli_num2); 
    }
    else
    {
        if (circ == 1) {
             distance = invdist_circular_nomem(g1, g2, num_gene); 
        } else {
            distance = invdist_noncircular_nomem(g1, g2, 0, num_gene);
        }
    }
    CAMLreturn(Val_int(distance));
}