aa484c99ddba1a965f16eaa122a08e3974a0544f
[mussa.git] / py / seq_span.cpp
1 #include <boost/iterator.hpp>
2
3 #include <boost/python.hpp>
4 #include <boost/python/return_value_policy.hpp>
5
6 #include <boost/python/register_ptr_to_python.hpp>
7 using namespace boost::python;
8
9 #include "alg/seq_span.hpp"
10
11 #include "stl_container_adapter.hpp"
12
13 void export_seq_span()
14 {
15   enum_<SeqSpan::strand_type>("strand_type")
16     .value("unknown", SeqSpan::UnknownStrand)
17     .value("minus", SeqSpan::MinusStrand)
18     .value("plus", SeqSpan::PlusStrand)
19     .value("both", SeqSpan::BothStrand)
20     .value("same", SeqSpan::SameStrand)
21     .value("opposite", SeqSpan::OppositeStrand)
22     .value("single", SeqSpan::SingleStrand)
23     ;
24
25
26   class_<SeqSpan>("SeqSpan", 
27                   init<std::string, optional<AlphabetRef, 
28                                              SeqSpan::strand_type> 
29                       >() )
30     .def("__len__", &SeqSpan::size)
31     .def("__getitem__", &std_item<SeqSpan>::get_const,
32         return_value_policy<copy_const_reference>())
33     .def("__str__", &SeqSpan::sequence)
34     .def("empty", &SeqSpan::empty)
35     .add_property("start", &SeqSpan::start, &SeqSpan::setStart,
36                   "start position relative to root sequence")
37     .add_property("stop", &SeqSpan::stop, &SeqSpan::setStop,
38                   "one past the last position relative to the root sequence.")
39     .add_property("strand", &SeqSpan::strand, 
40                   "describe which strand the span is on")
41
42     .add_property("parentStart", &SeqSpan::parentStart, &SeqSpan::setParentStart,
43                   "start position relative to parent sequence")
44     .add_property("parentStop", &SeqSpan::parentStop, &SeqSpan::setParentStop,
45                   "one past the last position relative to the parent sequence.")
46     .add_property("parent", &SeqSpan::parent)
47
48     .def("subseq", &SeqSpan::subseq)
49     ;
50  
51   register_ptr_to_python< boost::shared_ptr<SeqSpan> >();
52 }