コード例 #1
0
ファイル: Seq.py プロジェクト: manucorreia/biopython
 def __radd__(self, other):
     if hasattr(other, "alphabet"):
         #other should be a Seq or a MutableSeq
         if not Alphabet._check_type_compatible(
             [self.alphabet, other.alphabet]):
             raise TypeError("Incompatable alphabets %s and %s" \
                             % (repr(self.alphabet), repr(other.alphabet)))
         #They should be the same sequence type (or one of them is generic)
         a = Alphabet._consensus_alphabet([self.alphabet, other.alphabet])
         return self.__class__(str(other) + str(self), a)
     elif isinstance(other, basestring):
         #other is a plain string - use the current alphabet
         return self.__class__(other + str(self), self.alphabet)
     else:
         raise TypeError
コード例 #2
0
ファイル: Seq.py プロジェクト: nuin/biopython
 def __radd__(self, other):
     if hasattr(other, "alphabet") :
         #other should be a Seq or a MutableSeq
         if not Alphabet._check_type_compatible([self.alphabet,
                                                 other.alphabet]) :
             raise TypeError("Incompatable alphabets %s and %s" \
                             % (repr(self.alphabet), repr(other.alphabet)))
         #They should be the same sequence type (or one of them is generic)
         a = Alphabet._consensus_alphabet([self.alphabet, other.alphabet])
         return self.__class__(str(other) + str(self), a)
     elif isinstance(other, basestring) :
         #other is a plain string - use the current alphabet
         return self.__class__(other + str(self), self.alphabet)
     else :
         raise TypeError
コード例 #3
0
ファイル: Seq.py プロジェクト: manucorreia/biopython
 def __radd__(self, other):
     if hasattr(other, "alphabet"):
         #other should be a Seq or a MutableSeq
         if not Alphabet._check_type_compatible(
             [self.alphabet, other.alphabet]):
             raise TypeError("Incompatable alphabets %s and %s" \
                             % (repr(self.alphabet), repr(other.alphabet)))
         #They should be the same sequence type (or one of them is generic)
         a = Alphabet._consensus_alphabet([self.alphabet, other.alphabet])
         if isinstance(other, MutableSeq):
             #See test_GAQueens.py for an historic usage of a non-string
             #alphabet!  Adding the arrays should support this.
             return self.__class__(other.data + self.data, a)
         else:
             return self.__class__(str(other) + str(self), a)
     elif isinstance(other, basestring):
         #other is a plain string - use the current alphabet
         return self.__class__(str(other) + str(self), self.alphabet)
     else:
         raise TypeError
コード例 #4
0
ファイル: Seq.py プロジェクト: nuin/biopython
 def __radd__(self, other):
     if hasattr(other, "alphabet") :
         #other should be a Seq or a MutableSeq
         if not Alphabet._check_type_compatible([self.alphabet,
                                                 other.alphabet]) :
             raise TypeError("Incompatable alphabets %s and %s" \
                             % (repr(self.alphabet), repr(other.alphabet)))
         #They should be the same sequence type (or one of them is generic)
         a = Alphabet._consensus_alphabet([self.alphabet, other.alphabet])
         if isinstance(other, MutableSeq):
             #See test_GAQueens.py for an historic usage of a non-string
             #alphabet!  Adding the arrays should support this.
             return self.__class__(other.data + self.data, a)
         else :
             return self.__class__(str(other) + str(self), a)
     elif isinstance(other, basestring) :
         #other is a plain string - use the current alphabet
         return self.__class__(str(other) + str(self), self.alphabet)
     else :
         raise TypeError