# HG changeset patch
# User proteore
# Date 1542040000 18000
# Node ID 8d61f5ca50a491b3782c5598def7e0dc1c658cb5
planemo upload commit 9760cde192a15cdf3d2dbec05dd867eaa0392bcd-dirty
diff -r 000000000000 -r 8d61f5ca50a4 README.rst
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/README.rst Mon Nov 12 11:26:40 2018 -0500
@@ -0,0 +1,49 @@
+Wrapper for JVenn Diagram Tool
+==============================
+
+**Authors**
+
+Philippe Bardou, Jérôme Mariette, Frédéric Escudié, Christophe Djemiel and Christophe Klopp. jvenn: an interactive Venn diagram viewer. BMC Bioinformatics 2014, 15:293 doi:10.1186/1471-2105-15-293
+
+**Galaxy integration**
+
+T.P. Lien Nguyen, Florence Combes, Yves Vandenbrouck CEA, INSERM, CNRS, Grenoble-Alpes University, BIG Institute, FR
+
+Sandra Dérozier, Olivier Rué, Christophe Caron, Valentin Loux INRA, Paris-Saclay University, MAIAGE Unit,Migale Bioinformatics platform
+
+Contact support@proteore.org for any questions or concerns about the Galaxy implementation of this tool.
+
+------------------------------
+
+This tool draw a venn diagram from lists/files using Jvenn plug-in (http://jvenn.toulouse.inra.fr/app/index.html). It also creates output files that contain common or specific elements between query and each compared lists/files.
+
+**Inputs**
+
+* **Query file:** A file containing different information of proteins, could be output of previous components.
+
+* **File of a list of IDs:** .TXT format, each line contains 1 ID
+
+ AMY1A
+
+ ALB
+
+ IGKC
+
+ CSTA
+
+ IGHA1
+
+ ACTG1
+
+* **List of IDs:** IDs separated by a space
+ AMY1A ALB IGKC CSTA IGHA1 ACTG1
+
+If you choose a file, it is necessary to specify the column where you would like to perform the comparison.
+
+**Outputs**
+
+* **Summary file** (venn_diagram_summary.html):
+ Venn diagram: Could be downloaded as image (PNG, SVG)
+
+* **Venn text output file**
+ A text file containing common/specific elements among compared lists/files.
diff -r 000000000000 -r 8d61f5ca50a4 jvenn_template.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jvenn_template.html Mon Nov 12 11:26:40 2018 -0500
@@ -0,0 +1,228 @@
+
+
+
+
+ Jvenn+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ javascript is needed to display data.
+ If you try to view this data on galaxy please contact your administrator to authorise javascript or download the file to view.
+
+ javascript is needed to display data.
+ If you try to view this data on galaxy please contact your administrator to authorise javascript or download the file to view.
+
+
+
+
+
+
+
+
+
diff -r 000000000000 -r 8d61f5ca50a4 test-data/Venn_text_output.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/Venn_text_output.txt Mon Nov 12 11:26:40 2018 -0500
@@ -0,0 +1,81 @@
+Lacombe Bredberg Mucilli Mucilli_Bredberg Lacombe_Bredberg Lacombe_Mucilli_Bredberg Lacombe_Mucilli
+P0DMV9 P04217 Q7Z794 Q13835 P02787 P02768 P08779
+Q9Y6R7 P02649 P51149 P01023 P01833 P10599 P04259
+P30740 Q7Z351 P17900 P59665 P01625 P07355 O75223
+P68363 P08758 Q96KK5 Q15517 P22528 Q01469 P47756
+O75635 Q9UBC9 P10809 P05109 Q9UGM3 P68871 P06733
+O60911 P02760 O43175 P60709 Q96DA0 P07900 P20933
+P61160 O95436 Q6ZVX7 P62805 P02763 P15924 Q9NZH8
+Q15828 P02647 P01861 Q5D862 P61916 P25311 P09211
+P23284 P15814 P14174 P07737 P01009 Q86YZ3 P04792
+P20930 Q9NSK0 P01593 P12273 P05089 P36952
+P01860 P01717 Q15365 Q13867 Q08188 P01040
+Q96FX8 P04117 P37802 P01765 P04406 P60174
+P62937 Q13885 P29373 P01036 P07339 P26641
+Q15149 P01591 P30050 P01011 P06396 P14618
+P25705 O95613 Q6E0U4 P00338 P31944
+P19971 P01880 P23526 P61626 Q8N1N4
+O75342 P04233 Q13748 P04083 P04075
+Q92820 P01598 P05120 Q02413 P14923
+P25788 P01621 Q14134 P27482 Q8WVV4
+Q9HCY8 Q9UL77 P68431 P01871 O75369
+P19012 P05362 P35527 P80188 P00558
+Q8TAX7 P01024 Q5XKE5 P31947 P19013
+P42357 Q86SJ6 O15523 P31025 Q5T750
+P50395 P12429 P25787 Q96P63 P14735
+P01766 P43652 P22392 P63104 P47929
+P40121 P22897 P49189 P00738 Q06830
+P04080 P06313 P61978 P02788 P29508
+Q9HC84 B4E1Z4 P32119 P68371
+P59998 P01008 Q5VVQ6 Q9NZT1
+P23396 A2IPI6 Q8IW75 P11142
+P00491 P02790 P01620 P40926
+P62258 P61769 P02671 P01876
+P01623 P00450 P62244 P58107
+P31151 Q08380 P0CG48 P01834
+Q6P4A8 P02751 P02675 P18206
+P63261 Q8NF17 Q9Y277 Q04695
+P01877 Q14624 P02679 P08865
+P09228 P0C0L5 P02533 P13646
+P48637 P0C0L4 Q9Y337 P02545
+P07858 Q9UL83 P12035 P04040
+P07384 P08238 P52907 P13639
+P06870 P02766 P35321 P05090
+Q9UI42 Q9UL86 P13489 Q6KB66
+P35579 P02774 P29401 P01857
+P13473 P05155 P04264 Q6UWP8
+P62987 P11686 Q14210 Q9UIV8
+P04745 P01622 P28074 Q9C075
+P49720 Q6N093 P40925 O43707
+P11279 P04637 P28070 P11021
+P18510 Q96S96 P28072 P31949
+Q14574 P62807 Q14CN4 P60842
+P02538 P23528 Q9Y3R4
+P48594 P10909 P13647
+A8K2U0 A4F255 P54652
+P09972 P00734 Q08554
+O95274 P19827 P08107
+P01037 Q16378 P30041
+P0CG05 P01714 P06702
+P00441 P11217 O43790
+ A0A0U1RVJ5 Q96QA5
+ P01617 P23490
+ P01611 P22735
+ P04196 P13645
+ P01613 P17931
+ P02747 Q3ZCW2
+ P80748 P68104
+ A0N5G5 P06576
+ Q8IWL2 Q5T749
+ Q9BYE4 P05091
+ P06681 O60814
+ Q6MZX7 P37837
+ P22531
+ P03973
+ P63167
+ P05783
+ P50990
+ P15880
+ P35908
+ P07476
+ P49862
\ No newline at end of file
diff -r 000000000000 -r 8d61f5ca50a4 venn_diagram.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/venn_diagram.py Mon Nov 12 11:26:40 2018 -0500
@@ -0,0 +1,181 @@
+#!/usr/bin/env python2.7
+
+import os
+import sys
+import json
+import operator
+import argparse
+import re
+from itertools import combinations
+
+CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
+
+##################################################################################################################################################
+# FUNCTIONS
+##################################################################################################################################################
+
+def isnumber(format, n):
+ """
+ Check if an element is integer or float
+ """
+ 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)
+ elif format == "float":
+ test = re.match(float_format, n)
+ if test:
+ return True
+ else:
+ return False
+
+def input_to_dict(inputs):
+ """
+ Parse input and return a dictionary of name and data of each lists/files
+ """
+ comp_dict = {}
+ title_dict = {}
+ c = ["A", "B", "C", "D", "E", "F"]
+ for i in range(len(inputs)):
+ input_file = inputs[i][0]
+ name = inputs[i][1]
+ input_type = inputs[i][2]
+ title = c[i]
+ title_dict[title] = name
+ ids = set()
+ if input_type == "file":
+ header = inputs[i][3]
+ ncol = inputs[i][4]
+ file_content = open(input_file, "r").readlines()
+
+ # Check if column number is in right form
+ if isnumber("int", ncol.replace("c", "")):
+ if header == "true":
+ 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
+ else:
+ raise ValueError("Please fill in the right format of column number")
+ else:
+ ids = set()
+ file_content = inputs[i][0].split()
+
+ ids.update(file_content)
+ comp_dict[title] = ids
+
+ return comp_dict, title_dict
+
+def intersect(comp_dict):
+ """
+ Calculate the intersections of input
+ """
+ names = set(comp_dict)
+ for i in range(1, len(comp_dict) + 1):
+ for group in combinations(sorted(comp_dict), i):
+ others = set()
+ [others.add(name) for name in names if name not in group]
+ difference = []
+ intersected = set.intersection(*(comp_dict[k] for k in group))
+ if len(others) > 0:
+ difference = intersected.difference(set.union(*(comp_dict[k] for k in others)))
+ yield group, list(intersected), list(difference)
+
+def diagram(comp_dict, title_dict):
+ """
+ Create json string for jvenn diagram plot
+ """
+ result = {}
+ result["name"] = {}
+ for k in comp_dict.keys():
+ result["name"][k] = title_dict[k]
+
+ result["data"] = {}
+ result["values"] = {}
+ for group, intersected, difference in intersect(comp_dict):
+ if len(group) == 1:
+ result["data"]["".join(group)] = difference
+ result["values"]["".join(group)] = len(difference)
+ elif len(group) > 1 and len(group) < len(comp_dict):
+ result["data"]["".join(group)] = difference
+ result["values"]["".join(group)] = len(difference)
+ elif len(group) == len(comp_dict):
+ result["data"]["".join(group)] = intersected
+ result["values"]["".join(group)] = len(intersected)
+
+ return result
+
+def write_text_venn(json_result):
+ """
+ Write intersections of input to text output file
+ """
+ output = open("venn_diagram_text_output.txt", "w")
+ string = ""
+ lines = []
+ result = dict((k, v) for k, v in json_result["data"].iteritems() if v != [])
+ max_count = max(len(v) for v in result.values())
+ for i in range(max_count):
+ lines.append("")
+
+ for i in range(max_count):
+ header = ""
+ for d in range(len(result.keys())):
+ data = result.keys()[d]
+ 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)
+ output.write(string)
+ output.close()
+
+def write_summary(summary_file, inputs):
+ """
+ Paste json string into template file
+ """
+ a, b = input_to_dict(inputs)
+ data = diagram(a, b)
+ write_text_venn(data)
+
+ to_replace = {
+ "series": [data],
+ "displayStat": "true",
+ "displaySwitch": "true",
+ "shortNumber": "true",
+ }
+
+ FH_summary_tpl = open(os.path.join(CURRENT_DIR, "jvenn_template.html"))
+ FH_summary_out = open(summary_file, "w" )
+ for line in FH_summary_tpl:
+ if "###JVENN_DATA###" in line:
+ line = line.replace("###JVENN_DATA###", json.dumps(to_replace))
+ FH_summary_out.write(line)
+
+ FH_summary_out.close()
+ FH_summary_tpl.close()
+
+def process(args):
+ write_summary(args.summary, args.input)
+
+
+##################################################################################################################################################
+# MAIN
+##################################################################################################################################################
+if __name__ == '__main__':
+ # Parse parameters
+ parser = argparse.ArgumentParser(description='Filters an abundance file')
+ group_input = parser.add_argument_group( 'Inputs' )
+ group_input.add_argument('--input', nargs="+", action="append", required=True, help="The input tabular file.")
+ group_output = parser.add_argument_group( 'Outputs' )
+ group_output.add_argument('--summary', default="summary.html", help="The HTML file containing the graphs. [Default: %(default)s]")
+ args = parser.parse_args()
+
+ # Process
+ process( args )
diff -r 000000000000 -r 8d61f5ca50a4 venn_diagram.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/venn_diagram.xml Mon Nov 12 11:26:40 2018 -0500
@@ -0,0 +1,142 @@
+
+
+ (JVenn)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+This tool draw a venn diagram from lists/files using Jvenn plug-in (http://jvenn.toulouse.inra.fr/app/index.html). It also creates output files that contain common or specific elements between query and each compared lists/files.
+
+**Inputs**
+
+* **Query file:** A file containing different information of proteins, could be output of previous components.
+
+* **File of a list of IDs:** .TXT format, each line contains 1 ID
+
+ AMY1A
+
+ ALB
+
+ IGKC
+
+ CSTA
+
+ IGHA1
+
+ ACTG1
+
+* **List of IDs:** IDs separated by a space
+
+ AMY1A ALB IGKC CSTA IGHA1 ACTG1
+
+If you choose a file, it is necessary to specify the column where you would like to perform the comparison.
+
+**Outputs**
+
+* **Summary file** (venn_diagram_summary.html):
+ Venn diagram: Could be downloaded as image (PNG, SVG)
+
+* **Venn text output file**
+ A text file containing common/specific elements among compared lists/files.
+
+-----
+
+.. class:: infomark
+
+**Authors**
+
+Philippe Bardou, Jérôme Mariette, Frédéric Escudié, Christophe Djemiel and Christophe Klopp. jvenn: an interactive Venn diagram viewer. BMC Bioinformatics 2014, 15:293 doi:10.1186/1471-2105-15-293
+
+.. class:: infomark
+
+**Galaxy integration**
+
+T.P. Lien Nguyen, Florence Combes, Yves Vandenbrouck CEA, INSERM, CNRS, Grenoble-Alpes University, BIG Institute, FR
+
+Sandra Dérozier, Olivier Rué, Christophe Caron, Valentin Loux INRA, Paris-Saclay University, MAIAGE Unit,Migale Bioinformatics platform
+
+Contact support@proteore.org for any questions or concerns about the Galaxy implementation of this tool.
+
+
+
+
+