Skip to content

Commit

Permalink
Update C FFI bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-Liu-c0deb0t committed Jul 8, 2023
1 parent 0dc5c39 commit 60590a3
Showing 1 changed file with 103 additions and 3 deletions.
106 changes: 103 additions & 3 deletions c/block_aligner.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,15 @@ extern const struct ByteMatrix BYTES1;
*/
struct AAMatrix *block_new_simple_aamatrix(int8_t match_score, int8_t mismatch_score);

/**
* Set an entry in the AAMatrix.
*/
void block_set_aamatrix(struct AAMatrix *matrix, uint8_t a, uint8_t b, int8_t score);

/**
* Frees an AAMatrix.
*/
void block_free_simple_aamatrix(struct AAMatrix *matrix);
void block_free_aamatrix(struct AAMatrix *matrix);

/**
* Create a new profile of a specific length, with default (large negative) values.
Expand All @@ -190,19 +195,51 @@ struct AAProfile *block_new_aaprofile(uintptr_t str_len, uintptr_t block_size, i
uintptr_t block_len_aaprofile(const struct AAProfile *profile);

/**
* Clear the profile so it can be used for profile lengths less than or equal
* Clear the profile so it can be reused for profile lengths less than or equal
* to the length this struct was created with.
*/
void block_clear_aaprofile(struct AAProfile *profile, uintptr_t str_len);
void block_clear_aaprofile(struct AAProfile *profile, uintptr_t str_len, uintptr_t block_size);

/**
* Set the score for a position and byte.
*
* The profile should be first `clear`ed before it is reused with different lengths.
*
* The first column (`i = 0`) should be padded with large negative values.
* Therefore, set values starting from `i = 1`.
*/
void block_set_aaprofile(struct AAProfile *profile, uintptr_t i, uint8_t b, int8_t score);

/**
* Set the scores for all positions in the position specific scoring matrix.
*
* The profile should be first `clear`ed before it is reused with different lengths.
*
* Use `order` to specify the order of bytes that is used in the `scores` matrix.
* Scores (in `scores`) should be stored in row-major order, where each row is a different position
* and each column is a different byte.
*/
void block_set_all_aaprofile(struct AAProfile *profile,
const uint8_t *order,
uintptr_t order_len,
const int8_t *scores,
uintptr_t scores_len);

/**
* Set the scores for all positions in reverse in the position specific scoring matrix.
*
* The profile should be first `clear`ed before it is reused with different lengths.
*
* Use `order` to specify the order of bytes that is used in the `scores` matrix.
* Scores (in `scores`) should be stored in row-major order, where each row is a different position
* and each column is a different byte.
*/
void block_set_all_rev_aaprofile(struct AAProfile *profile,
const uint8_t *order,
uintptr_t order_len,
const int8_t *scores,
uintptr_t scores_len);

/**
* Set the gap open cost for a column.
*
Expand Down Expand Up @@ -230,6 +267,21 @@ void block_set_gap_close_C_aaprofile(struct AAProfile *profile, uintptr_t i, int
*/
void block_set_gap_open_R_aaprofile(struct AAProfile *profile, uintptr_t i, int8_t gap);

/**
* Set the gap open cost for all column transitions.
*/
void block_set_all_gap_open_C_aaprofile(struct AAProfile *profile, int8_t gap);

/**
* Set the gap close cost for all column transitions.
*/
void block_set_all_gap_close_C_aaprofile(struct AAProfile *profile, int8_t gap);

/**
* Set the gap open cost for all row transitions.
*/
void block_set_all_gap_open_R_aaprofile(struct AAProfile *profile, int8_t gap);

/**
* Get the score for a position and byte.
*/
Expand Down Expand Up @@ -278,6 +330,14 @@ void block_set_bytes_padded_aa(struct PaddedBytes *padded,
uintptr_t len,
uintptr_t max_size);

/**
* Write to a padded amino acid string, in reverse.
*/
void block_set_bytes_rev_padded_aa(struct PaddedBytes *padded,
const uint8_t *s,
uintptr_t len,
uintptr_t max_size);

/**
* Frees a padded amino acid string.
*/
Expand Down Expand Up @@ -321,6 +381,16 @@ void _block_cigar_aa(BlockHandle b,
uintptr_t reference_idx,
struct Cigar *cigar);

/**
*Don't use.
*/
void _block_cigar_eq_aa(BlockHandle b,
const struct PaddedBytes *q,
const struct PaddedBytes *r,
uintptr_t query_idx,
uintptr_t reference_idx,
struct Cigar *cigar);

/**
*Frees the block used for global alignment of two amino acid strings (no traceback).
*/
Expand Down Expand Up @@ -364,6 +434,16 @@ void _block_cigar_aa_xdrop(BlockHandle b,
uintptr_t reference_idx,
struct Cigar *cigar);

/**
*Don't use.
*/
void _block_cigar_eq_aa_xdrop(BlockHandle b,
const struct PaddedBytes *q,
const struct PaddedBytes *r,
uintptr_t query_idx,
uintptr_t reference_idx,
struct Cigar *cigar);

/**
*Frees the block used for X-drop alignment of two amino acid strings (no traceback).
*/
Expand Down Expand Up @@ -407,6 +487,16 @@ void block_cigar_aa_trace(BlockHandle b,
uintptr_t reference_idx,
struct Cigar *cigar);

/**
*Retrieves the resulting CIGAR string from global alignment of two amino acid strings, with traceback containing =/X.
*/
void block_cigar_eq_aa_trace(BlockHandle b,
const struct PaddedBytes *q,
const struct PaddedBytes *r,
uintptr_t query_idx,
uintptr_t reference_idx,
struct Cigar *cigar);

/**
*Frees the block used for global alignment of two amino acid strings, with traceback.
*/
Expand Down Expand Up @@ -452,6 +542,16 @@ void block_cigar_aa_trace_xdrop(BlockHandle b,
uintptr_t reference_idx,
struct Cigar *cigar);

/**
*Retrieves the resulting CIGAR string from X-drop alignment of two amino acid strings, with traceback containing =/X.
*/
void block_cigar_eq_aa_trace_xdrop(BlockHandle b,
const struct PaddedBytes *q,
const struct PaddedBytes *r,
uintptr_t query_idx,
uintptr_t reference_idx,
struct Cigar *cigar);

/**
*Frees the block used for X-drop alignment of two amino acid strings, with traceback.
*/
Expand Down

0 comments on commit 60590a3

Please sign in to comment.