diff --git a/modules/base/src/CMakeLists.txt b/modules/base/src/CMakeLists.txt
index 30660f6d5cdb4511271e8fb771b3ad4d11bcbb6f..386e9d920a5f23f59dd187bc0d25e6db7d3faac2 100644
--- a/modules/base/src/CMakeLists.txt
+++ b/modules/base/src/CMakeLists.txt
@@ -30,8 +30,13 @@ fixed_string.hh
 tri_matrix.hh
 )
 
+set(OST_EXPORT_HELPERS
+generic_property_def.hh 
+pair_to_tuple_conv.hh 
+)
 module(NAME base SOURCES ${OST_BASE_SOURCES} 
-       HEADERS generic_property_def.hh IN_DIR export_helper compare_files.hh IN_DIR test_utils ${OST_BASE_HEADERS}
+       HEADERS ${OST_EXPORT_HELPERS} IN_DIR export_helper 
+       compare_files.hh IN_DIR test_utils ${OST_BASE_HEADERS}
        DEPENDS_ON geom
        HEADER_OUTPUT_DIR ost)
 
diff --git a/modules/base/src/export_helper/pair_to_tuple_conv.hh b/modules/base/src/export_helper/pair_to_tuple_conv.hh
new file mode 100644
index 0000000000000000000000000000000000000000..eba6ebd9b1ebbdbd7723d6ebaee656d0121e02d8
--- /dev/null
+++ b/modules/base/src/export_helper/pair_to_tuple_conv.hh
@@ -0,0 +1,37 @@
+//------------------------------------------------------------------------------
+// This file is part of the OpenStructure project <www.openstructure.org>
+//
+// Copyright (C) 2008-2010 by the OpenStructure authors
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License as published by the Free
+// Software Foundation; either version 3.0 of the License, or (at your option)
+// any later version.
+// This library is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
+// details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+//------------------------------------------------------------------------------
+#include <boost/python.hpp>
+
+namespace ost {
+
+/// \brief helper to convert between python tuple and std::pair
+/// 
+/// Usage:
+/// 
+/// register_to_python_converter<PairToTupleConverter<T1, T2>, 
+///                              std::pair<T1, T2>>()
+template<class T1, class T2>
+struct PairToTupleConverter {
+  static PyObject* convert(const std::pair<T1, T2>& pair) {
+    boost::python::tuple t=boost::python::make_tuple<T1,T2>(pair.first,
+                                                            pair.second);
+    return boost::python::incref(t.ptr());
+  }
+};
+}
\ No newline at end of file
diff --git a/modules/gfx/pymod/export_entity.cc b/modules/gfx/pymod/export_entity.cc
index 23e341b04754d0d960e78747277459dba023d54c..a81f8299ea0cdc549b1fb34b0255cdb66f4938d7 100644
--- a/modules/gfx/pymod/export_entity.cc
+++ b/modules/gfx/pymod/export_entity.cc
@@ -23,7 +23,7 @@ using namespace boost::python;
 #include <ost/gfx/entity.hh>
 using namespace ost;
 using namespace ost::gfx;
-
+#include <ost/export_helper/pair_to_tuple_conv.hh>
 #include "color_by_def.hh"
 
 namespace {
@@ -177,14 +177,6 @@ void ent_apply_62(Entity* e, MapHandleColorOp& mhco){
 }
 #endif //OST_IMG_ENABLED
 
-template<class T1, class T2>
-struct PairToTupleConverter {
-  static PyObject* convert(const std::pair<T1, T2>& pair) {
-    tuple t=boost::python::make_tuple<T1,T2>(pair.first,pair.second);
-    return incref(t.ptr());
-  }
-};
-
 
 RenderOptionsPtr ent_sline_opts(Entity* ent)
 {
diff --git a/modules/seq/base/pymod/__init__.py b/modules/seq/base/pymod/__init__.py
index 27e186b7565ace6021f3cff5e274d9181c23b291..0bc8f1b300e952bbf5ce5ae9bd52cbf9735c3420 100644
--- a/modules/seq/base/pymod/__init__.py
+++ b/modules/seq/base/pymod/__init__.py
@@ -16,67 +16,4 @@
 # along with this library; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 #------------------------------------------------------------------------------
-from _seq import *
-from ost import mol
-
-## \brief Create two views from sequence alignment such that the matching 
-#      residues occur at the same index within the chain.
-#
-# The first sequence in the sequence alignment belongs to ent_a, the second to
-# ent_b.
-#
-# Requires that each of the entities/views only contains one chain and that
-# the sequence offset of the sequences in the alignment is set appropriately.
-def ViewsFromAlignment(multi_seq_ali, ent_a, ent_b, include_atoms=True):
-  seq_a=multi_seq_ali.GetSequence(0)
-  seq_b=multi_seq_ali.GetSequence(1)
-  return ViewsFromSequences(seq_a, seq_b, ent_a, ent_b, include_atoms)
-
-def ViewsFromSequences(seq_a, seq_b, ent_a=None, ent_b=None, 
-                       include_atoms=True):
-  ent_a=ent_a or seq_a.attached_view
-  ent_b=ent_b or seq_b.attached_view
-  if ent_a.chain_count>1:
-   raise RuntimeError("first entity contains more than one chain")
-  if ent_b.chain_count>1:
-   raise RuntimeError("second entity contains more than one chain")
-  is_ha=isinstance(ent_a, mol.EntityHandle)
-  is_hb=isinstance(ent_b, mol.EntityHandle)  
-
-  ev_a= is_ha and ent_a.CreateEmptyView() or ent_a.handle.CreateEmptyView()
-  ev_b= is_hb and ent_b.CreateEmptyView() or ent_b.handle.CreateEmptyView()
-
-  flags=include_atoms and mol.ViewAddFlag.INCLUDE_ATOMS or 0
-  res_a=ent_a.residues
-  res_b=ent_b.residues
-  off_a=seq_a.GetSequenceOffset()
-  off_b=seq_b.GetSequenceOffset()
-
-  index_a, index_b=(0, 0)
-  done=False
-  #~ for i,j in zip(ent_a.residues,ent_b.residues): print i,i.index,j,j.index
-  #~ print  
-  while index_a<seq_a.GetLength() and index_b<seq_b.GetLength():
-    while seq_a.GetOneLetterCode(index_a+off_b)=='-':
-      index_a+=1
-      print 'gap a'
-      if seq_a.GetLength()<=index_a+off_b:
-        done=True        
-        break
-    while seq_b.GetOneLetterCode(index_b+off_a)=='-':
-      index_b+=1
-      print 'gap b'
-      if seq_b.GetLength()<=index_b+off_a:
-        done=True
-        break
-    if done or len(res_a)<=index_b+off_a or len(res_b)<=index_a+off_b:
-      break
-    ra=res_a[off_a+index_b]
-    rb=res_b[off_b+index_a]
-    print 'index_a',index_a, seq_a.GetLength(),seq_a.GetOneLetterCode(index_a+off_a),ra
-    print 'index_b',index_b, seq_b.GetLength(),seq_b.GetOneLetterCode(index_b+off_b),rb
-    ev_a.AddResidue(is_ha and ra or ra.handle, flags)
-    ev_b.AddResidue(is_hb and rb or rb.handle, flags)
-    index_a+=1
-    index_b+=1
-  return ev_a, ev_b
+from _seq import *
\ No newline at end of file
diff --git a/modules/seq/base/pymod/export_sequence.cc b/modules/seq/base/pymod/export_sequence.cc
index 87f9d3a6f9dde794a00586cb7aecba81541f8cf1..ce0e19864e6e6d4ee182b4f74391f31c32a078bf 100644
--- a/modules/seq/base/pymod/export_sequence.cc
+++ b/modules/seq/base/pymod/export_sequence.cc
@@ -20,8 +20,9 @@
 #include <boost/python/slice.hpp>
 #include <boost/python/register_ptr_to_python.hpp>
 #include <boost/python/suite/indexing/vector_indexing_suite.hpp>
-using namespace boost::python;
 
+
+#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>
@@ -31,10 +32,12 @@ using namespace boost::python;
 #include <ost/seq/sequence_op.hh>
 #include <ost/seq/sequence_list.hh>
 #include <ost/seq/aligned_region.hh>
+#include <ost/seq/views_from_sequences.hh>
 #include "const_seq_list_export_def.hh"
 
 using namespace ost;
 using namespace ost::seq;
+using namespace boost::python;
 
 namespace {
 
@@ -292,10 +295,15 @@ void export_sequence()
     .def("__getitem__", &do_slice_b)
   ;
   implicitly_convertible<SequenceList, ConstSequenceList>();
+  to_python_converter<std::pair<mol::EntityView, mol::EntityView>, 
+                      PairToTupleConverter<mol::EntityView, mol::EntityView> >();
   def("CreateSequenceList", &CreateSequenceList);
   def("SequenceFromChain", seq_from_chain_a);
   def("SequenceFromChain", seq_from_chain_b);
   def("SequenceToInfo", &SequenceToInfo);
+  def("ViewsFromSequences", &ViewsFromSequences, (arg("seq1"), arg("seq2")));
+  def("ViewsFromAlignment", &ViewsFromAlignment, 
+      (arg("aln"), arg("index1")=0, arg("index2")=1));
   def("SequenceListToInfo", &SequenceListToInfo);
   def("SequenceFromInfo", &SequenceFromInfo);
   def("CreateAlignment", &CreateAlignment);
diff --git a/modules/seq/base/src/CMakeLists.txt b/modules/seq/base/src/CMakeLists.txt
index 3cd12d19a6af292471fde3dbb6d85c32e5eaaef5..9a7015bdae3e8162ab76c711893a70e874fea101 100644
--- a/modules/seq/base/src/CMakeLists.txt
+++ b/modules/seq/base/src/CMakeLists.txt
@@ -15,6 +15,7 @@ aligned_region.hh
 aligned_column.hh
 aligned_column_iterator.hh
 invalid_sequence.hh
+views_from_sequences.hh
 )
 
 set(OST_SEQ_SOURCES
@@ -26,6 +27,7 @@ aligned_column.cc
 sequence_list.cc
 alignment_handle.cc
 sequence_op.cc
+views_from_sequences.cc
 )
 module(NAME seq SOURCES ${OST_SEQ_SOURCES} 
        HEADERS ${OST_SEQ_IMPL_HEADERS} IN_DIR impl
diff --git a/modules/seq/base/src/sequence_handle.cc b/modules/seq/base/src/sequence_handle.cc
index eeb3d1acb8f363c750c3327e7e4a648d36f88a9c..a7f5347e1f36521635b28d4ef6076b0c876ef8a0 100644
--- a/modules/seq/base/src/sequence_handle.cc
+++ b/modules/seq/base/src/sequence_handle.cc
@@ -51,6 +51,11 @@ bool ConstSequenceHandle::operator!=(const ConstSequenceHandle& rhs) const
   return impl_!=rhs.impl_;
 }
 
+char ConstSequenceHandle::operator[](int index) const
+{
+  this->CheckValidity();
+  return this->GetOneLetterCode(index);
+}
 
 void ConstSequenceHandle::CheckValidity() const
 {
diff --git a/modules/seq/base/src/sequence_handle.hh b/modules/seq/base/src/sequence_handle.hh
index ad4d294e33f518cc6575ff1aed82df63db3397c3..de03a505be77b43ad87b9c5d97edf2a9a681a01b 100644
--- a/modules/seq/base/src/sequence_handle.hh
+++ b/modules/seq/base/src/sequence_handle.hh
@@ -116,6 +116,8 @@ public:
   bool operator==(const ConstSequenceHandle& rhs) const;
   bool operator!=(const ConstSequenceHandle& rhs) const;  
   
+  char operator[](int index) const;
+  
   /// \brief whether the sequence is valid
   bool IsValid() const;
   /// \internal
diff --git a/modules/seq/base/src/views_from_sequences.cc b/modules/seq/base/src/views_from_sequences.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7ab0ff1f6806c1d303baac5e0689f12d06d91f89
--- /dev/null
+++ b/modules/seq/base/src/views_from_sequences.cc
@@ -0,0 +1,87 @@
+//------------------------------------------------------------------------------
+// This file is part of the OpenStructure project <www.openstructure.org>
+//
+// Copyright (C) 2008-2010 by the OpenStructure authors
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License as published by the Free
+// Software Foundation; either version 3.0 of the License, or (at your option)
+// any later version.
+// This library is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
+// details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+//------------------------------------------------------------------------------
+#include <ost/integrity_error.hh>
+#include <ost/seq/views_from_sequences.hh>
+
+namespace ost { namespace seq {
+
+namespace {
+
+bool skip_gaps(const ConstSequenceHandle& seq1, 
+               const ConstSequenceHandle& seq2, int& pos, 
+               int& index_a, int& index_b)
+{
+  while (seq1.GetLength()>pos) {
+    if (seq1[pos]=='-') {
+      if (seq2[pos]!='-') {
+        index_b+=1;
+      }
+    } else if (seq2[pos]=='-') {
+      index_a+=1;
+    } else {
+      return true;
+    }
+    pos+=1;
+  }
+  return false;
+}
+
+}
+
+std::pair<mol::EntityView, mol::EntityView> 
+ViewsFromSequences(const ConstSequenceHandle& seq1, 
+                   const ConstSequenceHandle& seq2)
+{
+  if (seq1.GetLength()!=seq2.GetLength()) {
+    throw IntegrityError("Sequence lengths do not match");
+  }
+  if (!seq1.HasAttachedView()) {
+    throw IntegrityError("First sequence does not have an attached view");
+  }
+  if (!seq2.HasAttachedView()) {
+    throw IntegrityError("Second sequence does not have an attached view");
+  }
+  mol::EntityView src_a=seq1.GetAttachedView();
+  mol::EntityView src_b=seq2.GetAttachedView();
+  
+  mol::EntityView dst_a=src_a.CreateEmptyView();
+  mol::EntityView dst_b=src_b.CreateEmptyView();
+  mol::ResidueViewList res_a=src_a.GetResidueList();
+  mol::ResidueViewList res_b=src_b.GetResidueList();  
+  int pos=0, index_a=0, index_b=0;
+  while (skip_gaps(seq1, seq2, pos, index_a, index_b)) {
+    dst_a.AddResidue(res_a.at(seq1.GetSequenceOffset()+index_a), 
+                     mol::ViewAddFlag::INCLUDE_ATOMS);
+    dst_b.AddResidue(res_b.at(seq2.GetSequenceOffset()+index_b), 
+                     mol::ViewAddFlag::INCLUDE_ATOMS);
+    pos+=1;
+    index_a+=1;
+    index_b+=1;
+  }
+  return std::make_pair(dst_a, dst_b);
+}
+
+
+std::pair<mol::EntityView, mol::EntityView> 
+ViewsFromAlignment(const AlignmentHandle& aln, int index1, int index2)
+{
+  return ViewsFromSequences(aln.GetSequence(index1), aln.GetSequence(index2));
+}
+
+}}
diff --git a/modules/seq/base/src/views_from_sequences.hh b/modules/seq/base/src/views_from_sequences.hh
new file mode 100644
index 0000000000000000000000000000000000000000..1a46965b1a7078038bc868090a1b9d590d3c5376
--- /dev/null
+++ b/modules/seq/base/src/views_from_sequences.hh
@@ -0,0 +1,36 @@
+//------------------------------------------------------------------------------
+// This file is part of the OpenStructure project <www.openstructure.org>
+//
+// Copyright (C) 2008-2010 by the OpenStructure authors
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License as published by the Free
+// Software Foundation; either version 3.0 of the License, or (at your option)
+// any later version.
+// This library is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
+// details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this library; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+//------------------------------------------------------------------------------
+#ifndef OST_SEQ_VIEWS_FROM_SEQUENCES_HH
+#define OST_SEQ_VIEWS_FROM_SEQUENCES_HH
+
+#include <ost/seq/module_config.hh>
+#include <ost/seq/alignment_handle.hh>
+
+namespace ost { namespace seq {
+
+std::pair<mol::EntityView, mol::EntityView> DLLEXPORT_OST_SEQ 
+ViewsFromSequences(const ConstSequenceHandle& seq1, 
+                   const ConstSequenceHandle& seq2);
+
+std::pair<mol::EntityView, mol::EntityView> DLLEXPORT_OST_SEQ
+ViewsFromAlignment(const AlignmentHandle& aln, int index1=0, int index2=1);
+  
+}}
+
+#endif
diff --git a/modules/seq/base/tests/test_seq.py b/modules/seq/base/tests/test_seq.py
index 69644ffc80e707c2bb8282b23b58fb0586277082..4eed73b1132f82109cc0250807561cb0675db3c0 100644
--- a/modules/seq/base/tests/test_seq.py
+++ b/modules/seq/base/tests/test_seq.py
@@ -4,174 +4,124 @@ from ost import settings
 from ost import seq
 
 
-def fixture(seq_str='MRLDGKTALITGSAR'):
+def fixture():
   e=mol.CreateEntity()
   ede=e.RequestXCSEditor()
   chain=ede.InsertChain('A')
-  res_str='MET ARG LEU ASP GLY LYS THR ALA LEU ILE THR GLY SER ALA ARG'
-  res=res_str.split()
-  olc={}
-  counter=0
-  for i in 'MRLDGKTALITGSAR':
-    olc[i]=res[counter]
-    counter+=1
-  
-  for i in seq_str:
-    if i!='-':
-      r=ede.AppendResidue(chain,olc[i])
-      r.SetOneLetterCode(i)
-      a=ede.InsertAtom(r,'CA',geom.Vec3())
-  #~ for i in e.atoms: print i,i.index
-  return e.Copy()
+  for res in 'ABCDEFGH':
+    r=ede.AppendResidue(chain, res)
+    r.SetOneLetterCode(res)
+    ede.InsertAtom(r, "XXX", geom.Vec3())
+    
+  return e
   
 class TestSeq(unittest.TestCase):
   
   def setUp(self):
-    #sequence and entity must correspond
-    print 'initialising'
-    ent=fixture()
-    self.protein=ent.Select('')
-    c=self.protein.chains[0]
-    self.seq_a=seq.SequenceFromChain('0',c) # MRLDGKTALITGSAR
-    self.seq_a.AttachView(self.protein)
-    self.seq_b=seq.CreateSequence('1','---DGKTALITGSAR')
-    self.seq_b.AttachView(fixture('---DGKTALITGSAR').Select(''))
-    #~ self.seq_c=seq.CreateSequence('2','MRLDG---LITGSAR')
-    #~ self.seq_c.AttachView(self.protein)
-    #~ self.seq_d=seq.CreateSequence('3','MRLDG----ITGSAR')
-    #~ self.seq_d.AttachView(self.protein)
-    self.seq_e=seq.CreateSequence('4','AMRLDG----ITGSA')
-    self.seq_e.AttachView(fixture('AMRLDG----ITGSA').Select(''))
-    ##self.seq_e.AttachView(self.protein)
-    self.seq_e.SetSequenceOffset(1)
-    self.seq_f=seq.CreateSequence('5','MRLDGKTA-ITGSAR')
-    self.seq_f.AttachView(fixture('MRLDGKTA-ITGSAR').Select(''))
-    self.seq_g=seq.CreateSequence('6','MRLDGKTALITG---')
-    self.seq_g.AttachView(fixture('MRLDGKTALITG---').Select(''))
-    
-#~ MRLDGKTALITGSAR
-#~ ---DGKTALITGSAR
-  def testViewsFromSequences1(self):
+    self.ent=fixture()
+
+  def testViewsFromSequences_01(self):
+    seq_a=seq.CreateSequence("A", "ABCD-FGH")
+    seq_a.AttachView(self.ent.Select('rname=A,B,C,D,F,G,H'))
+    seq_b=seq.CreateSequence("B", "ABCDEFGH")
+    seq_b.AttachView(self.ent.Select(''))
+    a, b=seq.ViewsFromSequences(seq_a, seq_b)
+    string_a=''.join([r.one_letter_code for r in a.residues])
+    string_b=''.join([r.one_letter_code for r in b.residues])
+    self.assertEqual(string_a, 'ABCDFGH')
+    self.assertEqual(string_b, 'ABCDFGH')
+ 
+  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'))
+    seq_b=seq.CreateSequence("B", "ABCD-FGH")
+    seq_b.AttachView(self.ent.Select('rname=A,B,C,D,F,G,H'))
+    a, b=seq.ViewsFromSequences(seq_a, seq_b)
+    string_a=''.join([r.one_letter_code for r in a.residues])
+    string_b=''.join([r.one_letter_code for r in b.residues])
+    self.assertEqual(string_a, 'ABCDFGH')
+    self.assertEqual(string_b, 'ABCDFGH')
     
-    [a,b]=seq.ViewsFromSequences(self.seq_a,
-                                 self.seq_b,
-                                 self.seq_a.GetAttachedView(),
-                                 self.seq_b.GetAttachedView())
-
-    #~ for i,j in zip(a.atoms,b.atoms):
-      #~ print i,i.residue.one_letter_code,j,j.residue.one_letter_code
+  def testViewsFromSequences_03(self):
+    seq_a=seq.CreateSequence("A", "ABCD--GH")
+    seq_a.AttachView(self.ent.Select('rname=A,B,C,D,G,H'))
+    seq_b=seq.CreateSequence("B", "ABCD-FGH")
+    seq_b.AttachView(self.ent.Select('rname=A,B,C,D,F,G,H'))
+    a, b=seq.ViewsFromSequences(seq_a, seq_b)
+    string_a=''.join([r.one_letter_code for r in a.residues])
+    string_b=''.join([r.one_letter_code for r in b.residues])
+    self.assertEqual(string_a, 'ABCDGH')
+    self.assertEqual(string_b, 'ABCDGH')
+ 
+  def testViewsFromSequences_04(self):
+    seq_a=seq.CreateSequence("A", "ABCD-FGH")
+    seq_a.AttachView(self.ent.Select('rname=A,B,C,D,F,G,H'))
+    seq_b=seq.CreateSequence("B", "ABCD--GH")
+    seq_b.AttachView(self.ent.Select('rname=A,B,C,D,G,H'))
+    a, b=seq.ViewsFromSequences(seq_a, seq_b)
+    string_a=''.join([r.one_letter_code for r in a.residues])
+    string_b=''.join([r.one_letter_code for r in b.residues])
+    self.assertEqual(string_a, 'ABCDGH')
+    self.assertEqual(string_b, 'ABCDGH')
     
-    self.assertEqual(a.atoms[0].GetResidue().GetOneLetterCode(),'D');
-    self.assertEqual(b.atoms[0].GetResidue().GetOneLetterCode(),'D');
-    self.assertEqual(a.atoms[11].GetResidue().GetOneLetterCode(),'R');
-    self.assertEqual(b.atoms[11].GetResidue().GetOneLetterCode(),'R');
-
-#~ ---DGKTALITGSAR
-#~ MRLDGKTALITGSAR
-  def testViewsFromSequences2(self):
-    [a,b]=seq.ViewsFromSequences(self.seq_b,
-                                 self.seq_a,
-                                 self.seq_b.GetAttachedView(),
-                                 self.seq_a.GetAttachedView())
-
-    self.assertEqual(a.atoms[0].GetResidue().GetOneLetterCode(),'D');
-    self.assertEqual(b.atoms[0].GetResidue().GetOneLetterCode(),'D');
-    self.assertEqual(a.atoms[11].GetResidue().GetOneLetterCode(),'R');
-    self.assertEqual(b.atoms[11].GetResidue().GetOneLetterCode(),'R');
-
-
-##~ MRLDGKTALITGSAR
-##~ MRLDGKTALITG---
-  def testViewsFromSequences3(self):
-    [a,b]=seq.ViewsFromSequences(self.seq_a,
-                                 self.seq_g,
-                                 self.seq_a.GetAttachedView(),
-                                 self.seq_g.GetAttachedView())
-
-    self.assertEqual(a.atoms[0].GetResidue().GetOneLetterCode(),'M');
-    self.assertEqual(b.atoms[0].GetResidue().GetOneLetterCode(),'M');
-    self.assertEqual(a.atoms[-1].GetResidue().GetOneLetterCode(),'G');
-    self.assertEqual(b.atoms[-1].GetResidue().GetOneLetterCode(),'G');
+  def testViewsFromSequences_05(self):
+    seq_a=seq.CreateSequence("A", "ABCD-F--")
+    seq_a.AttachView(self.ent.Select('rname=A,B,C,D,F'))
+    seq_b=seq.CreateSequence("B", "ABCDEFGH")
+    seq_b.AttachView(self.ent.Select('rname=A,B,C,D,E,F,G,H'))
+    a, b=seq.ViewsFromSequences(seq_a, seq_b)
+    string_a=''.join([r.one_letter_code for r in a.residues])
+    string_b=''.join([r.one_letter_code for r in b.residues])
+    self.assertEqual(string_a, 'ABCDF')
+    self.assertEqual(string_b, 'ABCDF')
     
-
-##~ MRLDGKTALITG---
-##~ MRLDGKTALITGSAR
-  def testViewsFromSequences4(self):
-    [a,b]=seq.ViewsFromSequences(self.seq_g,
-                                 self.seq_a,
-                                 self.seq_g.GetAttachedView(),
-                                 self.seq_a.GetAttachedView())
-
-    self.assertEqual(a.atoms[0].GetResidue().GetOneLetterCode(),'M');
-    self.assertEqual(b.atoms[0].GetResidue().GetOneLetterCode(),'M');
-    self.assertEqual(a.atoms[-1].GetResidue().GetOneLetterCode(),'G');
-    self.assertEqual(b.atoms[-1].GetResidue().GetOneLetterCode(),'G');
-
-
-
-##~ MRLDGKTALITGSAR
-##~ MRLDGKTA-ITGSAR
-  def testViewsFromSequences5(self):
-    [a,b]=seq.ViewsFromSequences(self.seq_a,
-                                 self.seq_f,
-                                 self.seq_a.GetAttachedView(),
-                                 self.seq_f.GetAttachedView())
-    print 'result'
-    for i,j in zip(a.residues,b.residues): print i,i.index,j,j.index
-                                 
-    self.assertEqual(a.atoms[0].GetResidue().GetOneLetterCode(),'M');
-    self.assertEqual(b.atoms[0].GetResidue().GetOneLetterCode(),'M');
-    #~ for i,j in zip(a.atoms,b.atoms): print i,j
-    self.assertEqual(a.atoms[8].GetResidue().GetOneLetterCode(),'I');
-    self.assertEqual(b.atoms[8].GetResidue().GetOneLetterCode(),'I');
-
-##~ MRLDGKTA-ITGSAR
-##~ MRLDGKTALITGSAR
-  #def testViewsFromSequences6(self):
-    #[a,b]=seq.ViewsFromSequences(self.seq_f,
-                                 #self.seq_a,
-                                 #self.seq_f.GetAttachedView(),
-                                 #self.seq_a.GetAttachedView())
-
-    #self.assertEqual(a.atoms[0].GetResidue().GetOneLetterCode(),'M');
-    #self.assertEqual(b.atoms[0].GetResidue().GetOneLetterCode(),'M');
-    #self.assertEqual(a.atoms[8].GetResidue().GetOneLetterCode(),'I');
-    #self.assertEqual(b.atoms[8].GetResidue().GetOneLetterCode(),'I');
-    
-##~ MRLDG---LITGSAR
-##~ MRLDG----ITGSAR
-  #~ def testViewsFromSequences7(self):
-    #~ [a,b]=seq.ViewsFromSequences(self.seq_c,
-                                 #~ self.seq_d,
-                                 #~ self.seq_c.GetAttachedView(),
-                                 #~ self.seq_d.GetAttachedView())
-#~ 
-    #~ self.assertEqual(a.atoms[0].GetResidue().GetOneLetterCode(),'M');
-    #~ self.assertEqual(b.atoms[0].GetResidue().GetOneLetterCode(),'M');
-    #~ self.assertEqual(a.atoms[5].GetResidue().GetOneLetterCode(),'I');
-    #~ self.assertEqual(b.atoms[5].GetResidue().GetOneLetterCode(),'I');
-                  
-#~ MRLDGKTALITGSAR
-#~ AMRLDG----ITGSA
-  def testViewsFromSequences8(self):
-    [a,b]=seq.ViewsFromSequences(self.seq_a,
-                                 self.seq_e,
-                                 self.seq_a.GetAttachedView(),
-                                 self.seq_e.GetAttachedView())
-    print 'result'
-    for i,j in zip(a.residues,b.residues): print i,i.index,j,j.index
-    self.assertEqual(a.atoms[0].GetResidue().GetOneLetterCode(),'M');
-    self.assertEqual(b.atoms[0].GetResidue().GetOneLetterCode(),'M');
-    self.assertEqual(a.atoms[6].GetResidue().GetOneLetterCode(),'I');
-    self.assertEqual(b.atoms[6].GetResidue().GetOneLetterCode(),'I');
-               
- 
-
-
-if __name__ == "__main__":
-  # test if python extension for seq module work
-  suite = unittest.TestLoader().loadTestsFromTestCase(TestSeq)
-  unittest.TextTestRunner(verbosity=3).run(suite)
-
-  #~ unittest.main()
+  def testViewsFromSequences_06(self):
+    seq_a=seq.CreateSequence("A", "--CD-FGH")
+    seq_a.AttachView(self.ent.Select('rname=C,D,F,G,H'))
+    seq_b=seq.CreateSequence("B", "ABCDEFGH")
+    seq_b.AttachView(self.ent.Select('rname=A,B,C,D,E,F,G,H'))
+    a, b=seq.ViewsFromSequences(seq_a, seq_b)
+    string_a=''.join([r.one_letter_code for r in a.residues])
+    string_b=''.join([r.one_letter_code for r in b.residues])
+    self.assertEqual(string_a, 'CDFGH')
+    self.assertEqual(string_b, 'CDFGH')
+
+
+  def testViewsFromSequences_07(self):
+    seq_a=seq.CreateSequence("A", "AB-D-FGH")
+    seq_a.AttachView(self.ent.Select('rname=A,B,D,F,G,H'))
+    seq_b=seq.CreateSequence("B", "AB-DEF-H")
+    seq_b.AttachView(self.ent.Select('rname=A,B,D,E,F,H'))
+    a, b=seq.ViewsFromSequences(seq_a, seq_b)
+    string_a=''.join([r.one_letter_code for r in a.residues])
+    string_b=''.join([r.one_letter_code for r in b.residues])
+    self.assertEqual(string_a, 'ABDFH')
+    self.assertEqual(string_b, 'ABDFH')
+
+
+  def testViewsFromSequences_08(self):
+    seq_a=seq.CreateSequence("A", "A-C-E-G")
+    seq_a.AttachView(self.ent.Select('rname=A,C,E,G'))
+    seq_b=seq.CreateSequence("B", "-B-D-H-")
+    seq_b.AttachView(self.ent.Select('rname=B,D,H'))
+    a, b=seq.ViewsFromSequences(seq_a, seq_b)
+    string_a=''.join([r.one_letter_code for r in a.residues])
+    string_b=''.join([r.one_letter_code for r in b.residues])
+    self.assertEqual(string_a, '')
+    self.assertEqual(string_b, '')
+
+  def testViewsFromSequences_09(self):
+    seq_a=seq.CreateSequence("A", "B-D-FGH")
+    seq_a.AttachView(self.ent.Select('rname=A,B,D,F,G,H'))
+    seq_a.SetSequenceOffset(1)
+    seq_b=seq.CreateSequence("B", "B-DEF-H")
+    seq_b.SetSequenceOffset(1)
+    seq_b.AttachView(self.ent.Select('rname=A,B,D,E,F,H'))
+    a, b=seq.ViewsFromSequences(seq_a, seq_b)
+    string_a=''.join([r.one_letter_code for r in a.residues])
+    string_b=''.join([r.one_letter_code for r in b.residues])
+    self.assertEqual(string_a, 'BDFH')
+    self.assertEqual(string_b, 'BDFH')
+suite = unittest.TestLoader().loadTestsFromTestCase(TestSeq)
+unittest.TextTestRunner().run(suite)