Author: | Andreas Heger |
---|---|
Release: | $Id$ |
Date: | December 09, 2013 |
Tags: | Python |
read a map (pairs of values) from infile. returns a hash.
Use map functions to convert elements. If both_directions is set to true, both mapping directions are returned.
read a list of values from infile.
Use map_function to convert values. Use map_category, to map read values directory If with_title, first line is assumed to be a title
read a list of values from infile.
Use map_function to convert values. Use map_category, to map read values directory
read a map (pairs of values) from infile. returns a hash.
Use map functions to convert elements. If both_directions is set to true, both mapping directions are returned. This function can have n:n matches
read a table of values. There probably is a routine for this in Numpy, which I haven’t found yet.
If cumulate_out_of_range is set to true, the terminal bins will contain the cumulative values of bins out of range.
write a table to outfile.
If table is a dictionary, output columnwise. If columns is a list, only output columns in columns in the specified order.
read a numpy matrix from infile.
return tuple of matrix, row_headers, col_headers
write a numpy matrix to outfile.
row_header gives the title of the rows
returns an inverted dictionary with keys and values swapped.
read sequence from a fasta file.
returns a tuple with description and sequence
return last line of a file.
get number of lines in filename.
compatibility - see readMap.
return True if file exists and is empty.
raises OSError if file does not exist
manage a pool of output files
This class will keep a large number of files open. To see if you can handle this, check the limit within the shell:
ulimit -n
The number of currently open and maximum open files in the system:
cat /proc/sys/fs/file-nr
Changing these limits might not be easy for a user.
This class is inefficient if the number of files is larger than maxopen and calls to write do not group keys together.
close all open files.
get filename for an identifier.
open file.
If file is in a new directory, create directories.
delete all files below a minimum size.
Bases: IOTools.FilePool
manage a pool of output files
The data is cached in memory before writing to disk.
close all open files. writes the data to disk.
delete all files below a minimum size.
get filename for an identifier.
open file.
If file is in a new directory, create directories.
return formatted value.
If value does not fit format string, return “na”
guess type of value.
deprecated, use val2str
output a percent value or “na” if not defined
output val or na if val == None
Bases: collections.defaultdict
Auto-vivifying nested dictionaries.
For example:
nd= nested_dict()
nd["mouse"]["chr1"]["+"] = 311
iterate through values with nested keys flattened into a tuple
Factory for default value called by __missing__().
v defaults to None.
If key is not found, d is returned if given, otherwise KeyError is raised
2-tuple; but raise KeyError if D is empty.
If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
flatten a nested list/tuple.
check if program is in path.
from post at http://stackoverflow.com/questions/377017/test-if-executable-exists-in-python
convert a value to int, float or str.
iterate over infile skipping comments.
open file in filename with mode mode.
If create is set, the directory containing filename will be created if it does not exist.
gzip - compressed files are recognized by the suffix .gz and opened transparently.
Note that there are differences in the file like objects returned, for example in the ability to seek.
returns a file or file-like object.
iterate over infile and return a namedtuple according to first row.