libuproc  1.2.0
word.h
Go to the documentation of this file.
1 /* Copyright 2014 Peter Meinicke, Robin Martinjak
2  *
3  * This file is part of libuproc.
4  *
5  * libuproc is free software: you can redistribute it and/or modify it under
6  * the terms of the GNU Lesser General Public License as published by the Free
7  * Software Foundation, either version 3 of the License, or (at your option)
8  * any later version.
9  *
10  * libuproc is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libuproc. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
30 #ifndef UPROC_WORD_H
31 #define UPROC_WORD_H
32 
33 #include <stdint.h>
34 #include <stdbool.h>
35 #include "uproc/alphabet.h"
36 
45 struct uproc_word
46 {
49 
52 };
53 
55 #define UPROC_WORD_INITIALIZER \
56  { \
57  0, 0 \
58  }
59 
70 int uproc_word_from_string(struct uproc_word *word, const char *str,
71  const uproc_alphabet *alpha);
72 
83 int uproc_word_to_string(char *str, const struct uproc_word *word,
84  const uproc_alphabet *alpha);
85 
98 void uproc_word_append(struct uproc_word *word, uproc_amino amino);
99 
108 void uproc_word_prepend(struct uproc_word *word, uproc_amino amino);
109 
111 bool uproc_word_startswith(const struct uproc_word *word, uproc_amino amino);
112 
119 int uproc_word_cmp(const struct uproc_word *w1, const struct uproc_word *w2);
149 typedef struct uproc_worditer_s uproc_worditer;
150 
159 uproc_worditer *uproc_worditer_create(const char *seq,
160  const uproc_alphabet *alpha);
161 
172 int uproc_worditer_next(uproc_worditer *iter, size_t *index,
173  struct uproc_word *fwd, struct uproc_word *rev);
174 
183 #endif
int uproc_word_cmp(const struct uproc_word *w1, const struct uproc_word *w2)
Compare words.
uproc_suffix suffix
Last few amino acids.
Definition: word.h:51
Amino acid alphabet.
void uproc_word_append(struct uproc_word *word, uproc_amino amino)
Append amino acid.
Module: Amino acid translation alphabets.
int uproc_word_from_string(struct uproc_word *word, const char *str, const uproc_alphabet *alpha)
Transform a string to amino acid word.
int uproc_amino
Type to represent one amino acid.
Definition: common.h:52
struct uproc_worditer_s uproc_worditer
Iterator over all words in an amino acid sequence.
Definition: word.h:149
uproc_prefix prefix
First few amino acids.
Definition: word.h:48
uint_least64_t uproc_suffix
Type for suffixes.
Definition: common.h:84
uproc_worditer * uproc_worditer_create(const char *seq, const uproc_alphabet *alpha)
Create worditer object.
uint_least32_t uproc_prefix
Type for prefixes.
Definition: common.h:65
void uproc_worditer_destroy(uproc_worditer *iter)
Destroy worditer object.
Amino acid word.
Definition: word.h:45
bool uproc_word_startswith(const struct uproc_word *word, uproc_amino amino)
Compare first amino acid of a word.
void uproc_word_prepend(struct uproc_word *word, uproc_amino amino)
Prepend amino acid.
int uproc_worditer_next(uproc_worditer *iter, size_t *index, struct uproc_word *fwd, struct uproc_word *rev)
Obtain the next word(s) from a word iterator.
int uproc_word_to_string(char *str, const struct uproc_word *word, const uproc_alphabet *alpha)
Build string corresponding to amino acid word.