1 #include <boost/python.hpp>
2 #include <boost/iterator.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;
9 #include <boost/shared_ptr.hpp>
12 #include "alg/glsequence.hpp"
14 PyObject* seq_to_string(const Sequence& s) {
15 ::PyString_FromStringAndSize(s.data(), s.size());
18 void export_sequence()
20 class_<Sequence>("Sequence")
21 .def(init<std::string>())
22 .def("__str__", &seq_to_string, "cast to string")
23 .def("__repr__", &seq_to_string, "display as string")
24 .def("size", &Sequence::size, "return the length of the sequence")
25 .def("__len__", &Sequence::size, "return the length of the sequence")
26 .def("clear", &Sequence::clear, "clear the sequence and its annotations")
27 .add_property("header", &Sequence::get_fasta_header, &Sequence::set_fasta_header, "the fasta header")
28 .add_property("species", &Sequence::get_species, &Sequence::set_species)
29 .def("add_annotation", &Sequence::add_annotation, "append an annotation")
30 //.def("annotations", &Sequence::annotations, "return list of annotations")
31 .def("rcseq", &Sequence::rev_comp, return_value_policy<return_by_value>())
34 register_ptr_to_python< boost::shared_ptr<Sequence> >();