Skip to content

Commit

Permalink
added functional colors
Browse files Browse the repository at this point in the history
  • Loading branch information
gf777 committed Jun 21, 2024
1 parent a4c3fd8 commit 9ac9a02
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/kreeq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,20 @@ bool DBG::variantsToGFA(InSegment *inSegment, Log &threadLog) {

}

std::string colorPalette(uint8_t value){

const static phmap::parallel_flat_hash_map<uint8_t,std::string> value_to_color{ // map each value to a color
{0,"gray"},
{1,"blue"},
{2,"red"},
};
if (value > value_to_color.size()) {
fprintf(stderr, "Node color value %i does not exist\n", value);
exit(EXIT_FAILURE);
}
return (value_to_color.find(value)->second);
}

void DBG::DBGgraphToGFA() {

uint32_t idCounter = 0, seqPos = 0, edgeCounter = 0;
Expand Down Expand Up @@ -987,7 +1001,7 @@ void DBG::DBGgraphToGFA() {

Sequence* sequence = new Sequence {std::to_string(idCounter++), "", inSequence}; // add sequence
sequence->seqPos = seqPos; // remember the order
std::vector<Tag> inTags = {Tag{'i',"RC",std::to_string(pair->second.cov*k)},Tag{'z',"CL",std::to_string(pair->second.color)}};
std::vector<Tag> inTags = {Tag{'f',"DP",std::to_string(pair->second.cov)},Tag{'Z',"CB",colorPalette(pair->second.color)}};
GFAsubgraph.appendSegment(sequence, inTags);
seqPos++;

Expand Down Expand Up @@ -1061,7 +1075,7 @@ void DBG::DBGgraphToGFA() {
std::string* inSequence = new std::string(reverseHash(pair.first));
Sequence* sequence = new Sequence {std::to_string(idCounter++), "", inSequence};
sequence->seqPos = seqPos++; // remember the order
std::vector<Tag> inTags = {Tag{'i',"RC",std::to_string(pair.second.cov*k)},Tag{'z',"CL",std::to_string(pair.second.color)}};
std::vector<Tag> inTags = {Tag{'f',"DP",std::to_string(pair.second.cov)},Tag{'Z',"CB",colorPalette(pair.second.color)}};
GFAsubgraph.appendSegment(sequence, inTags);
}
jobWait(threadPool);
Expand Down

0 comments on commit 9ac9a02

Please sign in to comment.