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/filesystem/path.hpp>
10 namespace fs = boost::filesystem;
12 #include <boost/shared_ptr.hpp>
15 #include "alg/glsequence.hpp"
17 void export_sequence()
19 void (Sequence::*load_fasta_piii)(const fs::path, int, int, int) = &Sequence::load_fasta;
20 void (Sequence::*add_annotation_ssii)(
25 ) = &Sequence::add_annotation;
27 class_<Sequence>("Sequence")
28 .def(init<std::string>())
29 .def("__getitem__", &Sequence::at, "return base pair at specified location",
30 return_value_policy<return_by_value>())
31 .def("__len__", &Sequence::size, "return the length of the sequence")
32 .def("__repr__", &Sequence::get_sequence, "display as string")
33 .def("__str__", &Sequence::get_sequence, "cast to string")
34 .def("add_annotation", add_annotation_ssii,
35 "create an annotation from name, type, start, stop")
36 //.def("annotations", &Sequence::annotations, "return list of annotations")
37 .def("add_motif", &Sequence::add_motif, "add a motif sequenence")
38 .def("clear", &Sequence::clear, "clear the sequence and its annotations")
39 .def("empty", &Sequence::empty, "Is the sequence empty")
40 .def("load_fasta", load_fasta_piii, "Load fasta")
41 .add_property("header", &Sequence::get_fasta_header, &Sequence::set_fasta_header, "the fasta header")
42 .def("rcseq", &Sequence::rev_comp, return_value_policy<return_by_value>())
43 .def("size", &Sequence::size, "return the length of the sequence")
44 .add_property("species", &Sequence::get_species, &Sequence::set_species)
45 .def("subseq", &Sequence::subseq, "return a subsequence")
48 register_ptr_to_python< boost::shared_ptr<Sequence> >();