static mcxstatus mateMain ( int argc_unused cpl__unused , const char* argv[] ) { mcxIO* xfx, *xfy ; mclx* mx, *my, *meet, *teem, *myt ; dim x, y ; mcxIOopen(xfout, EXIT_ON_FAIL) ; xfx = mcxIOnew(argv[0], "r") ; mx = mclxRead(xfx, EXIT_ON_FAIL) ; mcxIOclose(xfx) ; xfy = mcxIOnew(argv[1], "r") ; my = mclxRead(xfy, EXIT_ON_FAIL) ; myt = mclxTranspose(my) ; if (!MCLD_EQUAL(mx->dom_rows, my->dom_rows)) mcxDie(1, me, "domains are not equal") ; meet= mclxCompose(myt, mx, 0, 0) /* fixme thread interface */ ; teem= mclxTranspose(meet) ; if (legend) fprintf ( xfout->fp , "%-10s %6s %6s %6s %6s %6s %6s %6s\n" , "overlap" , "x-idx" , "y-idx" , "meet" , "xdiff" , "ydiff" , "x-size" , "y-size" ) ; for (x=0;x<N_COLS(meet);x++) { mclv* xvec = meet->cols+x ; long X = xvec->vid ; long xsize = mx->cols[x].n_ivps ; if (one2many && xvec->n_ivps < 2) continue ; for (y=0;y<N_COLS(teem);y++) { mclv* yvec = teem->cols+y ; long Y = yvec->vid ; long ysize = my->cols[y].n_ivps ; double twinfac ; long meetsize ; mclp* ivp = mclvGetIvp(yvec, X, NULL) ; if (!ivp) continue /* * meet size, left diff, right diff, right size. */ ; meetsize = ivp->val ; if (!xsize && !ysize) /* paranoia */ continue ; twinfac = 2 * meetsize / ( (double) (xsize + ysize) ) ; if (xfout) fprintf ( xfout->fp , "%-10.3f %6ld %6ld %6ld %6ld %6ld %6ld %6ld\n" , twinfac , X , Y , meetsize , xsize - meetsize , ysize - meetsize , xsize , ysize ) ; } } return STATUS_OK ; }
static mcxstatus meetMain ( int argc , const char* argv[] ) { mcxIO **xfmcs = NULL ; mclMatrix *lft = NULL ; mclMatrix *rgt = NULL ; mclMatrix *dst = NULL ; int a = 0 ; int n_mx = 0 ; int j ; dim o, m, e ; mclxIOsetQMode("MCLXIOVERBOSITY", MCL_APP_VB_YES) ; mclx_app_init(stderr) ; xfmcs = (mcxIO**) mcxAlloc ( (argc)*sizeof(mcxIO*) , EXIT_ON_FAIL ) ; mcxIOopen(xfout, EXIT_ON_FAIL) ; for(j=a;j<argc;j++) { xfmcs[n_mx] = mcxIOnew(argv[j], "r") ; n_mx++ ; } if (!n_mx) mcxDie(1, me, "at least one clustering matrix required") /* Fixme: do a decent initialization with lft = clmTop() *before* * this loop (removing the need for ugly tmp assignment), but that requires * we know the correct domain to pass to it. For that, we need to peak into * the first matrix. */ ; for (j=0;j<n_mx;j++) { mclMatrix* tmp = mclxRead (xfmcs[j], EXIT_ON_FAIL) ; if (clmEnstrict(tmp, &o, &m, &e, ENSTRICT_SPLIT_OVERLAP)) report_partition("clmmeet", tmp, xfmcs[j]->fn, o, m, e) , mcxExit(1) ; if (!lft) { lft = tmp ; continue ; } else rgt = tmp ; if (!MCLD_EQUAL(lft->dom_rows, rgt->dom_rows)) mcxDie ( 1 , me , "domains not equal (files %s/%s)" , xfmcs[j-1]->fn->str , xfmcs[j]->fn->str ) ; mcxIOclose(xfmcs[j]) ; dst = clmMeet(lft, rgt) ; lft = dst ; mclxFree(&rgt) ; } mclxColumnsRealign(lft, mclvSizeRevCmp) ; mclxWrite(lft, xfout, MCLXIO_VALUE_NONE, EXIT_ON_FAIL) ; mclxFree(&lft) ; mcxIOfree(&xfout) ; free(xfmcs) ; return STATUS_OK ; }