This is simple C code to validate a fasta file. It only checks a few things, and by default only sets its response via the return code, so you will need to check that!
The simple rules that we adhere to are:
- Each header line starts with a
>
. The header preceedes the sequence. - Every other line is considered a sequence line
- Sequence lines may not contain whitespace, numbers, or non-sequence characters. In other words, they must only contain the characters [A-Z] and [a-z]
- Sequence lines can end with a new line or return depending on whether you have edited this file on a mac, pc, or linux machine.
- Sequence lines can be empty.
- The sequence identifier is the string of characters in the header line following the
>
and upto the first whitespace. Everything after the first whitespace is descriptive, and can be as long as you like - Each sequence identifier must be unique within the fasta file.
We will exit with the following return codes:
0
this is a valid fasta file1
the first line does not start with a > (rule 1 violated).2
there are duplicate sequence identifiers in the file (rule 7 violated)4
there are characters in a sequence line other than [A-Za-z]
Other exit codes (e.g. 255, 254, etc) indicate internal errors in the program.
The only prerequisite is ANSI C.
To clone the code from GitHub use:
git clone https://github.com/linsalrob/fasta_validator.git
cd fasta_validator
To build the code, use:
make
This will compile the source into an executable in the current working directory.
To install this code as root (sudo) you can use:
make install
and this will copy the executable to /usr/local/bin
.
to install it as a user, just copy the compiled binary fasta_validate
to somewhere on your path.
To test the code, please use
make test
or
bash test.sh
This tests the code against both valid and invalid fasta files provided in the test/ directory.
Please cite this as
Edwards, R.A. 2019. fasta_validate: a fast and efficient fasta validator written in pure C. DOI: 10.5281/zenodo.2532044
This software is released using the MIT License