@@ -75,12 +75,21 @@ int64_t VGset::merge_id_space(void) {
75
75
}
76
76
77
77
void VGset::to_xg (xg::XG& index) {
78
+
79
+ function<void (const string&, std::ifstream&)> check_stream = [&](const string&name, std::ifstream& in) {
80
+ if (name == " -" ){
81
+ if (!in) throw ifstream::failure (" vg_set: cannot read from stdin. Failed to open " + name);
82
+ }
83
+
84
+ if (!in) throw ifstream::failure (" failed to open " + name);
85
+ };
78
86
79
87
// We need to recostruct full removed paths from fragmentary paths encountered in each chunk.
80
88
// This maps from path name to all the Mappings in the path in the order we encountered them
81
89
auto for_each_sequence = [&](const std::function<void (const std::string& seq, const nid_t & node_id)>& lambda) {
82
90
for (auto & name : filenames) {
83
91
std::ifstream in (name);
92
+ check_stream (name, in);
84
93
vg::io::for_each (in, (function<void (Graph&)>)[&](Graph& graph) {
85
94
for (uint64_t i = 0 ; i < graph.node_size (); ++i) {
86
95
auto & node = graph.node (i);
@@ -93,6 +102,7 @@ void VGset::to_xg(xg::XG& index) {
93
102
auto for_each_edge = [&](const std::function<void (const nid_t & from, const bool & from_rev, const nid_t & to, const bool & to_rev)>& lambda) {
94
103
for (auto & name : filenames) {
95
104
std::ifstream in (name);
105
+ check_stream (name, in);
96
106
vg::io::for_each (in, (function<void (Graph&)>)[&](Graph& graph) {
97
107
for (uint64_t i = 0 ; i < graph.edge_size (); ++i) {
98
108
auto & edge = graph.edge (i);
@@ -107,6 +117,7 @@ void VGset::to_xg(xg::XG& index) {
107
117
map<string, vector<pair<nid_t , bool >>> paths;
108
118
for (auto & name : filenames) {
109
119
std::ifstream in (name);
120
+ check_stream (name, in);
110
121
vg::io::for_each (in, (function<void (Graph&)>)[&](Graph& graph) {
111
122
for (uint64_t i = 0 ; i < graph.path_size (); ++i) {
112
123
auto & path = graph.path (i);
0 commit comments