def get_arrow_polygon(self, scaling: float = 1., offset: int = 0, base: int = 35, height: int = 10, colour: str = "white") -> Polygon: """ Returns an SVG polygon shaped like an arrow that represents the Gene """ if self.reversed: start = int((offset - self.get_start()) * scaling) end = int((offset - self.get_end()) * scaling) else: start = int((self.get_start() + offset) * scaling) end = int((self.get_end() + offset) * scaling) start, end = sorted([start, end]) builder = ShapeBuilder() arrow_size = height // 2 if abs(start - end) < arrow_size: if self.strand > -1: points = [(start, base), (end, base - arrow_size), (start, base - height), (start, base)] else: points = [(start, base - arrow_size), (end, base - height), (end, base), (start, base - arrow_size)] else: if self.strand > -1: arrowstart = end - arrow_size points = [(start, base), (arrowstart, base), (end, base - arrow_size), (arrowstart, base - height), (start, base - height), (start, base)] else: arrowstart = start + arrow_size points = [(start, base - arrow_size), (arrowstart, base - height), (end, base - height), (end, base), (arrowstart, base), (start, base - arrow_size)] arrow = builder.createPolygon(strokewidth=1, stroke='black', fill=colour, points=builder.convertTupleArrayToPoints(points)) locus_tag = self.name if self.protein: locus_tag = self.protein.get_id() arrow.setAttribute('description', self._get_description()) arrow.setAttribute('locus_tag', locus_tag) arrow.set_class('clusterblast-orf') return arrow