### C API Usage Example Source: https://github.com/ksahlin/strobealign/blob/main/cpp/ext/ssw/README.md A basic example demonstrating how to use the C API of the SSW library. Ensure ssw.h and ssw.c are included in your project. ```c #include "ssw.h" #include #include int main(int argc, char **argv) { // Initialize the SSW alignment engine // match: 2, mismatch: -1, gap open: -3, gap extend: -1 // The Smith-Waterman penalties need to be integers. Small penalty numbers such as: // match: 2, mismatch: -1, gap open (the total penalty when one gap is opened): -3, gap extension: -1 are recommended, which will lead to shorter running time. unsigned int match = 2; unsigned int mismatch = 1; unsigned int gap_open = 3; unsigned int gap_extend = 1; // Target sequence char *target = "AGCACACA"; // Query sequence char *query = "ACACA"; // Initialize the SSW alignment engine ssw_profile_t *profile = ssw_init(query, strlen(query), match, mismatch, gap_open, gap_extend); // Initialize the SSW alignment result ssw_result_t *result = ssw_align(profile, target, strlen(target), match, mismatch, gap_open, gap_extend, 0); // Print the Smith-Waterman score printf("Score: %d\n", result->score); // Free the memory free(profile); free(result); return 0; } ``` -------------------------------- ### CMake: Install Target Source: https://github.com/ksahlin/strobealign/blob/main/cpp/python/CMakeLists.txt Installs the 'strobealign_extension' target as a library into the 'strobealign' directory. ```cmake install(TARGETS strobealign_extension LIBRARY DESTINATION strobealign ) ``` -------------------------------- ### C++ API Usage Example Source: https://github.com/ksahlin/strobealign/blob/main/cpp/ext/ssw/README.md A basic example demonstrating how to use the C++ wrapper API of the SSW library. Ensure ssw.h, ssw.c, ssw_cpp.h, and ssw_cpp.cpp are included in your project. ```cpp #include "ssw_cpp.h" #include int main(int argc, char **argv) { // Initialize the SSW alignment engine // match: 2, mismatch: -1, gap open: -3, gap extend: -1 unsigned int match = 2; unsigned int mismatch = 1; unsigned int gap_open = 3; unsigned int gap_extend = 1; // Target sequence char *target = "AGCACACA"; // Query sequence char *query = "ACACA"; // Initialize the SSW alignment engine StripedSmithWaterman ssw(query, strlen(query), match, mismatch, gap_open, gap_extend); // Align the target sequence AlignmentResult result = ssw.Align(target, strlen(target)); // Print the Smith-Waterman score std::cout << "Score: " << result.score << std::endl; return 0; } ``` -------------------------------- ### C++ API Usage Example Source: https://github.com/ksahlin/strobealign/blob/main/ext/ssw/README.md A basic example demonstrating how to use the C++ API for Smith-Waterman alignment. Include ssw_cpp.h, ssw.h, ssw.c, and ssw_cpp.cpp in your project. API function descriptions are in ssw_cpp.h. ```cpp #include "ssw_cpp.h" int main() { // Example usage of the C++ API // ... (API function calls) ... return 0; } ``` -------------------------------- ### C API Usage Example Source: https://github.com/ksahlin/strobealign/blob/main/ext/ssw/README.md A basic example demonstrating how to use the C API for Smith-Waterman alignment. Ensure ssw.h and ssw.c are included in your project. Recommended penalties are small integers for better performance. ```c #include "ssw.h" int main() { // Example usage of the C API // ... (API function calls) ... return 0; } ``` -------------------------------- ### BLAST-like Output Example Source: https://github.com/ksahlin/strobealign/blob/main/cpp/ext/ssw/README.md An example of the BLAST-like output format, which provides a more human-readable alignment visualization compared to SAM format. ```text target_name: chr1 query_name: 6:163296599:F:198;None;None/1 optimal_alignment_score: 37 sub-optimal_alignment_score: 28 strand: + target_begin: 453 target_end: 492 query_begin: 17 query_end: 51 Target: 453 CCAATGCCACAAAACATCTGTCTCTAACTGGTG--TGTGTGT 492 ||| ||| |||| |||||| | ||| ||||| | *|| ||| Query: 17 CCA--GCC-CAAA--ATCTGT-TTTAA-TGGTGGATTTGTGT 51 target_name: chr1 query_name: 3:153409880:F:224;None;3,153410143,G,A/1 optimal_alignment_score: 42 sub-optimal_alignment_score: 41 strand: + target_begin: 523 target_end: 577 query_begin: 3 query_end: 53 Target: 523 GAGAGAGAAAATTTCACTCCCTCCATAAATCTCACAGTATTCTTTTCTTTTTCCT 577 ||| ||||**|||||*|*||*||*||*||**|*|| ||| |||||| ||||*|| Query: 3 GA-AGAGTTAATTTAAGTCACTTCAAACAGATTAC-GTA-TCTTTT-TTTTCCCT 53 ... ``` -------------------------------- ### BLAST-like Output Example Source: https://github.com/ksahlin/strobealign/blob/main/ext/ssw/README.md An example of the BLAST-like output format, which provides a more human-readable alignment summary including scores and coordinate information. ```text target_name: chr1 query_name: 6:163296599:F:198;None;None/1 optimal_alignment_score: 37 sub-optimal_alignment_score: 28 strand: + target_begin: 453 target_end: 492 query_begin: 17 query_end: 51 Target: 453 CCAATGCCACAAAACATCTGTCTCTAACTGGTG--TGTGT 492 ||| ||| |||| |||||| | ||| ||||| |*||||| Query: 17 CCA--GCC-CAAA--ATCTGT-TTTAA-TGGTGGATTTGTGT 51 target_name: chr1 query_name: 3:153409880:F:224;None;3,153410143,G,A/1 optimal_alignment_score: 42 sub-optimal_alignment_score: 41 strand: + target_begin: 523 target_end: 577 query_begin: 3 query_end: 53 Target: 523 GAGAGAGAAAATTTCACTCCCTCCATAAATCTCACAGTATTCTTTTCTTTTTCCT 577 || ||||**|||||*|*||*||*||*|**|*|| ||| |||||| ||||*||| Query: 3 GA-AGAGTTAATTTAAGTCACTTCAAACAGATTAC-GTA-TCTTTT-TTTTCCCT 53 ... ``` -------------------------------- ### CMake Integration with ZLIB Source: https://github.com/ksahlin/strobealign/blob/main/cpp/ext/zstr/README.org Example of how to find the ZLIB package and link it to your executable using CMake. Ensure the ZLIB::ZLIB target is available. ```cmake find_package(ZLIB REQUIRED) add_executable(YourTarget main.cpp) target_link_libraries(YourTarget PRIVATE ZLIB::ZLIB) target_include_directories(YourTarget PRIVATE /path/to/zstr/src) ``` -------------------------------- ### Install Strobealign via Conda Source: https://github.com/ksahlin/strobealign/blob/main/README.md Installs strobealign and samtools into a new Conda environment named 'strobealign'. Ensure Bioconda setup instructions are followed first. ```bash conda create -n strobealign strobealign samtools ``` -------------------------------- ### Check Strobealign Version Source: https://github.com/ksahlin/strobealign/blob/main/README.md Verifies the installation by checking the strobealign version. ```bash strobealign --version ``` -------------------------------- ### SAM Format Output Example Source: https://github.com/ksahlin/strobealign/blob/main/cpp/ext/ssw/README.md An example of the SAM (Sequence Alignment Map) format output generated by the ssw_test tool. This format is commonly used in bioinformatics for storing sequence alignment data. ```text @HD VN:1.4 SO:queryname @SQ SN:chr1 LN:1001 6:163296599:F:198;None;None/1 0 chr1 453 5 3M2D3M1D4M2D6M1D5M1D5M2I7M * 0 0 CCAGCCCAAAATCTGTTTTAATGGTGGATTTGTGT * AS:i:37 NM:i:11 ZS:i:28 3:153409880:F:224;None;3,153410143,G,A/1 0 chr1 523 4 2M1D32M1D3M1D6M1D8M * 0 0 GAAGAGTTAATTTAAGTCACTTCAAACAGATTACGTATCTTTTTTTTCCCT * AS:i:42 NM:i:16 ZS:i:41 Y:26750420:R:-132;None;None/1 0 chr1 120 4 2M1I4M3D3M1I7M2I9M2D6M1I8M * 0 0 AACAACAGAAGTTAATTAGCTTCAAAAATACTTTATATTTGCAA * AS:i:32 NM:i:16 ZS:i:29 13:91170622:R:-276;None;None/1 0 chr1 302 4 8M1D8M1D3M2D6M1D4M2I2M1D2M3D5M1I4M * 0 0 CATTTATTGTTGTTTTTAAAGATTAAATGATTAAATGTTTCAAAA * AS:i:32 NM:i:18 ZS:i:30 15:37079528:R:-240;None;None/1 0 chr1 4 5 4M2D4M1D9M1I3M4I16M1I3M1D4M2D5M * 0 0 ACAGTGATGCCAAGCCAGTGGGTTTTAGCTTGTGGAGTTCCATAGGAGCGATGC * AS:i:30 NM:i:22 ZS:i:23 9:92308501:R:-176;None;None/1 0 chr1 142 4 4M3I5M4D10M2D4M1I2M2I6M5D1M1D6M2D3M * 0 0 AATAACCATAAAAATGGGCAAAGCAGCCTTCAGGGCTGCTGTTTCTA * AS:i:26 NM:i:25 ZS:i:26 ... ``` -------------------------------- ### SAM Format Output Example Source: https://github.com/ksahlin/strobealign/blob/main/ext/ssw/README.md An example of the SAM (Sequence Alignment Map) format output generated by ssw_test. This format is commonly used in bioinformatics for storing sequence alignment data. ```sam @HD VN:1.4 SO:queryname @SQ SN:chr1 LN:1001 6:163296599:F:198;None;None/1 0 chr1 453 5 3M2D3M1D4M2D6M1D5M1D5M2I7M * 0 0 CCAGCCCAAAATCTGTTTTAATGGTGGATTTGTGT * AS:i:37 NM:i:11 ZS:i:28 3:153409880:F:224;None;3,153410143,G,A/1 0 chr1 523 4 2M1D32M1D3M1D6M1D8M * 0 0 GAAGAGTTAATTTAAGTCACTTCAAACAGATTACGTATCTTTTTTTTCCCT * AS:i:42 NM:i:16 ZS:i:41 Y:26750420:R:-132;None;None/1 0 chr1 120 4 2M1I4M3D3M1I7M2I9M2D6M1I8M * 0 0 AACAACAGAAGTTAATTAGCTTCAAAAATACTTTATATTTGCAA * AS:i:32 NM:i:16 ZS:i:29 13:91170622:R:-276;None;None/1 0 chr1 302 4 8M1D8M1D3M2D6M1D4M2I2M1D2M3D5M1I4M * 0 0 CATTTATTGTTGTTTTTAAAGATTAAATGATTAAATGTTTCAAAA * AS:i:32 NM:i:18 ZS:i:30 15:37079528:R:-240;None;None/1 0 chr1 4 5 4M2D4M1D9M1I3M4I16M1I3M1D4M2D5M * 0 0 ACAGTGATGCCAAGCCAGTGGGTTTTAGCTTGTGGAGTTCCATAGGAGCGATGC * AS:i:30 NM:i:22 ZS:i:23 9:92308501:R:-176;None;None/1 0 chr1 142 4 4M3I5M4D10M2D4M1I2M2I6M5D1M1D6M2D3M * 0 0 AATAACCATAAAAATGGGCAAAGCAGCCTTCAGGGCTGCTGTTTCTA * AS:i:26 NM:i:25 ZS:i:26 ... ``` -------------------------------- ### Set Minimum CMake Version and Project Name Source: https://github.com/ksahlin/strobealign/blob/main/cpp/ext/zstr/CMakeLists.txt Specifies the minimum required CMake version and the project name. This is a standard starting point for any CMake project. ```cmake cmake_minimum_required(VERSION 3.10 FATAL_ERROR) project(zstr LANGUAGES CXX) ``` -------------------------------- ### CMake: Execute Process to Get nanobind Directory Source: https://github.com/ksahlin/strobealign/blob/main/cpp/python/CMakeLists.txt Executes a Python command to find the nanobind CMake directory and stores it in the NB_DIR variable. This is used to add nanobind to the CMAKE_PREFIX_PATH. ```cmake execute_process( COMMAND "${Python_EXECUTABLE}" -c "import nanobind; print(nanobind.cmake_dir())" OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE NB_DIR ) list(APPEND CMAKE_PREFIX_PATH "${NB_DIR}") ``` -------------------------------- ### Run strobealign in release mode with arguments Source: https://github.com/ksahlin/strobealign/blob/main/CONTRIBUTING.md Build and run the strobealign binary in release mode, passing arguments to the program after the '--' separator. The '-r' flag is a shortcut for '--release'. ```bash cargo run -r -- -t 8 tests/phix.fasta tests/phix.1.fastq ``` -------------------------------- ### Build strobealign with release optimizations Source: https://github.com/ksahlin/strobealign/blob/main/CONTRIBUTING.md Build the release version of strobealign for optimized performance. The compiled binary will be located at target/release/strobealign. ```bash cargo build --release ``` -------------------------------- ### Compiling the SSW Library Source: https://github.com/ksahlin/strobealign/blob/main/ext/ssw/README.md Instructions for compiling the SSW library using make. This process generates the executable file 'ssw_test'. ```bash cd src make ``` -------------------------------- ### Using Pre-generated Index Source: https://github.com/ksahlin/strobealign/blob/main/README.md Employ the --use-index option to utilize a pre-generated index file instead of creating a new one. This speeds up the mapping process when the index already exists. ```bash strobealign --use-index ref.fa reads.fastq.gz > output.sam ``` -------------------------------- ### Creating Index Files Source: https://github.com/ksahlin/strobealign/blob/main/README.md Use the --create-index or -i option to generate a strobemer index file (.sti) for the reference FASTA. This process does not map reads but can use read files to estimate read length. ```bash strobealign --create-index ref.fa ``` -------------------------------- ### ssw_test Command-Line Usage Source: https://github.com/ksahlin/strobealign/blob/main/ext/ssw/README.md Displays the available options for running the ssw_test alignment software, including parameters for scoring and output format. ```bash Usage: ssw_test [options] ... (or ) Options: -m N N is a positive integer for weight match in genome sequence alignment. [default: 2] -x N N is a positive integer. -N will be used as weight mismatch in genome sequence alignment. [default: 2] -o N N is a positive integer. -N will be used as the weight for the gap opening. [default: 3] -e N N is a positive integer. -N will be used as the weight for the gap extension. [default: 1] -p Do protein sequence alignment. Without this option, the ssw_test will do genome sequence alignment. -a FILE FILE is either the Blosum or Pam weight matrix. [default: Blosum50] -c Return the alignment path. -f N N is a positive integer. Only output the alignments with the Smith-Waterman score >= N. -r The best alignment will be picked between the original read alignment and the reverse complement read alignment. -s Output in SAM format. [default: no header] -h If -s is used, include header in SAM output. ``` -------------------------------- ### Build strobealign with CPU-specific optimizations Source: https://github.com/ksahlin/strobealign/blob/main/CONTRIBUTING.md Compile strobealign with release optimizations tailored to the native CPU architecture for maximum performance. This uses the RUSTFLAGS environment variable. ```bash RUSTFLAGS='-C target-cpu=native' cargo build --release ``` -------------------------------- ### Create Index with Noisy Profile Source: https://github.com/ksahlin/strobealign/blob/main/README.md Create an index using the predefined 'noisy' profile. This is an alternative to estimating the profile from reads or setting an explicit length. ```bash strobealign --create-index -t 8 -P noisy ref.fa ``` -------------------------------- ### Build Java Interface for SSW Library Source: https://github.com/ksahlin/strobealign/blob/main/ext/ssw/README.md Build the Java Native Interface (JNI) wrapper for the SSW library. This requires javac, jar, and JAVA_HOME to be set correctly. The command 'make java' generates libsswjni.so and ssw.jar. ```bash make java ``` -------------------------------- ### Create Index with Reads Source: https://github.com/ksahlin/strobealign/blob/main/README.md Create an index using a read-length profile estimated from provided reads. This is useful for repeated mapping of similar libraries. ```bash strobealign --create-index -t 8 ref.fa reads.1.fastq.gz reads.2.fastq.gz ``` -------------------------------- ### Run baseline comparison test script Source: https://github.com/ksahlin/strobealign/blob/main/CONTRIBUTING.md Execute the script to compare strobealign's mapping results against a known good baseline commit. This script downloads test data on the first run. ```bash tests/compare-baseline.sh ``` -------------------------------- ### Generate FASTQ Reads Source: https://github.com/ksahlin/strobealign/blob/main/tests/README.md Command to download and extract the first 100 reads from the SRR1377138 dataset using fastq-dump. This is useful for creating small test files. ```bash fastq-dump --split-3 -X 100 --defline-seq '@$ac.$si' --defline-qual '+' SRR1377138 ``` -------------------------------- ### Activate Conda Environment Source: https://github.com/ksahlin/strobealign/blob/main/README.md Activates the Conda environment previously created for strobealign. ```bash conda activate strobealign ``` -------------------------------- ### CMake: Find Python and nanobind Source: https://github.com/ksahlin/strobealign/blob/main/cpp/python/CMakeLists.txt Finds the required Python 3.10 interpreter and development components, and then locates the nanobind configuration. ```cmake find_package(Python 3.10 COMPONENTS Interpreter Development.Module REQUIRED) find_package(nanobind CONFIG REQUIRED) ``` -------------------------------- ### Compile SSW C Library Source: https://github.com/ksahlin/strobealign/blob/main/ext/ssw/README.md Compile the SSW C library into a dynamic shared object (.so) file using gcc. Ensure Wall, O3, and PIC flags are used for optimization and position-independent code. ```bash gcc -Wall -O3 -pipe -fPIC -shared -rdynamic -o libssw.so ssw.c ssw.h ``` -------------------------------- ### Find and Link zlib Library Source: https://github.com/ksahlin/strobealign/blob/main/cpp/ext/zstr/CMakeLists.txt Locates the zlib library version 1.2.3 or higher and defines an imported target ZLIB::ZLIB. It also prints the found zlib version. ```cmake # -- locate zlib find_package(ZLIB 1.2.3 REQUIRED) # defines imported target ZLIB::ZLIB message(STATUS "zstr - found ZLIB (version: ${ZLIB_VERSION_STRING})") ``` -------------------------------- ### CMake: Add nanobind Module Source: https://github.com/ksahlin/strobealign/blob/main/cpp/python/CMakeLists.txt Adds a new CMake target 'strobealign_extension' using nanobind, compiling 'strobealign.cpp'. It links against 'salib'. ```cmake nanobind_add_module(strobealign_extension strobealign.cpp) target_link_libraries(strobealign_extension PRIVATE salib) ``` -------------------------------- ### Create Index with Explicit Read Length Source: https://github.com/ksahlin/strobealign/blob/main/README.md Create an index by explicitly setting the read length using the -r option. This provides more control over the read profile used for indexing. ```bash strobealign --create-index -t 8 -r 150 ref.fa ``` -------------------------------- ### Set zstr Target Properties Source: https://github.com/ksahlin/strobealign/blob/main/cpp/ext/zstr/CMakeLists.txt Configures the properties for the 'zstr' interface target. It sets include directories to the 'src' folder, links against the ZLIB::ZLIB target, and requires C++11 support. ```cmake # -- set target properties target_include_directories(zstr INTERFACE "${PROJECT_SOURCE_DIR}/src") target_link_libraries(zstr INTERFACE ZLIB::ZLIB) target_compile_features(zstr INTERFACE cxx_std_11) # require c++11 flag ``` -------------------------------- ### Build legacy C++ version with RelWithDebInfo type Source: https://github.com/ksahlin/strobealign/blob/main/CONTRIBUTING.md Compile the legacy C++ version of strobealign using CMake with the RelWithDebInfo build type, which includes -O3, -g, and -DNDEBUG compiler flags for profiling. ```bash cmake -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo ``` -------------------------------- ### Build legacy C++ version of strobealign Source: https://github.com/ksahlin/strobealign/blob/main/CONTRIBUTING.md Compile the older C++ version of strobealign. CMake is used for the build process. Specify a build type for compiler options. ```bash cmake -B build ``` -------------------------------- ### Variant Calling with Bcftools Source: https://github.com/ksahlin/strobealign/blob/main/evaluation.md This snippet demonstrates the process of calling variants from aligned BAM files using bcftools mpileup and call. It then proceeds to split the called variants into SNVs and INDELs. ```bash bcftools mpileup -O z --fasta-ref ref aligned.bam > aligned.vcf.gz bcftools call -v -c -O v aligned.vcf.gz > aligned.variants.vcf.gz # Split into SNP and INDELS grep -v -E -e "INDEL;" aligned.variants.vcf.gz > aligned.variants.SNV.vcf grep "#" aligned.variants.vcf.gz > aligned.variants.INDEL.vcf grep -E -e "INDEL;" aligned.variants.vcf.gz >> aligned.variants.INDEL.vcf ``` -------------------------------- ### Align Paired-End Reads to SAM Source: https://github.com/ksahlin/strobealign/blob/main/README.md Aligns paired-end FASTQ files against a reference FASTA and pipes the SAM output to samtools for sorting into a BAM file. Uses 8 threads. ```bash strobealign -t 8 ref.fa reads.1.fastq.gz reads.2.fastq.gz | samtools sort -o sorted.bam ``` -------------------------------- ### Mapping Reads Only (PAF Output) Source: https://github.com/ksahlin/strobealign/blob/main/README.md Use the -x option to map reads without base-level alignment, changing the output format from SAM to PAF. This is useful when only read mapping locations are needed. ```bash strobealign -x ref.fa reads.fastq.gz > output.paf ``` -------------------------------- ### Map Reads Using Noisy Profile Index Source: https://github.com/ksahlin/strobealign/blob/main/README.md Map reads using a pre-computed index that was created with the 'noisy' profile. Ensure the -P noisy option is also used during mapping. ```bash strobealign --use-index -t 8 -P noisy ref.fa reads.1.fastq.gz reads.2.fastq.gz ``` -------------------------------- ### Align Single-End Reads to SAM Source: https://github.com/ksahlin/strobealign/blob/main/README.md Aligns single-end FASTQ files against a reference FASTA and pipes the SAM output to samtools for sorting into a BAM file. Uses 8 threads. ```bash strobealign -t 8 ref.fa reads.fastq.gz | samtools sort -o sorted.bam ``` -------------------------------- ### Print zstr Target Summary Source: https://github.com/ksahlin/strobealign/blob/main/cpp/ext/zstr/CMakeLists.txt Outputs a status message summarizing the 'zstr::zstr' interface target, including its include directories, linked libraries, and required C++ features. ```cmake # -- print target summary message(STATUS "zstr - added INTERFACE target 'zstr::zstr' includes : ${ZSTR_INCLUDE_DIRS} libraries: ZLIB::ZLIB features : cxx_std_11" ) ``` -------------------------------- ### Map Reads Using Pre-computed Index Source: https://github.com/ksahlin/strobealign/blob/main/README.md Map reads using a pre-computed index file. This significantly speeds up mapping when the index has already been generated. ```bash strobealign --use-index -t 8 ref.fa reads.1.fastq.gz reads.2.fastq.gz | samtools ... ``` -------------------------------- ### Build legacy C++ version with Release type Source: https://github.com/ksahlin/strobealign/blob/main/CONTRIBUTING.md Compile the legacy C++ version of strobealign using CMake with the Release build type, which includes -O3 and -DNDEBUG compiler flags. ```bash cmake -B build -DCMAKE_BUILD_TYPE=Release ``` -------------------------------- ### Abundance Estimation Mode (Paired-End) Source: https://github.com/ksahlin/strobealign/blob/main/README.md Use the --aemb option for abundance estimation mode, suitable for metagenomic binning. This command outputs a TSV table with abundance values per contig. Ensure reference FASTA and paired-end read files are provided. ```bash strobealign -t 8 --aemb ref.fa reads.1.fastq.gz reads.2.fastq.gz > abundances.tsv ``` -------------------------------- ### Set LD_LIBRARY_PATH Environment Variable Source: https://github.com/ksahlin/strobealign/blob/main/ext/ssw/README.md Export the LD_LIBRARY_PATH environment variable to include the directory containing libssw.so. This allows the system to find the dynamic library at runtime. ```bash export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:path_of_libssw.so ``` -------------------------------- ### Mapping-Only Mode to PAF Source: https://github.com/ksahlin/strobealign/blob/main/README.md Performs alignment in mapping-only mode, outputting PAF format instead of SAM. Pipes the output to igzip for compressed PAF. Uses 8 threads. ```bash strobealign -x -t 8 ref.fa reads.1.fastq.gz reads.2.fastq.gz | igzip > output.paf.gz ``` -------------------------------- ### pyssw.py Standalone Script Usage Source: https://github.com/ksahlin/strobealign/blob/main/ext/ssw/README.md Command-line usage for the pyssw.py script, which performs genome or protein sequence alignment. It accepts target and query files and various optional arguments for alignment parameters and output format. ```bash usage: pyssw.py [-h] [-l SLIBPATH] [-m NMATCH] [-x NMISMATCH] [-o NOPEN] [-e NEXT] [-p] [-a SMATRIX] [-c] [-f NTHR] [-r] [-s] [-header] [target] [query] positional arguments: target targe file query query file optional arguments: -h, --help show this help message and exit -l SLIBPATH, --sLibPath SLIBPATH path of libssw.so -m NMATCH, --nMatch NMATCH a positive integer as the score for a match in genome sequence alignment. [default: 2] -x NMISMATCH, --nMismatch NMISMATCH a positive integer as the score for a mismatch in genome sequence alignment. [default: 2] -o NOPEN, --nOpen NOPEN a positive integer as the penalty for the gap opening in genome sequence alignment. [default: 3] -e NEXT, --nExt NEXT a positive integer as the penalty for the gap extension in genome sequence alignment. [default: 1] -p, --bProtien Do protein sequence alignment. Without this option, the ssw_test will do genome sequence alignment. [default: False] -a SMATRIX, --sMatrix SMATRIX a file for either Blosum or Pam weight matrix. [default: Blosum50] -c, --bPath Return the alignment path. [default: False] -f NTHR, --nThr NTHR a positive integer. Only output the alignments with the Smith-Waterman score >= N. -r, --bBest The best alignment will be picked between the original read alignment and the reverse complement read alignment. [default: False] -s, --bSam Output in SAM format. [default: no header] -header, --bHeader If -s is used, include header in SAM output. ``` -------------------------------- ### Fetch zstr from a Git repository in CMake Source: https://github.com/ksahlin/strobealign/blob/main/cpp/ext/zstr/README.org Use CMake's FetchContent module to download zstr from a Git repository and link to the 'zstr::zstr' target. This method is useful for managing external dependencies in CMake projects, especially with CMake 3.14 and later. ```cmake include(FetchContent) FetchContent_Declare(ZStrGitRepo GIT_REPOSITORY "https://github.com/mateidavid/zstr" # can also be a local filesystem path! GIT_TAG "master" ) FetchContent_MakeAvailable(ZStrGitRepo) # defines INTERFACE target 'zstr::zstr' add_executable(YourTarget main.cpp) target_link_libraries(YourTarget PRIVATE zstr::zstr) ``` -------------------------------- ### Warn about Interface Library Support in Older CMake Versions Source: https://github.com/ksahlin/strobealign/blob/main/cpp/ext/zstr/CMakeLists.txt Issues a warning for CMake versions less than 3.13, as interface library targets are not well supported. It suggests manually adding ZSTR_INCLUDE_DIRS to include directories. ```cmake if(${CMAKE_VERSION} VERSION_LESS 3.13) message(WARNING "Interface library targets are not well supported before cmake 3.13 .... " "You may need to add \${ZSTR_INCLUDE_DIRS} to your include directories\n" "target_include_directories(YourTarget PRIVATE \${ZSTR_INCLUDE_DIRS}) " ) endif() ``` -------------------------------- ### Selecting Noisy Read Profile Source: https://github.com/ksahlin/strobealign/blob/main/README.md Use the -P noisy option to select a profile optimized for error-prone reads. This is equivalent to setting specific parameters (-k 16 -s 12 -l 2 -u 2 -m 100) and may increase accuracy at the cost of runtime. ```bash strobealign -P noisy ref.fa reads.fastq.gz > output.sam ``` -------------------------------- ### Build legacy C++ version with Debug type Source: https://github.com/ksahlin/strobealign/blob/main/CONTRIBUTING.md Compile the legacy C++ version of strobealign using CMake with the Debug build type, which includes -O2 and -g compiler flags for development. ```bash cmake -B build -DCMAKE_BUILD_TYPE=Debug ``` -------------------------------- ### Align Mixed Reads (Interleaved) to SAM Source: https://github.com/ksahlin/strobealign/blob/main/README.md Aligns interleaved FASTQ files (containing both single and paired-end reads) against a reference FASTA and pipes the SAM output to samtools for sorting into a BAM file. Uses 8 threads. ```bash strobealign -t 8 ref.fa --interleaved reads.fastq.gz | samtools sort -o sorted.bam ``` -------------------------------- ### Define zstr Interface Library Target Source: https://github.com/ksahlin/strobealign/blob/main/cpp/ext/zstr/CMakeLists.txt Creates an INTERFACE library target named 'zstr' and an ALIAS target 'zstr::zstr'. Interface libraries are useful for defining properties that should be propagated to targets linking against them. ```cmake # -- add target add_library(zstr INTERFACE) add_library(zstr::zstr ALIAS zstr) ``` -------------------------------- ### Add zstr include directory in CMake Source: https://github.com/ksahlin/strobealign/blob/main/cpp/ext/zstr/README.org Include the directory containing 'zstr.hpp' in your target's include directories. Note that with this method, you are responsible for finding and linking to the ZLIB library yourself. ```cmake #+BEGIN_SRC cmake # NOTE: With this method you're responsible for finding and linking to ZLIB !/ #+END_SRC ``` -------------------------------- ### Adding Read Group Metadata Source: https://github.com/ksahlin/strobealign/blob/main/README.md Specify read group information using --rg-id and --rg options. This adds RG tags to SAM records and metadata to the SAM header, useful for tracking sample origins and library information. ```bash strobealign --rg-id=1 --rg=SM:mysamle --rg=LB:mylibrary ref.fa reads.fastq.gz > output.sam ``` -------------------------------- ### Set Cache Variables for Include Directories and Libraries Source: https://github.com/ksahlin/strobealign/blob/main/cpp/ext/zstr/CMakeLists.txt Defines cache variables ZSTR_INCLUDE_DIRS and ZSTR_LIBRARIES. These are primarily for compatibility with CMake versions prior to 3.13. ```cmake # -- set cache variables # NOTE: these vars are mostly useful to people using cmake < 3.13 set(ZSTR_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src;${ZLIB_INCLUDE_DIRS}" CACHE PATH "" FORCE) set(ZSTR_LIBRARIES "${ZLIB_LIBRARIES}" CACHE PATH "" FORCE) ``` -------------------------------- ### Separating GIAB SNVs and INDELs Source: https://github.com/ksahlin/strobealign/blob/main/evaluation.md This code separates the true variants from the GIAB dataset into SNV and INDEL files based on their format in the VCF file. ```bash shell('zgrep "#" true.variants.vcf > true.variants.SNV.vcf') shell('zgrep -P "\t[ACGT]\t[ACGT]\t" true.variants.vcf >> true.variants.SNV.vcf') shell('zgrep -v -P "\t[ACGT]\t[ACGT]\t" true.variants.vcf > true.variants.INDEL.vcf') ``` -------------------------------- ### Add zstr as a subdirectory in CMake Source: https://github.com/ksahlin/strobealign/blob/main/cpp/ext/zstr/README.org Include zstr as a subdirectory in your CMake project and link to the 'zstr::zstr' target. This method is suitable for local development or when zstr is part of your project's source tree. ```cmake add_subdirectory(zstr) # defines INTERFACE target 'zstr::zstr' add_executable(YourTarget main.cpp) target_link_libraries(YourTarget PRIVATE zstr::zstr) # if using cmake < 3.13 you may also need the following line # target_include_directories(YourTarget PRIVATE ${ZSTR_INCLUDE_DIRS}) ``` -------------------------------- ### Handle CMake Policy CMP0074 for find_package Source: https://github.com/ksahlin/strobealign/blob/main/cpp/ext/zstr/CMakeLists.txt Sets the CMake policy CMP0074 to NEW for CMake versions 3.12 and greater. This policy affects how find_package uses _ROOT variables. ```cmake if (${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.12) cmake_policy(SET CMP0074 NEW) # find_package uses _ROOT variables endif() ``` -------------------------------- ### CMake: Set Target Properties Source: https://github.com/ksahlin/strobealign/blob/main/cpp/python/CMakeLists.txt Sets the POSITION_INDEPENDENT_CODE property for the 'salib' target. This is often required for shared libraries. ```cmake set_target_properties(salib PROPERTIES POSITION_INDEPENDENT_CODE ON) ``` -------------------------------- ### Intersection of True and Called Variants Source: https://github.com/ksahlin/strobealign/blob/main/evaluation.md This loop sorts and indexes the aligned variants, then uses bcftools isec to find the intersection between the true variants and the called variants for both SNVs and INDELs. ```bash for type in SNV INDEL do bcftools sort -Oz aligned.variants.$type.vcf.gz -o aligned.variants.sorted.$type.vcf.gz bcftools index aligned.variants.sorted.$type.vcf.gz bcftools isec --nfiles 2 -O u true_variants.sorted.$type.vcf.gz aligned.variants.sorted.$type.vcf -p out_$type done ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.