Skip to content

Commit

Permalink
r156: removed fastsim
Browse files Browse the repository at this point in the history
  • Loading branch information
lh3 committed Aug 27, 2014
1 parent e5a606d commit fe7ea56
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 69 deletions.
66 changes: 0 additions & 66 deletions dfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,69 +275,3 @@ int main_count(int argc, char *argv[])
free(d.str);
return 0;
}

/***********
* fastsim *
***********/

#include "fermi2.h"
#include "khash.h"
KHASH_MAP_INIT_INT64(64, int)

typedef struct {
const rld_t *e;
const fmsa_t *sa;
int k, max_occ;
kstring_t *s;
} dfs_sim_t;

static void dfs_sim2(void *data, int tid, int k, char *path, const rldintv_t *ik, const rldintv_t *ok, int *cont)
{
dfs_sim_t *d = (dfs_sim_t*)data;
int c, i;
kstring_t *s;
for (c = 0; c < 6; ++c)
if (ok[c].x[2] < 2) *cont &= ~(1<<c);
if (k < d->k || ik->x[2] > d->max_occ || ik->x[2] < 2) return;
s = &d->s[tid];
s->l = 0;
for (i = 0; i < ik->x[2]; ++i) {
int64_t si;
fm_sa(d->e, d->sa, ik->x[0] + i, &si);
if (i) kputc('\t', s);
kputl(si, s);
}
puts(s->s);
}

int main_fastsim(int argc, char *argv[])
{
int i, c, n_threads = 1;
rld_t *e;
fmsa_t *sa;
dfs_sim_t d;

d.k = 23, d.max_occ = 500;
while ((c = getopt(argc, argv, "t:k:m:")) >= 0) {
if (c == 't') n_threads = atoi(optarg);
else if (c == 'k') d.k = atoi(optarg);
else if (c == 'm') d.max_occ = atoi(optarg);
}
if (optind + 2 > argc) {
fprintf(stderr, "Usage: fermi2 fastsim [-t nThreads=%d] [-k kmer=%d] [-m maxOcc=%d] <in.fmd> <in.sa>\n", n_threads, d.k, d.max_occ);
return 1;
}
// initialize
e = rld_restore(argv[optind]);
sa = fm_sa_restore(argv[optind+1]);
d.e = e; d.sa = sa;
d.s = calloc(n_threads, sizeof(kstring_t));
// collect counts
fm_dfs(1, &e, 1, d.k, n_threads, 0, dfs_sim2, &d);
// free
fm_sa_destroy(sa);
rld_destroy(e);
for (i = 0; i < n_threads; ++i) free(d.s[i].s);
free(d.s);
return 0;
}
2 changes: 1 addition & 1 deletion fermi2.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <stdint.h>
#include "rld0.h"

#define FM_VERSION "r155"
#define FM_VERSION "r156"

#define fmd_comp(a) ((a) >= 1 && (a) <= 4? 5 - (a) : (a))
#define fmd_set_intv(e, c, ik) ((ik).x[0] = (e)->cnt[(int)(c)], (ik).x[2] = (e)->cnt[(int)(c)+1] - (e)->cnt[(int)(c)], (ik).x[1] = (e)->cnt[fmd_comp(c)], (ik).info = 0)
Expand Down
2 changes: 0 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ int main_assemble(int argc, char *argv[]);
int main_simplify(int argc, char *argv[]);
int main_sa(int argc, char *argv[]);
int main_match(int argc, char *argv[]);
int main_fastsim(int argc, char *argv[]);

void liftrlimit(void);
double cputime(void);
Expand Down Expand Up @@ -59,7 +58,6 @@ int main(int argc, char *argv[])
else if (strcmp(argv[1], "simplify") == 0) ret = main_simplify(argc-1, argv+1);
else if (strcmp(argv[1], "sa") == 0) ret = main_sa(argc-1, argv+1);
else if (strcmp(argv[1], "match") == 0) ret = main_match(argc-1, argv+1);
else if (strcmp(argv[1], "fastsim") == 0) ret = main_fastsim(argc-1, argv+1);
else {
fprintf(stderr, "[E::%s] unknown command\n", __func__);
return 1;
Expand Down

0 comments on commit fe7ea56

Please sign in to comment.