@@ 78-101 (lines=24) @@ | ||
75 | go2color[goid] = color_dflt |
|
76 | return go2color |
|
77 | ||
78 | def _get_item_str(self, res): |
|
79 | """Return genes in any of these formats: |
|
80 | 1. 19264, 17319, 12520, 12043, 74131, 22163, 12575 |
|
81 | 2. Ptprc, Mif, Cd81, Bcl2, Sash3, Tnfrsf4, Cdkn1a |
|
82 | 3. 7: Ptprc, Mif, Cd81, Bcl2, Sash3... |
|
83 | """ |
|
84 | ipl = self.items_p_line |
|
85 | prt_items = sorted([self._get_genestr(itemid) for itemid in res.study_items]) |
|
86 | prt_multiline = [prt_items[i:i+ipl] for i in range(0, len(prt_items), ipl)] |
|
87 | num_items = len(prt_items) |
|
88 | if self.study_items_max is None: |
|
89 | genestr = "\n".join([", ".join(str(e) for e in sublist) for sublist in prt_multiline]) |
|
90 | return "{N}) {GENES}".format(N=num_items, GENES=genestr) |
|
91 | else: |
|
92 | if num_items <= self.study_items_max: |
|
93 | gene_lines = [", ".join(str(e) for e in sublist) for sublist in prt_multiline] |
|
94 | genestr = "\n".join(gene_lines) |
|
95 | return genestr |
|
96 | else: |
|
97 | short_list = prt_items[:self.study_items_max] |
|
98 | short_mult = [short_list[i:i+ipl] for i in range(0, len(short_list), ipl)] |
|
99 | short_lines = [", ".join(str(e) for e in sublist) for sublist in short_mult] |
|
100 | short_str = "\n".join(short_lines) |
|
101 | return "".join(["{N} genes; ".format(N=num_items), short_str, "..."]) |
|
102 | ||
103 | def _get_genestr(self, itemid): |
|
104 | """Given a geneid, return the string geneid or a gene symbol.""" |
@@ 255-277 (lines=23) @@ | ||
252 | return self.pltvars.fmtres.format( |
|
253 | study_count=res.study_count) |
|
254 | ||
255 | def _get_item_str(self, res): |
|
256 | """Return genes in any of these formats: |
|
257 | 1. 19264, 17319, 12520, 12043, 74131, 22163, 12575 |
|
258 | 2. Ptprc, Mif, Cd81, Bcl2, Sash3, Tnfrsf4, Cdkn1a |
|
259 | 3. 7: Ptprc, Mif, Cd81, Bcl2, Sash3... |
|
260 | """ |
|
261 | npl = self.pltvars.items_p_line # Number of items Per Line |
|
262 | prt_items = sorted([self.__get_genestr(itemid) for itemid in res.study_items]) |
|
263 | prt_multiline = [prt_items[i:i+npl] for i in range(0, len(prt_items), npl)] |
|
264 | num_items = len(prt_items) |
|
265 | if self.study_items_max is None: |
|
266 | genestr = "\n".join([", ".join(str(e) for e in sublist) for sublist in prt_multiline]) |
|
267 | return "{N}) {GENES}".format(N=num_items, GENES=genestr) |
|
268 | else: |
|
269 | if num_items <= self.study_items_max: |
|
270 | strs = [", ".join(str(e) for e in sublist) for sublist in prt_multiline] |
|
271 | genestr = "\n".join([", ".join(str(e) for e in sublist) for sublist in prt_multiline]) |
|
272 | return genestr |
|
273 | else: |
|
274 | short_list = prt_items[:self.study_items_max] |
|
275 | short_mult = [short_list[i:i+npl] for i in range(0, len(short_list), npl)] |
|
276 | short_str = "\n".join([", ".join(str(e) for e in sublist) for sublist in short_mult]) |
|
277 | return "".join(["{N} genes; ".format(N=num_items), short_str, "..."]) |
|
278 | ||
279 | def __get_genestr(self, itemid): |
|
280 | """Given a geneid, return the string geneid or a gene symbol.""" |