Skip to content

Commit

Permalink
add qualities test & update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevinzjy committed Sep 8, 2022
1 parent 1c16dd5 commit d09a93b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use rust_spoa::poa_consensus;
fn main() {
let mut seqs = vec![];
let mut quals = vec![];
// generated each string by adding small tweaks to the expected consensus "AATGCCCGTT"
for seq in ["ATTGCCCGTT\0",
Expand Down
31 changes: 31 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,37 @@ mod tests {

}

#[test]
fn test_qualitites() {
let mut seqs = vec![];
let mut quals = vec![];

// expect consensus "FNLKPSWDDCQ"
for seq in [
"ATTGCCCATT\0".to_string(),
"ATTGCCCGTT\0".to_string(),
"ATTGCCCATT\0".to_string(),
"ATTGCCCGTT\0".to_string(),
].iter() {
seqs.push(seq.chars().into_iter().map(|x|{x as u8}).collect::<Vec<u8>>());
}

for qual in [
"FFFFFFFIFF\0".to_string(),
"FFFFFFF#FF\0".to_string(),
"FFFFFFFIFF\0".to_string(),
"FFFFFFF#FF\0".to_string(),
].iter() {
quals.push(qual.chars().into_iter().map(|x|{x as u8}).collect::<Vec<u8>>());
}

let consensus = poa_consensus(&seqs, &quals, 1, 5, -4, -3, -1, -3, -1);
eprintln!("{:?}", &consensus);

let expected = "ATTGCCCATT";
assert_eq!(consensus, expected);
}

#[test]
#[should_panic]
fn test_not_null_terminated() {
Expand Down
14 changes: 7 additions & 7 deletions src/poa_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ extern "C" {
unsigned poa_func(char** seqs, // the sequences (null-terminated) to perform multiple-sequence-alignment with.
char** quals, // the sequences (null-terminated) to perform multiple-sequence-alignment with.
int num_seqs, // the number of sequences being multiply aligned
int l, // the alignment type: 0 = local align, 1 = global align, 2 = semi-global
int m, // the score to give a sequence match in alignment, e.g. 5
int n, // the score to give a sequence mismatch in alignment, e.g. -4
int g, // the score to give a sequence gap in alignment, e.g. -3
int e, // the score to give a sequence gap extension in alignment, e.g. -1
int q, // the score to give a sequence second gap in alignment, e.g. -3
int c, // the score to give a sequence second gap extension in alignment, e.g. -1
int l, // alignment mode: 0 = local align, 1 = global align, 2 = semi-global
int m, // score for matching bases, e.g. 5
int n, // score for mismatching bases, e.g. -4
int g, // gap opening penalty (must be non-positive), e.g. -3
int e, // gap extension penalty (must be non-positivie), e.g. -1
int q, // gap opening penalty of the second affine function (must be non-positivie), e.g. -3
int c, // gap extension penalty of the second affine function (must be non-positivie), e.g. -1
);


Expand Down

0 comments on commit d09a93b

Please sign in to comment.