FastaVector 1.0.0-beta
|
Primary struct that stores data for a given FASTA file. More...
#include <FastaVector.h>
Data Fields | |
struct FastaVectorString | sequence |
Storage for sequence data. More... | |
struct FastaVectorString | header |
Storage for header data. More... | |
struct FastaVectorMetadataVector | metadata |
Storage for header and sequence metadata. More... | |
Related Functions | |
(Note that these are not member functions.) | |
enum FastaVectorReturnCode | fastaVectorInit (struct FastaVector *fastaVector) |
Initialize an empty FastaVector struct. More... | |
void | fastaVectorDealloc (struct FastaVector *fastaVector) |
Deinitialize FastaVector member data. More... | |
enum FastaVectorReturnCode | fastaVectorReadFasta (const char *restrict const fileSrc, struct FastaVector *fastaVector) |
Load the given fasta file. More... | |
enum FastaVectorReturnCode | fastaVectorWriteFasta (const char *restrict const filePath, struct FastaVector *fastaVector, uint32_t fileLineLength) |
Write a FastaVector to a file. More... | |
enum FastaVectorReturnCode | fastaVectorAddSequenceToList (struct FastaVector *fastaVector, char *header, size_t headerLength, char *sequence, size_t sequenceLength) |
Add a header and sequence to the given FastaVector . More... | |
void | fastaVectorFastaGetHeader (struct FastaVector *fastaVector, size_t headerIndex, char **headerPtr, size_t *headerLength) |
Gets a header from the given FastaVector . More... | |
void | fastaVectorFastaGetSequence (struct FastaVector *fastaVector, size_t sequenceIndex, char **sequencePtr, size_t *sequenceLength) |
Gets a sequence from the given FastaVector . More... | |
bool | fastaVectorGetLocalSequencePositionFromGlobal (const struct FastaVector *const fastaVector, const size_t globalSequencePosition, struct FastaVectorLocalPosition *localPosition) |
Gets a local sequence index and position from a FastaVector . More... | |
Primary struct that stores data for a given FASTA file.
|
related |
Add a header and sequence to the given FastaVector
.
fastaVector | the FastaVector to modify |
header | pointer to the first character in the header |
headerLength | length of the header, in bytes |
sequence | pointer to the first character in the sequence |
sequenceLength | length of the sequence, in bytes |
The header should not include the leading ">" character, it will be added automatically. The header and sequence will be automatically null-terminated upon insertion into the FastaVector
.
The return value is one of:
FASTA_VECTOR_OK
FASTA_VECTOR_ALLOCATION_FAIL
TODO: What if the original FV was not null-terminated?
|
related |
Deinitialize FastaVector
member data.
fastaVector | the vector to deinitialize |
This function does not deallocate (free) the FastaVector
itself, only the member data.
|
related |
Gets a header from the given FastaVector
.
fastaVector | the FastaVector to read |
headerIndex | the index of the header to be retrieved |
headerPtr | pointer to store the header |
headerLength | pointer to store the header length |
If the FastaVector was built with null-terminated headers, the null terminator will be included in the resulting headerPtr
and headerLength
.
The index is 0-based so, for example, index 4 is the 5th header.
TODO: Should we return a statuc code in case the index was out of bounds?
|
related |
Gets a sequence from the given FastaVector
.
fastaVector | the FastaVector to read |
sequenceIndex | the index of the sequence to be retrieved |
sequencePtr | pointer to store the sequence |
sequenceLength | pointer to store the sequence length |
If the FastaVector was built with null-terminated sequences, the null terminator will be included in the resulting sequencePtr
and sequenceLength
.
The index is 0-based so, for example, index 4 is the 5th sequence.
|
related |
Gets a local sequence index and position from a FastaVector
.
fastaVector | the FastaVector to inspect |
globalSequencePosition | position across the entire sequence collection |
localPosition | a pointer to the struct to load the local position data into |
The return value will be false if the given globalSequencePosition
is outside the range of positions in the vector of sequences. In other words, if globalSequencePosition
is greater than the sum of the lengths of all the sequences in the FastaVector
, minus 1.
|
related |
Initialize an empty FastaVector
struct.
fastaVector | the vector to initialize |
The struct itself must have been allocated before this function is called.
|
related |
Load the given fasta file.
fileSrc | the path of the FASTA file to load |
fastaVector | the vector to load the fasta into |
nullTerminateHeaders | whether null characters should be added to headers |
nullTerminateSequences | whether null characters should be added to sequences |
Loads its full contents into the initialized fasta vector. This function takes any properly formed fasta file, and loads all headers and sequences.
If nullTerminateHeaders
is set to true, then null characters ('\0') are added after each header to easily denote the end of the header (useful for printing). If nullTerminateSequences
is set to true, null characters ('\0') are added after each sequence to easily separate them (useful for printing or separating the sequences in an index).
|
related |
Write a FastaVector
to a file.
filePath | path of the file to be written |
fastaVector | the FASTA data to be written |
fileLineLength | maximum number of characters per line of sequence |
This function will overwrite the file at the given path.
struct FastaVectorString FastaVector::header |
Storage for header data.
struct FastaVectorMetadataVector FastaVector::metadata |
Storage for header and sequence metadata.
struct FastaVectorString FastaVector::sequence |
Storage for sequence data.