1 #ifndef _MUSSA_SEQUENCE_H_
2 #define _MUSSA_SEQUENCE_H_
3 // This file is part of the Mussa source distribution.
4 // http://mussa.caltech.edu/
5 // Contact author: Tristan De Buysscher, tristan@caltech.edu
7 // This program and all associated source code files are Copyright (C) 2005
8 // the California Institute of Technology, Pasadena, CA, 91125 USA. It is
9 // under the GNU Public License; please see the included LICENSE.txt
10 // file for more information, or contact Tristan directly.
13 // ----------------------------------------
14 // ---------- sequence.hh -----------
15 // ----------------------------------------
23 // Sequence data class
25 //! Attach annotation information to a sequence track
29 annot(int start, int end, std::string type, std::string name);
37 /* The way that motifs are found currently doesn't really
38 * indicate that the match was a reverse compliment
40 struct motif : public annot
44 //! this constructor is for when we're adding motifs to our annotations
45 motif(int start, std::string motif);
48 //! sequence track for mussa.
51 friend class ConnView;
58 std::list<annot> annots;
59 //! a seperate list for motifs since we're currently not saving them
60 std::list<motif> motif_list;
62 void motif_scan(std::string a_motif, std::vector<int> * motif_match_starts);
63 std::string rc_motif(std::string a_motif);
65 typedef std::string::iterator iterator;
66 typedef std::string::const_iterator const_iterator;
67 typedef std::string::size_type size_type;
70 Sequence(std::string seq);
71 //! assignment to constant sequences
72 Sequence &operator=(const Sequence&);
73 Sequence &operator=(const std::string &);
75 //! set sequence to a (sub)string containing nothing but AGCTN
76 void set_filtered_sequence(const std::string& seq,
77 std::string::size_type start=0,
78 std::string::size_type count=0);
80 //! load sequence AGCT from fasta file
81 /*! \throws mussa_load_error
83 void load_fasta(const std::string file_path, int seq_num=1,
84 int start_index=0, int end_index=0);
85 //! load sequence annotations
86 /*! \throws mussa_load_error
88 void load_annot(const std::string file_path, int start_index, int end_index);
89 const std::list<annot>& annotations() const;
90 const std::list<motif>& motifs() const;
92 // simple access functions
93 void set_seq(const std::string& a_seq);
94 const std::string& get_seq() const;
95 const char *c_seq() const;
96 std::string subseq(int start, int end) const;
97 std::string rev_comp() const;
99 // string-like functions
101 const_iterator begin() const;
103 const_iterator end() const;
105 //! alias for size, (included as this is much like a string)
106 std::string::size_type length() const;
107 //! the number of base pairs in this sequence
108 std::string::size_type size() const;
111 const std::string& get_header() const;
112 //! add a motif to our list of motifs
113 /*! \throws motif_normalize_error if there's something wrong with a_motif
115 void add_motif(std::string a_motif);
116 //! clear our list of found motifs
118 //! search a sequence for a_motif
119 /*! \throws motif_normalize_error if there's something wrong with a_motif
121 std::vector<int> find_motif(std::string a_motif);
122 //! convert IUPAC symbols to upperase
123 /*! \throws motif_normalize_error if there is an invalid symbol
125 static std::string motif_normalize(std::string a_motif);
126 void save(std::fstream &save_file);
127 void load_museq(std::string load_file_path, int seq_num);