Skip to content

Commit

Permalink
added option to display time for each step
Browse files Browse the repository at this point in the history
  • Loading branch information
genicos committed Dec 17, 2024
1 parent b53876a commit 05daa8b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Other options:
[default: ]
-Q <seed> Integer seed for random number generation. [default: 42]
-V --version Show version.
--time Show time taken at each step
-h --help Show this screen.
-D --dump Dump all seeds to file.
-X --dump-real Dump true seeds to file.
Expand Down Expand Up @@ -293,6 +294,8 @@ int main(int argc, const char** argv) {
bool placement_per_read = args["--place-per-read"] && args["--place-per-read"].isBool() ? args["--place-per-read"].asBool() : false;
bool genotype_from_sam = args["--genotype-from-sam"] && args["--genotype-from-sam"].isBool() ? args["--genotype-from-sam"].asBool() : false;
bool save_jaccard = args["--save-jaccard"] && args["--save-jaccard"].isBool() ? args["--save-jaccard"].asBool() : false;
bool show_time = args["--time"] && args["--time"].isBool() ? args["--time"].asBool() : false;


int k = std::stoi(args["-k"].asString());
int s = std::stoi(args["-s"].asString());
Expand Down Expand Up @@ -454,7 +457,7 @@ int main(int argc, const char** argv) {
std::cerr << "Reference node (" << refNode << ") specified but not found in the pangenome." << std::endl;
return 1;
}
pmi::place(T, index_input, reads1, reads2, mutMat, prefix, refFileName, samFileName, bamFileName, mpileupFileName, vcfFileName, aligner, refNode, save_jaccard);
pmi::place(T, index_input, reads1, reads2, mutMat, prefix, refFileName, samFileName, bamFileName, mpileupFileName, vcfFileName, aligner, refNode, save_jaccard, show_time);
}

auto end = std::chrono::high_resolution_clock::now();
Expand Down
18 changes: 17 additions & 1 deletion src/pmi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2363,8 +2363,9 @@ void pmi::place(
Tree *T, Index::Reader &index, const std::string &reads1Path, const std::string &reads2Path,
seed_annotated_tree::mutationMatrices &mutMat, std::string prefix,std::string refFileName,
std::string samFileName, std::string bamFileName, std::string mpileupFileName, std::string vcfFileName,
std::string aligner, const std::string& refNode, const bool& save_jaccard)
std::string aligner, const std::string& refNode, const bool& save_jaccard, bool show_time)
{
time_stamp();
// Setup for seed indexing
seed_annotated_tree::mutableTreeData data;

Expand Down Expand Up @@ -2564,6 +2565,10 @@ void pmi::place(
}

if (aligner == "minimap2") {
double time = time_stamp();
if(show_time){
std::cerr << "Placement time: " << time << "\n";
}
//Create SAM
std::vector<char *> samAlignments;
std::string samHeader;
Expand All @@ -2582,6 +2587,12 @@ void pmi::place(
samAlignments,
samHeader
);

time = time_stamp();
if(show_time){
std::cerr << "Alignment time: " << time << "\n";
}

//Convert to BAM
sam_hdr_t *header;
bam1_t **bamRecords;
Expand Down Expand Up @@ -2611,6 +2622,11 @@ void pmi::place(
0.0011
);

time = time_stamp();
if(show_time){
std::cerr << "Genotyping time: " << time << "\n";
}

// //std::string mpileupFileName = "MPILEUP";
// //Convert to Mplp
// char *mplpString;
Expand Down
4 changes: 2 additions & 2 deletions src/seed_annotated_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ std::chrono::time_point<std::chrono::high_resolution_clock> global_timer =
std::chrono::high_resolution_clock::now();


void time_stamp() {
double time_stamp() {
std::chrono::time_point<std::chrono::high_resolution_clock> newtime =
std::chrono::high_resolution_clock::now();
std::chrono::duration<float> duration = newtime - global_timer;
std::cerr << "timing " << duration.count() << "\n\n";
global_timer = newtime;
return duration.count();
}


Expand Down
2 changes: 1 addition & 1 deletion src/seed_annotated_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <unordered_map>
#include <vector>

void time_stamp();
double time_stamp();

using namespace seeding;

Expand Down

0 comments on commit 05daa8b

Please sign in to comment.