rstoolbox.components.Selection.shift

Selection.shift(seqID, shift)

Shifts the Selection according to a value and sets up the chain to which it is associated.

There are two ways in which a shift can be provided:

  • An int specifying the numerical identity of the first position of the sequence. As Selection works with sequence positioning, shifting by 1 is the same as not shifting at all (although then the seqID will be added and the Selection will be considered as shifted).
In [1]: from rstoolbox.components import Selection
   ...: ss = Selection([3, 4, 5, 13, 14, 15, 21, 25])
   ...: ss.shift("A", 3)
   ...: 
Out[1]: 5A-7A,15A-17A,23A,27A

In [2]: ss.shift("A", 1)
Out[2]: 3A-5A,13A-15A,21A,25A
  • A list() of int specifying the identity of each position of the sequence. This is usefull if your reference sequence has gaps in its numbering.
In [3]: from rstoolbox.components import Selection
   ...: ss = Selection([3, 4, 5, 13, 14, 15, 21, 25])
   ...: seq = range(1, 31)
   ...: seq = list(seq[:14]) + list(seq[19:])
   ...: ",".join([str(_) for _ in seq])
   ...: 
Out[3]: '1,2,3,4,5,6,7,8,9,10,11,12,13,14,20,21,22,23,24,25,26,27,28,29,30'

In [4]: ss.shift("A", seq)
Out[4]: 3A-5A,13A-14A,20A,26A,30A
Parameters:
  • seqID (str) – Identifier of the sequence of interest.
  • shift (Union[int, list() of int]) – Expected displacement
Returns:

Selection - new shifted selection

See also

unshift()