File: AssemblyCounters.h

package info (click to toggle)
abyss 2.3.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,284 kB
  • sloc: cpp: 78,182; ansic: 6,512; makefile: 2,252; perl: 672; sh: 509; haskell: 412; python: 4
file content (77 lines) | stat: -rw-r--r-- 1,567 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef _ASSEMBLY_COUNTERS_H_
#define _ASSEMBLY_COUNTERS_H_

#include "Common/IOUtil.h"
#include <iostream>
#include <cassert>
#include <string>

namespace BloomDBG {

	/**
	 * Counters for tracking assembly statistics and producing
	 * progress messages.
	 */
	struct AssemblyCounters
	{
		/** reads consisting entirely of solid k-mers */
		size_t solidReads;
		/**
		 * reads consisting entirely of k-mers already
		 * included in output contigs
		 */
		size_t visitedReads;
		size_t readsProcessed;
		size_t basesAssembled;
		size_t contigID;

		AssemblyCounters() : solidReads(0), visitedReads(0),
			readsProcessed(0), basesAssembled(0), contigID(0) {}

		/** serialize counters as a TSV table */
		friend std::ostream& operator<<(std::ostream& out,
			const AssemblyCounters& o)
		{
			/* write headers */

			out << "solid_reads"
				<< '\t' << "processed_reads"
				<< '\t' << "bases_assembled"
				<< '\t' << "next_contig_id"
				<< '\n';

			/* write data */

			out << o.solidReads
				<< '\t' << o.readsProcessed
				<< '\t' << o.basesAssembled
				<< '\t' << o.contigID
				<< '\n';

			return out;
		}

		/** deserialize counters from a TSV table  */
		friend std::istream& operator>>(std::istream& in,
			AssemblyCounters& o)
		{
			/* ignore header line */

			std::string headers;
			getline(in, headers);

			/* read data */

			in >> o.solidReads
				>> expect("\t") >> o.readsProcessed
				>> expect("\t") >> o.basesAssembled
				>> expect("\t") >> o.contigID
				>> expect("\n");

			return in;
		}
	};

} /* end of BloomDBG namespace */

#endif