Skip to content
Snippets Groups Projects
Commit 766dbd67 authored by Marco Biasini's avatar Marco Biasini
Browse files

fix BZDNG-187 and BZDNG-148

parent beef1852
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,8 @@
#include <boost/python/register_ptr_to_python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <ost/export_helper/pair_to_tuple_conv.hh>
#include <ost/generic_property.hh>
#include <ost/export_helper/generic_property_def.hh>
#include <ost/info/info.hh>
......@@ -206,6 +208,7 @@ void const_seq_handle_def(O& bp_class)
.def("GetLength", &C::GetLength)
.def("GetResidue", &C::GetResidue)
.def("GetOneLetterCode", &C::GetOneLetterCode)
.def("__iter__", iterator<C>())
.def("__getitem__", &C::GetOneLetterCode)
.def("GetOffset", &C::GetOffset)
.def("Copy", &C::Copy)
......@@ -297,8 +300,6 @@ void export_sequence()
.def("Copy", &AlignmentHandle::Copy)
.def("ToString", &AlignmentHandle::ToString)
.def("GetLength", &AlignmentHandle::GetLength)
.def("GetMatchingBackboneViews", &AlignmentHandle::GetMatchingBackboneViews,
(arg("index1")=0, arg("index2")=1))
.def("__len__", &AlignmentHandle::GetLength)
.def("GetSequences", &AlignmentHandle::GetSequences)
.def("GetCoverage", &AlignmentHandle::GetSequences)
......@@ -357,7 +358,7 @@ void export_sequence()
.def("__getitem__", &do_slice_b)
;
implicitly_convertible<SequenceList, ConstSequenceList>();
def("CreateSequenceList", &CreateSequenceList);
def("SequenceFromChain", seq_from_chain_a);
def("SequenceFromChain", seq_from_chain_b);
......
......@@ -58,6 +58,8 @@ char ConstSequenceHandle::operator[](int index) const
}
void ConstSequenceHandle::CheckValidity() const
{
if (!impl_) {
......@@ -398,4 +400,11 @@ int SequenceHandle::GetIndex(const String& substr) const
this->CheckValidity();
return Impl()->GetIndex(substr);
}
char SequenceHandle::operator[](size_t index) const
{
this->CheckValidity();
return this->GetString()[index];
}
}}
......@@ -49,6 +49,9 @@ public:
friend class AlignmentHandle;
friend class ConstSequenceList;
friend class SequenceList;
typedef String::const_iterator iterator;
/// \brief create invalid sequence handle
///
/// \sa IsValid()
......@@ -121,6 +124,8 @@ public:
char operator[](int index) const;
iterator begin() const { return this->GetString().begin(); }
iterator end() const { return this->GetString().end(); }
/// \brief whether the sequence is valid
bool IsValid() const;
......@@ -162,6 +167,7 @@ private:
class DLLEXPORT_OST_SEQ SequenceHandle :
public GenericPropContainer<SequenceHandle> {
public:
typedef String::const_iterator iterator;
friend class GenericPropContainer<SequenceHandle>;
friend class SequenceList;
......@@ -261,6 +267,10 @@ public:
void SetOneLetterCode(int position, char new_char);
char operator[](size_t index) const;
iterator begin() const { return this->GetString().begin(); }
iterator end() const { return this->GetString().end(); }
void Append(char olc);
operator ConstSequenceHandle() const;
......
......@@ -30,7 +30,10 @@ class TestSeq(unittest.TestCase):
string_b=''.join([r.one_letter_code for r in b.residues])
self.assertEqual(string_a, 'ABCDFGH')
self.assertEqual(string_b, 'ABCDFGH')
def testSeqIterBZDNG148(self):
s=seq.CreateSequence('A', 'abcdef')
for x in s:
pass
def testViewsFromSequences_02(self):
seq_a=seq.CreateSequence("A", "ABCD-FGH")
seq_a.AttachView(self.ent.Select('rname=A,B,C,D,F,G,H'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment