def _draw_nucleotide_body(nucleotide, center, subplot: plt_axes.Subplot, radius=10.0): nucleotide_color, nucleotide_base_class = _get_nucleotide_color(nucleotide) nucleotide_name = nucleotide.name if len(nucleotide_name) > 10: nucleotide_name = nucleotide_name.replace("_", "_\n") nucleotide_body = patches.Circle( center, radius=radius, color=nucleotide_color) text_object = subplot.text( center[0], center[1], nucleotide_name, va="center", ha="center") text_object.draw(subplot.figure.canvas.renderer) subplot.add_patch(nucleotide_body) nucleotide_body.add_callback( partial(_nucleotide_name_callback, text_object=text_object)) nucleotide_body.set_label(":".join([nucleotide_base_class.__name__, nucleotide.name])) nucleotide_body.set_picker(True) return nucleotide_body
def _draw_nucleotide_keys(keys_required: Optional[List[str]], keys_optional: Optional[List[str]], center: Sequence[float], nucleotide_body_patch: patches.Circle, subplot: plt_axes.Subplot, color, radius=10.0, width=5.0, theta_min=0, theta_max=180): # pylint: disable=too-many-arguments # not possible to have less arguments without more complexity # pylint: disable=too-many-locals # is not possible to split the method without more complexity keys_required = keys_required or [] keys_optional = keys_optional or [] keys_all = keys_required + keys_optional if not keys_all: return None number_of_keys = len(keys_all) theta_delta = (theta_max - theta_min) / number_of_keys thetas = np.arange(theta_min, theta_max, theta_delta) key_patches = {} for each_key, each_start_theta in zip(keys_all, thetas): hatch = "x" if each_key in keys_optional else None theta1 = each_start_theta theta2 = theta1 + theta_delta key_patch = patches.Wedge( center, radius + width, theta1, theta2, width=width, facecolor=color, hatch=hatch, edgecolor="white") key_patches[each_key] = key_patch text_object = _draw_key_text( each_key, center, theta1, theta2, radius, width, subplot) key_patch.add_callback(partial( _nucleotide_key_text_callback, text_object=text_object, nucleotide_body_patch=nucleotide_body_patch)) subplot.add_patch(key_patch) return key_patches