Skip to content

Commit

Permalink
Merge pull request #1529 from ComparativeGenomicsToolkit/oneshot
Browse files Browse the repository at this point in the history
Add checks for invalid sequence characters when writing temporary FASTA files
  • Loading branch information
glennhickey authored Nov 18, 2024
2 parents 80a603e + a21ffeb commit d07cb23
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions preprocessor/cactus_sanitizeFastaHeaders.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,17 @@ void addUniqueFastaPrefix(void* destination, const char *fastaHeader, const char
clipped_header = prefixed_header;
}

// sanity check
int64_t n = strlen(string);
for (int64_t i = 0; i < n; ++i) {
char c = tolower(string[i]);
if (c != 'a' && c != 'c' && c != 'g' && c != 't' && c != 'n') {
fprintf(stderr, "Error: Non-ACGTN character '%c' found at position %" PRIi64 " of FASTA sequence %s in event %s\n",
c, i, fastaHeader, eventName);
exit(1);
}
}

fastaWrite((char*)string, clipped_header, stdout);
free(clipped_header);
}
Expand Down
2 changes: 1 addition & 1 deletion submodules/paffy

0 comments on commit d07cb23

Please sign in to comment.