<commit_before><commit_msg>Example for `readRecord` with automatic file format detection.<commit_after>// FRAGMENT(header)
#include <fstream>
#include <iostream>

#include <seqan/basic.h>
#include <seqan/file.h>

#include <seqan/stream.h>

using namespace seqan;

int main(int argc, char const ** argv)
{
    if (argc != 2)
    {
        std::cerr << "ERROR: Invalid argument count." << std::endl
                  << "USAGE: " << argv[0] << " FILE" << std::endl;
        return 1;
    }
    
    // Open file and create RecordReader.
    std::ifstream fasta(argv[1], std::ios_base::in | std::ios_base::binary);
    if (!fasta.good())
        return 1;
    RecordReader<std::ifstream, SinglePass<> > reader(fasta);

// FRAGMENT(file-format)
    // Read FASTA file and output "$id\t$seq".
    AutoSeqStreamFormat formatTag;
    if (!checkStreamFormat(reader, formatTag))
    {
        std::cerr << "Could not determine file format!" << std::endl;
        return 1;
    }
    std::cout << "File format is " << getAutoSeqStreamFormatName(formatTag) << '\n';
    
    // Define variables for storing the sequences and sequence ids.
    CharString id;
    Dna5String seq;
// FRAGMENT(read-sequences)
    while (!atEnd(reader))
    {
        if (readRecord(id, seq, reader, formatTag) != 0)
        {
            std::cerr << "ERROR reading sequence file." << std::endl;
            return 1;
        }
        std::cout << id << "\t" << seq << "\n";
    }

// FRAGMENT(footer)    
    return 0;
}
{'fraction_non_alphanumeric': 0.15425888665325285, 'fraction_numerical': 0.00670690811535882, 'mean_word_length': 2.621359223300971, 'pattern_counts': {'":': 0, '<': 44, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6347044', 'n_tokens_mistral': 489, 'n_tokens_neox': 478, 'n_words': 124}