ColorScheme#
- class biotite.sequence.graphics.ColorScheme(name: str, alphabet: Alphabet, colors: list[MplColor | None])[source]#
Bases:
objectA color scheme assigning a color to each symbol of an alphabet.
- Attributes:
- namestr
The name of the scheme.
- alphabetAlphabet
The alphabet the scheme is defined for.
- colorslist of (str or tuple or None), length=n
A Matplotlib compatible color for each symbol in the alphabet, indexed by the symbol code.
Noneindicates that no color is defined for the respective symbol.
Examples
>>> alphabet = NucleotideSequence.alphabet_unambiguous >>> scheme = ColorScheme("example", alphabet, ["red", "green", None, "blue"]) >>> print(scheme.fit(alphabet, default="black")) ['red', 'green', 'black', 'blue']
- fit(alphabet: Alphabet, default: str | tuple[float, ...] | ndarray = '#FFFFFF') list[str | tuple[float, ...] | ndarray]#
Get the colors of this scheme for the symbols of the given alphabet.
- Parameters:
- alphabetAlphabet
The alphabet to obtain the colors for. The alphabet of this scheme must equal or extend this alphabet.
- defaultstr or tuple, optional
A Matplotlib compatible color that is used for symbols that have no defined color in the scheme.
- Returns:
- colorslist of (str or tuple), length=n
A list of Matplotlib compatible colors. The colors in the list have the same order as the symbols in the given alphabet.
- classmethod load(file_name: PathLike[str] | str) Self#
Load a color scheme from a JSON file.
- Parameters:
- file_namestr or PathLike
The file name of the JSON file containing the scheme.
- Returns:
- schemeColorScheme
The loaded color scheme. Symbols of the alphabet, that are not defined in the file, get
Noneas color.
Gallery#
Identification of a binding site by sequence conservation