-
Notifications
You must be signed in to change notification settings - Fork 0
/
Motif.hpp
109 lines (94 loc) · 3.22 KB
/
Motif.hpp
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
/*
* Copyright (C) 2006 Cold Spring Harbor Laboratory
* Authors: Andrew D. Smith, Pavel Sumazin and Michael Q. Zhang
*
* This file is part of CREAD.
*
* CREAD 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 2 of the License, or
* (at your option) any later version.
*
* CREAD 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 CREAD; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MOTIF_HPP
#define MOTIF_HPP
/**
\file Motif.hpp
\brief This header file contains class definitions for Motif class,
a subclass of Pattern.
*/
#include "Matrix.hpp"
#include "MotifSite.hpp"
#include "Pattern.hpp"
/**
\brief Class to represent DNA sequence (e.g. TF binding site)
motifs.
\class Motif
*/
class Motif : public Pattern {
public:
/// This constructor parses a vector of strings to populate the motif pattern
Motif(std::vector<std::string>&);
// The copy constructor
Motif(const Motif&);
/*!
\brief This constructor creates a minimal motif pattern from a matrix;
the accession is set to (none).
*/
Motif(const Matrix&);
/// Assignment operator
Motif& operator=(const Motif&);
// ACCESSORS
/// Returns the matrix
Matrix get_matrix() const {return matrix;}
/// Returns the MotifSites
std::vector<MotifSite> get_sites() const {return sites;}
/// Add a site that can not be modified
void add_site(const MotifSite& bs) {sites.push_back(MotifSite(bs));}
/// Add a site
void add_site(MotifSite& bs) {sites.push_back(MotifSite(bs));}
/// Parse a site from a string and add it
void add_site(std::string bs) {sites.push_back(MotifSite(bs));}
/// Delete all sites
void clear_sites() {sites.clear();}
/// Returns a constant matrix by reference
const Matrix& const_get_matrix() const {return matrix;}
/// Returns the width of the matrix
size_t get_width() const {return matrix.get_width();}
/// Returns true if the type is a motif type
static bool is_type(std::string s) {
return !s.compare(0, type_id_size, type_id);
}
/// Read a vector of motifs from a file
static std::vector<Motif> ReadMotifVector(std::string file_name);
private:
/// Stores the type id
static const char *type_id;
/// Stores the size of the type-id label
static const size_t type_id_size;
/// Stores the label of the matrix start
static const char *matrix_start;
void format_representation(std::ostream& os) const;
void format_sites(std::ostream& os) const;
Matrix matrix;
std::vector<MotifSite> sites;
};
/*!
\exception ModuleFormatterException
\brief Reports exceptions when writing a motif.
*/
class MotifFormatterException : public PatternFormatterException {};
/*!
\exception ModuleFormatterException
\brief Reports exceptions when parsing a Motif.
*/
class MotifFormatException : public PatternFormatException {};
#endif