Skip to content

Commit 1b1d100

Browse files
committed
ctx_contigs.c: make --no-reseed default
1 parent cc5c31c commit 1b1d100

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/commands/ctx_contigs.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ const char contigs_usage[] =
2424
" -c, --colour <c> Pull out contigs from the given colour [default: 0]\n"
2525
" -N, --ncontigs <N> Pull out <N> contigs from random kmers [default: 0, no limit]\n"
2626
" -s, --seed <in.fa> Use seed kmers from a file. Reads must be of kmer length\n"
27-
" -R, --no-reseed Do not use a seed kmer if it is used in a contig\n"
27+
" -r, --reseed Sample seed kmers with replacement\n"
28+
" -R, --no-reseed Do not use a seed kmer if it is used in a contig [default]\n"
2829
"\n";
2930

3031
static struct option longopts[] =
@@ -40,6 +41,7 @@ static struct option longopts[] =
4041
// command specific
4142
{"seed", required_argument, NULL, 's'},
4243
{"seq", required_argument, NULL, '1'},
44+
{"reseed", no_argument, NULL, 'r'},
4345
{"no-reseed", no_argument, NULL, 'R'},
4446
{"ncontigs", required_argument, NULL, 'N'},
4547
{"colour", required_argument, NULL, 'c'},
@@ -53,7 +55,7 @@ int ctx_contigs(int argc, char **argv)
5355
struct MemArgs memargs = MEM_ARGS_INIT;
5456
const char *out_path = NULL;
5557
size_t i, contig_limit = 0, colour = 0;
56-
bool no_reseed = false;
58+
bool cmd_reseed = false, cmd_no_reseed = false; // -r, -R
5759

5860
seq_file_t *tmp_seed_file = NULL;
5961
SeqFilePtrBuffer seed_buf;
@@ -92,7 +94,8 @@ int ctx_contigs(int argc, char **argv)
9294
die("Cannot read --seed file: %s", optarg);
9395
seq_file_ptr_buf_add(&seed_buf, tmp_seed_file);
9496
break;
95-
case 'R': cmd_check(!no_reseed,cmd); no_reseed = true; break;
97+
case 'r': cmd_check(!cmd_reseed,cmd); cmd_reseed = true; break;
98+
case 'R': cmd_check(!cmd_no_reseed,cmd); cmd_no_reseed = true; break;
9699
case 'N':
97100
cmd_check(!contig_limit,cmd);
98101
contig_limit = cmd_uint32_nonzero(cmd, optarg);
@@ -105,10 +108,15 @@ int ctx_contigs(int argc, char **argv)
105108
}
106109
}
107110

111+
if(cmd_no_reseed && cmd_reseed)
112+
cmd_print_usage("Cannot specify both -r and -R");
113+
114+
bool sample_with_replacement = cmd_reseed;
115+
108116
// Defaults
109117
if(nthreads == 0) nthreads = DEFAULT_NTHREADS;
110118

111-
if(!seed_buf.len && !contig_limit && !no_reseed) {
119+
if(!seed_buf.len && !contig_limit && sample_with_replacement) {
112120
cmd_print_usage("Please specify one or more of: "
113121
"--no-reseed | --ncontigs | --seed <in.fa>");
114122
}
@@ -137,9 +145,9 @@ int ctx_contigs(int argc, char **argv)
137145
//
138146
size_t bits_per_kmer, kmers_in_hash, graph_mem, path_mem, total_mem;
139147

140-
// 1 bit needed per kmer if we need to keep track of no_reseed
148+
// 1 bit needed per kmer if we need to keep track of kmer usage
141149
bits_per_kmer = sizeof(BinaryKmer)*8 + sizeof(Edges)*8 + sizeof(GPath)*8 +
142-
ncols + no_reseed;
150+
ncols + !sample_with_replacement;
143151

144152
kmers_in_hash = cmd_get_kmers_in_hash(memargs.mem_to_use,
145153
memargs.mem_to_use_set,
@@ -181,7 +189,7 @@ int ctx_contigs(int argc, char **argv)
181189

182190
uint8_t *visited = NULL;
183191

184-
if(no_reseed)
192+
if(!sample_with_replacement)
185193
visited = ctx_calloc(roundup_bits2bytes(db_graph.ht.capacity), 1);
186194

187195
// Load graph

tests/contigs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ seq.k$(K).ctp.gz: seq.k$(K).ctx seq.fa
1919
$(CTX) thread -m 1M --seq seq.fa --out $@ seq.k$(K).ctx
2020

2121
contigs.fa: seq.k$(K).ctx seq.k$(K).ctp.gz
22-
$(CTX) contigs --no-reseed --out $@ -p seq.k$(K).ctp.gz seq.k$(K).ctx
22+
$(CTX) contigs --out $@ -p seq.k$(K).ctp.gz seq.k$(K).ctx
2323

2424
contigs.rmdup.fa: contigs.fa
2525
$(CTX) rmsubstr $< > $@

0 commit comments

Comments
 (0)