allpy
view allpy/fileio.py @ 806:61e5d8e146c7
WARNING! Changed EOL formatting to UNIX everywhere! WARNING!
To avoid such nasty commits in the future, add the following lines to your
~/.hgrc:
[extensions]
hgext.eol =
Note: kodomo has this setting on by default.
Please also note .hgeol file, that has rules for EOL conversion.
author | Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru> |
---|---|
date | Thu, 14 Jul 2011 14:28:32 +0400 |
parents | d16e8559b6dd |
children | 4f896db3531d |
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."""
47 """Fasta parser & writer."""
50 """Append one sequence to file."""
63 """Write sequences to file.
65 Sequences are given as list of tuples (string, name, description).
66 """
71 """Read parts beginning with > in FASTA file.
73 This is a drop-in replacement for self.file.read().split("\n>")
74 It is required for markup format, which combines parts read with
75 different parsers. Python prohibits combining iterators and file.read
76 methods on the same file.
77 """
97 """Parser & writer for our own marked alignment file format.
99 Marked alignment file consists of a list of records, separated with one or
100 more empty lines. Each record consists of type name, header and optional
101 contents. Type name is a line, containing just one word, describing the
102 record type. Header is a sequence of lines, each in format `key: value`.
103 Content, if present, is separated from header with an empty line.
105 Type names and header key names are case-insensitive.
107 Known record types now are:
109 - `alignment` -- this must be the last record in file for now
110 - `sequence_markup`
111 - `alignment_markup`
113 Example::
115 sequence_markup
116 sequence_name: cyb5_mouse
117 sequence_description:
118 name: pdb_residue_number
119 type: SequencePDBResidueNumberMarkup
120 markup: -,12,121,122,123,124,13,14,15,-,-,16
122 alignment_markup
123 name: geometrical_core
124 type: AlignmentGeometricalCoreMarkup
125 markup: -,-,-,-,+,+,+,-,-,-,+,+,-,-,-,-
127 alignment
128 format: fasta
130 > cyb5_mouse
131 seqvencemouse
132 """
135 """Helper attribute for write_empty_line."""
138 """Write alignment to file."""
144 }
152 """Write a dictionary of markups as series of records."""
162 """Write record to file. Add new line before every but first record."""
170 """Add empty line every time except the first call."""
175 """Read alignment from file."""
181 """Found sequence markup record in file. Do something about it."""
189 return
193 """Found alignment markup record in file. Do something about it."""
198 """Found alignment record. It has been handled in read_payload."""
199 pass
202 """Read records and return them as a list of dicts."""
205 continue
209 """Read record headers and record payload."""
223 """Read record payload, if necessary."""
229 """Parser & writer for file formats supported by EMBOSS."""
232 """Write sequences to file."""
235 )
242 """EMBOSS does not permit : in file names. Fix sequences for that."""
247 """Read sequences from file."""
250 )
256 # vim: set et ts=4 sts=4 sw=4: