File: anfo_common.h

package info (click to toggle)
anfo 0.98-7
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 2,256 kB
  • sloc: sh: 10,041; cpp: 8,548; ansic: 530; lisp: 337; makefile: 64
file content (117 lines) | stat: -rw-r--r-- 3,399 bytes parent folder | download | duplicates (3)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//    Copyright 2009 Udo Stenzel
//    This file is part of ANFO
//
//    ANFO is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    Anfo is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with Anfo.  If not, see <http://www.gnu.org/licenses/>.

#ifndef INCLUDED_ANFO_COMMON_H
#define INCLUDED_ANFO_COMMON_H

// Commonalities between different command line utilities, factored out.

#include "align.h"
#include "index.h"
#include "stream.h"

#include "config.pb.h"
#include "output.pb.h"

#include <map>
#include <string>

#include <fnmatch.h>

//! \brief Configures type of alignment to be done.
//! This is a hack and only intended as a stopgap.
// typedef flat_alignment alignment_type ;
// typedef simple_adna alignment_type ;

/*
struct reference_overlaps {
	DnaP x, y ;
	reference_overlaps( DnaP u, DnaP v ) : x(u), y(v) {}
	bool operator()( const alignment_type& a ) {
		return a.reference >= x && a.reference <= y ; }
} ;
*/

namespace streams {

//! \brief takes care of stuff needed before aligning
//! This is for "housekeeping" that needs to be done before indexing
//! and alignment, most notably adapter/artefact trimming.

class Housekeeper : public Stream
{
	private:
		const int minscore_ ;
		vector< string > trim_left_ ;
		vector< string > trim_right_ ;

	public:
		Housekeeper( const config::Config &config ) :
			minscore_( config.min_trim_score() ),
			trim_left_( config.trim_left().begin(), config.trim_left().end() ),
			trim_right_( config.trim_right().begin(), config.trim_right().end() )
		{}

		Housekeeper( vector<string> left, vector<string> right, int minscore )
			: minscore_( minscore ), trim_left_( left ), trim_right_( right ) {}

		virtual void put_result( const Result& ) ;
} ;

//! \brief configured Indexer
//! Knows about one index, will look at each record, check the policy
//! and if appropriate, will do an index lookup.  Constructed seeds are
//! stored and passed on.  The policy is taken from a config file and
//! stored in the header.
class Indexer : public Stream
{
	private:
		config::Config conf_ ;
		std::string index_name_ ;
		const FixedIndex& index_ ;

	public:
		Indexer( const config::Config &config, const std::string& index_name ) ;
		virtual ~Indexer() ;

		virtual void put_header( const Header& ) ;
		virtual void put_result( const Result& ) ;
} ;

//! \brief configured mapper
//! Knows about one genome and an aligner configuration.  Looks at each
//! record, takes the seed collection for its genome and aligns.  Seeds
//! are removed, the result is added and passed on.
class Mapper : public Stream
{
	private:
		config::Aligner conf_ ;
		GenomeHolder genome_ ;
		adna_parblock parblock_ ;


	public:
		Mapper( const config::Aligner &config, const std::string& genome_name ) ;

		virtual void put_header( const Header& ) ;
		virtual void put_result( const Result& ) ;
} ;

} ; // namespace streams

std::string expand( const std::string&, int ) ;

#endif