{
seq_i->setX(0);
seq_i->setY(y);
- if (seq_i->length() > max_base_pairs)
- max_base_pairs = seq_i->length();
+ if (seq_i->size() > max_base_pairs)
+ max_base_pairs = seq_i->size();
}
} else if (track_count == 1) {
// center the single track
glseq_itor_type seq_i = track_container.begin();
seq_i->setX(0);
seq_i->setY(viewport_size.x /2);
- max_base_pairs = seq_i->length();
+ max_base_pairs = seq_i->size();
} else {
// nothing to do as we're empty
return;
GLfloat GlSequence::right() const
{
- return length()+seq_x;
+ return size()+seq_x;
}
void GlSequence::setY(GLfloat value)
return seq_height;
}
-GLfloat GlSequence::length() const
+GLfloat GlSequence::size() const
{
return seq->size();
}
++annot_itor)
{
glColor3f(0.0, 0.8, 0.0);
- draw_box(left, right, seq_x+annot_itor->start, seq_x+annot_itor->end,
+ draw_box(left, right, seq_x+annot_itor->begin, seq_x+annot_itor->end,
seq_height, annotation_z);
}
// if motifs?
++motifs_itor)
{
glColor3fv(color_mapper->lookup("motif", motifs_itor->sequence).get());
- draw_box(left, right, seq_x+motifs_itor->start, seq_x+motifs_itor->end,
+ draw_box(left, right, seq_x+motifs_itor->begin, seq_x+motifs_itor->end,
seq_height, annotation_z+1.0);
}
void setX(GLfloat);
//! get our starting x (horizontal) coordinate
GLfloat x() const;
- //! get our right (horizontal) coordinate (length-x)
+ //! get our right (horizontal) coordinate (size-x)
GLfloat right() const;
//! set our current y (vertical) position
void setY(GLfloat);
//! how thick (high) the track we're drawing is
GLfloat height() const;
//! how long is our sequence track? (computed from the sequence)
- GLfloat length() const;
+ GLfloat size() const;
//! return the left (lowest) base index that is fully visible
Sequence::size_type leftbase(GLfloat left) const;
static const char* iupac_alphabet = "AaCcGgTtUuRrYyMmKkSsWwBbDdHhVvNn\012\015";
annot::annot()
- : start(0),
+ : begin(0),
end(0),
type(""),
name("")
{
}
-annot::annot(int start, int end, std::string type, std::string name)
- : start(start),
+annot::annot(int begin, int end, std::string type, std::string name)
+ : begin(begin),
end(end),
type(type),
name(name)
bool operator==(const annot& left, const annot& right)
{
- return ((left.start == right.start) and
+ return ((left.begin== right.begin) and
(left.end == right.end) and
(left.type == right.type) and
(left.name == right.name));
}
-motif::motif(int start, std::string motif)
- : annot(start, start+motif.size(), "motif", motif),
+motif::motif(int begin, std::string motif)
+ : annot(begin, begin+motif.size(), "motif", motif),
sequence(motif)
{
}
annot_i != annots.end();
++annot_i)
{
- int annot_start = annot_i->start;
+ int annot_begin= annot_i->begin;
int annot_end = annot_i->end;
- if (annot_start < end) {
- if (annot_start >=start) {
- annot_start -= start;
+ if (annot_begin < end) {
+ if (annot_begin >= start) {
+ annot_begin -= start;
} else {
- annot_start = 0;
+ annot_begin = 0;
}
if (annot_end < end) {
annot_end = count;
}
- annot new_annot(annot_start, annot_end, annot_i->type, annot_i->name);
+ annot new_annot(annot_begin, annot_end, annot_i->type, annot_i->name);
new_seq.annots.push_back(new_annot);
}
}
save_file << species << std::endl;
for (annots_i = annots.begin(); annots_i != annots.end(); ++annots_i)
{
- save_file << annots_i->start << " " << annots_i->end << " " ;
+ save_file << annots_i->begin << " " << annots_i->end << " " ;
save_file << annots_i->name << " " << annots_i->type << std::endl;
}
save_file << "</Annotations>" << std::endl;
// get annot start index
space_split_i = file_data_line.find(" ");
annot_value = file_data_line.substr(0,space_split_i);
- an_annot.start = atoi (annot_value.c_str());
+ an_annot.begin = atoi (annot_value.c_str());
file_data_line = file_data_line.substr(space_split_i+1);
// get annot end index
space_split_i = file_data_line.find(" ");
struct annot
{
annot();
- annot(int start, int end, std::string type, std::string name);
+ annot(int begin, int end, std::string type, std::string name);
~annot();
- int start;
+ int begin;
int end;
std::string type;
std::string name;
std::string sequence;
//! this constructor is for when we're adding motifs to our annotations
- motif(int start, std::string motif);
+ motif(int begin, std::string motif);
~motif();
};
BOOST_CHECK_EQUAL( ac.lookup("venchent", "a"), white );
annot a;
- a.start = 30;
+ a.begin = 30;
a.end = 45;
a.type = "bleem";
a.name = "a";
std::list<annot> annots_list = seq.annotations();
std::vector<annot> annots(annots_list.begin(), annots_list.end());
BOOST_REQUIRE_EQUAL( annots.size(), 8);
- BOOST_CHECK_EQUAL( annots[0].start, 0 );
+ BOOST_CHECK_EQUAL( annots[0].begin, 0 );
BOOST_CHECK_EQUAL( annots[0].end, 10 );
BOOST_CHECK_EQUAL( annots[0].type, "type");
BOOST_CHECK_EQUAL( annots[0].name, "name");
BOOST_CHECK_EQUAL( annots[4].name, "backward");
BOOST_CHECK_EQUAL( annots[5].name, "name2");
BOOST_CHECK_EQUAL( annots[5].end, 90);
- BOOST_CHECK_EQUAL( annots[6].start, 100);
+ BOOST_CHECK_EQUAL( annots[6].begin, 100);
BOOST_CHECK_EQUAL( annots[6].end, 120);
BOOST_CHECK_EQUAL( annots[6].name, "name-asdf");
BOOST_CHECK_EQUAL( annots[6].type, "type!@#$%");
// sequence defined annotations will always be after the
// absolute positions
BOOST_CHECK_EQUAL( annots[7].name, "ident3 asdf");
- BOOST_CHECK_EQUAL( annots[7].start, 100);
+ BOOST_CHECK_EQUAL( annots[7].begin, 100);
//BOOST_CHECK_EQUAL( annots
}
std::list<annot> annots_list = seq.annotations();
std::vector<annot> annots(annots_list.begin(), annots_list.end());
BOOST_REQUIRE_EQUAL( annots.size(), 8);
- BOOST_CHECK_EQUAL( annots[0].start, 0 );
+ BOOST_CHECK_EQUAL( annots[0].begin, 0 );
BOOST_CHECK_EQUAL( annots[0].end, 10 );
BOOST_CHECK_EQUAL( annots[0].type, "type");
}
{
annot a(0, 10, "test", "thing");
- BOOST_CHECK_EQUAL( a.start, 0 );
+ BOOST_CHECK_EQUAL( a.begin, 0 );
BOOST_CHECK_EQUAL( a.end, 10 );
BOOST_CHECK_EQUAL( a.type, "test" );
BOOST_CHECK_EQUAL( a.name, "thing" );
motif m(10, "AAGGCC");
- BOOST_CHECK_EQUAL( m.start, 10 );
+ BOOST_CHECK_EQUAL( m.begin, 10 );
BOOST_CHECK_EQUAL( m.type, "motif" );
BOOST_CHECK_EQUAL( m.name, "AAGGCC" );
BOOST_CHECK_EQUAL( m.end, 10+6 );
IF(BOOST_PYTHON_LIBRARY)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH} ${QT_INCLUDES})
SET(SOURCES
+ annot.cpp
annotation_colors.cpp
conserved_path.cpp
glsequence.cpp
--- /dev/null
+#include <boost/python.hpp>
+using namespace boost::python;
+
+#include "alg/sequence.hpp"
+
+void export_annot()
+{
+ class_<annot>("annot")
+ .def(init<int, int, std::string, std::string>())
+ .def_readwrite("begin", &annot::begin)
+ .def_readwrite("end", &annot::end)
+ .def_readwrite("type", &annot::type)
+ .def_readwrite("name", &annot::name)
+ ;
+
+ class_<motif, bases<annot> >("motif", init<int, std::string>())
+ .def_readwrite("sequence", &motif::sequence)
+ ;
+}
return_internal_reference<>())
.add_property("x", &GlSequence::x, &GlSequence::setX)
.add_property("y", &GlSequence::y, &GlSequence::setY)
- .add_property("length", &GlSequence::length)
+ .add_property("__len__", &GlSequence::size)
;
}
#include <boost/python.hpp>
using namespace boost::python;
+void export_annot();
void export_annotation_colors();
void export_conserved_path();
void export_glsequence();
BOOST_PYTHON_MODULE(mussa)
{
+ export_annot();
export_annotation_colors();
export_conserved_path();
export_glsequence();
{
class_<Sequence>("Sequence")
.def(init<std::string>())
- .def("__str__", &seq_to_string)
- .def("size", &Sequence::size)
- .def("__len__", &Sequence::size)
- .add_property("header", &Sequence::get_fasta_header, &Sequence::set_fasta_header)
+ .def("__str__", &seq_to_string, "cast to string")
+ .def("__repr__", &seq_to_string, "display as string")
+ .def("size", &Sequence::size, "return the length of the sequence")
+ .def("__len__", &Sequence::size, "return the length of the sequence")
+ .def("clear", &Sequence::clear, "clear the sequence and its annotations")
+ .add_property("header", &Sequence::get_fasta_header, &Sequence::set_fasta_header, "the fasta header")
.add_property("species", &Sequence::get_species, &Sequence::set_species)
+ .def("add_annotation", &Sequence::add_annotation, "append an annotation")
+ //.def("annotations", &Sequence::annotations, "return list of annotations")
.def("rcseq", &Sequence::rev_comp, return_value_policy<return_by_value>())
;
s.species = species
self.failUnless(s.header == header_text)
self.failUnless(s.species == species)
-
+
+ def testAnnotations(self):
+ annot = mussa.annot()
+ annot.begin = 0
+ annot.end = 10
+ annot.name = "foo"
+ annot.type = "utr"
+
+ seq = mussa.Sequence("AAGGCCTTAATTGGCCTT")
+ seq.add_annotation(annot)
+
+ def notestFile(self):
+ # remove no prefix once we have sequence loading from a stream
+ seq_text = "AAGGCCTT"
+ from StringIO import StringIO
+ s = StringIO(seq_text)
+
+ seq = mussa.Sequence(s)
+
+ self.failUnless(seq == seq_text)
+
def suite():
return unittest.makeSuite(TestSequence, 'test')