libuproc  1.2.0
Data Structures | Macros | Functions

Amino acid word. More...

Data Structures

struct  uproc_word
 Amino acid word. More...
 

Macros

#define UPROC_WORD_INITIALIZER
 Initializer to be used for all uproc_word structs. More...
 

Functions

int uproc_word_from_string (struct uproc_word *word, const char *str, const uproc_alphabet *alpha)
 Transform a string to amino acid word. More...
 
int uproc_word_to_string (char *str, const struct uproc_word *word, const uproc_alphabet *alpha)
 Build string corresponding to amino acid word. More...
 
void uproc_word_append (struct uproc_word *word, uproc_amino amino)
 Append amino acid. More...
 
void uproc_word_prepend (struct uproc_word *word, uproc_amino amino)
 Prepend amino acid. More...
 
bool uproc_word_startswith (const struct uproc_word *word, uproc_amino amino)
 Compare first amino acid of a word. More...
 
int uproc_word_cmp (const struct uproc_word *w1, const struct uproc_word *w2)
 Compare words. More...
 

Detailed Description

Amino acid word.

Macro Definition Documentation

#define UPROC_WORD_INITIALIZER
Value:
{ \
0, 0 \
}

Initializer to be used for all uproc_word structs.

Function Documentation

int uproc_word_from_string ( struct uproc_word word,
const char *  str,
const uproc_alphabet alpha 
)

Transform a string to amino acid word.

Translates the first UPROC_WORD_LEN characters of the given string to a word object. Failure occurs if the string ends or an invalid character is encountered.

Parameters
wordOUT: amino acid word
strstring representation
alphaalphabet to use for translation
int uproc_word_to_string ( char *  str,
const struct uproc_word word,
const uproc_alphabet alpha 
)

Build string corresponding to amino acid word.

Translates an amino acid word back to a string. The string will be null-terminated, thus str should point to a buffer of at least UPROC_WORD_LEN + 1 bytes.

Parameters
strbuffer to store the string in
wordamino acid word
alphaalphabet to use for translation
void uproc_word_append ( struct uproc_word word,
uproc_amino  amino 
)

Append amino acid.

The leftmost amino acid of word is removed, for example (in case of a word length of 5):

1 append(ANERD, S) == NERDS

NOTE: It will not be verified whether amino represents a valid amino acid.

Parameters
wordword to append to
aminoamino acid to append
void uproc_word_prepend ( struct uproc_word word,
uproc_amino  amino 
)

Prepend amino acid.

Complement to the append operation, e.g.

1 prepend(NERDS, A) == ANERD
Parameters
wordword to prepend to
aminoamino acid to prepend
bool uproc_word_startswith ( const struct uproc_word word,
uproc_amino  amino 
)

Compare first amino acid of a word.

int uproc_word_cmp ( const struct uproc_word w1,
const struct uproc_word w2 
)

Compare words.

Comparison is done lexcographically (prefix first, suffix second).

Returns
-1, 0 or 1 if w1 is less than, equal to, or greater than w2.