//cout << endl;
}
+void Sequence::add_string_annotation(std::string a_seq,
+ std::string name)
+{
+ vector<int> seq_starts = find_motif(a_seq);
+
+ for(vector<int>::iterator seq_start_i = seq_starts.begin();
+ seq_start_i != seq_starts.end();
+ ++seq_start_i)
+ {
+ annots.push_back(annot(*seq_start_i,
+ *seq_start_i+a_seq.size(),
+ "",
+ name));
+ }
+}
+
+void Sequence::find_sequences(std::list<Sequence>::iterator start,
+ std::list<Sequence>::iterator end)
+{
+ while (start != end) {
+ add_string_annotation(start->get_seq(), start->get_header());
+ ++start;
+ }
+}
+
void motif_scan(std::string a_motif, std::vector<int> * motif_match_starts);
std::string rc_motif(std::string a_motif);
+ //! look for a string sequence type and and it to an annotation list
+ void add_string_annotation(std::string a_seq, std::string name);
+
public:
typedef std::string::iterator iterator;
typedef std::string::const_iterator const_iterator;
const std::string& get_header() const;
//! add a motif to our list of motifs
- /*! \throws motif_normalize_error if there's something wrong with a_motif
- */
+ //! \throws motif_normalize_error if there's something wrong with a_motif
void add_motif(std::string a_motif);
//! clear our list of found motifs
void clear_motifs();
//! search a sequence for a_motif
- /*! \throws motif_normalize_error if there's something wrong with a_motif
- */
+ //! \throws motif_normalize_error if there's something wrong with a_motif
std::vector<int> find_motif(std::string a_motif);
//! convert IUPAC symbols to upperase
- /*! \throws motif_normalize_error if there is an invalid symbol
- */
+ //! \throws motif_normalize_error if there is an invalid symbol
static std::string motif_normalize(std::string a_motif);
+
+ //! annotate the current sequence with other sequences
+ void find_sequences(std::list<Sequence>::iterator start,
+ std::list<Sequence>::iterator end);
+
void save(boost::filesystem::fstream &save_file);
void load_museq(boost::filesystem::path load_file_path, int seq_num);
};
BOOST_CHECK_EQUAL( m.name, "AAGGCC" );
BOOST_CHECK_EQUAL( m.end, 10+6 );
}
+
+BOOST_AUTO_TEST_CASE( annotate_from_sequence )
+{
+ Sequence s("CCGCCCCCCATCATCGCGGCTCTCCGAGAGTCCCGCGCCCCACTCCCGGC"
+ "ACCCACCTGACCGCGGGCGGCTCCGGCCCCGCTTCGCCCCACTGCGATCA"
+ "GTCGCGTCCCGCAGGCCAGGCACGCCCCGCCGCTCCCGCTGCGCCGGGCG"
+ "TCTGGGACCTCGGGCGGCTCCTCCGAGGGGCGGGGCAGCCGGGAGCCACG"
+ "CCCCCGCAGGTGAGCCGGCCACGCCCACCGCCCGTGGGAAGTTCAGCCTC"
+ "GGGGCTCCAGCCCCGCGGGAATGGCAGAACTTCGCACGCGGAACTGGTAA"
+ "CCTCCAGGACACCTCGAATCAGGGTGATTGTAGCGCAGGGGCCTTGGCCA"
+ "AGCTAAAACTTTGGAAACTTTAGATCCCAGACAGGTGGCTTTCTTGCAGT");
+
+ std::list<Sequence> query_list;
+ query_list.push_back(Sequence("GCCCCC"));
+ query_list.push_back(Sequence("GGACACCTC"));
+
+ BOOST_CHECK_EQUAL( s.annotations().size(), 0 );
+ s.find_sequences(query_list.begin(), query_list.end());
+ BOOST_CHECK_EQUAL( s.annotations().size(), 4 );
+}
+