Skip to content

Commit

Permalink
Merge branch 'master' into v0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kdm9 committed Aug 12, 2014
2 parents 2223a2a + 50311f9 commit 47d1c14
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 41 deletions.
52 changes: 34 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
AXE
===

> Demultiplex NGS reads using fast data structures. It's fast, and made of tries!
> Demultiplex NGS reads using trie data structures. It's fast, and made of tries!
AXE very rapidly selects the optimal barcode present in a sequence read, even
in the presence of sequencing errors. The algorithm is able to handle
Expand All @@ -17,17 +17,6 @@ existing demultiplexers. Unscientific trials show AXE processes more than
**Warning**: Axe has not yet been comprehensively tested. However, in the
spirit of "release early and often", here it is.

Implementation Progress:
------------------------

- [x] Single ended read demultiplexing
- [x] Interleaved/Paired input and output with single-ended demultiplexing
- [x] Combinatorial demultiplexing
- [x] CLI integration tests
- [ ] Comprehensive `libaxe` tests
- [ ] Comprehensive CLI tests

See also TODO.md

Installation:
-------------
Expand Down Expand Up @@ -58,30 +47,57 @@ e.g.:
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/ ..

For me, using `~/` as the prefix will install `axe` under `/home/kevin/bin` on
GNU/Linux, and `/Users/kevin/bin` on Mac OSX.

It's also wise to use `make install` not `sudo make install` when installing to
a home directory.
GNU/Linux, and (if I had one) `/Users/kevin/bin` on Mac OSX.It's also wise to
use `make install` not `sudo make install` when installing to a home directory.

###Dependencies:

- cmake. This is installable via `sudo apt-get install cmake` on debian based
- cmake. This is installable via `sudo apt-get install cmake` on Debian based
systems, or `brew install cmake` using homebrew on OS X.
- zlib version >= 1.2.5. On debian, use the pacakge `zlib1g-dev`.
- zlib version >= 1.2.5. On Debian, use the pacakge `zlib1g-dev`.
- kmlib, tinytest and libdatrie (bundled in source, if you used
`git clone --recursive` or an installation tarball)

You'll possibly need to install zlib to your chosen prefix (e.g. `~/`) on
supercomuters, which often have very old versions of zlib. To do so:

wget http://zlib.net/zlib-1.2.8.tar.gz
tar xvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure --prefix=<your_prefix> # e.g. --prefix=~/
make && make install

And then, use the following cmake command, assuming your prefix is `~/`:

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/ -DZLIB_ROOT=~/ ..


Usage:
------

Full documentation, including a basic description of the algorithm, is hosted
at https://axe-demultiplexer.readthedocs.org/en/latest/ .


Implementation Progress:
------------------------

- [x] Single ended read demultiplexing
- [x] Interleaved/Paired input and output with single-ended demultiplexing
- [x] Combinatorial demultiplexing
- [x] CLI integration tests
- [ ] Comprehensive `libaxe` tests
- [ ] Comprehensive CLI tests

See also TODO.md


Publication
-----------

A publication is coming soon, if the reviewer gods decide to smile upon us.


LICENSE
-------

Expand Down
40 changes: 27 additions & 13 deletions src/axe.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,14 +486,16 @@ load_tries_combo(struct axe_config *config)

if (!axe_config_ok(config)) {
fprintf(stderr, "[load_tries] Bad config\n");
return -1;
ret = -1;
goto exit;
}
/* Make mutated barcodes and add to trie */
for (iii = 0; iii < config->n_barcode_pairs; iii++) {
this_bcd = config->barcodes[iii];
if (!axe_barcode_ok(this_bcd)) {
fprintf(stderr, "[load_tries] Bad R1 barcode at %zu\n", iii);
return -1;
ret = -1;
goto exit;
}
/* Either lookup the index of the first read in the barcode table, or
* insert this barcode into the table, storing its index.
Expand All @@ -503,7 +505,8 @@ load_tries_combo(struct axe_config *config)
if (ret != 0) {
fprintf(stderr, "ERROR: Could not load barcode %s into trie %zu\n",
this_bcd->seq1, iii);
return 1;
ret = 1;
goto exit;
}
} else {
continue;
Expand All @@ -512,7 +515,10 @@ load_tries_combo(struct axe_config *config)
/* Do the forwards read barcode */
mutated = hamming_mutate_dna(&num_mutated, this_bcd->seq1,
this_bcd->len1, jjj, 0);
assert(mutated != NULL);
if (mutated == NULL) {
ret = 1;
goto exit;
}
for (mmm = 0; mmm < num_mutated; mmm++) {
ret = axe_trie_add(config->fwd_tries[jjj], mutated[mmm], bcd1);
if (ret != 0) {
Expand All @@ -521,7 +527,6 @@ load_tries_combo(struct axe_config *config)
fprintf(stderr,
"[%s] warning: Will only match %s to %dmm\n",
__func__, this_bcd->id, (int)jjj - 1);

}
trie_delete(config->fwd_tries[jjj]->trie,
mutated[mmm]);
Expand All @@ -548,7 +553,8 @@ load_tries_combo(struct axe_config *config)
if (ret != 0) {
fprintf(stderr, "ERROR: Could not load barcode %s into trie %zu\n",
this_bcd->seq2, iii);
return 1;
retval = 1;
goto exit;
}
} else {
continue;
Expand All @@ -557,7 +563,10 @@ load_tries_combo(struct axe_config *config)
num_mutated = 0;
mutated = hamming_mutate_dna(&num_mutated, this_bcd->seq2,
this_bcd->len2, jjj, 0);
assert(mutated != NULL);
if (mutated == NULL) {
ret = 1;
goto exit;
}
for (mmm = 0; mmm < num_mutated; mmm++) {
ret = axe_trie_add(config->rev_tries[jjj], mutated[mmm], bcd2);
if (ret != 0) {
Expand All @@ -566,7 +575,6 @@ load_tries_combo(struct axe_config *config)
fprintf(stderr,
"[%s] warning: Will only match %s to %dmm\n",
__func__, this_bcd->id, (int)jjj - 1);

}
trie_delete(config->rev_tries[jjj]->trie,
mutated[mmm]);
Expand All @@ -586,6 +594,7 @@ load_tries_combo(struct axe_config *config)
}
/* we got here, so we succeeded. set retval accordingly */
retval = 0;

exit:
if (mutated != NULL) {
for (mmm = 0; mmm < num_mutated; mmm++) {
Expand Down Expand Up @@ -638,7 +647,10 @@ load_tries_single(struct axe_config *config)
for (jjj = 1; jjj <= config->mismatches; jjj++) {
mutated = hamming_mutate_dna(&num_mutated, this_bcd->seq1,
this_bcd->len1, jjj, 0);
assert(mutated != NULL);
if (mutated == NULL) {
ret = 1;
goto exit;
}
for (mmm = 0; mmm < num_mutated; mmm++) {
ret = axe_trie_add(config->fwd_tries[jjj], mutated[mmm], iii);
if (ret != 0) {
Expand All @@ -647,7 +659,6 @@ load_tries_single(struct axe_config *config)
fprintf(stderr,
"[%s] warning: Will only match %s to %dmm\n",
__func__, this_bcd->id, (int)jjj - 1);

}
trie_delete(config->fwd_tries[jjj]->trie,
mutated[mmm]);
Expand All @@ -668,11 +679,14 @@ load_tries_single(struct axe_config *config)
}
/* we got here, so we succeeded */
retval = 0;

exit:
for (mmm = 0; mmm < num_mutated; mmm++) {
km_free(mutated[mmm]);
if (mutated != NULL) {
for (mmm = 0; mmm < num_mutated; mmm++) {
km_free(mutated[mmm]);
}
km_free(mutated);
}
km_free(mutated);
return retval;
}

Expand Down
20 changes: 10 additions & 10 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,6 @@ parse_args(struct axe_config *config, int argc, char * const *argv)
fprintf(stderr, "ERROR: Setting revese read input file failed.\n");
goto error;
break;
fprintf(stderr, "ERROR: Setting interleaved input file failed.\n");
goto error;
break;
case READS_UNKNOWN:
default:
goto error;
Expand All @@ -264,6 +261,9 @@ parse_args(struct axe_config *config, int argc, char * const *argv)
goto error;
break;
case READS_SINGLE:
fprintf(stderr, "ERROR: Revese read input file set in single-end mode.\n");
goto error;
break;
case READS_UNKNOWN:
default:
/* Misc weirdness */
Expand Down Expand Up @@ -369,16 +369,16 @@ parse_args(struct axe_config *config, int argc, char * const *argv)
}
config->have_cli_opts = 1;
return 0;
version:
axe_config_destroy(config);
print_version();
return 0;
help:
config->have_cli_opts = 0;
return 2;
error:
config->have_cli_opts = 0;
return 1;
help:
config->have_cli_opts = 0;
return 2;
version:
print_version();
axe_config_destroy(config);
exit(0);
}

int
Expand Down

0 comments on commit 47d1c14

Please sign in to comment.