It turns out we no longer need any of this logic to handle GFA input specially.
At https://github.com/babyplutokurt/vg/blame/842fdc5cef32eac62fda9feaade0c34e10f5fc7b/src/subcommand/convert_main.cpp#L304-L306 we decided we needed to handle GFA here separate from the normal load-a-HandleGraph codepath so that we could keep the filename around and use the disk-backed GFA loader, and also so we could stream straight to XG without a HandleGraph in memory. But then we decided to set up the HandleGraph load path so it could track filenames (see https://github.com/vgteam/vg/blame/bf85ab04b251e7a2bc308750d6c8c44afda213f5/src/io/register_loader_saver_gfa.cpp#L96 and https://github.com/vgteam/libvgio/blame/65e0ba22246c7443b879f40d0bb69ac96c467107/include/vg/io/registry.hpp#L315-L322). And I had to remove the straight-to-XG code and use an intermediate HandleGraph anyway.
So now nothing important or special actually happens when input == input_gfa, and we should just treat it the same as input == input_handlegraph and use the vg::io::VPKG::load_one<HandleGraph>() approach. (We might want a warning if we load the HandleGraph and it is not an instance of GFAHandleGraph when we thought it would be.)
...
We'd also want to combine the corresponding cases in vg view:
|
} else if (input_type == "handlegraph") { |
|
if (output_type == "stream") { |
|
logger.error() << "Cannot stream a generic HandleGraph to JSON" << endl; |
|
} else { |
|
graph = vg::io::VPKG::load_one<PathHandleGraph>(file_name); |
|
} |
|
} else if (input_type == "gfa") { |
|
graph = make_unique<bdsg::HashGraph>(); |
|
|
|
try { |
|
// Use the disk-backed GFA loader that `vg convert` also uses. |
|
vg::algorithms::gfa_to_path_handle_graph(file_name, |
|
dynamic_cast<MutablePathMutableHandleGraph*>(graph.get()), |
|
nullptr, |
|
0); // set rgfa path rank to 0 to be consistent with vg convert's default logic |
|
} catch (vg::algorithms::GFAFormatError& e) { |
|
logger.error() << "Input GFA is not acceptable\n" << e.what() << endl; |
|
} catch (std::ios_base::failure& e) { |
|
logger.error() << "IO error processing input GFA\n" << e.what() << endl; |
|
} |
|
|
|
// GFA can convert to any of the graph formats, so keep going |
Originally posted by @adamnovak in #4861 (comment)
It turns out we no longer need any of this logic to handle GFA input specially.
At https://github.com/babyplutokurt/vg/blame/842fdc5cef32eac62fda9feaade0c34e10f5fc7b/src/subcommand/convert_main.cpp#L304-L306 we decided we needed to handle GFA here separate from the normal load-a-HandleGraph codepath so that we could keep the filename around and use the disk-backed GFA loader, and also so we could stream straight to XG without a HandleGraph in memory. But then we decided to set up the HandleGraph load path so it could track filenames (see https://github.com/vgteam/vg/blame/bf85ab04b251e7a2bc308750d6c8c44afda213f5/src/io/register_loader_saver_gfa.cpp#L96 and https://github.com/vgteam/libvgio/blame/65e0ba22246c7443b879f40d0bb69ac96c467107/include/vg/io/registry.hpp#L315-L322). And I had to remove the straight-to-XG code and use an intermediate HandleGraph anyway.
So now nothing important or special actually happens when
input == input_gfa, and we should just treat it the same asinput == input_handlegraphand use thevg::io::VPKG::load_one<HandleGraph>()approach. (We might want a warning if we load the HandleGraph and it is not an instance ofGFAHandleGraphwhen we thought it would be.)...
We'd also want to combine the corresponding cases in
vg view:vg/src/subcommand/view_main.cpp
Lines 557 to 578 in bf85ab0
Originally posted by @adamnovak in #4861 (comment)