changeset 0:6bf83148cae7 draft

planemo upload commit 9a018b286f77a088d30dfea877ccbc7341356c8b-dirty
author vmarcon
date Thu, 02 Aug 2018 11:18:49 -0400
parents
children 0e4dc43800b8
files Cytoscape.pl Cytoscape.sh Cytoscape.xml test-data/input.json test-data/network.html
diffstat 5 files changed, 348 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Cytoscape.pl	Thu Aug 02 11:18:49 2018 -0400
@@ -0,0 +1,115 @@
+#!/usr/bin/perl
+
+use strict;
+#use Switch;
+use Getopt::Long;
+use Bio::SeqIO;
+
+use Cwd;
+my $dir = getcwd;
+
+
+my $usage = qq~Usage:$0 <args> [<opts>]
+where <args> are:
+    -i, --input         <input>
+    -h, --html          <html_output>
+~;
+$usage .= "\n";
+
+my ($infile,$htmlout);
+
+
+GetOptions(
+	"input=s"    => \$infile,
+	"html=s"     => \$htmlout,
+);
+
+
+die $usage
+  if ( !$infile);
+
+
+my $datain = "";
+open(I,$infile);
+while(<I>){
+	my $line = $_;
+	$datain.=$line;
+}
+close(I);
+chomp($datain);chomp($datain);
+# remove brackets at the beginning and end of JSON
+my $new_datain = substr($datain,1,length($datain)-2);
+$datain = $new_datain;
+	
+my @colors = ("#ed292a","#ed292a","#82ABA0","#2255a6","#6ebe43","#e76599","#662e91","#c180ff","#ea8b2f","#fff100","#666666","#01ffff","#bfbfbf","#2ac966","#666666");
+
+
+my $pie_block = "";
+for (my $i = 0; $i <= scalar @colors; $i++){
+        $pie_block .= "'pie-$i-background-color': '$colors[$i]',\n";
+        $pie_block .= "'pie-$i-background-size': 'mapData(group$i, 0, 10, 0, 100)',\n";
+}
+
+open(HTML_CYTOSCAPE,">$htmlout");
+                        my $html = qq~<!DOCTYPE html>
+<html><head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+<link href="http://sniplay.southgreen.fr/cytoscape/Pie_style/style.css" rel="stylesheet">
+<meta charset="utf-8">
+<meta name="viewport" content="user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, minimal-ui">
+<title>Pie style</title>
+<script src="http://sniplay.southgreen.fr/cytoscape/Pie_style/jquery.js"></script>
+<script src="http://sniplay.southgreen.fr/cytoscape/Pie_style/cytoscape.js"></script>
+<script type="text/javascript">
+\$(function(){ // on dom ready
+
+\$('#cy').cytoscape({
+
+  style: cytoscape.stylesheet()
+    .selector(':selected')
+      .css({
+        'background-color': 'black',
+        'line-color': 'black',
+        'opacity': 1
+      })
+    .selector('.faded')
+      .css({
+        'opacity': 0.25,
+        'text-opacity': 0
+      })
+    .selector('edge')
+      .css({
+                'width': 1,
+                'line-color': 'black',
+      })
+    .selector('node')
+      .css({
+        'width': 'mapData(width, 0, 10, 0, 100)',
+        'height': 'mapData(width, 0, 10, 0, 100)',
+        'content': 'data(id)',
+        'pie-size': '98%',
+        $pie_block
+      }),
+$datain
+  ,
+layout: {
+        name: 'cose',
+    padding: 10
+  },
+
+  ready: function(){
+    window.cy = this;
+  }
+});
+
+});
+
+</script>
+</head>
+<body>
+<div id="cy">
+</div>
+~;
+print HTML_CYTOSCAPE $html;
+close(HTML_CYTOSCAPE);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Cytoscape.sh	Thu Aug 02 11:18:49 2018 -0400
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+tool_path=$(dirname $0)
+
+filein=$1
+cytoscape_html=$2
+logfile=$3
+
+perl $tool_path/Cytoscape.pl --input $filein --html $cytoscape_html >>$logfile 2>&1
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Cytoscape.xml	Thu Aug 02 11:18:49 2018 -0400
@@ -0,0 +1,87 @@
+<tool id="Cytoscape" name="Cytoscape" version="1.0.0">
+    
+    <!-- [REQUIRED] Tool description displayed after the tool name -->
+    <description>Visualize interaction networks from JSON file</description>
+    
+    <!-- [OPTIONAL] 3rd party tools, binaries, modules... required for the tool to work -->
+    <requirements>
+        <requirement type="binary">perl</requirement>
+        <requirement type="package" version="1.6.924">perl-bioperl</requirement>
+    </requirements>
+    
+
+    <!-- [STRONGLY RECOMMANDED] Exit code rules -->
+    <stdio>
+        <!-- [HELP] If no exit code rule is defined, the tool will stop if anything is written to STDERR -->
+        <exit_code range="1:" level="fatal" />
+    </stdio>    
+
+    <!-- [REQUIRED] The command to execute -->
+    <command interpreter="perl">
+	Cytoscape.sh $input $cytoscape_html $filelog 
+    </command>
+    <!-- [REQUIRED] Input files and tool parameters -->
+    <inputs>
+	<param name="input" type="data" format="json" optional="false" label="Cytoscape JSON file" />
+    </inputs>
+    
+    <!-- [REQUIRED] Output files -->
+    <outputs>
+	<data name="cytoscape_html" format="html" label="Cytoscape network" />
+	<data name="filelog" format="txt" label="Logfile" />
+    </outputs>
+
+    <!-- [OPTIONAL] Tests to be run manually by the Galaxy admin -->
+    <tests>
+        <!-- [HELP] Test files have to be in the ~/test-data directory -->
+        <test>
+            <param name="input" value="input.json" />
+            <output name="cytoscape_html" file="network.html"/>
+        </test>
+    </tests>    
+
+    <!-- [OPTIONAL] Help displayed in Galaxy -->
+    <help>
+
+.. class:: infomark
+
+**Authors**     Max Franz : Cytoscape.js_
+
+.. _Cytoscape.js: http://js.cytoscape.org/
+
+.. class:: infomark
+
+**Galaxy integration** Alexis Dereeper, IRD.
+
+.. class:: infomark
+
+**Support** For any questions about Galaxy integration, please send an e-mail to alexis.dereeper@ird.fr
+
+---------------------------------------------------
+
+================
+Cytoscape
+================
+
+-----------
+Description
+-----------
+
+  | Create a Cytoscape network from Cytoscape JSON file
+
+----------
+Input file
+----------
+
+JSON file for Cytoscape
+
+------------
+Output files
+------------
+
+Cytoscape network
+
+Log file
+    </help>
+
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/input.json	Thu Aug 02 11:18:49 2018 -0400
@@ -0,0 +1,22 @@
+{"elements": {"nodes": [{ "data": { "id": "MV1", "width": 0.1} },
+{ "data": { "id": "MV2", "width": 0.1} },
+{ "data": { "id": "MV3", "width": 0.1} },
+{ "data": { "id": "haplo1", "width": 1.2000000000000002 } },
+{ "data": { "id": "haplo2", "width": 0.8 } },
+{ "data": { "id": "haplo3", "width": 5.0 } },
+{ "data": { "id": "haplo4", "width": 0.8 } },
+{ "data": { "id": "haplo5", "width": 0.8 } },
+{ "data": { "id": "haplo6", "width": 0.8 } },
+{ "data": { "id": "haplo7", "width": 0.8 } },
+{ "data": { "id": "haplo8", "width": 0.8 } }],
+"edges": [
+{ "data": { "id": "haplo4MV1", "weight": 1, "source": "haplo4", "target": "MV1"} },
+{ "data": { "id": "haplo3haplo4", "weight": 1, "source": "haplo3", "target": "haplo4"} },
+{ "data": { "id": "haplo4haplo6", "weight": 1, "source": "haplo4", "target": "haplo6"} },
+{ "data": { "id": "haplo1MV1", "weight": 1, "source": "haplo1", "target": "MV1"} },
+{ "data": { "id": "haplo1haplo2", "weight": 1, "source": "haplo1", "target": "haplo2"} },
+{ "data": { "id": "haplo7MV2", "weight": 1, "source": "haplo7", "target": "MV2"} },
+{ "data": { "id": "MV2MV3", "weight": 1, "source": "MV2", "target": "MV3"} },
+{ "data": { "id": "haplo5MV3", "weight": 1, "source": "haplo5", "target": "MV3"} },
+{ "data": { "id": "MV1MV2", "weight": 1, "source": "MV1", "target": "MV2"} },
+{ "data": { "id": "haplo8MV3", "weight": 1, "source": "haplo8", "target": "MV3"} }]}}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/network.html	Thu Aug 02 11:18:49 2018 -0400
@@ -0,0 +1,111 @@
+<!DOCTYPE html>
+<html><head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+<link href="http://sniplay.southgreen.fr/cytoscape/Pie_style/style.css" rel="stylesheet">
+<meta charset="utf-8">
+<meta name="viewport" content="user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, minimal-ui">
+<title>Pie style</title>
+<script src="http://sniplay.southgreen.fr/cytoscape/Pie_style/jquery.js"></script>
+<script src="http://sniplay.southgreen.fr/cytoscape/Pie_style/cytoscape.js"></script>
+<script type="text/javascript">
+$(function(){ // on dom ready
+
+$('#cy').cytoscape({
+
+  style: cytoscape.stylesheet()
+    .selector(':selected')
+      .css({
+        'background-color': 'black',
+        'line-color': 'black',
+        'opacity': 1
+      })
+    .selector('.faded')
+      .css({
+        'opacity': 0.25,
+        'text-opacity': 0
+      })
+    .selector('edge')
+      .css({
+                'width': 1,
+                'line-color': 'black',
+      })
+    .selector('node')
+      .css({
+        'width': 'mapData(width, 0, 10, 0, 100)',
+        'height': 'mapData(width, 0, 10, 0, 100)',
+        'content': 'data(id)',
+        'pie-size': '98%',
+        'pie-0-background-color': '#ed292a',
+'pie-0-background-size': 'mapData(group0, 0, 10, 0, 100)',
+'pie-1-background-color': '#ed292a',
+'pie-1-background-size': 'mapData(group1, 0, 10, 0, 100)',
+'pie-2-background-color': '#82ABA0',
+'pie-2-background-size': 'mapData(group2, 0, 10, 0, 100)',
+'pie-3-background-color': '#2255a6',
+'pie-3-background-size': 'mapData(group3, 0, 10, 0, 100)',
+'pie-4-background-color': '#6ebe43',
+'pie-4-background-size': 'mapData(group4, 0, 10, 0, 100)',
+'pie-5-background-color': '#e76599',
+'pie-5-background-size': 'mapData(group5, 0, 10, 0, 100)',
+'pie-6-background-color': '#662e91',
+'pie-6-background-size': 'mapData(group6, 0, 10, 0, 100)',
+'pie-7-background-color': '#c180ff',
+'pie-7-background-size': 'mapData(group7, 0, 10, 0, 100)',
+'pie-8-background-color': '#ea8b2f',
+'pie-8-background-size': 'mapData(group8, 0, 10, 0, 100)',
+'pie-9-background-color': '#fff100',
+'pie-9-background-size': 'mapData(group9, 0, 10, 0, 100)',
+'pie-10-background-color': '#666666',
+'pie-10-background-size': 'mapData(group10, 0, 10, 0, 100)',
+'pie-11-background-color': '#01ffff',
+'pie-11-background-size': 'mapData(group11, 0, 10, 0, 100)',
+'pie-12-background-color': '#bfbfbf',
+'pie-12-background-size': 'mapData(group12, 0, 10, 0, 100)',
+'pie-13-background-color': '#2ac966',
+'pie-13-background-size': 'mapData(group13, 0, 10, 0, 100)',
+'pie-14-background-color': '#666666',
+'pie-14-background-size': 'mapData(group14, 0, 10, 0, 100)',
+'pie-15-background-color': '',
+'pie-15-background-size': 'mapData(group15, 0, 10, 0, 100)',
+
+      }),
+"elements": {"nodes": [{ "data": { "id": "MV1", "width": 0.1} },
+{ "data": { "id": "MV2", "width": 0.1} },
+{ "data": { "id": "MV3", "width": 0.1} },
+{ "data": { "id": "haplo1", "width": 1.2000000000000002 } },
+{ "data": { "id": "haplo2", "width": 0.8 } },
+{ "data": { "id": "haplo3", "width": 5.0 } },
+{ "data": { "id": "haplo4", "width": 0.8 } },
+{ "data": { "id": "haplo5", "width": 0.8 } },
+{ "data": { "id": "haplo6", "width": 0.8 } },
+{ "data": { "id": "haplo7", "width": 0.8 } },
+{ "data": { "id": "haplo8", "width": 0.8 } }],
+"edges": [
+{ "data": { "id": "haplo4MV1", "weight": 1, "source": "haplo4", "target": "MV1"} },
+{ "data": { "id": "haplo3haplo4", "weight": 1, "source": "haplo3", "target": "haplo4"} },
+{ "data": { "id": "haplo4haplo6", "weight": 1, "source": "haplo4", "target": "haplo6"} },
+{ "data": { "id": "haplo1MV1", "weight": 1, "source": "haplo1", "target": "MV1"} },
+{ "data": { "id": "haplo1haplo2", "weight": 1, "source": "haplo1", "target": "haplo2"} },
+{ "data": { "id": "haplo7MV2", "weight": 1, "source": "haplo7", "target": "MV2"} },
+{ "data": { "id": "MV2MV3", "weight": 1, "source": "MV2", "target": "MV3"} },
+{ "data": { "id": "haplo5MV3", "weight": 1, "source": "haplo5", "target": "MV3"} },
+{ "data": { "id": "MV1MV2", "weight": 1, "source": "MV1", "target": "MV2"} },
+{ "data": { "id": "haplo8MV3", "weight": 1, "source": "haplo8", "target": "MV3"} }]}
+  ,
+layout: {
+        name: 'cose',
+    padding: 10
+  },
+
+  ready: function(){
+    window.cy = this;
+  }
+});
+
+});
+
+</script>
+</head>
+<body>
+<div id="cy">
+</div>