allpy
view allpy/markup.py @ 426:43bca78ece0c
add class Markup (see #30)
add module allpy/markup
class MarkedAlignment seems to be added later
author | boris <bnagaev@gmail.com> |
---|---|
date | Mon, 14 Feb 2011 19:32:51 +0300 |
parents | |
children | c37a2c56deb7 |
line source
4 """ object for use as key for default value """
7 """ Markup for Sequence or Alignment
9 container is iterable collection of items.
10 item is object getting markup data (new attribute).
12 container: Alignment, item: Column
13 container: Sequence, item: Monomer
15 Markup stored in attributes of item is internal value.
16 When export or import, it is mapped to or from external value.
17 Internal value could be of any type.
18 External value should be single character.
20 Data:
21 * name -- name (str) of attribute of object
22 * container
23 * map_out -- dict, mapping internal values to external
24 * map_in -- dict, mapping external values to internal
26 map_in and map_out can have key markup.default, which used when
27 input key is not in map. To drop this defaults, drop this key
28 from map_out and map_in dicts. In this case to_string() and
29 from_string() methods can raise KeyError
30 """
33 """ Note: adds convenient defaults to maps """
55 """ returns internal value for given item
57 markup[monomer] <==> monomer.name, where name is markup.name
58 """
62 """ returns if intarnal value determined for given item
64 usage: if item in markup
65 """
69 """ delete all attributes from items """
74 """ return string representing markup """
84 """ adds (or replaces) attributes to items """