Commit 657a89ce authored by Mathieu Giraud's avatar Mathieu Giraud

core/output.{h,cpp}: CloneOutputAIRR, SampleOutputAIRR

See #2828 and #3457.
parent e0c43986
......@@ -47,6 +47,11 @@ void Output::add_warning(string code, string msg, string level)
json_add_warning(j, code, msg, level);
}
CloneOutput::~CloneOutput()
{
}
json CloneOutput::toJson()
{
return j;
......@@ -89,7 +94,7 @@ CloneOutput* SampleOutput::getClone(junction junction)
}
}
// .vidjil json output
void SampleOutputVidjil::out(ostream &s)
{
......@@ -102,3 +107,49 @@ void SampleOutputVidjil::out(ostream &s)
s << j.dump(2);
}
// AIRR .tsv output
map <string, string> CloneOutputAIRR::fields()
{
map <string, string> fields;
fields["locus"] = get("germline");
fields["sequence_id"] = get("id");
fields["clone_id"] = get("id");
fields["sequence"] = get("sequence");
fields["v_call"] = get(KEY_SEG, "5", "name");
fields["d_call"] = get(KEY_SEG, "4", "name");
fields["j_call"] = get(KEY_SEG, "3", "name");
return fields;
}
void SampleOutputAIRR::out(ostream &s)
{
vector <string> fields = {
"locus",
"consensus_count",
"v_call", "d_call", "j_call",
"sequence_id",
"sequence",
"sequence_alignment",
"germline_alignment",
"v_cigar", "d_cigar", "j_cigar",
"clone_id"
};
for (string f: fields)
s << f << "\t" ;
s << endl ;
for (auto it: clones)
{
map <string, string> clone_fields = static_cast<CloneOutputAIRR *>(it.second) -> fields();
for (string f: fields)
s << clone_fields[f] << "\t" ;
s << endl;
}
}
......@@ -34,6 +34,8 @@ public:
class CloneOutput : public Output
{
public:
virtual ~CloneOutput();
void setSeg(string subkey, json val);
json toJson();
......@@ -59,27 +61,24 @@ public:
};
/*
class CloneOutputFormatter
{
}
class CloneOutputFormatterCSV(CloneOutputFormatter)
// Native Json .vidjil format
// See vidjil-format.md
class SampleOutputVidjil : public SampleOutput
{
public:
void out(ostream &s);
};
}
class CloneOutputFormatterJson(CloneOutputFormatter)
// AIRR
// See http://docs.airr-community.org
class CloneOutputAIRR : public CloneOutput
{
public:
void out(ostream &s);
map <string, string> fields();
};
}
*/
// Native Json .vidjil format
// See vidjil-format.md
class SampleOutputVidjil : public SampleOutput
class SampleOutputAIRR : public SampleOutput
{
public:
void out(ostream &s);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment