Scaffolding  0.1
This program can assemble genome scaffolds using the pairing information in paired-end reads.
write_fasta.hpp
1 
2 #ifndef WRITE_FASTA
3 #define WRITE_FASTA
4 
5 #include <iostream>
6 #include <fstream>
7 #include <string>
8 
9 #include "utils/exceptions.hpp"
10 #include "utils/scaffolding_typedefs.hpp"
11 #include "utils/instance.hpp"
12 
13 #define FASTA_MAX_LINELENGTH 79
14 
15 namespace scaffold { namespace io {
16  // write the contigs into a fasta file
17  void write_contigs_as_fasta(std::ostream& out, SequenceMap& name_to_seq)
18  {
19  for(const auto& name_seq: name_to_seq){
20  out << ">" << name_seq.first << std::endl;
21  unsigned pos = 0;
22  try{
23  while(true){
24  const std::string buffer = name_seq.second.sequence.substr(pos, FASTA_MAX_LINELENGTH);
25  out << buffer << std::endl;
26  pos += FASTA_MAX_LINELENGTH;
27  }
28  } catch(std::out_of_range e) {};
29  }
30  }// function
31 }}// namespace
32 
33 #endif
Definition: read_adj_list.hpp:22
Definition: read_phytree.hpp:10