Bio.SubsMat.FreqTable module

A class to handle frequency tables or letter count files.

Example files for a DNA alphabet:

A count file (whitespace separated):

A  50
C  37
G  23
T  58

The same info as a frequency file:

A 0.2976
C 0.2202
G 0.1369
T 0.3452
Functions:
read_count(f)

read a count file from stream f. Then convert to frequencies.

read_freq(f)

read a frequency data file from stream f. Of course, we then don’t have the counts, but it is usually the letter frequencies which are interesting.

Methods:

(all internal)

Attributes:
alphabet

The letters you are using as indices into the table.

data

Frequency dictionary.

count

Count dictionary. Empty if no counts are provided.

Example of use:
>>> import io
>>> from Bio.SubsMat import FreqTable
>>> f_count = io.StringIO(u"A  50\nC  37\nG  23\nT  58")
>>> ftab = FreqTable.read_count(f_count)
>>> for nb in sorted(ftab):
...     print("%s %0.4f" %(nb, ftab[nb]))
...
A 0.2976
C 0.2202
G 0.1369
T 0.3452
class Bio.SubsMat.FreqTable.FreqTable(in_dict, dict_type, alphabet=None)

Bases: dict

Define class to handle frequency tables or letter count files.

__init__(self, in_dict, dict_type, alphabet=None)

Initialize the class.

Bio.SubsMat.FreqTable.read_count(f)

Read a count file f and load values to the Frequency Table.

Bio.SubsMat.FreqTable.read_freq(f)

Read a frequency data file f and load values to the Frequency Table.