Skip to content

Commit

Permalink
Avoid name space conflict with bwa (Addresses lh3#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
tillea committed Oct 25, 2018
1 parent bd329ba commit e93040b
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ sketch of the example:
int main(int argc, char *argv[])
{
int i, n_seqs, n_utgs;
bseq1_t *seqs; // array of input sequences
fml_seq1_t *seqs; // array of input sequences
fml_utg_t *utgs; // array of output unitigs
fml_opt_t opt;
if (argc == 1) return 1; // do nothing if there is no input file
seqs = bseq_read(argv[1], &n_seqs); // or fill the array with callers' functions
seqs = fml_seq_read(argv[1], &n_seqs); // or fill the array with callers' functions
fml_opt_init(&opt); // initialize parameters
utgs = fml_assemble(&opt, n_seqs, seqs, &n_utgs); // assemble!
for (i = 0; i < n_utgs; ++i) // output in fasta
Expand Down
18 changes: 9 additions & 9 deletions bfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ typedef struct { // cache to reduce locking
typedef struct {
int k, q;
int n_seqs;
const bseq1_t *seqs;
const fml_seq1_t *seqs;
bfc_ch_t *ch;
int *n_buf;
insbuf_t **buf;
Expand Down Expand Up @@ -97,7 +97,7 @@ static void bfc_kmer_insert(cnt_step_t *cs, const bfc_kmer_t *x, int is_high, in
static void worker_count(void *_data, long k, int tid)
{
cnt_step_t *cs = (cnt_step_t*)_data;
const bseq1_t *s = &cs->seqs[k];
const fml_seq1_t *s = &cs->seqs[k];
int i, l;
bfc_kmer_t x = bfc_kmer_null;
uint64_t qmer = 0, mask = (1ULL<<cs->k) - 1;
Expand All @@ -111,7 +111,7 @@ static void worker_count(void *_data, long k, int tid)
}
}

struct bfc_ch_s *fml_count(int n, const bseq1_t *seq, int k, int q, int l_pre, int n_threads)
struct bfc_ch_s *fml_count(int n, const fml_seq1_t *seq, int k, int q, int l_pre, int n_threads)
{
int i;
cnt_step_t cs;
Expand Down Expand Up @@ -577,10 +577,10 @@ typedef struct {
bfc_ec1buf_t **e;
int64_t n_processed;
int n_seqs, flt_uniq;
bseq1_t *seqs;
fml_seq1_t *seqs;
} ec_step_t;

static uint64_t max_streak(int k, const bfc_ch_t *ch, const bseq1_t *s)
static uint64_t max_streak(int k, const bfc_ch_t *ch, const fml_seq1_t *s)
{
int i, l;
uint64_t max = 0, t = 0;
Expand All @@ -602,7 +602,7 @@ static uint64_t max_streak(int k, const bfc_ch_t *ch, const bseq1_t *s)
static void worker_ec(void *_data, long k, int tid)
{
ec_step_t *es = (ec_step_t*)_data;
bseq1_t *s = &es->seqs[k];
fml_seq1_t *s = &es->seqs[k];
if (es->flt_uniq) {
uint64_t max;
max = max_streak(es->opt->k, es->ch, s);
Expand All @@ -624,7 +624,7 @@ static void worker_ec(void *_data, long k, int tid)
} else bfc_ec1(es->e[tid], s->seq, s->qual);
}

float fml_correct_core(const fml_opt_t *opt, int flt_uniq, int n, bseq1_t *seq)
float fml_correct_core(const fml_opt_t *opt, int flt_uniq, int n, fml_seq1_t *seq)
{
bfc_ch_t *ch;
int i, mode;
Expand Down Expand Up @@ -663,12 +663,12 @@ float fml_correct_core(const fml_opt_t *opt, int flt_uniq, int n, bseq1_t *seq)
return kcov;
}

float fml_correct(const fml_opt_t *opt, int n, bseq1_t *seq)
float fml_correct(const fml_opt_t *opt, int n, fml_seq1_t *seq)
{
return fml_correct_core(opt, 0, n, seq);
}

float fml_fltuniq(const fml_opt_t *opt, int n, bseq1_t *seq)
float fml_fltuniq(const fml_opt_t *opt, int n, fml_seq1_t *seq)
{
return fml_correct_core(opt, 1, n, seq);
}
8 changes: 4 additions & 4 deletions bseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#include "kseq.h"
KSEQ_INIT(gzFile, gzread)

bseq1_t *bseq_read(const char *fn, int *n_)
fml_seq1_t *fml_seq_read(const char *fn, int *n_)
{
gzFile fp;
bseq1_t *seqs;
fml_seq1_t *seqs;
kseq_t *ks;
int m, n;
uint64_t size = 0;
Expand All @@ -21,10 +21,10 @@ bseq1_t *bseq_read(const char *fn, int *n_)

m = n = 0; seqs = 0;
while (kseq_read(ks) >= 0) {
bseq1_t *s;
fml_seq1_t *s;
if (n >= m) {
m = m? m<<1 : 256;
seqs = realloc(seqs, m * sizeof(bseq1_t));
seqs = realloc(seqs, m * sizeof(fml_seq1_t));
}
s = &seqs[n];
s->seq = strdup(ks->seq.s);
Expand Down
4 changes: 2 additions & 2 deletions example.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int main(int argc, char *argv[])
{
fml_opt_t opt;
int c, n_seqs, n_utg, gfa_out = 0;
bseq1_t *seqs;
fml_seq1_t *seqs;
fml_utg_t *utg;

fml_opt_init(&opt);
Expand Down Expand Up @@ -41,7 +41,7 @@ int main(int argc, char *argv[])
fprintf(stderr, " -g output the assembly graph in the GFA format\n");
return 1;
}
seqs = bseq_read(argv[optind], &n_seqs);
seqs = fml_seq_read(argv[optind], &n_seqs);
utg = fml_assemble(&opt, n_seqs, seqs, &n_utg);
if (!gfa_out) fml_utg_print(n_utg, utg);
else fml_utg_print_gfa(n_utg, utg);
Expand Down
14 changes: 7 additions & 7 deletions fml.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
typedef struct {
int32_t l_seq;
char *seq, *qual; // NULL-terminated strings; length expected to match $l_seq
} bseq1_t;
} fml_seq1_t;

#define MAG_F_AGGRESSIVE 0x20 // pop variant bubbles (not default)
#define MAG_F_POPOPEN 0x40 // aggressive tip trimming (default)
Expand Down Expand Up @@ -63,7 +63,7 @@ extern "C" {
*
* @return array of sequences
*/
bseq1_t *bseq_read(const char *fn, int *n);
fml_seq1_t *fml_seq_read(const char *fn, int *n);

/**
* Initialize default parameters
Expand All @@ -82,7 +82,7 @@ void fml_opt_init(fml_opt_t *opt);
*
* @return array of unitigs
*/
fml_utg_t *fml_assemble(const fml_opt_t *opt, int n_seqs, bseq1_t *seqs, int *n_utg);
fml_utg_t *fml_assemble(const fml_opt_t *opt, int n_seqs, fml_seq1_t *seqs, int *n_utg);

/**
* Free unitigs
Expand All @@ -103,7 +103,7 @@ void fml_utg_destroy(int n_utg, fml_utg_t *utg);
* @param n_seqs number of sequences
* @param seqs array of sequences
*/
void fml_opt_adjust(fml_opt_t *opt, int n_seqs, const bseq1_t *seqs);
void fml_opt_adjust(fml_opt_t *opt, int n_seqs, const fml_seq1_t *seqs);

/**
* Error correction
Expand All @@ -114,8 +114,8 @@ void fml_opt_adjust(fml_opt_t *opt, int n_seqs, const bseq1_t *seqs);
*
* @return k-mer coverage
*/
float fml_correct(const fml_opt_t *opt, int n, bseq1_t *seq);
float fml_fltuniq(const fml_opt_t *opt, int n, bseq1_t *seq);
float fml_correct(const fml_opt_t *opt, int n, fml_seq1_t *seq);
float fml_fltuniq(const fml_opt_t *opt, int n, fml_seq1_t *seq);

/**
* Construct FMD-index
Expand All @@ -126,7 +126,7 @@ float fml_fltuniq(const fml_opt_t *opt, int n, bseq1_t *seq);
*
* @return FMD-index
*/
struct rld_t *fml_seq2fmi(const fml_opt_t *opt, int n, bseq1_t *seq);
struct rld_t *fml_seq2fmi(const fml_opt_t *opt, int n, fml_seq1_t *seq);

/**
* Generate initial overlap graph
Expand Down
2 changes: 1 addition & 1 deletion internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extern "C" {
void kt_for(int n_threads, void (*func)(void*,long,int), void *data, long n);
void seq_reverse(int l, unsigned char *s);
void seq_revcomp6(int l, unsigned char *s);
struct bfc_ch_s *fml_count(int n, const bseq1_t *seq, int k, int q, int l_pre, int n_threads);
struct bfc_ch_s *fml_count(int n, const fml_seq1_t *seq, int k, int q, int l_pre, int n_threads);

#ifdef __cplusplus
}
Expand Down
10 changes: 5 additions & 5 deletions misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void fml_opt_init(fml_opt_t *opt)
opt->mag_opt.flag = MAG_F_NO_SIMPL | MAG_F_POPOPEN;
}

void fml_opt_adjust(fml_opt_t *opt, int n_seqs, const bseq1_t *seqs)
void fml_opt_adjust(fml_opt_t *opt, int n_seqs, const fml_seq1_t *seqs)
{
int i, log_len;
uint64_t tot_len = 0;
Expand All @@ -62,7 +62,7 @@ static inline int is_rev_same(int l, const char *s)
return (i == l>>1);
}

struct rld_t *fml_fmi_gen(int n, bseq1_t *seq, int is_mt)
struct rld_t *fml_fmi_gen(int n, fml_seq1_t *seq, int is_mt)
{
mrope_t *mr;
kstring_t str = {0,0,0};
Expand All @@ -75,7 +75,7 @@ struct rld_t *fml_fmi_gen(int n, bseq1_t *seq, int is_mt)
mr = mr_init(ROPE_DEF_MAX_NODES, ROPE_DEF_BLOCK_LEN, MR_SO_RCLO);
for (k = 0; k < n; ++k) {
int i;
bseq1_t *s = &seq[k];
fml_seq1_t *s = &seq[k];
if (s->l_seq == 0) continue;
free(s->qual);
for (i = 0; i < s->l_seq; ++i)
Expand Down Expand Up @@ -116,7 +116,7 @@ struct rld_t *fml_fmi_gen(int n, bseq1_t *seq, int is_mt)
return e;
}

struct rld_t *fml_seq2fmi(const fml_opt_t *opt, int n, bseq1_t *seq)
struct rld_t *fml_seq2fmi(const fml_opt_t *opt, int n, fml_seq1_t *seq)
{
return fml_fmi_gen(n, seq, opt->n_threads > 1? 1 : 0);
}
Expand Down Expand Up @@ -272,7 +272,7 @@ void fml_utg_destroy(int n, fml_utg_t *utg)

#define MAG_MIN_NSR_COEF .1

fml_utg_t *fml_assemble(const fml_opt_t *opt0, int n_seqs, bseq1_t *seqs, int *n_utg)
fml_utg_t *fml_assemble(const fml_opt_t *opt0, int n_seqs, fml_seq1_t *seqs, int *n_utg)
{
rld_t *e;
mag_t *g;
Expand Down

0 comments on commit e93040b

Please sign in to comment.