11 #include "repertoire.h" 12 #include "genesegment.h" 17 #define CELL_FILL(i, limit, ofs, if_letter, else_letter) { if (i < limit - 1) { ofs << if_letter; } else { ofs << else_letter; } } 29 bool write(
const std::string &filepath,
32 bool append =
false)
const {
35 ofs.open(filepath, std::ofstream::out | std::ofstream::app);
41 ofs <<
"Nucleotide sequence" <<
'\t' <<
42 "Amino acid sequence" <<
'\t' <<
44 "Diversity" <<
'\t' <<
46 "V alignment" <<
'\t' <<
47 "D alignment" <<
'\t' <<
48 "J alignment" << std::endl;
52 for (
auto i = 0; i < cloneset.size(); ++i) {
53 if (cloneset[i].sequence_type() == NUCLEOTIDE) {
54 ofs << cloneset[i].sequence() <<
'\t';
55 ofs << translate(cloneset[i].sequence()) <<
'\t';
58 ofs << cloneset[i].sequence() <<
'\t';
61 for (
auto seg_i = 0; seg_i < cloneset[i].nVar(); ++seg_i) {
62 ofs << gene_segments.V()[cloneset[i].getVar(seg_i)].allele;
63 CELL_FILL(seg_i, cloneset[i].nVar(), ofs,
',',
'\t')
66 if (gene_segments.is_vdj()) {
67 for (
auto seg_i = 0; seg_i < cloneset[i].nDiv(); ++seg_i) {
68 ofs << gene_segments.D()[cloneset[i].getDiv(seg_i)].allele;
69 CELL_FILL(seg_i, cloneset[i].nDiv(), ofs,
',',
'\t')
75 for (
auto seg_i = 0; seg_i < cloneset[i].nJoi(); ++seg_i) {
76 ofs << gene_segments.J()[cloneset[i].getJoi(seg_i)].allele;
77 CELL_FILL(seg_i, cloneset[i].nJoi(), ofs,
',',
'\t')
80 for (
auto seg_i = 0; seg_i < cloneset[i].nVar(); ++seg_i) {
81 ofs << cloneset[i].getVarGeneStart(seg_i) <<
"|";
82 ofs << cloneset[i].getVarSeqStart(seg_i) <<
"|";
83 ofs << cloneset[i].getVarLen(seg_i);
84 CELL_FILL(seg_i, cloneset[i].nVar(), ofs,
',',
'\t')
87 if (gene_segments.is_vdj()) {
91 for (
auto seg_i = 0; seg_i < cloneset[i].nDiv(); ++seg_i) {
92 ofs << cloneset[i].getDivGeneStart(seg_i, 0) <<
"|";
93 ofs << cloneset[i].getDivSeqStart(seg_i, 0) <<
"|";
94 ofs << cloneset[i].getDivLen(seg_i, 0);
95 CELL_FILL(seg_i, cloneset[i].nDiv(), ofs,
';',
'\t')
101 for (
auto seg_i = 0; seg_i < cloneset[i].nJoi(); ++seg_i) {
102 ofs << cloneset[i].getJoiGeneStart(seg_i) <<
"|";
103 ofs << cloneset[i].getJoiSeqStart(seg_i) <<
"|";
104 ofs << cloneset[i].getJoiLen(seg_i);
105 CELL_FILL(seg_i, cloneset[i].nJoi(), ofs,
',', std::endl)
123 #endif //YMIR_WRITER_H
Definition: genesegment.h:265
Definition: repertoire.h:51