allpy
view allpy/util.py @ 1091:afed1fd8920c
Added backreferences to `Seqeunce`s from `Monomer`s (closes #49)
WARNING! Please note that `Sequence` API almost changed entirely!
WARNING! This commit immediately obsoletes classmethods `Monomer.from_code*`,
`Monomer.from_name` and `Sequence.from_monomers`.
Turns out, python can not pickle sets/dicts which have keys, which inderecly
reference the set/dict itself: http://bugs.python.org/issue9269 -- which is
excatly what we have in abundance after this change.
To allow pickling added `__getstate__` to `Monomer` to return all attributes,
except `sequence` and `__setstate__` to `Sequence`, which runs through all
monomers and returns the `sequence` attribute back to where it belongs.
WARNING! This MAY result in unexpected behaviour in some cases. (Which should
be rare enough).
author | Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru> |
---|---|
date | Sat, 02 Jun 2012 19:33:42 +0400 |
parents | a3e439d09322 |
children | bc1a7595d9d1 |
line source
1 """Miscellanous utilities.
2 """
10 """The oppozite of zip() builtin."""
18 """Open file. Return stdin/stdout for filename '-'."""
29 """Remove each of substrings from string."""
35 """Clone of dict that user may add attributes to."""
36 pass
39 """Clone of list that user may add attributes to."""
40 pass
43 """Clone of str that user may add attributes to."""
44 pass
47 """Warn about function being deprecated."""
51 """Context manager for use with `with`.
53 Run code in context without any message to the screen, but show all output
54 that was there if an error occured. E.g.::
56 with Silence():
57 structure = PDBParser().get_structure(name, file)
59 There are two mutually exclusive ways of silencing:
61 1. By replacing OS'es stdout/stderr with tempfile (called `dup`)
62 2. By replacing python's sys.stdout/sys.stderr with StringIO (`hide`)
64 For each of ways you may specify values: 'stdout', 'stderr' or 'both'.
65 E.g::
67 with Silence(dup="both"):
68 check_call(["mucle", alignment])
70 `Silence()` is equivalent to `Silence(hide='stderr')`
71 """
127 # vim: set et ts=4 sts=4 sw=4: