Skip to content

Commit

Permalink
Added HP tag to filter. Started work on sort command
Browse files Browse the repository at this point in the history
  • Loading branch information
kcleal committed Jul 12, 2024
1 parent 1642994 commit c5ca172
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gw.ini
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ font_size=14
sv_arcs=true
mods=false
mods_qual_threshold=50
haplotags=0,1
session_file=

[view_thresholds]
Expand Down
1 change: 1 addition & 0 deletions src/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ namespace Menu {
else if (opts.menu_level == "low_memory") { tip = "The distance in base-pairs when using low-memory mode (reads are not buffered in this mode)"; }
else if (opts.menu_level == "mods") { tip = "Display modified bases"; }
else if (opts.menu_level == "mods_qual_threshold") { tip = "Threshold (>) for displaying modified bases [0-255]"; }
else if (opts.menu_level == "haplotags") { tip = "Comma-seperated list of haplotype tags to display, derived from the HP bam-tag"; }
else if (opts.menu_level == "scroll_right") { tip = "Keyboard key to use for scrolling right"; }
else if (opts.menu_level == "scroll_left") { tip = "Keyboard key to use for scrolling left"; }
else if (opts.menu_level == "scroll_down") { tip = "Keyboard key to use for scrolling down"; }
Expand Down
5 changes: 5 additions & 0 deletions src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace Parse {
opMap["AS"] = AS;
opMap["BX"] = BX;
opMap["RX"] = RX;
opMap["HP"] = HP;

opMap["eq"] = EQ;
opMap["ne"] = NE;
Expand Down Expand Up @@ -133,6 +134,7 @@ namespace Parse {
permit[TC] = numeric_like;
permit[UQ] = numeric_like;
permit[AS] = numeric_like;
permit[HP] = numeric_like;

permit[PATTERN] = string_like;

Expand Down Expand Up @@ -611,6 +613,9 @@ namespace Parse {
case AS:
getIntTag("AS", int_val, aln);
break;
case HP:
getIntTag("HP", int_val, aln);
break;
case CIGAR:
getCigarStr(str_val, aln);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace Parse {
ABS_TLEN = 3007,
SEQ_LEN = 3008,
NM = 3009, CM = 3010, FI = 3011, HO = 3012, MQ = 3013, SM = 3014, TC = 3015, UQ = 3016, AS = 3017,
TID = 3018, MID = 3019,
TID = 3018, MID = 3019, HP = 3020,

// Patterns
PATTERN = 3500,
Expand Down
28 changes: 28 additions & 0 deletions src/plot_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,33 @@ namespace Commands {
return Err::NONE;
}

Err sort_command(Plot* p, std::string& command, std::vector<std::string> parts, std::ostream& out) {
if (parts.size() == 1) {

return Err::NONE;
}
if (parts[1] != "hap" && parts[1] != "strand") {
return Err::OPTION_NOT_SUPPORTED;
}

if (parts.size() == 2) {
int n_groups = 2;
std::vector<int> groups = {0, 1};
} else {
std::vector<int> groups;
for (int i=2; i < (int)parts.size(); ++i) {
try {
groups.push_back(std::stoi(parts[i]));
} catch (...) {
return Err::OPTION_NOT_UNDERSTOOD;
}
}
int n_groups = (int)groups.size();

}
return Err::NONE;
}

void cache_command_or_handle_err(Plot* p, Err result, std::ostream& out,
std::vector<std::string>* applied, std::string& command) {
switch (result) {
Expand Down Expand Up @@ -1481,6 +1508,7 @@ namespace Commands {
{"colour", PARAMS { return update_colour(p, command, parts, out); }},
{"color", PARAMS { return update_colour(p, command, parts, out); }},
{"roi", PARAMS { return add_roi(p, command, parts, out); }},
{"group", PARAMS { return sort_command(p, command, parts, out); }},

{"count", PARAMS { return count(p, command, out); }},
{"filter", PARAMS { return addFilter(p, command, out); }},
Expand Down
1 change: 1 addition & 0 deletions src/plot_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ namespace Manager {
pool.reset(opts.threads);
}
triggerClose = false;
sortReadsBy = Manager::SortType::NONE;
}

GwPlot::~GwPlot() {
Expand Down
9 changes: 9 additions & 0 deletions src/plot_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ namespace Manager {
SETTINGS
};

enum SortType {
NONE,
STRAND,
HP
};

class HiddenWindow {
public:
HiddenWindow () = default;
Expand Down Expand Up @@ -88,6 +94,9 @@ namespace Manager {
bool drawLine;

bool terminalOutput; // recoverable runtime errors and output sent to terminal or outStr

SortType sortReadsBy;

std::ostringstream outStr;

std::vector<char> pixelMemory;
Expand Down
2 changes: 1 addition & 1 deletion src/term_out.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@ namespace Term {
}

#if !defined(__EMSCRIPTEN__)
const char* CURRENT_VERSION = "v0.10.0";
const char* CURRENT_VERSION = "v0.10.1";

size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp) {
((std::string*)userp)->append((char*)contents, size * nmemb);
Expand Down

0 comments on commit c5ca172

Please sign in to comment.