<commit_before>//
// Created by <NAME>. on 07/08/2015.
//

#ifndef YMIR_WRITER_H
#define YMIR_WRITER_H


#include <ostream>

#include "repertoire.h"
#include "genesegment.h"


namespace ymir {

    #define CELL_FILL(i, limit, ofs, if_letter, else_letter) { if (i < limit - 1) { ofs << if_letter; } else { ofs << else_letter; } }

    class RepertoireWriter {
    public:


        RepertoireWriter() { }


        virtual ~RepertoireWriter() { }


        bool write(const std::string &filepath,
                   const ClonesetView &cloneset,
                   const VDJRecombinationGenes& gene_segments,
                   bool append = false) const {
            std::ofstream ofs;

            ofs.open(filepath);

            if (ofs.is_open()) {

                // write the header
                ofs << "Nucleotide sequence" << '\t' <<
                        "Amino acid sequence" << '\t' <<
                        "Variable" << '\t' <<
                        "Diversity" << '\t' <<
                        "Joining" << '\t' <<
                        "V alignment" << '\t' <<
                        "D alignment" << '\t' <<
                        "J alignment" << std::endl;

                // write clonotypes
                for (auto i = 0; i < cloneset.size(); ++i) {
                    if (cloneset[i].sequence_type() == NUCLEOTIDE) {
                        ofs << cloneset[i].sequence() << '\t';
                        ofs << translate(cloneset[i].sequence()) << '\t';<commit_msg>streaming writer<commit_after>//
// Created by <NAME>. on 07/08/2015.
//

#ifndef YMIR_WRITER_H
#define YMIR_WRITER_H


#include <ostream>

#include "repertoire.h"
#include "genesegment.h"


namespace ymir {

    #define CELL_FILL(i, limit, ofs, if_letter, else_letter) { if (i < limit - 1) { ofs << if_letter; } else { ofs << else_letter; } }

    class RepertoireWriter {
    public:


        RepertoireWriter() { }


        virtual ~RepertoireWriter() { }


        bool write(const std::string &filepath,
                   const ClonesetView &cloneset,
                   const VDJRecombinationGenes& gene_segments,
                   bool append = false) const {
            std::ofstream ofs;

            ofs.open(filepath, std::ofstream::out | std::ofstream::app);

            if (ofs.is_open()) {

                if (!append) {
                    // write the header
                    ofs <<  "Nucleotide sequence" << '\t' <<
                            "Amino acid sequence" << '\t' <<
                            "Variable" << '\t' <<
                            "Diversity" << '\t' <<
                            "Joining" << '\t' <<
                            "V alignment" << '\t' <<
                            "D alignment" << '\t' <<
                            "J alignment" << std::endl;
                }

                // write clonotypes
                for (auto i = 0; i < cloneset.size(); ++i) {
                    if (cloneset[i].sequence_type() == NUCLEOTIDE) {
                        ofs << cloneset[i].sequence() << '\t';
                        ofs << translate(cloneset[i].sequence()) << '\t';
{'fraction_non_alphanumeric': 0.1409033078880407, 'fraction_numerical': 0.006361323155216285, 'mean_word_length': 1.3575712143928036, 'pattern_counts': {'":': 0, '<': 99, '<?xml version=': 0, '>': 7, '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': '7103174', 'n_tokens_mistral': 990, 'n_tokens_neox': 896, 'n_words': 208}