class Segment
module
segment
The documentation is
here
.
Instances of this class are used for
Partition
class, but it may be useful to handle them.
A
Segment
is made of
two positions (begin and end),
included
in the segment;
a list of descriptors numbers (optionaly empty);
a float for the value of the segment (optionaly zero).
a string corresponding to a
descriptor pattern
(optionaly this string is empty);
Construction
__init__
Optional keywords:
beg=d
begin position is d (default: 0);
end=f
end position is f (default: 0);
val=v
value is v (default:0).
num=l
descriptor numbers are a copy of list l (default: []);
str=s
descriptor
is string s (default: "");
read_str
builds from a string in
specific
format; returns
True
if parsing is ok,
False
otherwise;
copy
returns a copy of this
Segment
.
Handling
g_beg
gets the first position;
g_end
gets the last position;
g_num
gets the list of descriptors numbers;
g_str
gets the string of the pattern;
g_val
gets the value;
deb
returns the first position;
fin
returns the last position;
num
returns the list of descriptors numbers;
word
returns the string of the pattern;
val
returns the value;
__len__
returns the length of the
Segment
, ie
fin-deb+1
.
Input-Output
Specific format is:
description
<begin-end>sequence_of_descriptors_numbers:value:
descriptor_pattern
if sequence_of_descriptors_numbers is empty, it is not output
if value is zero, it is not output
if descriptor_pattern is empty, it is not output
examples
<0-123>1,2:-5.0:+{A(-1)CG}T
<5-3922>:0.45:
<87-332>1::
__str__
outputs in specific format;
abr
outputs in specific format, without the
descriptor pattern
.