### Clone and Build kseq++ from Source Source: https://github.com/cartoonist/kseqpp/blob/main/README.md Install kseq++ from source using Git and CMake. Ensure CMake version 3.10 or higher is installed. The installation prefix can be customized. ```shell git clone https://github.com/cartoonist/kseqpp cd kseqpp mkdir build && cd build cmake .. # -DCMAKE_INSTALL_PREFIX=/path/to/custom/install/prefix (optional) make install ``` -------------------------------- ### Build and Install kseq++ from Source Source: https://context7.com/cartoonist/kseqpp/llms.txt Builds and installs kseq++ from source using CMake, with options to enable testing and benchmarking. ```shell git clone https://github.com/cartoonist/kseqpp cd kseqpp mkdir build && cd build cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local \ -DBUILD_TESTING=on \ -DBUILD_BENCHMARKING=on make install ``` -------------------------------- ### Low-Level Input Stream with KStream and make_ikstream Source: https://context7.com/cartoonist/kseqpp/llms.txt Shows how to use the KStream template class with C++11/14 template argument deduction via `make_ikstream` for reading from various file types like gzFile. Includes examples of inspecting stream state and handling errors. ```cpp #include #include using namespace klibpp; int main(int argc, char* argv[]) { const char* filename = argv[1]; KSeq record; // --- gzFile input stream (C++11/14 compatible via make_ikstream) --- gzFile fp = gzopen(filename, "r"); auto iks = make_ikstream(fp, gzread); // Equivalent with explicit mode: make_kstream(fp, gzread, mode::in) // C++17 only: KStream iks(fp, gzread, mode::in); // KStreamIn iks(fp, gzread); while (iks >> record) { std::cout << ">" << record.name << " " << record.comment << "\n" << record.seq << "\n"; } // Inspect stream state std::cout << "Records parsed: " << iks.counts() << "\n"; if (iks.err()) std::cerr << "Read error\n"; if (iks.eof()) std::cout << "EOF reached\n"; if (iks.tqs()) std::cerr << "Truncated quality string detected\n"; if (iks.fail()) std::cerr << "Stream in failed state\n"; gzclose(fp); // manual close when not using RAII close function // --- Pass close function for RAII-style cleanup --- gzFile fp2 = gzopen(filename, "r"); auto iks2 = make_kstream(fp2, gzread, mode::in, gzclose); // gzclose called automatically when iks2 is destroyed // --- Bulk read variant --- gzFile fp3 = gzopen(filename, "r"); auto iks3 = make_ikstream(fp3, gzread); auto all = iks3.read(); // all records auto first10 = iks3.read(10); // read up to 10 more gzclose(fp3); return 0; } ``` -------------------------------- ### Install kseq++ using Conda Source: https://github.com/cartoonist/kseqpp/blob/main/README.md Install kseq++ from the bioconda channel using the conda package manager. ```shell conda install -c bioconda kseqpp ``` -------------------------------- ### Low-Level KStream Output Examples Source: https://context7.com/cartoonist/kseqpp/llms.txt Demonstrates outputting sequences using the low-level KStream API with different stream types (file descriptor, gzip) and custom buffer sizes. Remember to call `ks << kend` to flush the buffer before closing the stream when using the low-level API. ```cpp #include #include #include #include using namespace klibpp; int main() { KSeq r1; r1.name = "seq1"; r1.seq = "ACGTACGTACGT"; r1.qual = "IIIIIIIIIIII"; KSeq r2; r2.name = "seq2"; r2.seq = "TTAACCGG"; // FASTA (no qual) // --- Plain file output via POSIX write --- int ofd = open("/tmp/out.fq", O_CREAT | O_WRONLY | O_TRUNC, 0644); auto oks = make_okstream(ofd, write); // Equivalent: make_kstream(ofd, write, mode::out) oks.set_wraplen(60); oks << r1 << r2; oks << kend; // flush before close — required with low-level API! close(ofd); // --- gzip output --- gzFile gfp = gzopen("/tmp/out.fa.gz", "w"); auto goks = make_kstream(gfp, gzwrite, mode::out, format::fasta); goks << r1 << r2; // Destructor flushes and closes (if close function registered), or: goks << kend; gzclose(gfp); // --- Custom buffer size (default: 131072 bytes) --- int fd2 = open("/tmp/out2.fa", O_CREAT | O_WRONLY | O_TRUNC, 0644); std::size_t bufsize = 65536; auto oks2 = make_kstream(fd2, write, mode::out, bufsize); oks2 << r1; oks2 << kend; close(fd2); return 0; } ``` -------------------------------- ### Format Modifiers and Line Wrapping with SeqStreamOut Source: https://context7.com/cartoonist/kseqpp/llms.txt Illustrates changing output format mid-stream using format modifiers and controlling FASTA sequence line wrapping with SeqStreamOut. Includes examples of setting wrap length, disabling wrapping, and querying stream state. ```cpp #include using namespace klibpp; int main() { KSeq fq; fq.name = "r1"; fq.seq = std::string(200, 'A'); fq.qual = std::string(200, 'I'); KSeq fa; fa.name = "r2"; fa.seq = std::string(200, 'G'); SeqStreamOut oss("out.fa"); // Switch format inline; affects all subsequent writes until changed oss << format::fasta << fq; // write FASTQ record in FASTA format oss << fa; // still FASTA mode oss << format::mix; // revert to auto-detect // Adjust FASTA line wrapping (default = 60 bp) oss.set_wraplen(80); // wrap at 80 bp oss << fa; oss.set_nowrapping(); // disable wrapping entirely oss << fa; oss.set_wrapping(); // re-enable wrapping at default 60 bp oss << fa; // Query state std::cout << "Records written: " << oss.counts() << "\n"; std::cout << "Current format: " << oss.get_format() << "\n"; // 0=mix,1=fasta,2=fastq std::cout << "Stream ok: " << (bool(oss) ? "yes" : "no") << "\n"; return 0; } ``` -------------------------------- ### Write FASTA/FASTQ with SeqStreamOut Source: https://context7.com/cartoonist/kseqpp/llms.txt Demonstrates writing FASTA and FASTQ records to a file using SeqStreamOut. Supports auto-detection of format, gzip compression, and explicit format selection. The stream is managed with RAII. ```cpp #include using namespace klibpp; int main() { // Build sample records KSeq fq_rec; fq_rec.name = "read1"; fq_rec.seq = "ACGTACGT"; fq_rec.qual = "IIIIIIII"; KSeq fa_rec; fa_rec.name = "seq1"; fa_rec.seq = "TTAGGCAATCC"; // no qual → FASTA // --- Write uncompressed, auto-detect format (mix mode) --- { SeqStreamOut oss("output.fq"); oss << fq_rec; // written as FASTQ (has qual) oss << fa_rec; // written as FASTA (no qual) } // RAII: buffer flushed and file closed here // --- Write gzip-compressed FASTA (force FASTA format) --- { SeqStreamOut oss("output.fa.gz", /* compressed= */ true, format::fasta); oss << fq_rec; // FASTQ record written as FASTA (qual discarded) oss << fa_rec; } // --- Force FASTQ format (throws if record has no qual) --- { SeqStreamOut oss("output.fastq", format::fastq); oss << fq_rec; // oss << fa_rec; // would throw: no quality string } // --- Write to file descriptor --- int fd = open("out.fa", O_CREAT | O_WRONLY, 0644); { SeqStreamOut oss(fd, /* compressed= */ false, format::fasta); oss << fq_rec; } return 0; } ``` -------------------------------- ### Find and Configure SeqAn Dependency Source: https://github.com/cartoonist/kseqpp/blob/main/benchmark/CMakeLists.txt This snippet finds the SeqAn library using CMake's find_package command and sets up an imported target if it's found. This is necessary for linking against SeqAn in the project. ```cmake find_package(ZLIB REQUIRED) find_package(BZip2 REQUIRED) find_package(OpenMP) find_package(SeqAn REQUIRED CONFIG) if (SeqAn_FOUND AND NOT TARGET SeqAn::SeqAn) add_library(SeqAn::SeqAn INTERFACE IMPORTED) set_target_properties(SeqAn::SeqAn PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${SEQAN_INCLUDE_DIRS}" INTERFACE_LINK_LIBRARIES "${SEQAN_LIBRARIES}") endif() ``` -------------------------------- ### SeqStreamOut: Writing Sequence Files Source: https://context7.com/cartoonist/kseqpp/llms.txt Demonstrates how to use SeqStreamOut to write FASTA and FASTQ records to files, with options for compression and format selection. The stream is automatically flushed and closed when the object goes out of scope. ```APIDOC ## SeqStreamOut — High-Level Sequence File Writer `SeqStreamOut` writes FASTA or FASTQ records to a file (by name or file descriptor), with optional gzip compression and explicit output format selection. The stream is flushed and the file closed automatically when the object goes out of scope (RAII). ### Usage Examples: * **Write uncompressed, auto-detect format (mix mode):** ```cpp #include using namespace klibpp; SeqStreamOut oss("output.fq"); oss << fq_rec; // written as FASTQ (has qual) oss << fa_rec; // written as FASTA (no qual) // RAII: buffer flushed and file closed here ``` * **Write gzip-compressed FASTA (force FASTA format):** ```cpp #include using namespace klibpp; SeqStreamOut oss("output.fa.gz", /* compressed= */ true, format::fasta); oss << fq_rec; // FASTQ record written as FASTA (qual discarded) oss << fa_rec; ``` * **Force FASTQ format (throws if record has no qual):** ```cpp #include using namespace klibpp; SeqStreamOut oss("output.fastq", format::fastq); oss << fq_rec; // oss << fa_rec; // would throw: no quality string ``` * **Write to file descriptor:** ```cpp #include #include using namespace klibpp; int fd = open("out.fa", O_CREAT | O_WRONLY, 0644); SeqStreamOut oss(fd, /* compressed= */ false, format::fasta); oss << fq_rec; ``` ``` -------------------------------- ### SeqStreamIn: High-Level Sequence File Reader Source: https://context7.com/cartoonist/kseqpp/llms.txt SeqStreamIn transparently handles gzip-compressed and plain-text FASTA/FASTQ files. It supports record-by-record streaming, bulk reads into a vector, chunked reads, and opening by file descriptor. ```cpp #include #include using namespace klibpp; int main() { KSeq record; // --- Record-by-record streaming (gzip or plain) --- SeqStreamIn iss("reads.fq.gz"); while (iss >> record) { std::cout << record.name; if (!record.comment.empty()) std::cout << " " << record.comment; std::cout << "\n" << record.seq << "\n"; if (!record.qual.empty()) std::cout << "+\n" << record.qual << "\n"; } // --- Bulk read: all records into a vector --- SeqStreamIn iss2("genome.fa"); std::vector all = iss2.read(); std::cout << "Loaded " << all.size() << " records\n"; // --- Chunked read: 100 records at a time --- SeqStreamIn iss3("large.fq.gz"); while (true) { auto chunk = iss3.read(100); if (chunk.empty()) break; std::cout << "Processing chunk of " << chunk.size() << " records\n"; // process chunk... } // --- Open by file descriptor --- int fd = open("reads.fa", O_RDONLY); SeqStreamIn iss4(fd); while (iss4 >> record) { /* process */ } return 0; } ``` -------------------------------- ### Define seqio Test Executable Source: https://github.com/cartoonist/kseqpp/blob/main/test/CMakeLists.txt Defines the 'seqio-test' executable, similar to 'kseq++-test', with its own source file, compile options, include directories, and linked libraries. It also links against the kseq++ library. ```cmake add_executable(seqio-test src/seqio_test.cpp) target_compile_options(seqio-test PRIVATE -g -Wall -Wpedantic -Werror) target_include_directories(seqio-test PRIVATE ${PROJECT_SOURCE_DIR}/test/include PRIVATE kseq++::kseq++) target_link_libraries(seqio-test PRIVATE kseq++::kseq++) ``` -------------------------------- ### Integrate kseq++ with CMake Source: https://github.com/cartoonist/kseqpp/blob/main/README.md Use CMake's `find_package` to import the kseq++ library. The `kseq++::kseq++` target can then be used for `target_include_directories` and `target_link_libraries`. ```cmake cmake_minimum_required(VERSION 3.10) project(myprogram VERSION 0.0.1 LANGUAGES CXX) find_package(kseq++ REQUIRED) set(SOURCES "src/main.cpp") add_executable(myprogram ${SOURCES}) target_include_directories(myprogram PRIVATE kseq++::kseq++) target_link_libraries(myprogram PRIVATE kseq++::kseq++) ``` -------------------------------- ### Read FASTQ/A Records One by One with SeqStreamIn Source: https://github.com/cartoonist/kseqpp/blob/main/README.md Use SeqStreamIn to read records sequentially from compressed or uncompressed files. This is suitable for processing large files record by record. ```c++ #include #include using namespace klibpp; int main(int argc, char* argv[]) { KSeq record; SeqStreamIn iss("file.fq.gz"); while (iss >> record) { std::cout << record.name << std::endl; if (!record.comment.empty()) std::cout << record.comment << std::endl; std::cout << record.seq << std::endl; if (!record.qual.empty()) std::cout << record.qual << std::endl; } } ``` -------------------------------- ### Read FASTQ/A Records with Low-level KStream API Source: https://github.com/cartoonist/kseqpp/blob/main/README.md Utilize the low-level KStream API for reading records, offering more control. Ensure gzFile is properly opened and closed. ```c++ #include #include #include using namespace klibpp; int main(int argc, char* argv[]) { KSeq record; gzFile fp = gzopen(filename, "r"); auto ks = make_kstream(fp, gzread, mode::in); // auto ks = KStream(fp, gzread, mode::in); // C++17 // auto ks = KStreamIn(fp, gzread); // C++17 while (ks >> record) { std::cout << record.name << std::endl; if (!record.comment.empty()) std::cout << record.comment << std::endl; std::cout << record.seq << std::endl; if (!record.qual.empty()) std::cout << record.qual << std::endl; } gzclose(fp); } ``` -------------------------------- ### Define kseq++-bench Executable Source: https://github.com/cartoonist/kseqpp/blob/main/benchmark/CMakeLists.txt This defines the kseq++-bench executable target, specifying its source file and setting private compilation options. It also includes directories and links libraries required for the benchmark. ```cmake set(CMAKE_BUILD_TYPE "Release") add_executable(kseq++-bench kseq++_bench.cpp) target_compile_options(kseq++-bench PRIVATE -g -Wall -Wpedantic -Werror) target_include_directories(kseq++-bench PRIVATE ${PROJECT_SOURCE_DIR}/benchmark/include PRIVATE SeqAn::SeqAn PRIVATE kseq++::kseq++) target_link_libraries(kseq++-bench PRIVATE SeqAn::SeqAn PRIVATE kseq++::kseq++) ``` -------------------------------- ### Write FASTQ/A Records to a File with Low-level KStream API Source: https://github.com/cartoonist/kseqpp/blob/main/README.md Write records using the low-level KStream API. Explicitly call ks << kend before closing the file descriptor to ensure all data is written. ```c++ #include #include #include using namespace klibpp; int main(int argc, char* argv[]) { int fd = open(filename, O_WRONLY); auto ks = make_kstream(fd, write, mode::out); // auto ks = KStreamOut(fd, write); // C++ 17 // ... for (KSeq const& r : records) ks << r; ks << kend; close(fd); } ``` -------------------------------- ### Define kseq++ Test Executable Source: https://github.com/cartoonist/kseqpp/blob/main/test/CMakeLists.txt Defines the 'kseq++-test' executable, specifying its source file, compile options, include directories, and linked libraries. It includes debug flags and links against the kseq++ library. ```cmake add_executable(kseq++-test src/kseq++_test.cpp) target_compile_options(kseq++-test PRIVATE -g -Wall -Wpedantic -Werror) target_include_directories(kseq++-test PRIVATE ${PROJECT_SOURCE_DIR}/test/include PRIVATE kseq++::kseq++) target_link_libraries(kseq++-test PRIVATE kseq++::kseq++) ``` -------------------------------- ### Define Custom Test Target Source: https://github.com/cartoonist/kseqpp/blob/main/test/CMakeLists.txt Creates a custom 'test' target that executes both 'kseq++-test' and 'seqio-test' with specified data files. This target depends on the successful compilation of the test executables and sets the working directory for execution. ```cmake add_custom_target(test COMMAND ./test/kseq++-test ${PROJECT_SOURCE_DIR}/test/kseq++_test.dat COMMAND ./test/seqio-test ${PROJECT_SOURCE_DIR}/test/kseq++_test.dat DEPENDS kseq++-test seqio-test WORKING_DIRECTORY ${PROJECT_BINARY_DIR} ) ``` -------------------------------- ### Read FASTQ/A Records into a Vector with Low-level KStream API Source: https://github.com/cartoonist/kseqpp/blob/main/README.md Use the low-level KStream API to read all or a chunk of records into a vector. Ensure the file descriptor is properly managed. ```c++ #include #include #include using namespace klibpp; int main(int argc, char* argv[]) { gzFile fp = gzopen(filename, "r"); auto ks = make_ikstream(fp, gzread); auto records = ks.read(); // fetch all the records // auto records = ks.read(100); // read a chunk of 100 records gzclose(fp); } ``` -------------------------------- ### SeqStreamOut: Format Modifiers and Line Wrapping Source: https://context7.com/cartoonist/kseqpp/llms.txt Explains how to control output format mid-stream using format modifiers and adjust FASTA line wrapping with methods like `set_wraplen()`, `set_wrapping()`, and `set_nowrapping()`. ```APIDOC ## SeqStreamOut — Format Modifiers and Line Wrapping Output format can be switched mid-stream using `format::fasta`, `format::fastq`, and `format::mix` stream modifiers. FASTA sequences are wrapped at 60 bp by default; wrapping is controllable via `set_wraplen()`, `set_wrapping()`, and `set_nowrapping()`. ### Usage Examples: * **Switch format inline and adjust line wrapping:** ```cpp #include #include using namespace klibpp; SeqStreamOut oss("out.fa"); // Switch format inline oss << format::fasta << fq; // write FASTQ record in FASTA format oss << fa; // still FASTA mode oss << format::mix; // revert to auto-detect // Adjust FASTA line wrapping oss.set_wraplen(80); // wrap at 80 bp oss << fa; oss.set_nowrapping(); // disable wrapping entirely oss << fa; oss.set_wrapping(); // re-enable wrapping at default 60 bp oss << fa; ``` * **Query stream state:** ```cpp // ... (previous code) std::cout << "Records written: " << oss.counts() << "\n"; std::cout << "Current format: " << oss.get_format() << "\n"; // 0=mix,1=fasta,2=fastq std::cout << "Stream ok: " << (bool(oss) ? "yes" : "no") << "\n"; ``` ``` -------------------------------- ### Write FASTQ/A Records to a File with SeqStreamOut Source: https://github.com/cartoonist/kseqpp/blob/main/README.md Write KSeq records to an uncompressed file using SeqStreamOut. The stream is automatically flushed when the object goes out of scope. ```c++ #include #include using namespace klibpp; int main(int argc, char* argv[]) { SeqStreamOut oss("file.dat"); for (KSeq const& r : records) oss << r; } ``` -------------------------------- ### Write FASTQ Records to a Gzipped FASTA File Source: https://github.com/cartoonist/kseqpp/blob/main/README.md Write a series of FASTQ records to a gzipped file in FASTA format by specifying compression and format options in SeqStreamOut. ```c++ #include #include using namespace klibpp; int main(int argc, char* argv[]) { /* let `record` be a list of FASTQ records */ SeqStreamOut oss("file.fa.gz", /* compression */ true, format::fasta); for (KSeq const& r : records) oss << r; } ``` -------------------------------- ### Read FASTQ/A Records into a Vector with SeqStreamIn Source: https://github.com/cartoonist/kseqpp/blob/main/README.md Fetch records into a std::vector in chunks using SeqStreamIn. This is efficient for processing multiple records at once. ```c++ #include #include using namespace klibpp; int main(int argc, char* argv[]) { SeqStreamIn iss("file.fq"); auto records = iss.read(); // auto records = iss.read(100); // read a chunk of 100 records } ``` -------------------------------- ### Force Output Format in C++ Source: https://github.com/cartoonist/kseqpp/blob/main/README.md Use format modifiers to explicitly set the output format to FASTA or FASTQ. These modifiers affect all subsequent writes until another modifier is applied. Use `format::mix` to revert to default behavior. ```c++ out << format::fasta << fastq_record; out << another_record; // all other calls after this will also be in FASTA format. ``` -------------------------------- ### SeqStreamIn Class Source: https://context7.com/cartoonist/kseqpp/llms.txt SeqStreamIn is a high-level reader for sequence files. It transparently handles both gzip-compressed and plain-text FASTA/FASTQ files. It supports record-by-record streaming, bulk reads into a vector, and chunked reads. ```APIDOC ## SeqStreamIn — High-Level Sequence File Reader `SeqStreamIn` (defined in `seqio.hpp`) opens a file by name or file descriptor using `gzFile` internally, transparently handling both gzip-compressed and plain-text FASTA/FASTQ files. It supports both record-by-record streaming and bulk reads into a `std::vector`. ```cpp #include #include using namespace klibpp; int main() { KSeq record; // --- Record-by-record streaming (gzip or plain) --- SeqStreamIn iss("reads.fq.gz"); while (iss >> record) { std::cout << record.name; if (!record.comment.empty()) std::cout << " " << record.comment; std::cout << "\n" << record.seq << "\n"; if (!record.qual.empty()) std::cout << "+\n" << record.qual << "\n"; } // --- Bulk read: all records into a vector --- SeqStreamIn iss2("genome.fa"); std::vector all = iss2.read(); std::cout << "Loaded " << all.size() << " records\n"; // --- Chunked read: 100 records at a time --- SeqStreamIn iss3("large.fq.gz"); while (true) { auto chunk = iss3.read(100); if (chunk.empty()) break; std::cout << "Processing chunk of " << chunk.size() << " records\n"; // process chunk... } // --- Open by file descriptor --- int fd = open("reads.fa", O_RDONLY); SeqStreamIn iss4(fd); while (iss4 >> record) { /* process */ } return 0; } ``` ``` -------------------------------- ### KStream: Low-Level Input Stream Source: https://context7.com/cartoonist/kseqpp/llms.txt Details the `KStream` template class for reading from various file types (e.g., `gzFile`, `FILE*`, POSIX `int` fd) using `make_kstream` or `make_ikstream` for C++11/14 template argument deduction. ```APIDOC ## KStream (Low-Level) — Input Stream with `make_kstream` / `make_ikstream` The `KStream` template class works with any file type (e.g., `gzFile`, `FILE*`, POSIX `int` fd) and its matching read function. Use `make_kstream` or `make_ikstream` to construct input streams with C++11/14 template argument deduction. ### Usage Examples: * **`gzFile` input stream (C++11/14 compatible via `make_ikstream`):** ```cpp #include #include #include #include using namespace klibpp; const char* filename = "input.fq.gz"; // Replace with actual filename KSeq record; gzFile fp = gzopen(filename, "r"); auto iks = make_ikstream(fp, gzread); while (iks >> record) { std::cout << ">" << record.name << " " << record.comment << "\n" << record.seq << "\n"; } gzclose(fp); // manual close when not using RAII close function ``` * **Inspect stream state:** ```cpp // ... (previous code) std::cout << "Records parsed: " << iks.counts() << "\n"; if (iks.err()) std::cerr << "Read error\n"; if (iks.eof()) std::cout << "EOF reached\n"; if (iks.tqs()) std::cerr << "Truncated quality string detected\n"; if (iks.fail()) std::cerr << "Stream in failed state\n"; ``` * **RAII-style cleanup with `make_kstream`:** ```cpp #include #include using namespace klibpp; gzFile fp2 = gzopen(filename, "r"); auto iks2 = make_kstream(fp2, gzread, mode::in, gzclose); // gzclose called automatically when iks2 is destroyed ``` * **Bulk read variant:** ```cpp #include #include using namespace klibpp; gzFile fp3 = gzopen(filename, "r"); auto iks3 = make_ikstream(fp3, gzread); auto all = iks3.read(); // all records auto first10 = iks3.read(10); // read up to 10 more gzclose(fp3); ``` ``` -------------------------------- ### Set Build Type to Debug Source: https://github.com/cartoonist/kseqpp/blob/main/test/CMakeLists.txt Enables assertions by setting the CMAKE_BUILD_TYPE to 'Debug'. This should be done early in the CMakeLists.txt file. ```cmake set(CMAKE_BUILD_TYPE "Debug") ``` -------------------------------- ### KSeq Struct: Sequence Record Source: https://context7.com/cartoonist/kseqpp/llms.txt The KSeq struct holds FASTA/FASTQ record data. Use clear() to reset fields for reuse. Fields comment and qual may be empty for FASTA. ```cpp #include using namespace klibpp; KSeq record; // Fields available after parsing: // record.name — sequence identifier (no leading > or @) // record.comment — everything after the first space on the header line (may be empty) // record.seq — nucleotide/amino acid sequence string // record.qual — quality string (empty for FASTA records) // Manual construction and inspection record.name = "read1"; record.comment = "length=150 flag=0"; record.seq = "ACGTACGTACGT"; record.qual = "IIIIIIIIIIII"; std::cout << "Name: " << record.name << "\n"; std::cout << "Comment: " << record.comment << "\n"; std::cout << "Seq len: " << record.seq.size() << "\n"; std::cout << "Has qual: " << (!record.qual.empty() ? "yes" : "no") << "\n"; record.clear(); // reset all fields to empty ``` -------------------------------- ### KSeq Struct Source: https://context7.com/cartoonist/kseqpp/llms.txt The KSeq struct holds a single FASTA or FASTQ record. Fields like name, comment, seq, and qual are available as std::string members. The clear() method can be used to reset all fields for record reuse. ```APIDOC ## KSeq — Sequence Record Struct The `KSeq` struct (namespace `klibpp`) holds a single FASTA or FASTQ record. Fields `comment` and `qual` may be empty for FASTA records. The `clear()` method resets all fields for record reuse. ```cpp #include using namespace klibpp; KSeq record; // Fields available after parsing: // record.name — sequence identifier (no leading > or @) // record.comment — everything after the first space on the header line (may be empty) // record.seq — nucleotide/amino acid sequence string // record.qual — quality string (empty for FASTA records) // Manual construction and inspection record.name = "read1"; record.comment = "length=150 flag=0"; record.seq = "ACGTACGTACGT"; record.qual = "IIIIIIIIIIII"; std::cout << "Name: " << record.name << "\n"; std::cout << "Comment: " << record.comment << "\n"; std::cout << "Seq len: " << record.seq.size() << "\n"; std::cout << "Has qual: " << (!record.qual.empty() ? "yes" : "no") << "\n"; record.clear(); // reset all fields to empty ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.