Changeset 579
- Timestamp:
- 05/17/10 14:24:29 (4 months ago)
- Location:
- current/src
- Files:
-
- 3 edited
-
dawg.cpp (modified) (1 diff)
-
include/dawg/output.h (modified) (4 diffs)
-
lib/output.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
current/src/dawg.cpp
r575 r579 131 131 const char *file_name = arg.output.empty() ? glopts.output_file.c_str() 132 132 : arg.output.c_str(); 133 unsigned int max_rep = (!arg.unsplit && (arg.split || glopts.output_split)) 134 ? num_reps-1 : 0; 133 bool split = (!arg.unsplit && (arg.split || glopts.output_split)); 135 134 bool append = (!arg.unappend && (arg.append || glopts.output_append)); 136 if(!write_aln.open(file_name, max_rep, append)) {135 if(!write_aln.open(file_name, num_reps-1, split, append)) { 137 136 DAWG_ERROR("bad configuration"); 138 137 return EXIT_FAILURE; 139 138 } 139 write_aln.set_blocks(glopts.output_block_head.c_str(), 140 glopts.output_block_between.c_str(), 141 glopts.output_block_tail.c_str(), 142 glopts.output_block_before.c_str(), 143 glopts.output_block_after.c_str() 144 ); 140 145 141 146 vector<dawg::ma> configs; -
current/src/include/dawg/output.h
r572 r579 22 22 split_width(0), app(false), rep(0), split_id_offset(0) { } 23 23 24 bool open(const char *file_name, unsigned int max_rep=0, bool append=false);24 bool open(const char *file_name, unsigned int max_rep=0, bool split = false, bool append=false); 25 25 26 26 inline bool operator()(const alignment& aln) { … … 28 28 if(p_out == NULL) 29 29 return false; 30 std::ostream &out = *p_out; 31 if(split_width == 0) 32 out << ((rep == 0) ? block_head : block_between); 33 out << block_before; 30 34 (this->*do_op)(aln); 35 out << block_after; 36 if(split_width == 0 && rep == last_rep) 37 out << block_tail; 31 38 ++rep; 39 out.flush(); 32 40 return true; 33 41 } … … 41 49 inline void set_ostream(std::ostream *os) { 42 50 p_out = os; 51 } 52 53 inline void set_blocks(const char *h, const char *w, 54 const char *t, const char *b, const char *a) { 55 block_head.assign(h); 56 block_between.assign(w); 57 block_tail.assign(t); 58 block_before.assign(b); 59 block_after.assign(a); 43 60 } 44 61 … … 59 76 std::ofstream fout; 60 77 std::size_t format_id; 61 unsigned int rep, split_width ;78 unsigned int rep, split_width, last_rep; 62 79 bool app; 63 80 std::string split_file_name; 64 81 std::string::size_type split_id_offset; 82 83 std::string block_head; 84 std::string block_between; 85 std::string block_tail; 86 std::string block_before; 87 std::string block_after; 65 88 }; 66 89 -
current/src/lib/output.cpp
r574 r579 21 21 using namespace std; 22 22 23 bool dawg::output::open(const char *file_name, unsigned int max_rep, bool append) {23 bool dawg::output::open(const char *file_name, unsigned int max_rep, bool split, bool append) { 24 24 typedef boost::iterator_range<const char*> cs_range; 25 25 set_format("aln"); 26 last_rep = max_rep; 26 27 rep = 0; 27 28 cs_range format(file_name, file_name); … … 52 53 app = append; 53 54 // find how wide the id number must be 54 unsigned int m = max_rep;55 unsigned int m = split ? max_rep : 0; 55 56 split_width = (m == 0) ? 0 : (m < 10) ? 1 : (m < 100) ? 2 : (m < 1000) ? 3 : 56 57 (m < 10000) ? 4 : (m < 100000) ? 5 : (m < 1000000) ? 6 :
Note: See TracChangeset
for help on using the changeset viewer.
