rstoolbox.components.Selection.map_to_sequences

Selection.map_to_sequences(sequence_map)

Generator for parse_rosetta_file().

This function is not really expected to be directly accessed by the user.

For a Selection without seqID, a sequence_map can be provided. A sequence_map is an array as long as all the sequences available with the seqID per position. These are created when parsing Rosetta files. It will return a dict with Selection for each available seqID. The Selection won’t have seqID, as the shift is not added.

Note

If a seqID is present in the sequence_map but has no residue selected, an empty Selection will be generated for that key.

Parameters:

sequence_map (list() of str) – List with seqID per position.

Returns:

SelectionContainer

Raises:
KeyError:If the Selection has a seqID.
IndexError:If position exceeds the sequencee map.

Warning

It cannot be applied to an already shifted Selection.

Example

In [1]: from rstoolbox.components import Selection
   ...: seq = ["A",] * 14 + ["B",] * 11
   ...: "".join(seq)
   ...: 
Out[1]: 'AAAAAAAAAAAAAABBBBBBBBBBB'

In [2]: ss = Selection([3, 4, 5, 13, 14, 15, 21, 25])
   ...: sd = ss.map_to_sequences(seq)
   ...: for seqID in sd:
   ...:     print(seqID, sd[seqID])
   ...: 
A 3-5,13-14
B 1,7,11