SigAlign is appropriate for the task of - quickly picking out similar alignments, rather than quantifying similarity or finding global optimum to also receive results for alignment with low similarity. - defining boundaries of results clearly, so when describing a result, instead of saying "I used this algorithm", results have their own semantics.
Rust
developercrate.io
and can be added using cargo
in the project directory:
cargo add sigalign
// (1) Build Reference
let fasta =
br#">target_1
ACACAGATCGCAAACTCACAATTGTATTTCTTTGCCACCTGGGCATATACTTTTTGCGCCCCCTCATTTA
target2 TCTGGGGCCATTGTATTTCTTTGCCAGCTGGGGCATATACTTTTTCCGCCCCCTCATTTACGCTCATCAC"#; let reference = DefaultReference::fromfasta_bytes(fasta).unwrap();
// (2) Instantiate Aligner
let mut aligner = DefaultAligner::new(
4, // Mismatch penalty
6, // Gap-open penalty
2, // Gap-extend penalty
50, // Minimum aligned length
0.2, // Maximum penalty per length
).unwrap();
// (3) Perform alignment let query = b"CAAACTCACAATTGTATTTCTTTGCCAGCTGGGCATATACTTTTTCCGCCCCCTCATTTAACTTCTTGGA"; let result = aligner.align_query(&reference, query).unwrap(); println!("{:#?}", result); ``` - The detailed features and usage are in API documentation of crate (https://docs.rs/sigalign/).
Python
developerpip
the python package manager to install the package:
pip install sigalign
Reference
reference = Reference.fromfastafile("./YOUR_REFERENCE.fa")
Aligner
aligner = Aligner(4, 6, 2, 50, 0.2)
query = "CAAACTCACAATTGTATTTCTTTGCCAGCTGGGCATATACTTTTTCCGCCCCCTCATTTAACTTCTTGGA" results = aligner.align_query(reference, query)
for targetresult in results:
print(f"# Target index: {targetresult.index}")
for idx, alignment in enumerate(targetresult.alignments):
print(f" - Result: {idx+1}")
print(f" - Penalty: {alignment.penalty}")
print(f" - Length: {alignment.length}")
print(f" - Query position: {alignment.queryposition}")
print(f" - Target position: {alignment.target_position}")
``
- For a detailed guide on how to use SigAlign in Python including a more comprehensive tutorial, please refer to the
sigalign-py` subdirectory README.
Web
developernpm
, plans for web support are in the pipeline.example
directory. Below is a TypeScript example showcasing SigAlign's application via this WASM wrapper:```ts import init, { Reference, Aligner, type AlignmentResult } from '../wasm/sigaligndemowasm';
async function run() { await init();
// (1) Construct `Reference`
const fasta: string = `>target_1
ACACAGATCGCAAACTCACAATTGTATTTCTTTGCCACCTGGGCATATACTTTTTGCGCCCCCTCATTTA
target_2 TCTGGGGCCATTGTATTTCTTTGCCAGCTGGGGCATATACTTTTTCCGCCCCCTCATTTACGCTCATCAC`;
const reference: Reference = await Reference.build(fasta);
// (2) Initialize `Aligner`
const aligner: Aligner = new Aligner(
4, // Mismatch penalty
6, // Gap-open penalty
2, // Gap-extend penalty
50, // Minimum aligned length
0.2, // Maximum penalty per length
);
// (3) Execute Alignment
const query: string = "CAAACTCACAATTGTATTTCTTTGCCAGCTGGGCATATACTTTTTCCGCCCCCTCATTTAACTTCTTGGA";
const result: AlignmentResult = await aligner.alignment(query, reference);
// (4) Parse and Display Results
const parsedJsonObj = JSON.parse(result.to_json());
console.log(parsedJsonObj);
}
run(); ``` - To gain further insight into web-based implementation of SigAlign, visit the SigAlign tour page. This page utilizes the WASM wrapper exemplified above.
SigAlign is released under the MIT License. Please refer to the LICENSE file in the repository for the full text.