FastaVector 1.0.0-beta
FastaVector Struct Reference

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...
 

Detailed Description

Primary struct that stores data for a given FASTA file.

Friends And Related Function Documentation

◆ fastaVectorAddSequenceToList()

enum FastaVectorReturnCode fastaVectorAddSequenceToList ( struct FastaVector fastaVector,
char *  header,
size_t  headerLength,
char *  sequence,
size_t  sequenceLength 
)
related

Add a header and sequence to the given FastaVector.

Parameters
fastaVectorthe FastaVector to modify
headerpointer to the first character in the header
headerLengthlength of the header, in bytes
sequencepointer to the first character in the sequence
sequenceLengthlength of the sequence, in bytes
Returns
a status code

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?

◆ fastaVectorDealloc()

void fastaVectorDealloc ( struct FastaVector fastaVector)
related

Deinitialize FastaVector member data.

Parameters
fastaVectorthe vector to deinitialize

This function does not deallocate (free) the FastaVector itself, only the member data.

◆ fastaVectorFastaGetHeader()

void fastaVectorFastaGetHeader ( struct FastaVector fastaVector,
size_t  headerIndex,
char **  headerPtr,
size_t *  headerLength 
)
related

Gets a header from the given FastaVector.

Parameters
fastaVectorthe FastaVector to read
headerIndexthe index of the header to be retrieved
headerPtrpointer to store the header
headerLengthpointer 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?

◆ fastaVectorFastaGetSequence()

void fastaVectorFastaGetSequence ( struct FastaVector fastaVector,
size_t  sequenceIndex,
char **  sequencePtr,
size_t *  sequenceLength 
)
related

Gets a sequence from the given FastaVector.

Parameters
fastaVectorthe FastaVector to read
sequenceIndexthe index of the sequence to be retrieved
sequencePtrpointer to store the sequence
sequenceLengthpointer 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.

◆ fastaVectorGetLocalSequencePositionFromGlobal()

bool fastaVectorGetLocalSequencePositionFromGlobal ( const struct FastaVector *const  fastaVector,
const size_t  globalSequencePosition,
struct FastaVectorLocalPosition localPosition 
)
related

Gets a local sequence index and position from a FastaVector.

Parameters
fastaVectorthe FastaVector to inspect
globalSequencePositionposition across the entire sequence collection
localPositiona pointer to the struct to load the local position data into
Returns
true on success, false on failure

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.

◆ fastaVectorInit()

enum FastaVectorReturnCode fastaVectorInit ( struct FastaVector fastaVector)
related

Initialize an empty FastaVector struct.

Parameters
fastaVectorthe vector to initialize
Returns
a status code

The struct itself must have been allocated before this function is called.

◆ fastaVectorReadFasta()

enum FastaVectorReturnCode fastaVectorReadFasta ( const char *restrict const  fileSrc,
struct FastaVector fastaVector 
)
related

Load the given fasta file.

Parameters
fileSrcthe path of the FASTA file to load
fastaVectorthe vector to load the fasta into
nullTerminateHeaderswhether null characters should be added to headers
nullTerminateSequenceswhether null characters should be added to sequences
Returns
a status code

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).

◆ fastaVectorWriteFasta()

enum FastaVectorReturnCode fastaVectorWriteFasta ( const char *restrict const  filePath,
struct FastaVector fastaVector,
uint32_t  fileLineLength 
)
related

Write a FastaVector to a file.

Parameters
filePathpath of the file to be written
fastaVectorthe FASTA data to be written
fileLineLengthmaximum number of characters per line of sequence
Returns
a status code

This function will overwrite the file at the given path.

Field Documentation

◆ header

struct FastaVectorString FastaVector::header

Storage for header data.

◆ metadata

struct FastaVectorMetadataVector FastaVector::metadata

Storage for header and sequence metadata.

◆ sequence

struct FastaVectorString FastaVector::sequence

Storage for sequence data.


The documentation for this struct was generated from the following file: