rstoolbox.components.Selection.unshift

Selection.unshift(seqID, shift)

Unhifts the Selection according to a value.

Inverst the shift in the Selection to allow for direct sequence position targeting.

There are two ways in which the unshift can be provided:

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

In [2]: sf.unshift("A", 3)
Out[2]: 3-5,13-15,21,25

In [3]: sf.unshift("A", 1)
Out[3]: 5-7,15-17,23,27
  • 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 [4]: 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[4]: '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 [5]: sf = ss.shift("A", seq)
   ...: sf
   ...: 
Out[5]: 3A-5A,13A-14A,20A,26A,30A

In [6]: sf.unshift("A", seq)
Out[6]: 3-5,13-15,21,25
Parameters:
  • seqID (str) – Identifier of the sequence of interest.
  • shift (Union[int, list() of int]) – Expected displacement.
Returns:

New unshifted Selection.

See also

shift()