Skip to content

Commit

Permalink
restylized.
Browse files Browse the repository at this point in the history
  • Loading branch information
yatisht committed Oct 29, 2021
1 parent 05c3f19 commit 48549b3
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/matOptimize/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ int main(int argc, char **argv) {
}
if (allow_drift) {
nodes_to_search=bfs_ordered_nodes;
}else {
find_nodes_to_move(bfs_ordered_nodes, nodes_to_search,isfirst,radius,t);
} else {
find_nodes_to_move(bfs_ordered_nodes, nodes_to_search,isfirst,radius,t);
}
if (search_proportion<1) {
std::vector<MAT::Node *> nodes_to_search_temp;
Expand Down
6 changes: 3 additions & 3 deletions src/matOptimize/optimize_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@ void optimize_tree_main_thread(std::vector<size_t> &nodes_to_search,
tbb::flow::graph g;
std::vector<std::string> defered_node_identifier;
resolver_node_t resover_node(g, 1,
Conflict_Resolver(potential_crosses,
deferred_moves,
&defered_node_identifier));
Conflict_Resolver(potential_crosses,
deferred_moves,
&defered_node_identifier));
std::thread move_reciever(MPI_recieve_move,std::ref(dfs_ordered_nodes),std::ref(resover_node));
//progress bar
searcher_node_t searcher(g,num_threads+1,move_searcher{dfs_ordered_nodes,radius,allow_drift});
Expand Down
16 changes: 6 additions & 10 deletions src/matUtils/annotate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ void assignLineages (MAT::Tree& T, const std::string& clade_to_nid_filename, boo
fprintf(stderr, "Completed in %ld msec \n\n", timer.Stop());
}

MAT::Mutation* mutation_from_string(const std::string& mut_string)
{
MAT::Mutation* mutation_from_string(const std::string& mut_string) {
// Parse string like /[A-Z][0-9]+[A-Z]/ e.g. A23403G; create & return (pointer to) MAT::Mutation
// with par_nuc set to ref_nuc (same as VCF parsing code in usher.cpp).
// If mut_string is not in expected format, print error message and return NULL.
Expand All @@ -231,8 +230,7 @@ MAT::Mutation* mutation_from_string(const std::string& mut_string)
}

void parse_clade_mutations(const std::string& clade_mutations_filename,
std::map<std::string, std::vector<MAT::Mutation>>& clade_mutations)
{
std::map<std::string, std::vector<MAT::Mutation>>& clade_mutations) {
std::ifstream infile(clade_mutations_filename);
if (!infile) {
fprintf(stderr, "ERROR: Could not open the clade mutations file: %s!\n", clade_mutations_filename.c_str());
Expand Down Expand Up @@ -296,16 +294,15 @@ void parse_clade_mutations(const std::string& clade_mutations_filename,
void parse_clade_names(const std::string& clade_filename,
std::map<std::string, std::vector<MAT::Mutation>>& clade_mutations,
std::map<std::string, std::vector<MAT::Node*>>& clade_map,
MAT::Tree& uncondensed_T, float min_freq, float mask_freq)
{
MAT::Tree& uncondensed_T, float min_freq, float mask_freq) {
std::ifstream infile(clade_filename);
if (!infile) {
fprintf(stderr, "ERROR: Could not open the clade assignment file: %s!\n", clade_filename.c_str());
exit(1);
}
std::string line;

//Read the clade assignment file line by line and fill up map values
//Read the clade assignment file line by line and fill up map values
fprintf(stderr, "Reading clade assignment file %s.\n", clade_filename.c_str());
timer.Start();
while (std::getline(infile, line)) {
Expand Down Expand Up @@ -514,7 +511,7 @@ void assignLineages (MAT::Tree& T, const std::string& clade_filename,
if (clade_filename != "") {
parse_clade_names(clade_filename, clade_mutations_map, clade_map, uncondensed_T,
min_freq, mask_freq);

}

struct Node_freq {
Expand Down Expand Up @@ -552,8 +549,7 @@ void assignLineages (MAT::Tree& T, const std::string& clade_filename,
return true;
} else if (this->clade_size > 0 && c.clade_size == 0) {
return false;
}
else {
} else {
return ((this->best_node_frequencies.size() < c.best_node_frequencies.size()) ||
((this->best_node_frequencies.size() == c.best_node_frequencies.size()) && (this->clade_size > c.clade_size)));
}
Expand Down
10 changes: 5 additions & 5 deletions src/matUtils/convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ std::unordered_map<std::string, std::vector<std::string>> read_metafiles_tax(std
exit(1);
}
continue;
}
}
std::string key = words[strain_column];
if ( seen_in_this_file.find(key) != seen_in_this_file.end() ) {
continue; // ignore duplicates in each metadata file
Expand All @@ -779,13 +779,13 @@ std::unordered_map<std::string, std::vector<std::string>> read_metafiles_tax(std
// if we haven't seen this sample yet
metadata[key] = std::vector<std::string>();
}
for (auto word : words){
for (auto word : words) {
metadata[key].push_back(word);
}
if (metadata[key].size() == header.size() - 1) {
metadata[key].push_back(""); // the case where the last column is empty
}
}
}
infile.close();
}
// Then use map to make taxodium encodings and check for defined/generic fields
Expand Down Expand Up @@ -849,7 +849,7 @@ std::unordered_map<std::string, std::vector<std::string>> read_metafiles_tax(std
fprintf(stderr, "-- %s\n", name.c_str());
}
}


for (auto &v : metadata) { // for each metadata value
// Build mappings for generic metadata types
Expand All @@ -864,7 +864,7 @@ std::unordered_map<std::string, std::vector<std::string>> read_metafiles_tax(std

}



fprintf(stderr, "\nPerforming conversion.\n");

Expand Down
2 changes: 1 addition & 1 deletion src/matUtils/extract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ usher_single_subtree_size == 0 && usher_minimum_subtrees_size == 0) {
tv = add_random + samples.size();
}
samples = fill_random_samples(&T, samples, tv, limit_lca);
}
}
//the final step of selection is to invert the set if prune is set
//this is done by getting all sample names which are not in the samples vector.
if (prune_samples) {
Expand Down

0 comments on commit 48549b3

Please sign in to comment.