Mercurial > repos > proteore > proteore_venn_diagram
changeset 3:145f347dc0e1 draft
planemo upload commit b5beb4f7f3c60838b88a4cc32dfcb94c399d20ce-dirty
author | proteore |
---|---|
date | Tue, 20 Mar 2018 06:35:27 -0400 |
parents | 774d9cbe6937 |
children | 094cc3c46c5b |
files | venn_diagram.py |
diffstat | 1 files changed, 7 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/venn_diagram.py Wed Mar 07 08:51:48 2018 -0500 +++ b/venn_diagram.py Tue Mar 20 06:35:27 2018 -0400 @@ -18,8 +18,8 @@ """ Check if an element is integer or float """ - float_format = re.compile("^[\-]?[1-9][0-9]*\.?[0-9]+$") - int_format = re.compile("^[\-]?[1-9][0-9]*$") + float_format = re.compile(r"^[-]?[1-9][0-9]*.?[0-9]+$") + int_format = re.compile(r"^[-]?[1-9][0-9]*$") test = "" if format == "int": test = re.match(int_format, n) @@ -55,7 +55,6 @@ file_content = [x.strip() for x in [line.split("\t")[int(ncol.replace("c", ""))-1].split(";")[0] for line in file_content[1:]]] # take only first IDs else: file_content = [x.strip() for x in [line.split("\t")[int(ncol.replace("c", ""))-1].split(";")[0] for line in file_content]] # take only first IDs - #print(file_content[1:13]) else: raise ValueError("Please fill in the right format of column number") else: @@ -78,7 +77,6 @@ [others.add(name) for name in names if name not in group] difference = [] intersected = set.intersection(*(comp_dict[k] for k in group)) - n = "".join(group) if len(others) > 0: difference = intersected.difference(set.union(*(comp_dict[k] for k in others))) yield group, list(intersected), list(difference) @@ -115,9 +113,7 @@ string = "" lines = [] result = dict((k, v) for k, v in json_result["data"].iteritems() if v != []) - print(result) max_count = max(len(v) for v in result.values()) - print(max_count) for i in range(max_count): lines.append("") @@ -128,16 +124,19 @@ name = "_".join([json_result["name"][x] for x in data]) header += name + "\t" if len(result[data]) > i: + print("a", result[data][i]) lines[i] += result[data][i] + "\t" else: lines[i] += "\t" + # Strip last tab in the end of the lines + header = header.rstrip() + lines = [line.rstrip() for line in lines] string += header + "\n" string += "\n".join(lines) - print(string) output.write(string) output.close() -def write_summary( summary_file, inputs): +def write_summary(summary_file, inputs): """ Paste json string into template file """