Package corebio :: Module seq :: Class Alphabet
[frames | no frames]

Type Alphabet

object --+
         |
        Alphabet


An ordered subset of printable ascii characters.

Status:
    Beta
Authors: 
    - GEC 2005

Method Summary
  __eq__(self, other)
  __getitem__(self, key)
  __iter__(self)
  __len__(self)
  __ne__(self, other)
  __new__(cls, letters, alternatives)
Create a new, immutable Alphabet. (Static method)
  __repr__(self)
  __str__(self)
  alphabetic(self, string)
True if all characters of the string are in this alphabet.
  chr(self, n)
The n'th character in the alphabet (zero indexed) or \0...
  chrs(self, sequence_of_ints)
Convert a sequence of ordinals into an alphabetic string.
  letters(self)
Letters of the alphabet as a string.
  normalize(self, string)
Normalize an alphabetic string by converting all alternative symbols to the canonical equivalent in 'letters'.
  ord(self, c)
The ordinal position of the character c in this alphabet, or 255 if no such character.
  ords(self, string)
Convert an alphabetic string into a byte array of ordinals.
    Inherited from object
  __init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature...
  __delattr__(...)
x.__delattr__('name') <==> del x.name...
  __getattribute__(...)
x.__getattribute__('name') <==> x.name...
  __hash__(x)
x.__hash__() <==> hash(x)...
  __reduce__(...)
helper for pickle...
  __reduce_ex__(...)
helper for pickle...
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value...

Class Variable Summary
list __slots__ = ['_letters', '_alternatives', '_ord_table', ...

Instance Method Details

alphabetic(self, string)

True if all characters of the string are in this alphabet.

chr(self, n)

The n'th character in the alphabet (zero indexed) or \0

chrs(self, sequence_of_ints)

Convert a sequence of ordinals into an alphabetic string.

letters(self)

Letters of the alphabet as a string.

normalize(self, string)

Normalize an alphabetic string by converting all alternative symbols 
to the canonical equivalent in 'letters'.

ord(self, c)

The ordinal position of the character c in this alphabet,
or 255 if no such character.

ords(self, string)

Convert an alphabetic string into a byte array of ordinals.

Static Method Details

__new__(cls, letters, alternatives=None)

Create a new, immutable Alphabet.

arguments:
- letters -- the letters in the alphabet. The ordering determines
    the ordinal position of each character in this alphabet.
- alt -- A list of (alternative, canonical) letters. The alternatives
    are given the same ordinal position as the canonical character. 
    e.g. (('?','X'),('x', 'X')) states that '?' and 'x' are synomonous 
    with 'X'.  Values that are not in 'letters' are ignored. Alternatives
    that are already in 'letters' are also ignored. If the same
    alternative character is used twice then the alternative is assigned
    to the canonical character that occurs first in 'letters'. The 
    default is to assume that upper and lower case characters are
    equivalent, unless both cases are included in 'letters'.                   
raises:
    ValueError : Repetitive or otherwise illegal set of letters.
Overrides:
__builtin__.object.__new__

Class Variable Details

__slots__

Type:
list
Value:
['_letters', '_alternatives', '_ord_table', '_chr_table']              

Generated by Epydoc 2.1 on http://epydoc.sf.net