Skip to content

Commit

Permalink
Merge pull request #3264 from code-s-witch/min-cut-graph
Browse files Browse the repository at this point in the history
Add ensure_vg() to mcmc_main subcommand
  • Loading branch information
adamnovak authored May 21, 2021
2 parents f52d3a2 + 21027b8 commit 99cbb47
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
8 changes: 4 additions & 4 deletions scripts/mcmc_Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ $(TOIL_OS)/$(BASENAME)_thread_$(SAMP)_$(HAPLO_0).vg: $(TOIL_OS)/$(BASENAME)_$(HA
$(TOIL_OS)/$(BASENAME)_thread_$(SAMP)_$(HAPLO_0).xg: $(TOIL_OS)/$(BASENAME)_thread_$(SAMP)_$(HAPLO_0).vg
vg index -x $(TOIL_OS)/$(BASENAME)_thread_$(SAMP)_$(HAPLO_0).xg $(TOIL_OS)/$(BASENAME)_thread_$(SAMP)_$(HAPLO_0).vg

$(TOIL_OS)/$(BASENAME)_$(HAPLO_0).gam: $(TOIL_OS)/$(BASENAME)_thread_$(SAMP)_$(HAPLO_0).xg
toil-vg sim --gam --sim_opts '--sub-rate 0.1 --indel-rate 0.1 --read-length 100' --container None --out_name $(BASENAME)_$(HAPLO_0) $(TOIL_JS) $(TOIL_OS)/$(BASENAME)_thread_$(SAMP)_$(HAPLO_0).xg $(READS) $(TOIL_OS)
$(TOIL_OS)/$(BASENAME)_$(HAPLO_0).gam: $(TOIL_OS)/$(BASENAME).xg $(TOIL_OS)/$(BASENAME).gbwt
vg sim -x $(TOIL_OS)/$(BASENAME).xg -g $(TOIL_OS)/$(BASENAME).gbwt -m $(SAMP) -n 300 --sub-rate 0.05 --indel-rate 0.05 --read-length 100 -a > $(TOIL_OS)/$(BASENAME)_$(HAPLO_0).gam

$(TOIL_OS)/$(BASENAME)_$(HAPLO_1)_thread.merge.vg: $(TOIL_OS)/$(BASENAME).vg $(TOIL_OS)/$(BASENAME).gbwt $(TOIL_OS)/$(BASENAME).xg
vg paths -d -v $(TOIL_OS)/$(BASENAME).vg > $(TOIL_OS)/$(BASENAME)_$(HAPLO_1)_thread.merge.vg
Expand All @@ -65,8 +65,8 @@ $(TOIL_OS)/$(BASENAME)_thread_$(SAMP)_$(HAPLO_1).vg: $(TOIL_OS)/$(BASENAME)_$(HA
$(TOIL_OS)/$(BASENAME)_thread_$(SAMP)_$(HAPLO_1).xg: $(TOIL_OS)/$(BASENAME)_thread_$(SAMP)_$(HAPLO_1).vg
vg index -x $(TOIL_OS)/$(BASENAME)_thread_$(SAMP)_$(HAPLO_1).xg $(TOIL_OS)/$(BASENAME)_thread_$(SAMP)_$(HAPLO_1).vg

$(TOIL_OS)/$(BASENAME)_$(HAPLO_1).gam: $(TOIL_OS)/$(BASENAME)_thread_$(SAMP)_$(HAPLO_1).xg
toil-vg sim --gam --sim_opts '--sub-rate 0.1 --indel-rate 0.1 --read-length 100' --container None --out_name $(BASENAME)_$(HAPLO_1) $(TOIL_JS) $(TOIL_OS)/$(BASENAME)_thread_$(SAMP)_$(HAPLO_1).xg $(READS) $(TOIL_OS)
$(TOIL_OS)/$(BASENAME)_$(HAPLO_1).gam: $(TOIL_OS)/$(BASENAME).xg $(TOIL_OS)/$(BASENAME).gbwt
vg sim -x $(TOIL_OS)/$(BASENAME).xg -g $(TOIL_OS)/$(BASENAME).gbwt -m $(SAMP) -n 300 --sub-rate 0.05 --indel-rate 0.05 --read-length 100 -a > $(TOIL_OS)/$(BASENAME)_$(HAPLO_1).gam

$(TOIL_OS)/$(BASENAME)_merged.gam: $(TOIL_OS)/$(BASENAME)_$(HAPLO_0).gam $(TOIL_OS)/$(BASENAME)_$(HAPLO_1).gam
cat $(TOIL_OS)/$(BASENAME)_$(HAPLO_0).gam $(TOIL_OS)/$(BASENAME)_$(HAPLO_1).gam > $(TOIL_OS)/$(BASENAME)_merged.gam
Expand Down
28 changes: 24 additions & 4 deletions src/subcommand/mcmc_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,36 @@ int main_mcmc(int argc, char** argv) {
unique_ptr<SnarlManager> snarls = (vg::io::VPKG::load_one<SnarlManager>(snarls_file));

// // create a PathHandleGraph
unique_ptr<VG> vg_graph;
unique_ptr<PathHandleGraph> path_hgraph;
bdsg::PathPositionOverlayHelper overlay_helper;
vg_graph = vg::io::VPKG::load_one<VG>(graph_file);
path_hgraph = vg::io::VPKG::load_one<PathHandleGraph>(graph_file);

if(vg_graph.get() == nullptr || vg_graph.get() == 0){
// Some stuff below here needs a vg graph.
VG* vg_graph = dynamic_cast<vg::VG*>(path_hgraph.get());

// Call this to populate the vg_graph if it isn't populated.
auto ensure_vg = [&]() -> vg::VG* {
if (vg_graph == nullptr) {
// Copy instead.
vg_graph = new vg::VG();
handlealgs::copy_path_handle_graph(path_hgraph.get(), vg_graph);
// Give the unique_ptr ownership and delete the graph we loaded.
path_hgraph.reset(vg_graph);
// Make sure the paths are all synced up
vg_graph->paths.to_graph(vg_graph->graph);
}
return vg_graph;
};

//convert to VG graph if needed
ensure_vg();

if(vg_graph == nullptr || vg_graph == 0){
cerr << "Graph is NULL" <<endl;
exit(1);
}
PathPositionHandleGraph* graph = nullptr;
graph = overlay_helper.apply(vg_graph.get());
graph = overlay_helper.apply(vg_graph);


// Check our paths
Expand Down

1 comment on commit 99cbb47

@adamnovak
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vg CI tests complete for merge to master. View the full report here.

16 tests passed, 0 tests failed and 0 tests skipped in 11369 seconds

Please sign in to comment.