Commit 10b6e79d authored by Marc Duez's avatar Marc Duez

segment.cpp : use json c++11 lib

parent 719c3329
......@@ -1002,8 +1002,35 @@ void FineSegmenter::toJsonList(JsonList *seg){
json_cdr->add("stop", CDR3end);
seg->add("cdr3", *json_cdr);
}
}
}
json FineSegmenter::toJson(){
json seg;
if (isSegmented()) {
seg["5"] = segmented_germline->rep_5.label(best_V);
seg["5start"] = 0;
seg["5end"] = Vend;
if (score_D.size()>0){
seg["4"] = segmented_germline->rep_4.label(best_D);
seg["4start"] = Dstart;
seg["4end"] = Dend;
}
seg["3"] = segmented_germline->rep_3.label(best_J);
seg["3start"] = Jstart;
if (CDR3start >= 0) {
seg["cdr3"] = {
{"start", CDR3start},
{"stop", CDR3end}
};
}
}
return seg;
}
void KmerSegmenter::toJsonList(JsonList *seg)
......@@ -1036,4 +1063,29 @@ void KmerSegmenter::toJsonList(JsonList *seg)
delete json_affectSigns;
}
json KmerSegmenter::toJson() {
json seg;
int sequenceSize = sequence.size();
if (evalue > NO_LIMIT_VALUE)
seg["_evalue"] = scientific_string_of_double(evalue);
if (evalue_left > NO_LIMIT_VALUE)
seg["_evalue_left"] = scientific_string_of_double(evalue_left);
if (evalue_right > NO_LIMIT_VALUE)
seg["_evalue_right"] = scientific_string_of_double(evalue_right);
seg["affectValues"] = {
{"start", 0},
{"stop", sequenceSize},
{"seq", getKmerAffectAnalyser()->toStringValues()}
};
seg["affectSigns"] = {
{"start", 0},
{"stop", sequenceSize},
{"seq", getKmerAffectAnalyser()->toStringSigns()}
};
return seg;
}
......@@ -11,6 +11,7 @@
#include "kmeraffect.h"
#include "affectanalyser.h"
#include "json.h"
#include "../lib/json.hpp"
#define EXTEND_D_ZONE 5
......@@ -33,6 +34,7 @@
using namespace std;
using json = nlohmann::json;
enum SEGMENTED { NOT_PROCESSED,
TOTAL_SEG_AND_WINDOW,
......@@ -195,6 +197,7 @@ class KmerSegmenter : public Segmenter
string getInfoLineWithAffects() const;
void toJsonList(JsonList *seg);
json toJson();
private:
void computeSegmentation(int strand, KmerAffect left, KmerAffect right,
......@@ -245,6 +248,7 @@ class FineSegmenter : public Segmenter
void findCDR3();
void toJsonList(JsonList *seg);
json toJson();
};
......
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