Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paths -> Walkers #5

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 34 additions & 13 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,28 @@ namespace svaha {
};

struct walker_t{
std::uint64_t rank;
std::uint64_t rank = 0;
char* pathname;
walker_t(){
rank = 0;
}

walker_t(){
this->rank = 0;
};

walker_t(char*& s){
this->rank = 0;
pliib::strcopy(s, this->pathname);
};

walker_t(std::string s){
pliib::strcopy(s.c_str(), this->pathname);
};

std::uint64_t get_next_rank(){
return ++rank;
};
walk_t add_node(svaha::node*& n, bool forward = true){
walk_t w(n, pathname, get_next_rank(), forward);
return w;
};
};

Expand Down Expand Up @@ -261,7 +273,7 @@ namespace svaha {
return ++curr_edge_id;
};
spp::sparse_hash_map<string, pre_contig> name_to_contig;
spp::sparse_hash_map<std::string, svaha::path> name_to_path;
spp::sparse_hash_map<std::string, svaha::walker_t> name_to_walker;

//spp::sparse_hash_map<string, vector<TVCF::variant>> name_to_variants;
void re_id(){
Expand Down Expand Up @@ -612,10 +624,16 @@ int main(int argc, char** argv){
}
TFA::getSequence(tf, c.first.c_str(), c.second.seq);
std::size_t numbp = c.second.breakpoints.size();


if (output_paths){
svaha::path cp(numbp);
cp.name = c.first;
sg.name_to_path[c.first] = cp;
// Create reference walkers to output ref paths.
//svaha::path cp(numbp);
//cp.name = c.first;
//sg.name_to_path[c.first] = cp;

svaha::walker_t walker(c.first);
sg.name_to_walker[c.first] = walker;
}


Expand All @@ -639,7 +657,7 @@ int main(int argc, char** argv){
// continue;
// }
svaha::node* n = sg.create_node();
pliib::strcopy(c.first.c_str(), n->contig);
//pliib::strcopy(c.first.c_str(), n->contig);
#ifdef DEBUG
cerr << c.second.seqlen << " " << pos << " " << brk - pos << endl;
#endif
Expand All @@ -649,7 +667,10 @@ int main(int argc, char** argv){
// Emit the node, caching it if we need it later for a variant.
cout << n->emit() << endl;
if (output_paths){
sg.name_to_path[c.first].add_node(n);
// Add a walk for the given node
//sg.name_to_path[c.first].add_node(n);
svaha::walk_t w = sg.name_to_walker[c.first].add_node(n);
cout << w.to_string() << endl;
}

//pliib::strdelete(n->seq);
Expand Down Expand Up @@ -899,9 +920,9 @@ int main(int argc, char** argv){

processed_alleles[allele->make_id()] = 1;
}
if (output_paths){
cout << sg.name_to_path[c.first].to_string() << endl;
}
// if (output_paths){
// cout << sg.name_to_path[c.first].to_string() << endl;
// }
}

pliib::strdelete(ref_file);
Expand Down