Skip to content

Commit

Permalink
Merge pull request #4296 from vgteam/read-lr-giraffe
Browse files Browse the repository at this point in the history
Allow reading GAMs with embedded JSON metadata
  • Loading branch information
adamnovak authored May 23, 2024
2 parents 4a86fc5 + c70da62 commit db574a5
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/io/register_libvg_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "register_loader_saver_packed_graph.hpp"
#include "register_loader_saver_hash_graph.hpp"
#include "register_loader_saver_gfa.hpp"
#include "register_loader_params_json.hpp"

#include "register_libvg_io.hpp"

Expand All @@ -46,6 +47,7 @@ bool register_libvg_io() {
register_loader_saver_xg();
register_loader_saver_packed_graph();
register_loader_saver_hash_graph();
register_loader_params_json();
return true;
}

Expand Down
29 changes: 29 additions & 0 deletions src/io/register_loader_params_json.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* \file register_loader_params_json.cpp
* Defines IO for a VG graph from stream files of Graph objects.
*/

#include <vg/io/registry.hpp>
#include "register_loader_params_json.hpp"

#include <iterator>


namespace vg {

namespace io {

using namespace std;
using namespace vg::io;

void register_loader_params_json() {
Registry::register_loader<std::string>("PARAMS_JSON", wrap_bare_loader([](std::istream& stream) -> void* {
// Read the whole stream with an iterator. See <https://stackoverflow.com/a/3203502>.
return new std::string(std::istreambuf_iterator<char>(stream), {});
}));
}

}

}

21 changes: 21 additions & 0 deletions src/io/register_loader_params_json.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef VG_IO_REGISTER_LOADER_PARAMS_JSON_HPP_INCLUDED
#define VG_IO_REGISTER_LOADER_PARAMS_JSON_HPP_INCLUDED

/**
* \file register_loader_params_json.hpp
* Defines IO for embedded parameters.
*/

namespace vg {

namespace io {

using namespace std;

void register_loader_params_json();

}

}

#endif

1 comment on commit db574a5

@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 17091 seconds

Please sign in to comment.