Previous Up Next

class Lcompte



module lcompte

The documentation is here.

This class is like a dictionnary in which the keys are the descriptor numbers, and the items the corresponding Compte.

Moreover, the number of transitions between such descriptors are stored. If not specified, this number of transitions is null.

The aim of this class is to build easily hidden Markov chains.

Construction

__init__
Optional keyword fic allows construction by reading from a filename in specific format;
read_nf
builds from a filename in specific format;
read_nf_seq
counts specified-length words from a list of filenames. In each file are the counted sequences, and descriptor number (n-1) is related to file number n. Between-descriptors transitions are uniformly distributed.

Optional keyword:
alpha=st
Compte are restricted to letters in string st. If st=”, behaves as if no option alpha.
read_Lpart
counts the words of a specified length from a Lpartition. The Compte affected to the descriptor numbers are computed from the descriptors of the Partitions on the positions of the corresponding Sequences.

Optional keyword:
alpha=st
Compte are restricted to letters in string st. If st=”, behaves as if not option alpha.

Handling

strip
returns a new Lcompte from the words of self that do not have the end-character ^, using strip method;
rstrip
returns a new Lcompte from the words of self that do not end with character ^, using rstrip method;
__getitem__
returns the Compte of specified descriptor number;
__setitem__
gets the specified Compte to the specified descriptor number;
num
returns the list of descriptors numbers;
lg_max
returns the length of the longest word;
inter
returns the count of transitions between two descriptor numbers;
g_inter
gets the count of transitions between two valid descriptor numbers;
alph
returns the list of used letters;
add_Partition
adds counts of words of specified length on the positions of a Sequence, on the basis of a Compte per descriptor number of a Partition;

Optional keyword:
alpha=a
counts only words which letters are in string a. If a=”, as if not option alpha;
fact=f
each word counts f (default: 1 ).

Input-Output

Specific format is:
description
sections of
  decriptor number:
  lines of     word whitespace count
 
lines of counts of transitions
         between descriptors numbers in format:
 
    num1ber, number2 whitespace count
 
 
 
 
 
 
 
 
 
 
 
 
example  
1:
AB 35
AA 71
BB 55
BA 245
A^ 1
B^ 9
 
2:
ABB 45
ABA 5
AAA 24
AAB 64
AB 19
A 1
 
1,2 242
1,1 854
2,2 964
2,1 610
__str__
outputs in specific format.

Previous Up Next