Scaffolding  0.1
This program can assemble genome scaffolds using the pairing information in paired-end reads.
write_adj_list.hpp
1 /*
2  Writes edgelist
3  This works, but could use some polishing.
4 */
5 
6 /* ----------------------------------------------------------------- */
7 
8 #ifndef BOOST_GRAPH_WRITE_ADJ_LIST_GRAPH_HPP
9 #define BOOST_GRAPH_WRITE_ADJ_LIST_GRAPH_HPP
10 
11 #include <iostream>
12 
13 #include <boost/graph/graph_traits.hpp>
14 #include "utils/graph_typedefs.hpp"
15 #include "utils/scaffolding_typedefs.hpp"
16 
17 
18 namespace scaffold { namespace io {
19 
20  // write the graph g to the outstream "out"
21  void write_adj_list_graph(std::ostream& out, const Instance& I){
22  // write # vertices
23  const RawScaffoldGraph& g = I.get_graph();
24  out << boost::num_vertices(g) << std::endl << '&' << std::endl;
25 
26  // adjacency lists. To this end, iterate over all vertices & print their adjacent vertices one by one
27  for(ScafVIterRange ur = boost::vertices(g); ur.first != ur.second; ++ur.first){
28  const ScafVertex& u = *ur.first;
29  // output vertex name + some spaces
30  out << g[u].name << '\t';
31  // for each incident edge output the target and its weight if the index of the target is larger than our own
32  for(ScafOEdgeIterRange er = boost::out_edges(u, g); er.first != er.second; ++er.first){
33  // only output edges from smaller to larger index
34  const ScafVertex& v = boost::target(*er.first, g);
35  if(g[u].index < g[v].index)
36  out << g[v].name << ',' << g[*er.first].weight << ' ';
37  } // for
38  // close the line
39  out << std::endl;
40  }
41  } // function
42 }} // namespace
43 
44 #endif
Definition: read_adj_list.hpp:22
Definition: read_phytree.hpp:10