Skip to content

Commit

Permalink
Ensure that sample IDs don't contain weird chars
Browse files Browse the repository at this point in the history
This ensures that the file names created don't contain them either.
  • Loading branch information
kdm9 committed Dec 8, 2014
1 parent 5a1cdfb commit 80871b1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ MESSAGE(STATUS "${CMAKE_BUILD_TYPE} build of axe version: ${AXE_VERSION}")

INCLUDE(CheckSymbolExists)
INCLUDE(CheckIncludeFiles)
CHECK_INCLUDE_FILES(regex.h REGEX_H_FOUND)
FIND_PACKAGE(ZLIB 1.2.5 REQUIRED)
FIND_PACKAGE(GSL 1.5 REQUIRED)
SET(AXE_DEPENDS_LIBS
Expand Down
2 changes: 0 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
TODO list:
==========

- Check that a sample's name doesn't contain weird characters that shouldn't be
in file names. (i.e.: '"\[]{}()/!@#$%^&*;: )
- Re-read documentation; fix errors
- Exhaustive CLI tests
- Refactor trie lookups to hide all datrie operations from main body of code
Expand Down
8 changes: 8 additions & 0 deletions src/axe.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ axe_read_barcodes(struct axe_config *config)
struct axe_barcode **barcodes = NULL;
size_t n_barcode_pairs = 0; /* Entries in file */
size_t n_barcodes_alloced = 8;
const char *bad_fname_chars = "'\"!@#$%^&*()+=~`[]{}\\|;:/?><,";
char *line = NULL;
char *tmp = NULL;
size_t linesz = 128;
ssize_t linelen = 0;
size_t iii = 0;
Expand Down Expand Up @@ -281,6 +283,12 @@ axe_read_barcodes(struct axe_config *config)
fprintf(stderr, "Couldn't parse barcode line '%s'\n", line);
goto error;
}
/* Replace all bad chars with '-' */
tmp = strpbrk(this_barcode->id, bad_fname_chars);
while (tmp != NULL) {
*tmp = '-'; /* Replace with dash */
tmp = strpbrk(tmp + 1, bad_fname_chars);
}
/* Add the barcode to the array */
barcodes[n_barcode_pairs++] = this_barcode;
}
Expand Down

0 comments on commit 80871b1

Please sign in to comment.