def get_svg_groups(self, h_offset: int = 0, v_offset: int = 0, scaling: float = 1., screenwidth: int = 1024, colours: Dict[str, str] = None, overview: bool = False, prefix: str = "dummy") -> List[Group]: """ Returns all SVG elements required to draw the Cluster """ if not colours: colours = {} groups = [] group = Group() self._add_label(group, v_offset) line_y = 35 + v_offset group.addElement(ShapeBuilder().createLine(10, line_y, 10 + (screenwidth * 0.75), line_y, strokewidth=1, stroke="grey")) groups.append(group) # Add gene arrows arrow_y = line_y + 5 offset = h_offset - self.start if self.reversed: offset = h_offset + self.end for i, gene in enumerate(self.genes): group = Group() arrow = gene.get_arrow_polygon(scaling=scaling, offset=offset, base=arrow_y, colour=colours.get(gene.name, "white")) if overview: label = "all_" else: label = "h" arrow.set_id("%s-%d_%s%d_%s_%s" % (prefix, self.query_cluster_number, label, self.query_cluster_number, self.rank, i)) group.addElement(arrow) # Can be used for domains group.set_id("a%s_00%s" % (self.query_cluster_number, i)) groups.append(group) return groups
def _add_label(self, group: Group, v_offset: int) -> Group: acc = Text(self.full_description, 5, 20 + v_offset) if self.prefix == "knownclusterblast": desc = "%80s (%s), %s" % (self.description, self.similarity_string, self.cluster_type) acc = Text( '<a xlink:href="https://mibig.secondarymetabolites.org/go/' + self.accession + '/%s" target="_blank">' % self.ref_cluster_number + self.accession + '</a>: ' + desc, 5, 20 + v_offset) elif self.prefix == "general": acc = Text( '<a xlink:href="https://antismash-db.secondarymetabolites.org/go/' + self.accession + '/%s" target="_blank">' % self.ref_cluster_number + self.full_description.replace(":", "</a>:", 1), 5, 20 + v_offset) # Don't do any linking for subclusterblast acc.set_class("clusterblast-acc") group.addElement(acc) group.setAttribute('label', self.accession) group.setAttribute('description', self.full_description) group.set_class('clusterblast-cluster') return group
def _add_label(self, group: Group, v_offset: int) -> Group: acc = Text(self.full_description, 5, 20 + v_offset) if self.accession.startswith('BGC'): acc = Text('<a xlink:href="http://mibig.secondarymetabolites.org/repository/' + self.accession + '/index.html#cluster-1" target="_blank">' + self.accession + '</a>: ' + "%80s (%s)" % (self.description, self.similarity), 5, 20 + v_offset) elif self.accession.split("_")[0] in get_antismash_db_accessions(): acc = Text('<a xlink:href="http://antismash-db.secondarymetabolites.org/output/' + self.accession + '/index.html#cluster-%s" target="_blank">' % self.ref_cluster_number[1:] + self.full_description.replace(":", "</a>:"), 5, 20 + v_offset) acc.set_class("clusterblast-acc") group.addElement(acc) group.setAttribute('label', self.accession) group.setAttribute('description', self.full_description) group.set_class('clusterblast-cluster') return group
def get_svg_groups(self, h_offset: int = 0, v_offset: int = 0, scaling: float = 1., screenwidth: int = 1024, colours: Dict[str, str] = None, overview: bool = False, prefix: str = "dummy") -> List[Group]: """ Returns all SVG elements required to draw the Cluster """ if not colours: colours = {} groups = [] group = Group() acc = Text(self.description, 5, 20) acc.set_class("clusterblast-acc") group.addElement(acc) line_y = 35 + v_offset group.addElement(ShapeBuilder().createLine(10, line_y, 10 + (screenwidth * 0.75), line_y, strokewidth=1, stroke="grey")) group.setAttribute('label', self.description) group.set_class('clusterblast-cluster') groups.append(group) base = line_y + 5 offset = h_offset + 10 - self.start # 10 for margin for index, gene in enumerate(self.genes): arrow = gene.get_arrow_polygon(scaling=scaling, offset=offset, base=base, colour=colours.get(gene.name, "white")) arrow.set_id("%s-%s_q%s_%s_%s" % (prefix, self.query_cluster_number, index, self.rank, "all")) group.addElement(arrow) return groups