Mercurial > repos > dereeper > cytoscape
comparison Cytoscape.pl @ 0:e3beb33f88f0 draft
planemo upload commit 11382afe87364aaafb19973470d5066229a6e34f
author | dereeper |
---|---|
date | Tue, 14 Aug 2018 08:02:10 -0400 |
parents | |
children | 0e43c52e2449 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e3beb33f88f0 |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 use strict; | |
4 #use Switch; | |
5 use Getopt::Long; | |
6 use Bio::SeqIO; | |
7 | |
8 use Cwd; | |
9 my $dir = getcwd; | |
10 | |
11 | |
12 my $usage = qq~Usage:$0 <args> [<opts>] | |
13 where <args> are: | |
14 -i, --input <input> | |
15 -h, --html <html_output> | |
16 ~; | |
17 $usage .= "\n"; | |
18 | |
19 my ($infile,$htmlout); | |
20 | |
21 | |
22 GetOptions( | |
23 "input=s" => \$infile, | |
24 "html=s" => \$htmlout, | |
25 ); | |
26 | |
27 | |
28 die $usage | |
29 if ( !$infile); | |
30 | |
31 | |
32 my $datain = ""; | |
33 open(I,$infile); | |
34 while(<I>){ | |
35 my $line = $_; | |
36 $datain.=$line; | |
37 } | |
38 close(I); | |
39 chomp($datain);chomp($datain); | |
40 # remove brackets at the beginning and end of JSON | |
41 my $new_datain = substr($datain,1,length($datain)-2); | |
42 $datain = $new_datain; | |
43 | |
44 my @colors = ("#ed292a","#ed292a","#82ABA0","#2255a6","#6ebe43","#e76599","#662e91","#c180ff","#ea8b2f","#fff100","#666666","#01ffff","#bfbfbf","#2ac966","#666666"); | |
45 | |
46 | |
47 my $pie_block = ""; | |
48 for (my $i = 0; $i <= scalar @colors; $i++){ | |
49 $pie_block .= "'pie-$i-background-color': '$colors[$i]',\n"; | |
50 $pie_block .= "'pie-$i-background-size': 'mapData(group$i, 0, 10, 0, 100)',\n"; | |
51 } | |
52 | |
53 open(HTML_CYTOSCAPE,">$htmlout"); | |
54 my $html = qq~<!DOCTYPE html> | |
55 <html><head> | |
56 <meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
57 <link href="http://sniplay.southgreen.fr/cytoscape/Pie_style/style.css" rel="stylesheet"> | |
58 <meta charset="utf-8"> | |
59 <meta name="viewport" content="user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, minimal-ui"> | |
60 <title>Pie style</title> | |
61 <script src="http://sniplay.southgreen.fr/cytoscape/Pie_style/jquery.js"></script> | |
62 <script src="http://sniplay.southgreen.fr/cytoscape/Pie_style/cytoscape.js"></script> | |
63 <script type="text/javascript"> | |
64 \$(function(){ // on dom ready | |
65 | |
66 \$('#cy').cytoscape({ | |
67 | |
68 style: cytoscape.stylesheet() | |
69 .selector(':selected') | |
70 .css({ | |
71 'background-color': 'black', | |
72 'line-color': 'black', | |
73 'opacity': 1 | |
74 }) | |
75 .selector('.faded') | |
76 .css({ | |
77 'opacity': 0.25, | |
78 'text-opacity': 0 | |
79 }) | |
80 .selector('edge') | |
81 .css({ | |
82 'width': 1, | |
83 'line-color': 'black', | |
84 }) | |
85 .selector('node') | |
86 .css({ | |
87 'width': 'mapData(width, 0, 10, 0, 100)', | |
88 'height': 'mapData(width, 0, 10, 0, 100)', | |
89 'content': 'data(id)', | |
90 'pie-size': '98%', | |
91 $pie_block | |
92 }), | |
93 $datain | |
94 , | |
95 layout: { | |
96 name: 'cose', | |
97 padding: 10 | |
98 }, | |
99 | |
100 ready: function(){ | |
101 window.cy = this; | |
102 } | |
103 }); | |
104 | |
105 }); | |
106 | |
107 </script> | |
108 </head> | |
109 <body> | |
110 <div id="cy"> | |
111 </div> | |
112 ~; | |
113 print HTML_CYTOSCAPE $html; | |
114 close(HTML_CYTOSCAPE); | |
115 |