allpy
view allpy/fileio.py @ 848:d60d8993ac35
Fixed versions in NEWS; added comment for 1.4.1
author | Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru> |
---|---|
date | Wed, 20 Jul 2011 18:29:18 +0400 |
parents | 4f896db3531d |
children | 6cc007e68af6 |
line source
7 """This ugly helper is to avoid bad untimely import loops."""
12 """Automatical file IO."""
25 """Some helpers."""
34 """Append alignment to the file."""
38 )
41 """Read alignment from the file."""
48 """Fasta parser & writer."""
51 """Append one sequence to file."""
64 """Write sequences to file.
66 Sequences are given as list of tuples (string, name, description).
67 """
72 """Read parts beginning with > in FASTA file.
74 This is a drop-in replacement for self.file.read().split("\n>")
75 It is required for markup format, which combines parts read with
76 different parsers. Python prohibits combining iterators and file.read
77 methods on the same file.
78 """
98 """Parser & writer for our own marked alignment file format.
100 Marked alignment file consists of a list of records, separated with one or
101 more empty lines. Each record consists of type name, header and optional
102 contents. Type name is a line, containing just one word, describing the
103 record type. Header is a sequence of lines, each in format `key: value`.
104 Content, if present, is separated from header with an empty line.
106 Type names and header key names are case-insensitive and '-' and '_' in
107 them are equivalent.
109 Known record types now are:
111 - `alignment` -- this must be the last record in file for now
112 - `sequence_markup`
113 - `alignment_markup`
115 Example::
117 sequence-markup
118 sequence-name: cyb5_mouse
119 sequence-description:
120 name: pdb_residue_number
121 type: SequencePDBResidueNumberMarkup
122 markup: -,12,121,122,123,124,13,14,15,-,-,16
124 alignment-markup
125 name: geometrical_core
126 type: AlignmentGeometricalCoreMarkup
127 markup: -,-,-,-,+,+,+,-,-,-,+,+,-,-,-,-
129 alignment
130 format: fasta
132 > cyb5_mouse
133 seqvencemouse
134 """
137 """Helper attribute for write_empty_line."""
140 """Write alignment to file."""
146 }
154 """Write a dictionary of markups as series of records."""
164 """Write record to file. Add new line before every but first record."""
173 """Add empty line every time except the first call."""
178 """Read alignment from file."""
184 """Found sequence markup record in file. Do something about it."""
192 return
196 """Found alignment markup record in file. Do something about it."""
201 """Found alignment record. It has been handled in read_payload."""
202 pass
205 """Read records and return them as a list of dicts."""
208 continue
212 """Read record headers and record payload."""
226 """Read record payload, if necessary."""
231 @staticmethod
239 """Parser & writer for file formats supported by EMBOSS."""
242 """Write sequences to file."""
245 )
252 """EMBOSS does not permit : in file names. Fix sequences for that."""
257 """Read sequences from file."""
260 )
266 # vim: set et ts=4 sts=4 sw=4: