diff --git a/funannotate/compare.py b/funannotate/compare.py index 5dd1021..03b0a8b 100755 --- a/funannotate/compare.py +++ b/funannotate/compare.py @@ -1519,19 +1519,15 @@ def addlink(x): baseurl = "http://eggnog5.embl.de/" elif x.startswith("ENOG41"): baseurl = "http://eggnog45.embl.de/" - x = '{x}' return x def addlink2(x): - x = ( - '' - + x - + "" - ) + if x == "None": + return "None found" + x = f'{x}' return x # building remaining HTML output @@ -1540,35 +1536,39 @@ def addlink2(x): df = pd.read_csv(orthologs, sep="\t", header=None) orthtable = [] for row in df.itertuples(): + # eggnog results for table if isinstance(row[3], str): - if ", " in row[3]: - t = row[3].split(", ") # convert Eggnog to list + if row[3] == "None": + value = "None found" else: - t = [row[3]] - else: - t = ["None"] - if t[0] == "None": - t = ["None"] + if ", " in row[3]: + t = row[3].split(", ") # convert Eggnog to list + else: + t = [row[3]] + t = [addlink(y) for y in t] + t = [x for x in t if x not in ["None", None, ""]] + if len(t) > 0: + value = "; ".join(t) + else: + value = "None found" else: - t = [addlink(y) for y in t] - try: - value = "; ".join(t) - except TypeError: value = "None found" + # busco results for table if isinstance(row[4], str): - if ", " in row[4]: - r = row[4].split(", ") # convert BUSCO to list + if row[4] == "None": + value2 = "None found" else: - r = [row[4]] - else: - r = ["None"] - if r[0] == "None": - r = ["None"] + if ", " in row[4]: + r = row[4].split(", ") # convert BUSCO to list + else: + r = [row[4]] + r = [x for x in r if x not in ["None", None, ""]] + r = [addlink2(y) for y in r] + if len(r) > 0: + value2 = "; ".join(r) + else: + value2 = "None found" else: - r = [addlink2(y) for y in r] - try: - value2 = "; ".join(r) - except TypeError: value2 = "None found" final = [row[0], row[1], row[2], value, value2, row[5]] orthtable.append(final) @@ -1586,11 +1586,10 @@ def addlink2(x): pd.set_option("display.max_colwidth", None) except ValueError: pd.set_option("display.max_colwidth", 0) + html_table = df2html(df2) output.write(lib.HEADER) output.write(lib.ORTHOLOGS) - output.write( - df2.to_html(index=False, escape=False, classes="table table-hover") - ) + output.write(html_table) output.write(lib.FOOTER) else: @@ -1643,5 +1642,21 @@ def addlink2(x): lib.log.info("Funannotate compare completed successfully!") +def df2html(df): + # for some effing reason pandas isn't doing this properly + html = '' + html += '' + for x in df.columns.values.tolist(): + html += f"" + html += "" + for row in df.itertuples(index=False): + html += "" + for i in range(len(row)): + html += f"" + html += "" + html += "
{x}
{row[i]}
" + return html + + if __name__ == "__main__": main(sys.argv[1:]) diff --git a/funannotate/library.py b/funannotate/library.py index fd87051..9c80580 100755 --- a/funannotate/library.py +++ b/funannotate/library.py @@ -11360,6 +11360,8 @@ def getBlastDBinfo(input): + + """ ORTHOLOGS = """ -
-
-

Orthologous protein groups

-
+
+

Orthologous protein groups

""" INDEX = """
@@ -11535,6 +11535,13 @@ def getBlastDBinfo(input): +