Skip to content

Commit

Permalink
Allow multiline titles in xlsx. Add sections val in title.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvklopfenstein committed Jul 22, 2018
1 parent 3f89453 commit 2ea3e3a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 5 additions & 2 deletions goatools/cli/find_enrichment.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class GoeaCliFnc(object):

def __init__(self, args):
self.args = args
print("SSSSSSSSSSSSSSSSS", self.args.sections)
self.sections = read_sections(self.args.sections) if self.args.sections else None
_optional_attrs = ['relationship'] if self.sections else None
self.godag = GODag(obo_file=self.args.obo, optional_attrs=_optional_attrs)
Expand Down Expand Up @@ -291,7 +292,9 @@ def __init__(self, gene2gos, objcli, godag_version):
self.grprdflt = GrouperDflts(self.gosubdag, objcli.args.goslim)
self.hdrobj = HdrgosSections(self.grprdflt.gosubdag, self.grprdflt.hdrgos_dflt, objcli.sections)
self.pval_fld = objcli.get_pval_field() # primary pvalue of interest
self.ver_list = [godag_version, self.grprdflt.ver_goslims]
self.ver_list = [godag_version,
self.grprdflt.ver_goslims,
"Sections: {S}".format(S=objcli.args.sections)]
# self.objaartall = self._init_objaartall()

def get_objgrpwr(self, goea_results):
Expand Down Expand Up @@ -355,7 +358,7 @@ def wr_xlsx(self, fout_xlsx):
# 'ratio_in_study': {'align':'right'},
# 'ratio_in_pop':{'align':'right'}}
kws_xlsx = {
'title': "; ".join(self.ver_list),
'title': self.ver_list,
'fld2fmt': {f:'{:8.2e}' for f in self.flds_cur if f[:2] == 'p_'},
#'ntfld_wbfmt': ntfld_wbfmt,
#### 'ntval2wbfmtdict': ntval2wbfmtdict,
Expand Down
11 changes: 9 additions & 2 deletions goatools/wr_tbl_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,15 @@ def __init__(self, fout_xlsx, nt_flds, **kws):
def wr_title(self, worksheet, row_idx=0):
"""Write title (optional)."""
if self.vars.title is not None:
return self.wr_row_mergeall(worksheet, self.vars.title, self.fmt_hdr, row_idx)
return row_idx
# Title is one line
if isinstance(self.vars.title, str):
return self.wr_row_mergeall(worksheet, self.vars.title, self.fmt_hdr, row_idx)
# Title is multi-line
else:
ridx = row_idx
for title_line in self.vars.title:
ridx = self.wr_row_mergeall(worksheet, title_line, self.fmt_hdr, ridx)
return ridx

def wr_row_mergeall(self, worksheet, txtstr, fmt, row_idx):
"""Merge all columns and place text string in widened cell."""
Expand Down

0 comments on commit 2ea3e3a

Please sign in to comment.