rstoolbox.components.SelectionContainer

class rstoolbox.components.SelectionContainer(*args)

Helper class to manage representation of selectors in pandas.

A SelectionContainer is generated when labels are read through the parse_rosetta_file(), as ResidueLabels are saved in RosettaNumbering.

Basically it is just a dict mimic that allows to quickly access the Selection data avoiding raising errors if Selection for particular seqID are not present and wraps the shifting functions.

The other main function is to minimize the representation of Selection in the printed DataFrame. Thus, its way of being represented by the length of each contained Selection:

In [1]: from rstoolbox.components import Selection, SelectionContainer
   ...: sc = SelectionContainer()
   ...: sc.setdefault("A", Selection([3, 4, 5, 13, 14, 15, 21, 25]))
   ...: sc.setdefault("B", Selection("15-19,21-25"))
   ...: sc
   ...: 
Out[1]: A:#(8),B:#(10)

Representation of the individual Selection changes if it is_shifted():

In [2]: sc.shift("A", 3)
   ...: sc
   ...: 
Out[2]: A:@(8),B:#(10)

And when it is reversed:

In [3]: sc["A"] = ~sc["A"]
   ...: sc
   ...: 
Out[3]: A:~@(8),B:#(10)

Methods

shift(seqID, value) Shifts by value the labels assigned to a given seqID.
unshift(seqID, value) Unshifts by value the labels assigned to a given seqID.