| Crates.io | abpoa-sys |
| lib.rs | abpoa-sys |
| version | 0.1.1 |
| created_at | 2024-09-11 15:58:30.598888+00 |
| updated_at | 2024-09-12 15:13:25.919506+00 |
| description | Automatically generated FFI definitions for abPOA |
| homepage | |
| repository | https://github.com/broadinstitute/abpoa-rs |
| max_upload_size | |
| id | 1372026 |
| size | 6,951,610 |
TODO
The minimum supported Rust version is 1.80.
Clone the repository.
git clone https://github.com/broadinstitute/abpoa-rs
Move into the directory.
cd abpoa-rs
Build using cargo. We enable a flag to ensure the compiler uses all features of your machine's CPU.
To maximize portability of the binary, however, remove the RUSTFLAGS="..." part.
RUSTFLAGS="-C target-cpu=native" cargo build --release
Features not yet supported:
// Configure the alignment parameters
let aln_params = AlignmentParametersBuilder::new()
.alignment_mode(AlignmentMode::Global)
.gap_affine_penalties(0, 4, 6, 2)
.verbosity(Verbosity::None)
.build();
// Create a new empty POA graph
let mut graph = Graph::new(&aln_params);
let test_seq: Vec<&[u8]> = vec![
b"ACGTGTACAGTTGAC",
b"AGGTACACGTTAC",
b"AGTGTCACGTTGAC",
b"ACGTGTACATTGAC",
];
// Align and add each sequence to the graph
for (i, seq) in test_seq.iter().enumerate() {
let weights = vec![1; seq.len()];
let result = graph
.align_and_add_sequence(&aln_params, seq, &weights, format!("seq{}", i + 1).as_bytes())
.unwrap();
eprintln!("Sequence {}: score = {}", i + 1, result.get_best_score());
}
// Compute the row-column MSA output
graph.generate_rc_msa();
let msa = graph.get_msa();
assert_eq!(msa.len(), 4);
let truth = [
b"ACGTGTACAGTTGAC",
b"A--GGTACACGTTAC",
b"A-GTGTCACGTTGAC",
b"ACGTGTACA-TTGAC",
];
for (i, seq) in msa.sequences().iter().enumerate() {
// The sequence in the MSA object is coded, so we use `reverse_seq` to convert it to ASCII.
let ascii = aln_params.reverse_seq(seq);
assert_eq!(&ascii, truth[i]);
}
// Generate consensus
graph.generate_consensus(ConsensusAlgorithm::HeaviestBundle);
let consensus = graph.get_consensus().unwrap();
let ascii = aln_params.reverse_seq(consensus.sequences().iter().next().unwrap());
eprintln!("Consensus: {}", std::str::from_utf8(ascii).unwrap());