[−][src]Function rust_spoa::poa_consensus
pub fn poa_consensus(
seqs: &Vec<Vec<u8>>,
consensus_max_length: usize,
alignment_type: i32,
match_score: i32,
mismatch_score: i32,
gap_open: i32,
gap_extend: i32
) -> Vec<u8>
Generates a consensus sequence from a list of sequences.
Arguments
seqs
- a vector holding the sequences (each as a null-terminated vector of u8) to form a consensus fromconsensus_max_len
- The upper bound for the output consensus length. If the output consensus sequence is longer than this value, it will be truncated to this length. Setting a large value uses more memory and runtime, since a buffer of this size is allocated internally.alignment_type
- alignment mode: 0 = local, 1 = global, 2 = gappedmatch_score
- the match score for alignmentmismatch_score
- the mismatch score for alignmentgap_open
- the gap open score for alignmentgap_extend
- the gap extend score for alignment
Returns
- returns the consensus of the input sequences as a vector of u8
Examples
use rust_spoa::poa_consensus; fn test_dna_consensus() { let mut seqs = vec![]; // generated each string by adding small tweaks to the expected consensus "AATGCCCGTT" // convert sequences to Vec<u8> for seq in ["ATTGCCCGTT\0", "AATGCCGTT\0", "AATGCCCGAT\0", "AACGCCCGTC\0", "AGTGCTCGTT\0", "AATGCTCGTT\0"].iter() { seqs.push((*seq).bytes().map(|x|{x as u8}).collect::<Vec<u8>>()); } // generate consensus sequence let consensus = poa_consensus(&seqs, 20, 1, 5, -4, -3, -1); let expected = "AATGCCCGTT".to_string().into_bytes(); assert_eq!(consensus, expected); }