Skip to content

Commit

Permalink
Fix a bug in block order string where a bad index was used while outp…
Browse files Browse the repository at this point in the history
…utting paths
  • Loading branch information
edawson committed Apr 5, 2018
1 parent ad47105 commit 28325fc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
8 changes: 7 additions & 1 deletion src/gfakluge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ namespace gfak{
this->version = v;
verz.val = std::to_string((double) this->version).substr(0,3);
this->header[verz.key] = verz;
//gfa_1_ize();
//gfa_2_ize();
}
void GFAKluge::set_version(){
header_elem verz;
Expand Down Expand Up @@ -896,6 +898,10 @@ namespace gfak{
}

std::string GFAKluge::block_order_string(){

this->gfa_1_ize();
this->gfa_2_ize();

if (version >= 2.0){
return block_order_string_2();
}
Expand Down Expand Up @@ -960,7 +966,7 @@ namespace gfak{
vector<string> ovec;
for (int oi = 0; oi < pt->second.segment_names.size(); oi++){
stringstream o_str;
o_str << pt->second.segment_names[oi] << (pt->second.orientations[i] ? "-" : "+");
o_str << pt->second.segment_names[oi] << (pt->second.orientations[oi] ? "-" : "+");
ovec.push_back(o_str.str());
}
pat << join(ovec, ",");
Expand Down
23 changes: 17 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ int diff_main(int argc, char** argv){
int convert_main(int argc, char** argv){
string gfa_file = "";
bool block_order = false;
double spec_version = 0.1;
double spec_version = 2.0;
bool use_paths = true;

if (argc < 3){
Expand Down Expand Up @@ -538,7 +538,7 @@ int merge_main(int argc, char** argv){
int sort_main(int argc, char** argv){
string gfa_file = "";
bool block_order = true;
double spec = 0.0;
double spec_version = 2.0;

if (argc <= 2){
sort_help(argv);
Expand Down Expand Up @@ -574,7 +574,7 @@ int sort_main(int argc, char** argv){
exit(1);

case 'S':
spec = stod(optarg);
spec_version = stod(optarg);
break;

default:
Expand All @@ -586,10 +586,21 @@ int sort_main(int argc, char** argv){
GFAKluge gg;
gg.parse_gfa_file(gfa_file);

if (spec != 0){
gg.set_version(spec);
if (spec_version == 0.1){
gg.set_version(0.1);
}

else if (spec_version == 1.0){
gg.set_version(1.0);
}
else if (spec_version == 2.0){
gg.set_version(2.0);
}
else if (spec_version != 0.0){
cerr << "Invalid specification number: " << spec_version << endl
<< "Please provide one of [0.1, 1.0, 2.0]." << endl;
exit(22);
}

cout << gg.block_order_string();


Expand Down

0 comments on commit 28325fc

Please sign in to comment.