Store Sequence sequence location in a shared_ptr class
[mussa.git] / py / flp.cpp
1 #include <boost/python.hpp>
2 #include <boost/python/list.hpp>
3 #include <boost/python/return_internal_reference.hpp>
4 #include <boost/python/return_by_value.hpp>
5 #include <boost/python/return_value_policy.hpp>
6 #include <boost/python/register_ptr_to_python.hpp>
7 using namespace boost::python;
8
9 #include "alg/flp.hpp"
10 #include "alg/sequence.hpp"
11
12 struct listint_to_python {
13   static PyObject *convert(const std::list<int> l) {
14     PyObject *pylist = PyList_New(0);
15     for(std::list<int>::const_iterator li = l.begin();
16         li != l.end();
17         ++li)
18     {      
19       PyList_Append(pylist, PyInt_FromLong(*li));
20     }
21     return pylist;
22   }
23 };
24
25 void export_flps()
26 {
27   
28   class_<FLPs>("FLP")
29     .def("setup", &FLPs::setup, "set window size and lowest threshold")
30     .def("seqcomp", &FLPs::seqcomp, "compare two sequences\n"
31                                     "takes: sequence, seqeuence, bool is_reveresed flag")
32     .def("size", &FLPs::size, "return the length of the sequence")
33     .def("match_locations", &FLPs::match_locations, "return list of matches at a window location")
34     .def("thres_matches", &FLPs::thres_matches, "return list of matches at a window location above a threshold")
35   ;
36     //std::list<match> matches(int index) const;    
37     //void save(boost::filesystem::path save_file_path);
38     //void load(boost::filesystem::path file_path);
39   to_python_converter< std::list<int>, listint_to_python>();
40 }