File: AdjacencyAlgorithm.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 (50 lines) | stat: -rw-r--r-- 1,308 bytes parent folder | download | duplicates (6)
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
#ifndef ASSEMBLY_ADJACENCYALGORITHM_H
#define ASSEMBLY_ADJACENCYALGORITHM_H 1

namespace AssemblyAlgorithms {

/** Generate the adjacency information for each sequence in the
 * collection. */
template <typename Graph>
size_t generateAdjacency(Graph* seqCollection)
{
	typedef typename graph_traits<Graph>::vertex_descriptor V;
	typedef typename Graph::Symbol Symbol;
	typedef typename Graph::SymbolSet SymbolSet;

	Timer timer("GenerateAdjacency");

	size_t count = 0;
	size_t numBasesSet = 0;
	for (typename Graph::iterator iter = seqCollection->begin();
			iter != seqCollection->end(); ++iter) {
		if (iter->second.deleted())
			continue;

		if (++count % 1000000 == 0)
			logger(1) << "Finding adjacent k-mer: " << count << '\n';

		for (extDirection dir = SENSE; dir <= ANTISENSE; ++dir) {
			V testSeq(iter->first);
			Symbol adjBase = testSeq.shift(dir);
			for (unsigned i = 0; i < SymbolSet::NUM; ++i) {
				testSeq.setLastBase(dir, Symbol(i));
				if (seqCollection->setBaseExtension(
							testSeq, !dir, adjBase))
					numBasesSet++;
			}
		}
		seqCollection->pumpNetwork();
	}

	if (numBasesSet > 0) {
		logger(0) << "Added " << numBasesSet << " edges.\n";
		if (!opt::db.empty())
			addToDb("EdgesGenerated", numBasesSet);
	}
	return numBasesSet;
}

} // namespace AssemblyAlgorithms

#endif