28.02.2014 Views

An Integrated Data Analysis Suite and Programming ... - TOBIAS-lib

An Integrated Data Analysis Suite and Programming ... - TOBIAS-lib

An Integrated Data Analysis Suite and Programming ... - TOBIAS-lib

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

68 CHAPTER 3. A C++ FRAMEWORK FOR HIGH-THROUGHPUT DNA SEQUENCING<br />

1 class order_paired_reads_pipe<br />

:public pipe_facade<br />

{<br />

private:<br />

10 // Grants pipe_facade access to private member functions.<br />

friend class pipeline_core_access;<br />

15<br />

// Stores all reads with the same identifier.<br />

std::vector m_buffer;<br />

// Orders all reads collected in buffer by their paired-end index.<br />

void order_reads_by_index();<br />

// Tests if a read has no mates.<br />

20 static bool is_single_read(const read &);<br />

void next()<br />

{<br />

if(!m_buffer.empty())<br />

25 {<br />

m_buffer.pop_front();<br />

30 }<br />

}<br />

if(!m_buffer.empty())<br />

emit(m_buffer.front());<br />

void prepare(const read & r)<br />

{<br />

35 if(!m_buffer.empty() && (r.id != m_buffer.front().id))<br />

{<br />

order_reads_by_index();<br />

emit(m_buffer.front());<br />

}<br />

40 }<br />

void append(const read & r)<br />

{<br />

if(is_single_read(r))<br />

45 emit(r);<br />

else<br />

m_buffer.push_back(r);<br />

}<br />

50 void flush()<br />

{<br />

if(!m_buffer.empty())<br />

{<br />

order_reads_by_index();<br />

55 emit(m_buffer.front());<br />

}<br />

}<br />

};<br />

Listing 3.3: Usage Example for the pipe_facade Template

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!