Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/rev/5091fef2ad88
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 00:17:03 2012
Кодировка:
allpy: 5091fef2ad88

allpy

changeset 101:5091fef2ad88

lib::MonomerType operator== consider only one letter code align -- additional check of monomer equality fix bug with missing __ne__ where __eq__ present
author boris <bnagaev@gmail.com>
date Thu, 21 Oct 2010 00:39:57 +0400
parents a49f40ace6a8
children 6479950a9ee3
files lib/monomer.py lib/project.py lib/sequence.py
diffstat 3 files changed, 16 insertions(+), 6 deletions(-) [+]
line diff
     1.1 --- a/lib/monomer.py	Thu Oct 21 00:27:15 2010 +0400
     1.2 +++ b/lib/monomer.py	Thu Oct 21 00:39:57 2010 +0400
     1.3 @@ -32,9 +32,12 @@
     1.4      def from_name(name):
     1.5          return index_name[name.capitalize()]
     1.6          
     1.7 -    
     1.8 +    # TO DISCUSS
     1.9 +    def __eq__(self, other):
    1.10 +        return self.code1 == other.code1
    1.11  
    1.12 -# TODO -- create all MonomerTypes
    1.13 +    def __ne__(self, other):
    1.14 +        return not self == other
    1.15  
    1.16  
    1.17  class Monomer(object):
    1.18 @@ -52,7 +55,8 @@
    1.19      def __eq__(self, other):
    1.20          return self.monomer_type == other.monomer_type
    1.21  
    1.22 -
    1.23 +    def __ne__(self, other):
    1.24 +        return not self == other
    1.25  
    1.26  class AminoAcidType(MonomerType):
    1.27      def __init__(self, name, code1, code3, is_modified=False):
     2.1 --- a/lib/project.py	Thu Oct 21 00:27:15 2010 +0400
     2.2 +++ b/lib/project.py	Thu Oct 21 00:39:57 2010 +0400
     2.3 @@ -182,11 +182,14 @@
     2.4                  new_sequence = [i for i in sequences if sequence==i][0]
     2.5              except:
     2.6                  raise Exception("Align: Cann't find sequence %s in muscle output" % sequence.name)
     2.7 -            old_monomers = sequence.monomers.__iter__()
     2.8 +            old_monomers = iter(sequence.monomers)
     2.9              self.alignment[sequence] = []
    2.10              for monomer in alignment[new_sequence]:
    2.11                  if not monomer:
    2.12                      self.alignment[sequence].append(monomer)
    2.13                  else:
    2.14 -                    self.alignment[sequence].append(old_monomers.next())
    2.15 +                    old_monomer = old_monomers.next()
    2.16 +                    if monomer != old_monomer:
    2.17 +                        raise Exception("Align: alignment errors")
    2.18 +                    self.alignment[sequence].append(old_monomer)
    2.19              
     3.1 --- a/lib/sequence.py	Thu Oct 21 00:27:15 2010 +0400
     3.2 +++ b/lib/sequence.py	Thu Oct 21 00:39:57 2010 +0400
     3.3 @@ -31,7 +31,10 @@
     3.4      def __eq__(self, other):
     3.5          return len(self) == len(other) and \
     3.6          all([a==b for a, b in zip(self.monomers, other.monomers)])
     3.7 -        
     3.8 +    
     3.9 +    def __ne__(self, other):
    3.10 +        return not (self == other)
    3.11 +    
    3.12      def pdb_chain_add(self, pdb_file, pdb_id, pdb_chain, pdb_model=0):
    3.13          """
    3.14          Reads Pdb chain from file