1 #include <boost/iterator.hpp>
3 #include <boost/python.hpp>
4 #include <boost/python/return_value_policy.hpp>
5 #include <boost/python/manage_new_object.hpp>
7 #include <boost/python/register_ptr_to_python.hpp>
8 using namespace boost::python;
10 #include "alg/seq_span.hpp"
12 #include "stl_container_adapter.hpp"
14 SeqSpanRef seq_span_factory(
16 AlphabetRef a = dna_alphabet,
17 SeqSpan::strand_type strand = SeqSpan::PlusStrand)
19 SeqSpanRef seq(new SeqSpan(s, a, strand));
23 BOOST_PYTHON_FUNCTION_OVERLOADS(
24 seq_span_factory_overloads,
26 1, // minimum arguments
27 3 // maximum arguments
30 void export_seq_span()
32 enum_<SeqSpan::strand_type>("strand")
33 .value("unknown", SeqSpan::UnknownStrand)
34 .value("minus", SeqSpan::MinusStrand)
35 .value("plus", SeqSpan::PlusStrand)
36 .value("both", SeqSpan::BothStrand)
37 .value("same", SeqSpan::SameStrand)
38 .value("opposite", SeqSpan::OppositeStrand)
39 .value("single", SeqSpan::SingleStrand)
42 def("SeqSpan", seq_span_factory,
43 seq_span_factory_overloads(args("sequence", "alphabet", "strand"))
46 class_<SeqSpan>("_SeqSpan", no_init)
47 .def("__getitem__", &std_item<SeqSpan>::get_const,
48 return_value_policy<copy_const_reference>())
49 .def("__len__", &SeqSpan::size)
50 .def("__str__", &SeqSpan::sequence)
51 .def("empty", &SeqSpan::empty)
52 //.add_property("alphabet",
53 // make_getter(&SeqSpan::get_alphabet,
54 // return_value_policy<copy_const_reference>()))
55 .add_property("annotations", &SeqSpan::annotations,
56 &SeqSpan::setAnnotations)
57 .add_property("drawable", &SeqSpan::drawable, &SeqSpan::setDrawable)
58 .add_property("start", &SeqSpan::start, &SeqSpan::setStart,
59 "start position relative to root sequence")
60 .add_property("stop", &SeqSpan::stop, &SeqSpan::setStop,
61 "one past the last position relative to the root sequence.")
62 .add_property("strand", &SeqSpan::strand,
63 "describe which strand the span is on")
65 .add_property("parentStart", &SeqSpan::parentStart, &SeqSpan::setParentStart,
66 "start position relative to parent sequence")
67 .add_property("parentStop", &SeqSpan::parentStop, &SeqSpan::setParentStop,
68 "one past the last position relative to the parent sequence.")
69 // doesn't work because I keep getting new python objects for the same
71 //.def("parent", &SeqSpan::parent)
72 .def("subseq", &SeqSpan::subseq)
75 register_ptr_to_python< SeqSpanRef >();