# HG changeset patch # User proteore # Date 1521542127 14400 # Node ID 145f347dc0e182a4844083fa99d426deb9cb3408 # Parent 774d9cbe693724700e8237c9a1969e1ecc545342 planemo upload commit b5beb4f7f3c60838b88a4cc32dfcb94c399d20ce-dirty diff -r 774d9cbe6937 -r 145f347dc0e1 venn_diagram.py --- 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 """