Helpers
helpers module.
This module houses a collection of auxiliary functions designed to provide general-purpose utility and support across different parts of the GRAMEP package. These functions are not domain-specific and are meant to assist with common tasks that might be needed in various contexts.
Contents
- get_sequence_interval: Create a closed interval using the 'start' and 'end' values from a row of data.
- make_report: Generate a report for variations and annotations in a sequence.
- get_colours: Get a dictionary of colours based on the specified palette.
- next_colour: Get the next colour from the predefined colour cycle.
Todo
- Implement tests.
COLOR_CYCLE = cycle(COLOR_LIST)
module-attribute
itertools.cycle: A cycle iterator that iterates through the COLOR_LIST repeatedly.
COLOR_LIST = ['lightgrey', 'white']
module-attribute
list[str]: A list of color values for cycling through in the color cycle.
message = Messages()
module-attribute
Set the Message class for logging.
get_colours(colour_palette)
Get a dictionary of colours based on the specified palette.
This function takes a colour palette name and returns a dictionary mapping predefined keys to nested dictionaries containing colour values based on the chosen palette.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
colour_palette
|
str
|
The name of the colour palette to use. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, dict[str, str]]
|
dict[str, dict[str, str]]: A dictionary mapping predefined keys to nested dictionaries containing colour values. |
Source code in python/gramep/helpers.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | |
get_sequence_interval(row)
Create a closed interval using the 'start' and 'end' values from a row of data.
This function constructs a closed interval using the 'start' and 'end' values from a pandas Series row. The interval is closed on both ends.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row
|
Series
|
A pandas Series containing 'start' and 'end' values. |
required |
Returns:
| Type | Description |
|---|---|
Interval
|
pd.Interval: A closed interval defined by the 'start' and 'end' values. |
Source code in python/gramep/helpers.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
make_report(variation_position, seq_name, sequence_interval, annotation_dataframe)
Generate a report for variations and annotations in a sequence.
This function takes variation positions, sequence name, sequence intervals, and an annotation DataFrame, and generates a report detailing variations and annotations present in the sequence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variation_position
|
list
|
A list of variation positions in the sequence. |
required |
seq_name
|
str
|
The name of the sequence being analyzed. |
required |
sequence_interval
|
IntervalIndex
|
Interval index representing sequence intervals. |
required |
annotation_dataframe
|
DataFrame
|
DataFrame containing sequence annotations. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: A list of strings representing the generated report. |
Source code in python/gramep/helpers.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
next_colour()
Get the next colour from the predefined colour cycle.
This function returns the next colour from the predefined colour cycle, which is used to cycle through a list of colour values.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The next colour from the colour cycle. |
Source code in python/gramep/helpers.py
256 257 258 259 260 261 262 263 264 265 266 | |