### Install pyabpoa from source Source: https://github.com/yangao07/abpoa/blob/main/python/README.md Install pyabpoa from its source code. This method requires git and make, and cython must be installed. ```bash git clone --recursive https://github.com/yangao07/abPOA.git cd abPOA make install_py ``` -------------------------------- ### Install abPOA via Homebrew Source: https://github.com/yangao07/abpoa/blob/main/README.md Installs abPOA on macOS using Homebrew. Ensure Homebrew is installed and up to date. ```bash brew install abpoa ``` -------------------------------- ### Install pyabpoa with pip Source: https://github.com/yangao07/abpoa/blob/main/python/README.md Install the pyabpoa library using pip. This is the recommended method for most users. ```bash pip install pyabpoa ``` -------------------------------- ### Run example script Source: https://github.com/yangao07/abpoa/blob/main/python/README.md Execute the example script provided within the pyabpoa source code. This script likely demonstrates various functionalities of the library. ```bash python ./python/example.py ``` -------------------------------- ### MSA Input Example for Alignment Source: https://github.com/yangao07/abpoa/blob/main/README.md Demonstrates generating an MSA file for a single sequence, which can then be used as input for aligning another sequence. ```bash abpoa seq1.fa -r1 > seq1.msa abpoa -i seq1.msa seq2.fa > cons.fa ``` -------------------------------- ### Install abPOA via Conda Source: https://github.com/yangao07/abpoa/blob/main/README.md Installs abPOA using the bioconda channel. Ensure conda is configured with bioconda. ```bash conda install -c bioconda abpoa ``` -------------------------------- ### Install and Run abPOA via Conda Source: https://github.com/yangao07/abpoa/blob/main/README.md Install abPOA using the bioconda channel and then run it with a FASTA file to generate a consensus sequence. ```bash conda install -c bioconda abpoa abpoa ./test_data/seq.fa > cons.fa ``` -------------------------------- ### Install Graphviz for Plotting Source: https://github.com/yangao07/abpoa/blob/main/README.md Installs the graphviz package required for generating plots of the alignment graph. This command is for Debian/Ubuntu-based systems. ```bash sudo apt-get install graphviz ``` -------------------------------- ### Download and Extract abPOA Release Source: https://github.com/yangao07/abpoa/blob/main/README.md Download the latest release of abPOA and extract the archive. Navigate into the extracted directory to proceed with building or installation. ```bash wget https://github.com/yangao07/abPOA/releases/download/v1.5.6/abPOA-v1.5.6.tar.gz tar -zxvf abPOA-v1.5.6.tar.gz && cd abPOA-v1.5.6 ``` -------------------------------- ### Initialize and Configure C API Source: https://context7.com/yangao07/abpoa/llms.txt Sets up alignment parameters and context structures. Requires manual memory management using free functions. ```c #include #include #include "abpoa.h" int main() { // Initialize abPOA alignment structure abpoa_t *ab = abpoa_init(); // Initialize parameters with defaults abpoa_para_t *abpt = abpoa_init_para(); // Configure alignment mode abpt->align_mode = ABPOA_GLOBAL_MODE; // 0:global, 1:local, 2:extension // Configure scoring parameters abpt->match = 2; abpt->mismatch = 4; abpt->gap_mode = ABPOA_CONVEX_GAP; // ABPOA_LINEAR_GAP, ABPOA_AFFINE_GAP abpt->gap_open1 = 4; abpt->gap_ext1 = 2; abpt->gap_open2 = 24; abpt->gap_ext2 = 1; // Configure adaptive banding abpt->wb = 10; // extra_b abpt->wf = 0.01; // extra_f, band width = wb + wf * seq_len // Configure output options abpt->out_msa = 1; // Generate row-column MSA abpt->out_cons = 1; // Generate consensus abpt->max_n_cons = 1; // Apply parameter settings (must call after configuration) abpoa_post_set_para(abpt); // ... perform alignment ... // Cleanup abpoa_free(ab); abpoa_free_para(abpt); return 0; } ``` -------------------------------- ### Download Pre-built Binary for Linux Source: https://github.com/yangao07/abpoa/blob/main/README.md Downloads and extracts a pre-compiled abPOA binary for 64-bit Linux systems. Useful if compilation fails. ```bash wget https://github.com/yangao07/abPOA/releases/download/v1.5.6/abPOA-v1.5.6_x64-linux.tar.gz tar -zxvf abPOA-v1.5.6_x64-linux.tar.gz ``` -------------------------------- ### Download Pre-built Binary for macOS Source: https://github.com/yangao07/abpoa/blob/main/README.md Downloads and extracts a pre-compiled abPOA binary for ARM64 macOS systems. Useful if compilation fails. ```bash wget https://github.com/yangao07/abPOA/releases/download/v1.5.6/abPOA-v1.5.6_arm64-macos.tar.gz tar -zxvf abPOA-v1.5.6_arm64-macos.tar.gz ``` -------------------------------- ### Build abPOA from Source (Release Tarball) Source: https://github.com/yangao07/abpoa/blob/main/README.md Downloads, extracts, and compiles abPOA from a release tarball. Requires gcc and zlib. Recommended for stable releases. ```bash wget https://github.com/yangao07/abPOA/releases/download/v1.5.6/abPOA-v1.5.6.tar.gz tar -zxvf abPOA-v1.5.6.tar.gz cd abPOA-v1.5.6; make ``` -------------------------------- ### Build abPOA from Source (Git Clone) Source: https://github.com/yangao07/abpoa/blob/main/README.md Clones the abPOA repository and compiles it. Use this for the latest development version. Requires recursive clone. ```bash git clone --recursive https://github.com/yangao07/abPOA.git cd abPOA; make ``` -------------------------------- ### Compile and Link abPOA C Library Source: https://context7.com/yangao07/abpoa/llms.txt Provides bash commands for compiling a C program that uses the abPOA library, linking against the static library, and building abPOA from source. Ensure correct include and library paths are specified. ```bash # Compile with static library gcc -g myprogram.c -I./include -L./lib -labpoa -lz -lm -lpthread -o myprogram ``` ```bash # Or link directly with the archive gcc -g myprogram.c -I./include ./lib/libabpoa.a -lz -lm -lpthread -o myprogram ``` ```bash # Build abPOA from source git clone --recursive https://github.com/yangao07/abPOA.git cd abPOA && make ``` ```bash # Install Python bindings pip install pyabpoa ``` ```bash # Or build from source with cython cd abPOA && make install_py ``` -------------------------------- ### Build abPOA from Source (MacOS ARMv7) Source: https://github.com/yangao07/abpoa/blob/main/README.md Compile abPOA from source code on MacOS systems with ARMv7 architecture. Use the 'armv7=1' flag during the make process. ```bash make armv7=1; ./bin/abpoa ./test_data/seq.fa > cons.fa ``` -------------------------------- ### Output Alignment Graph and Sequences using C API Source: https://context7.com/yangao07/abpoa/llms.txt Demonstrates how to configure and use abPOA C API functions to output alignment graphs in GFA format, consensus sequences, and MSAs to files. Requires initialization of abpoa_t and abpoa_para_t structures. ```c #include #include #include "abpoa.h" int main() { abpoa_t *ab = abpoa_init(); abpoa_para_t *abpt = abpoa_init_para(); // Configure for GFA output abpt->out_gfa = 1; abpt->out_cons = 1; abpt->out_msa = 1; abpoa_post_set_para(abpt); // ... perform MSA ... // Output GFA to file FILE *gfa_fp = fopen("output.gfa", "w"); abpoa_generate_gfa(ab, abpt, gfa_fp); fclose(gfa_fp); // Output consensus sequence FILE *cons_fp = fopen("consensus.fa", "w"); abpoa_output_fx_consensus(ab, abpt, cons_fp); fclose(cons_fp); // Output row-column MSA FILE *msa_fp = fopen("alignment.msa", "w"); abpoa_output_rc_msa(ab, abpt, msa_fp); fclose(msa_fp); // Generate alignment graph visualization abpt->out_pog = strdup("graph.png"); // or "graph.pdf" abpoa_dump_pog(ab, abpt); // Requires graphviz 'dot' command // Combined output (respects out_cons, out_msa, out_gfa flags) abpoa_output(ab, abpt, stdout); abpoa_free(ab); abpoa_free_para(abpt); return 0; } ``` -------------------------------- ### Perform initial alignment for incremental updates Source: https://github.com/yangao07/abpoa/blob/main/python/README.md Initializes an alignment process that can be followed by incremental additions. Use `msa_align` to set up the initial alignment before adding more sequences. ```python pyabpoa.msa_aligner.msa_align(seqs, out_cons, out_msa, max_n_cons=1, min_freq=0.25, incr_fn=b'') ``` -------------------------------- ### Perform Incremental MSA in C Source: https://context7.com/yangao07/abpoa/llms.txt Demonstrates initializing the abpoa structure, aligning sequences in multiple batches, and cleaning up memory between steps. Ensure abpoa_clean_msa_cons() is called after each batch to avoid memory leaks. ```c #include #include #include #include "abpoa.h" extern unsigned char nt4_table[256]; int main() { int i, j; int n_seqs = 10, first_batch = 5, second_batch = 3, third_batch = 2; char *seqs[] = { "CGATCGATCGATCGATGCATGCATCGATGCATCGATCGATGCATGCAT", "CGATCGATCGATAAAAAAAAAAAAACGATGCATGCATCGATGCATCGATCGATGCATGCAT", "CGATCGATCGATCGATGCATGCATCGATGCATCGATCGATGCATGCAT", "CGATCGATCGATCGATGCATGCATCGATGCATCGATCGATGCATGCAT", "CGATCGATCGATAAAAAAAAAAAAACGATGCATGCATCGATGCATCGATCGATGCATGCAT", "CGATCGATCGATAAAAAAAAAAAAACGATGCATGCATCGATGCATCGATCGATGCATGCAT", "CGATCGATCGATAAAAAAAAAAAAACGATGCATGCATCGATGCATCGATCGATGCATGCAT", "CGATCGATCGATCGATGCATGCATCGATGCATCGATCGATGCATGCAT", "CGATCGATCGATCGATGCATGCATCGATGCATCGATCGATGCATGCAT", "CGATCGATCGATCGATGCATGCATCGATGCATCGATCGATGCATGCAT" }; // Initialize abpoa_t *ab = abpoa_init(); abpoa_para_t *abpt = abpoa_init_para(); abpt->out_msa = 1; abpt->out_cons = 1; abpt->max_n_cons = 2; abpoa_post_set_para(abpt); // Prepare all sequences int *seq_lens = malloc(sizeof(int) * n_seqs); uint8_t **bseqs = malloc(sizeof(uint8_t*) * n_seqs); for (i = 0; i < n_seqs; i++) { seq_lens[i] = strlen(seqs[i]); bseqs[i] = malloc(sizeof(uint8_t) * seq_lens[i]); for (j = 0; j < seq_lens[i]; j++) bseqs[i][j] = nt4_table[(int)seqs[i][j]]; } // Step 1: Align first batch printf("=== First batch: %d sequences ===\n", first_batch); abpoa_msa(ab, abpt, first_batch, NULL, seq_lens, bseqs, NULL, stdout); // IMPORTANT: Clean MSA/consensus memory before incremental add abpoa_clean_msa_cons(ab); // Step 2: Add sequences one by one (disable output for intermediate steps) printf("\nGraph has %d sequences, %d nodes\n", ab->abs->n_seq, ab->abg->node_n); abpt->out_msa = 0; abpt->out_cons = 0; for (i = 0; i < second_batch; i++) { abpoa_msa(ab, abpt, 1, NULL, seq_lens + first_batch + i, bseqs + first_batch + i, NULL, stdout); } // Step 3: Add final batch and output results printf("\n=== Final batch: %d sequences ===\n", third_batch); abpt->out_msa = 1; abpt->out_cons = 1; abpoa_msa(ab, abpt, third_batch, NULL, seq_lens + first_batch + second_batch, bseqs + first_batch + second_batch, NULL, stdout); printf("\nFinal graph: %d sequences, %d nodes\n", ab->abs->n_seq, ab->abg->node_n); // Cleanup for (i = 0; i < n_seqs; i++) free(bseqs[i]); free(bseqs); free(seq_lens); abpoa_free(ab); abpoa_free_para(abpt); return 0; } ``` -------------------------------- ### Build abPOA from Source (Linux/MacOS ARMv8) Source: https://github.com/yangao07/abpoa/blob/main/README.md Compile abPOA from source code on Linux or MacOS systems with ARMv8 architecture. After successful compilation, you can run the executable. ```bash make; ./bin/abpoa ./test_data/seq.fa > cons.fa ``` -------------------------------- ### Configure Score Matrix and Parameters Source: https://context7.com/yangao07/abpoa/llms.txt Use abpoa_set_mat_from_file to load external scoring matrices and configure gap penalties or adaptive banding for alignment. ```c #include #include #include #include "abpoa.h" int main() { // Initialize abpoa_t *ab = abpoa_init(); abpoa_para_t *abpt = abpoa_init_para(); // Method 1: Use built-in match/mismatch scores abpt->match = 2; abpt->mismatch = 4; // Method 2: Load score matrix from file abpt->mat_fn = strdup("BLOSUM62.mtx"); abpt->use_score_matrix = 1; abpoa_set_mat_from_file(abpt, abpt->mat_fn); // Configure gap penalties (convex gap model) abpt->gap_mode = ABPOA_CONVEX_GAP; abpt->gap_open1 = 4; abpt->gap_ext1 = 2; abpt->gap_open2 = 24; abpt->gap_ext2 = 1; // Effective penalty: min(gap_open1 + len*gap_ext1, gap_open2 + len*gap_ext2) // Configure adaptive banding abpt->wb = 10; // Base extra band width abpt->wf = 0.01; // Proportional factor // Actual band: wb + wf * sequence_length // Output settings abpt->out_msa = 1; abpt->out_cons = 1; // Finalize parameters abpoa_post_set_para(abpt); // ... perform alignment with amino acid sequences ... abpoa_free(ab); abpoa_free_para(abpt); return 0; } ``` -------------------------------- ### Run abPOA via Command Line Source: https://context7.com/yangao07/abpoa/llms.txt Perform multiple sequence alignment and consensus calling using the abpoa command-line interface. ```bash # Basic consensus sequence generation abpoa seq.fa > cons.fa # Generate multiple consensus sequences for diploid data abpoa heter.fa -d2 > 2cons.fa # Generate row-column multiple sequence alignment in FASTA format abpoa seq.fa -r1 > out.msa # Generate MSA with consensus sequence included abpoa seq.fa -r2 > out_cons.msa # Generate graph information in GFA format abpoa seq.fa -r3 > out.gfa # Generate GFA with consensus path abpoa seq.fa -r4 > out.gfa # Use most frequent bases method for consensus abpoa seq.fa -a1 > cons.fa # Align sequences to an existing graph abpoa -i existing.gfa seq.fa -r3 > out.gfa abpoa -i existing.msa seq.fa -r1 > out.msa # Generate alignment graph plot (requires graphviz) abpoa seq.fa -g poa.png > cons.fa # Process amino acid sequences with scoring matrix abpoa -c -t BLOSUM62.mtx input_aa.fa > output_aa_cons.fa # Batch processing with file list abpoa -l file_list.txt > all_cons.fa ``` -------------------------------- ### Perform MSA and print results Source: https://github.com/yangao07/abpoa/blob/main/python/README.md Demonstrates how to perform a multiple sequence alignment using pyabpoa, generate consensus sequences, and print the alignment. Requires importing the pyabpoa library. ```python import pyabpoa as pa a = pa.msa_aligner() seqs=[ 'CCGAAGA', 'CCGAACTCGA', 'CCCGGAAGA', 'CCGAAGA' ] a_res=a.msa(seqs, out_cons=True, out_msa=True) # perform multiple sequence alignment for seq in a_res.cons_seq: print(seq) # print consensus sequence a_res.print_msa() # print row-column multiple sequence alignment in PIR format ``` -------------------------------- ### Generate Consensus Sequence (FASTA) Source: https://github.com/yangao07/abpoa/blob/main/README.md Outputs the consensus sequence in FASTA format. The name field is set to 'Consensus_sequence'. ```text >Consensus_sequence ACGTGTACACGTTGAC ``` -------------------------------- ### Generate Consensus Sequences with Python Source: https://context7.com/yangao07/abpoa/llms.txt Configures consensus generation parameters such as maximum count and frequency thresholds. ```python result = aligner.msa( seqs, out_cons=True, out_msa=True, max_n_cons=2, # Maximum number of consensus sequences min_freq=0.25 # Minimum frequency threshold for each consensus ) print(f"Generated {result.n_cons} consensus sequences") for i in range(result.n_cons): print(f">Consensus_sequence_{i+1}") print(result.cons_seq[i]) print(f"Length: {result.cons_len[i]}") ``` -------------------------------- ### Perform Multiple Sequence Alignment with abpoa_msa Source: https://context7.com/yangao07/abpoa/llms.txt This C code demonstrates how to use the abpoa_msa function for multiple sequence alignment. It includes sequence encoding, parameter initialization, execution, and programmatic access to the alignment results. Ensure necessary headers are included and memory is managed properly. ```c #include #include #include #include "abpoa.h" // Nucleotide encoding table: ACGT -> 0123 unsigned char nt4_table[256] = { 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,0,4,1, 4,4,4,2, 4,4,4,4, 4,4,4,4, // A=0, C=1, G=2 4,4,4,4, 3,3,4,4, 4,4,4,4, 4,4,4,4, // T=U=3 4,0,4,1, 4,4,4,2, 4,4,4,4, 4,4,4,4, 4,4,4,4, 3,3,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4 }; const char nt256_table[256] = { 'A','C','G','T', 'N','-','N','N', 'N','N','N','N', 'N','N','N','N', // ... (maps encoded values back to characters) }; int main() { int i, j, n_seqs = 4; char *seqs[] = { "CGTCAATCTATCGAAGCATACGCGGGCAGAGCC", "CCACGTCAATCTATCGAAGCATACGCGGCAGCC", "CGTCAATCTATCGAAGCATACGCGGCAGAGCCC", "CGTCAATGCTAGTCGAAGCAGCTGCGGCAGAGCC" }; // Initialize abpoa_t *ab = abpoa_init(); abpoa_para_t *abpt = abpoa_init_para(); abpt->out_msa = 1; abpt->out_cons = 1; abpt->max_n_cons = 2; abpoa_post_set_para(abpt); // Prepare sequence data int *seq_lens = malloc(sizeof(int) * n_seqs); uint8_t **bseqs = malloc(sizeof(uint8_t*) * n_seqs); for (i = 0; i < n_seqs; i++) { seq_lens[i] = strlen(seqs[i]); bseqs[i] = malloc(sizeof(uint8_t) * seq_lens[i]); for (j = 0; j < seq_lens[i]; j++) { bseqs[i][j] = nt4_table[(int)seqs[i][j]]; } } // Perform MSA - output directly to stdout abpoa_msa(ab, abpt, n_seqs, NULL, seq_lens, bseqs, NULL, stdout); // Access results programmatically abpoa_cons_t *abc = ab->abc; printf("\n=== Programmatic access ===\n"); printf("MSA length: %d\n", abc->msa_len); printf("Number of consensus: %d\n", abc->n_cons); // Print MSA for (i = 0; i < abc->n_seq; i++) { printf(">Seq_%d\n", i + 1); for (j = 0; j < abc->msa_len; j++) { printf("%c", nt256_table[abc->msa_base[i][j]]); } printf("\n"); } // Print consensus sequences for (i = 0; i < abc->n_cons; i++) { printf(">Consensus_%d (length: %d)\n", i + 1, abc->cons_len[i]); for (j = 0; j < abc->cons_len[i]; j++) { printf("%c", nt256_table[abc->cons_base[i][j]]); } printf("\n"); } // Cleanup for (i = 0; i < n_seqs; i++) free(bseqs[i]); free(bseqs); free(seq_lens); abpoa_free(ab); abpoa_free_para(abpt); return 0; } ``` -------------------------------- ### Align Sequence to Existing Graph (MSA Input) Source: https://github.com/yangao07/abpoa/blob/main/README.md Aligns a sequence to an existing graph provided in MSA (FASTA) format. Gaps are indicated by '-'. ```bash abpoa -i in.msa seq.fa -r1 > out.msa ``` -------------------------------- ### Generate Default Consensus Sequence Source: https://github.com/yangao07/abpoa/blob/main/README.md Generates a consensus sequence from a FASTA file using the default 'heaviest bundling' method. ```bash abpoa seq.fa > cons.fa ``` -------------------------------- ### Generate Graph Information in GFA Format Source: https://github.com/yangao07/abpoa/blob/main/README.md Generates graph information in GFA format. Use '-r3' for basic GFA output. ```bash abpoa seq.fa -r3 > out.gfa ``` -------------------------------- ### pyabpoa.msa_aligner Source: https://context7.com/yangao07/abpoa/llms.txt Initializes the alignment engine with custom parameters for sequence processing. ```APIDOC ## Class: pyabpoa.msa_aligner ### Description Initializes the alignment engine for performing multiple sequence alignment (MSA) and consensus calling. ### Parameters - **aln_mode** (str) - Optional - Alignment mode: 'g' (global), 'l' (local), 'e' (extension). - **is_aa** (bool) - Optional - Set True for amino acid sequences. - **match** (int) - Optional - Match score. - **mismatch** (int) - Optional - Mismatch penalty. - **gap_open1** (int) - Optional - First gap opening penalty. - **gap_ext1** (int) - Optional - First gap extension penalty. - **gap_open2** (int) - Optional - Second gap opening penalty (convex). - **gap_ext2** (int) - Optional - Second gap extension penalty (convex). - **extra_b** (int) - Optional - Adaptive banding parameter. - **extra_f** (float) - Optional - Banding factor. - **cons_algrm** (str) - Optional - Consensus algorithm: 'HB' (heaviest bundling), 'MF' (most frequent). ### Request Example ```python aligner = pa.msa_aligner(aln_mode='g', match=2, mismatch=4) ``` ``` -------------------------------- ### Generate Consensus Sequence (Most Frequent Bases) Source: https://github.com/yangao07/abpoa/blob/main/README.md Generates a consensus sequence using the 'most frequent bases' method. Use the '-a1' flag. ```bash abpoa seq.fa -a1 > cons.fa ``` -------------------------------- ### Align Sequence to Existing Graph (GFA Input) Source: https://github.com/yangao07/abpoa/blob/main/README.md Aligns a sequence to an existing graph provided in GFA format. Requires 'S' and 'P' lines in the GFA file. ```bash abpoa -i in.gfa seq.fa -r3 > out.gfa ``` -------------------------------- ### Visualize Alignment Graphs in Python Source: https://context7.com/yangao07/abpoa/llms.txt Generates visual representations of the partial order alignment graph, requiring the graphviz package. ```python import pyabpoa as pa aligner = pa.msa_aligner() seqs = [ 'ACGTACGT', 'ACGTTACGT', 'ACGTACGT', 'ACGAACGT' ] # Generate MSA with graph visualization result = aligner.msa( seqs, out_cons=True, out_msa=True, out_pog='alignment_graph.png' # or 'alignment_graph.pdf' ) # Graph is saved to the specified file # Nodes contain base and ID, edges show weights print("Graph saved to alignment_graph.png") ``` -------------------------------- ### Instantiate msa_aligner Source: https://github.com/yangao07/abpoa/blob/main/python/README.md Constructs a multiple sequence alignment handler. The `aln_mode` parameter controls the alignment type (global, local, or extension). ```python pyabpoa.msa_aligner(aln_mode='g', ...) ``` -------------------------------- ### Generate Multiple Consensus Sequences Source: https://github.com/yangao07/abpoa/blob/main/README.md Generates multiple consensus sequences for files containing 2 or 3 alleles. Use '-d2' for two and '-d3' for three. ```bash abpoa heter.fa -d2 > 2cons.fa abpoa 3alleles.fa -d3 > 3cons.fa ``` -------------------------------- ### Generate Multiple Consensus Sequences in Python Source: https://context7.com/yangao07/abpoa/llms.txt Cluster sequences to generate multiple consensus outputs for heterozygous or diploid data. ```python import pyabpoa as pa aligner = pa.msa_aligner() # Heterozygous sequences (two distinct alleles) seqs = [ 'CGATCGATCGATCGATGCATGCATCGATGCATCGATCGATGCATGCAT', 'CGATCGATCGATAAAAAAAAAAAAAAAAAAACGATGCATGCATCGATGCATCGATCGATGCATGCAT', 'CGATCGATCGATCGATGCATGCATCGATGCATCGATCGATGCATGCAT', 'CGATCGATCGATCGATGCATGCATCGATGCATCGATCGATGCATGCAT', 'CGATCGATCGATAAAAAAAAAAAAAAAAAAACGATGCATGCATCGATGCATCGATCGATGCATGCAT', 'CGATCGATCGATAAAAAAAAAAAAAAAAAAACGATGCATGCATCGATGCATCGATCGATGCATGCAT', 'CGATCGATCGATAAAAAAAAAAAAAAAAAAACGATGCATGCATCGATGCATCGATCGATGCATGCAT', 'CGATCGATCGATCGATGCATGCATCGATGCATCGATCGATGCATGCAT', 'CGATCGATCGATCGATGCATGCATCGATGCATCGATCGATGCATGCAT', 'CGATCGATCGATCGATGCATGCATCGATGCATCGATCGATGCATGCAT' ] ``` -------------------------------- ### Generate Alignment Graph Plot Source: https://github.com/yangao07/abpoa/blob/main/README.md Generates a plot of the alignment graph and saves it as a PNG file. Requires the '-g' option. ```bash abpoa seq.fa -g poa.png > cons.fa ``` -------------------------------- ### Perform Incremental MSA in Python Source: https://context7.com/yangao07/abpoa/llms.txt Adds new sequences to an existing alignment graph or loads from a file to avoid full recomputation. ```python import pyabpoa as pa # Initial sequences seqs = [ 'CCGAAGA', 'CCGAACTCGA', 'CCCGGAAGA', 'CCGAAGA' ] # New sequences to add incrementally new_seqs = [ 'CCAGA', 'CCGAAAGA' ] # Create aligner and perform initial MSA aligner = pa.msa_aligner() # Method 1: Using msa_align + msa_add + msa_output aligner.msa_align(seqs, out_cons=True, out_msa=True) aligner.msa_add(new_seqs) result = aligner.msa_output() print("Incremental MSA result:") result.print_msa() for seq in result.cons_seq: print(f"Consensus: {seq}") # Method 2: Load from existing graph/MSA file aligner2 = pa.msa_aligner() result2 = aligner2.msa( new_seqs, out_cons=True, out_msa=True, incr_fn='existing.gfa' # or 'existing.msa' FASTA file ) ``` -------------------------------- ### Incrementally add sequences to MSA Source: https://github.com/yangao07/abpoa/blob/main/python/README.md Shows how to incrementally add new sequences to an existing alignment using pyabpoa. This involves creating a new aligner, performing an initial alignment, adding new sequences, and then outputting the updated alignment. ```python # incrementally add new seqs new_seqs=[ 'CCAGA', 'CCGAAAGA' ] b = pa.msa_aligner() b.msa_align(seqs, out_cons=True, out_msa=True) b.msa_add(new_seqs) b_res = b.msa_output() b_res.print_msa() ``` -------------------------------- ### Generate GFA with Consensus Path Source: https://github.com/yangao07/abpoa/blob/main/README.md Generates GFA format output that includes the consensus sequence as a path. Use '-r4'. ```bash abpoa seq.fa -r4 > out.gfa ``` -------------------------------- ### Generate Multiple Consensus Sequences Source: https://github.com/yangao07/abpoa/blob/main/README.md Use the -d/--max-num-cons option to generate two or more consensus sequences for diploid input. The output includes sequences named 'Consensus_sequence_1', 'Consensus_sequence_2', etc. ```bash abpoa heter.fa -d2 ``` ```text >Consensus_sequence_1 CCATTCCCACCATCCTTACCATCAACATCACCATCCCCACCATCCCCAACACCATTCCCACCATCCCTACCATCACCATCACCATCCCCACCAACATCCCCACCACCATCCTCACTACCATCCCCACCACCATTTCCACCATTCCCACCACAGTCACCATCACCCCCACCATCCCCATCATCATCCGCACCATCCCCACCATCCCCACCACCATCTCCATTACCATCCCCACCACCATCCCCATTACCATCCCCACCACCATCCCCATTACCATCCCCACCACCATTTCCACCATTCCCACCATCATCCCCACCACCATCCTCGTTACCATCCCCACCACCTTTTCCACCATTCCCACCATCTCCAACACCTCCCCCACCATCATCCCCACCATCCCCACCACCTTCTCCACCATCATTCTCACCATCCCCACCACCATCTCCACCACCATTCTCACCATCTCCACCAACATCCCCACCATCCCCACCCCCATGCCCACCAACATCCCCACCATCCCCACCCCCATGCCCACCAACATCCCCACCATCCCCACCCCCATGCCCACCATCATCCCCACCATCC >Consensus_sequence_2 CCATTCCCACCATCCTTACCATCAACATCACCATCCCCACCATCCCCAACACCATTCCCACCATCCCTACCATCACCATCACCATCCCCACCAACATCCCCACCACCATCCTCACTACCATCCCCACCACCATTTCCACCATTCCCACCACAGTCACCATCACCCCCACCATCCCCATCATCATCCGCACCATCCCCACCATCCCCACCACCATCTCCATTACCATCCCCACCACCATCCCCATTACCATCCCCACCACCATCCCCATTACCATCCCCACCACCATTTCCACCATTCCCACCATCATCCCCACCACCATCCTCGTTACCATCCCCACCACCATCCCCATTACCATCCCCACCACCATTTCCACCATTCCCACCATCATCCCCACCACCATCCCCATTACCATCCCCACCACCATCCCCATTACCATCCCCACCACCATTTCCACCATTCCCACCATCATCCCCACCACCATCCTCGTTACCATCCCCACCACCTTTTCCACCATTCCCACCATCATCCCCACCGCCATCCTCGTTACCATCCCCACCACCTTTTCCACCATTCCCACCATCTCCAACACCTCCCCCACCATCATCCCCACCATCCCCACCACCTTCTCCACCATCATTCTCACCATCCCCACCACCATCTCCACCACCATTCTCACCATCTCCACCAACATCCCCACCATCCCCACCCCCATGCCCACCAACATCCCCACCATCCCCACCCCCATGCCCACCATCATCCCCACCATCC ``` -------------------------------- ### Generate Consensus for Amino Acid Sequences Source: https://github.com/yangao07/abpoa/blob/main/README.md Generates a consensus sequence for amino acid sequences using a specified scoring matrix (e.g., BLOSUM62). ```bash abpoa -c -t BLOSUM62.mtx input_aa.fa > output_aa_cons.fa ``` -------------------------------- ### Add new sequences incrementally Source: https://github.com/yangao07/abpoa/blob/main/python/README.md Adds new sequences to an ongoing alignment process. This method should be called after `msa_align` and before `msa_output`. ```python pyabpoa.msa_aligner.msa_add(new_seqs) ``` -------------------------------- ### Generate Row-Column Multiple Sequence Alignment Source: https://github.com/yangao07/abpoa/blob/main/README.md Generates a multiple sequence alignment in FASTA format. Use '-r1' for standard MSA and '-r2' for MSA with consensus. ```bash abpoa seq.fa -r1 > out.msa abpoa seq.fa -r2 > out_cons.msa ``` -------------------------------- ### Output Full Graph Information (GFA format) Source: https://github.com/yangao07/abpoa/blob/main/README.md Outputs the final alignment graph in GFA format. Segment lines ('S') represent nodes, link lines ('L') represent edges, and path lines ('P') describe original sequences and consensus. Header lines ('H') contain node ('NS') and edge ('NL') counts. ```text H VN:Z:1.0 NS:i:10 NL:i:15 S 1 * LN:i:10 L 1 + 2 + 10 ... ``` -------------------------------- ### Perform MSA with Python API Source: https://context7.com/yangao07/abpoa/llms.txt Use the msa_aligner class to configure alignment parameters and process sequences in Python. ```python import pyabpoa as pa # Create aligner with default parameters aligner = pa.msa_aligner() # Create aligner with custom parameters aligner = pa.msa_aligner( aln_mode='g', # 'g': global, 'l': local, 'e': extension is_aa=False, # Set True for amino acid sequences match=2, # Match score mismatch=4, # Mismatch penalty gap_open1=4, # First gap opening penalty gap_ext1=2, # First gap extension penalty gap_open2=24, # Second gap opening penalty (convex) gap_ext2=1, # Second gap extension penalty (convex) extra_b=10, # Adaptive banding parameter (-1 to disable) extra_f=0.01, # Banding factor: width = extra_b + extra_f * L cons_algrm='HB' # 'HB': heaviest bundling, 'MF': most frequent ) # Perform MSA on a list of sequences seqs = [ 'CGTCAATCTATCGAAGCATACGCGGGCAGAGCCGAAGACCTCGGCAATCCA', 'CCACGTCAATCTATCGAAGCATACGCGGCAGCCGAACTCGACCTCGGCAATCAC', 'CGTCAATCTATCGAAGCATACGCGGCAGAGCCCGGAAGACCTCGGCAATCAC', 'CGTCAATGCTAGTCGAAGCAGCTGCGGCAGAGCCGAAGACCTCGGCAATCAC' ] result = aligner.msa(seqs, out_cons=True, out_msa=True) # Access results print(f"Number of sequences: {result.n_seq}") print(f"Number of consensus: {result.n_cons}") print(f"MSA length: {result.msa_len}") for i, cons in enumerate(result.cons_seq): print(f">Consensus_{i+1}\n{cons}") # Print row-column MSA result.print_msa() ``` -------------------------------- ### Print RC-MSA Source: https://github.com/yangao07/abpoa/blob/main/python/README.md Prints the Row-Column Multiple Sequence Alignment (RC-MSA) to the console. This is a method of the `msa_result` object. ```python pyabpoa.msa_result().print_msa() ``` -------------------------------- ### Output MSA results Source: https://github.com/yangao07/abpoa/blob/main/python/README.md Retrieves the results of the multiple sequence alignment, including consensus sequences and the alignment itself. This method must be called after `msa_align` and `msa_add`. ```python pyabpoa.msa_aligner.msa_output() ``` -------------------------------- ### Class pyabpoa.msa_result Source: https://github.com/yangao07/abpoa/blob/main/python/README.md Contains the output data from the alignment process, including consensus sequences and the RC-MSA. ```APIDOC ## Class pyabpoa.msa_result ### Description Stores and provides access to the results of the multiple sequence alignment. ### Properties - **n_seq** (int) - Number of input sequences. - **n_cons** (int) - Number of consensus sequences. - **clu_n_seq** (array) - Cluster sizes. - **cons_len** (array) - Lengths of consensus sequences. - **cons_seq** (array) - The consensus sequences. - **cons_cov** (array) - Coverage for each base. - **msa_len** (int) - Size of each row in RC-MSA. - **msa_seq** (array) - The RC-MSA alignment strings. ### Methods - **print_msa()** - Prints the RC-MSA to the screen. ``` -------------------------------- ### Method pyabpoa.msa_aligner.msa Source: https://github.com/yangao07/abpoa/blob/main/python/README.md Performs multiple sequence alignment on a list of sequences and returns an msa_result object. ```APIDOC ## Method pyabpoa.msa_aligner.msa ### Description Executes the MSA process and returns the alignment results. ### Parameters - **seqs** (list) - Required - List of input sequences. - **out_cons** (bool) - Required - Generate consensus sequence. - **out_msa** (bool) - Required - Generate RC-MSA. - **max_n_cons** (int) - Optional - Max number of consensus sequences. Default: 1. - **min_freq** (float) - Optional - Minimum frequency for consensus. Default: 0.3. - **out_pog** (str) - Optional - File path to save alignment graph plot. - **incr_fn** (str) - Optional - Existing graph or MSA file for incremental alignment. ### Response - **msa_result** (object) - An object containing the alignment results. ``` -------------------------------- ### Perform MSA with msa method Source: https://github.com/yangao07/abpoa/blob/main/python/README.md Performs multiple sequence alignment using the `msa` method of the `msa_aligner` class. It takes a list of sequences and boolean flags to control output generation. ```python pyabpoa.msa_aligner.msa(seqs, out_cons, out_msa, out_pog='', incr_fn='') ``` -------------------------------- ### Generate Row-Column Multiple Sequence Alignment (RC-MSA) Source: https://github.com/yangao07/abpoa/blob/main/README.md Outputs the row-column multiple sequence alignment (RC-MSA) of all aligned sequences in FASTA format. Alignment gaps are represented by '-'. ```text >1 ACGTGTACA-GTTGAC >2 A-G-GTACACGTT-AC >3 A-GTGT-CACGTTGAC >4 ACGTGTACA--TTGAC ``` -------------------------------- ### Class pyabpoa.msa_aligner Source: https://github.com/yangao07/abpoa/blob/main/python/README.md The msa_aligner class is the primary handler for configuring and performing multiple sequence alignment. ```APIDOC ## Class pyabpoa.msa_aligner ### Description Initializes the alignment handler with specific parameters for scoring and gap penalties. ### Parameters - **aln_mode** (str) - Optional - Alignment mode: 'g' (global), 'l' (local), 'e' (extension). Default: 'g'. - **is_aa** (bool) - Optional - True if input is amino acid sequence. Default: False. - **match** (int) - Optional - Match score. Default: 2. - **mismatch** (int) - Optional - Mismatch penalty. Default: 4. - **score_matrix** (str) - Optional - Scoring matrix file path. - **gap_open1** (int) - Optional - First gap opening penalty. Default: 4. - **gap_ext1** (int) - Optional - First gap extension penalty. Default: 2. - **gap_open2** (int) - Optional - Second gap opening penalty. Default: 24. - **gap_ext2** (int) - Optional - Second gap extension penalty. Default: 1. - **extra_b** (int) - Optional - First adaptive banding parameter. Default: 10. - **extra_f** (float) - Optional - Second adaptive banding parameter. Default: 0.01. - **cons_algrm** (str) - Optional - Consensus algorithm: 'HB' (heaviest bundling), 'MF' (most frequent). Default: 'HB'. ```