diff --git a/src/common/assembly_graph/paths/bidirectional_path_io/bidirectional_path_output.cpp b/src/common/assembly_graph/paths/bidirectional_path_io/bidirectional_path_output.cpp index 7d790bb32..b2d365761 100644 --- a/src/common/assembly_graph/paths/bidirectional_path_io/bidirectional_path_output.cpp +++ b/src/common/assembly_graph/paths/bidirectional_path_io/bidirectional_path_output.cpp @@ -142,6 +142,15 @@ void GFAPathWriter::WritePaths12(const std::vector &edges, os_ << '\n'; } +void GFAPathWriter::WriteHeader() { + os_ << "H\t" + << "VN:Z:" << (version_ == Version::GFAv11 ? "1.1" : "1.2") << '\t' + << "sp:Z:" << version::flavour() << '-' << version::package() << '\t' + << "sg:Z:" << version::gitrev() << '\t' + << "sr:Z:" << version::refspec() << '\n'; +} + + void GFAPathWriter::WritePaths(const std::vector &edges, const std::string &name, const std::string &flags) { diff --git a/src/common/assembly_graph/paths/bidirectional_path_io/bidirectional_path_output.hpp b/src/common/assembly_graph/paths/bidirectional_path_io/bidirectional_path_output.hpp index 72403533a..384b12088 100644 --- a/src/common/assembly_graph/paths/bidirectional_path_io/bidirectional_path_output.hpp +++ b/src/common/assembly_graph/paths/bidirectional_path_io/bidirectional_path_output.hpp @@ -76,6 +76,9 @@ class GFAPathWriter : public gfa::GFAWriter { using JumpLinks = std::unordered_set>; void WriteJumpLinks(const JumpLinks &links); +protected: + void WriteHeader() override; + public: enum class Version { GFAv11, // Split gapped paths into segments diff --git a/src/common/io/graph/gfa_writer.cpp b/src/common/io/graph/gfa_writer.cpp index 628f952f0..f16557182 100644 --- a/src/common/io/graph/gfa_writer.cpp +++ b/src/common/io/graph/gfa_writer.cpp @@ -65,6 +65,7 @@ void GFAWriter::WriteLinks(const Component &gc) { } void GFAWriter::WriteSegmentsAndLinks(const Component &gc) { + WriteHeader(); WriteSegments(gc); WriteLinks(gc); } @@ -109,3 +110,9 @@ void GFAWriter::WriteVertexLinks(const VertexId &vertex, const Component &gc) { } } +void GFAWriter::WriteHeader() { + os_ << "H\t" + << "sp:Z:" << version::flavour() << '-' << version::package() << '\t' + << "sg:Z:" << version::gitrev() << '\t' + << "sr:Z:" << version::refspec() << '\n'; +} diff --git a/src/common/io/graph/gfa_writer.hpp b/src/common/io/graph/gfa_writer.hpp index 6b3edaf5b..98f1d709d 100644 --- a/src/common/io/graph/gfa_writer.hpp +++ b/src/common/io/graph/gfa_writer.hpp @@ -10,17 +10,13 @@ #include "assembly_graph/components/graph_component.hpp" #include "assembly_graph/core/graph.hpp" #include "io/utils/edge_namer.hpp" -#include "io/utils/id_mapper.hpp" -#include -#include #include namespace omnigraph { template class GraphComponent; - } namespace gfa { @@ -36,15 +32,20 @@ class GFAWriter { io::EdgeNamingF naming_f = io::IdNamingF()) : graph_(graph), edge_namer_(graph_, naming_f), - os_(os) { - } + os_(os) {} + + virtual ~GFAWriter() = default; void WriteSegmentsAndLinks() { + WriteHeader(); WriteSegments(); WriteLinks(); } void WriteSegmentsAndLinks(const Component &gc); + protected: + virtual void WriteHeader(); + private: void WriteSegments(); void WriteLinks(); @@ -62,4 +63,3 @@ class GFAWriter { }; } - diff --git a/src/include/version.hpp b/src/include/version.hpp index 775770d0d..49f16a228 100644 --- a/src/include/version.hpp +++ b/src/include/version.hpp @@ -6,6 +6,11 @@ //*************************************************************************** namespace version { +const char *major(); +const char *minor(); +const char *patch(); +const char *package(); +const char *flavour(); const char *refspec(); const char *gitrev(); };