Some kind of SVG display in Kegg

Source: Internet
Author: User

#!perluse warnings;use strict;use svg;use file::basename qw (Basename);d ie "Perl $ <sample.list> < pathway.sorted> <outprefix>note:support colors to sample~ "if @ARGV! = 3;my (@file, @pwtmp, @pw2sp); my $i = 0 ; open PW, $ARGV [1] or Die $!; while (<PW>) {chomp;my @tmp = split/\t/; $pwtmp [$i]{$tmp [0]} = 1; $i + +;} My $f = 0;open SP, $ARGV [0] or Die $!; while (<SP>) {chomp;my @ft = split;my $name = basename ($ft [0]), my ($id) = $ft [0] =~/^ ([^\.] +)/;p ush @file, $ft [1];open FA, $ft [0] or Die $!; <fa>;for (My $n = 0; $n < @pwtmp; $n + +) {$PW 2sp[$f] [$n] = 1;} while (my $line = <FA>) {chomp ($line), my @tmp = Split/\t/, $line; for (my $j = 0; $j < @pwtmp; $j + +) {if (exists $PWT mp[$j]{$tmp [0]}) {$PW 2sp[$f] [$j] = $tmp [4];last;}}} $f + +;} my $fn = @file; My $pwn = @pwtmp, my $svg = svg->new (width = ($FN * + 1100), height = = ($PWN * +)); $svg- >rect (x = =, y =, width = (($FN + 1) * +), height = (($pwn + 1) * +), fill =&GT "White", stroke = "grey", ' stroke-width ' and 8); for (my $j = 0; $j < @pwtmp; $j + +) {My $n = $j + 1; $svg->line ( x1, y1 = (+ $n *), X2 (+ ($FN + 1) *, y2 = (+ $n *), stroke = "orange", ' Strok E-width ' + 3); foreach my $pc (keys%{$pwtmp [$j]}) {$svg->text (x = (($FN + 1) * +), y = + + $n *, St yle = {' font ' + ' Times New Roman ', ' font-size ', ' font-weight ' = ' Bold '}->cdata ($PC);} My @color = (' Red ', ' green ', ' blue ', ' yellow ', ' cyan ', ' purple ', ' sandybrown ', ' Navy ', ' Violet ', ' DarkSalmon ', ' bisque ', ' Fuchsia ', ' lightcoral ', ' goldenrod ', ' Silver ', ' brown ', ' lawngreen ', ' skyblue ', ' Indigo ', ' forestgreen ', ' Lightseagreen ', ' aqua ', ' lime '), #my @color = (' Red ', ' red ', ' green ', ' green ', ' blue ', ' blue ', ' yellow ', ' yellow '); my $colu MN = 0;my $row = 0;for (My $j = 0; $j < @file; $j + +) {My $n = $j + 1;my $rx = + $n * + int (length ($file [$j])/2) * 14;my $ry = + ($PWN + 1) * + Length ($file[$j]) * $svg->line (x1 + $n *), y1, x2 = (+ $n *), y2 = (+ ($PWN + 1) * 50),  Stroke = "Orange", ' stroke-width ' = 3), $svg->text (x = + $n *), y = (+ ($PWN + 1) *), style + = {' font ' + ' Times New Roman ', ' font-size ' +, ' font-weight ' = ' bold '}, ' transform ' = ' rotate ' (-45, $rx, $ry) ")->cdata ($file [$j]); for (my $k = 0; $k < @{$PW 2sp[$j]}; $k + +) {if ($PW 2sp[$j] [$k] >= 0.05) {$svg->circ Le (cx = + $n *, cy = + ($k + 1) *, R = 1, fill = $color [$j], stroke = ' black ');} elsif ($PW 2sp[$j] [$k] < 0.05 and $PW 2sp[$j] [$k] >= 0.01) {$svg->circle (cx + $n *), cy = ($k + 1), R = +, fill = $color [$j], stroke = ' black ');}  else{$svg->circle (cx = + $n *), cy = (+ ($k + 1) *, r = =, fill = $color [$j], stroke = ' Black ');}} if (($n/6) =~/\./) {$svg->circle (cx = + (@file + 1) * + $coLumn *), cy = (+ ($PWN + 1) * + $row *), R = +, fill = "$color [$j]", stroke = ' black '); $svg- >text (x = + (@file + 1) * + $column *), y = (+ + ($PWN + 1) * + $row * *), style = {' Font ' + ' Times New Roman ', ' font-size ', ' font-weight ' and ' Bold '}->cdata ($file [$j]); $column + +;} else{$svg->circle (cx + + (@file + 1) * + $column * +), cy = (+ ($PWN + 1) * + $row *), R =&G T  Fill = "$color [$j]", stroke = ' black '), $svg->text (x = + (@file + 1) * + $column *), y =  (+ + ($PWN + 1) * + $row *), style + = {' font ' + ' Times New Roman ', ' font-size ' and ' font-weight ' + ' Bold '})->cdata ($file [$j]); $row + +; $column = 0;}} $svg->circle (cx = + (@file + 1) *, cy = (+ ($PWN + 1) *), R = +, fill = ' Sandybrown ', s Troke = ' black '), $svg->circle (cx + + (@file + 1) *, cy = (+ ($PWN + 1) * 50), r =, fill = ' sandybrown ', stroke = ' black '), $svg->text (x = (122 + (@file + 1) *, y = (75 + ($PWN + 1) *, style = {' font ' + ' Times New Roman ', ' font-size ' and ' font-weight ', '->cdat ' and ' bold '}) A ("FDR < 0.05"), $svg->text (x = = (147 + (@file + 1) *, y = + ($pwn + 1) *, style = {' Font ' =& Gt ' Times New Roman ', ' font-size ' (+), ' font-weight ' = ' Bold '})->cdata ("FDR < 0.01"); open out, "> $ARGV [2].s VG "or Die $!; Print out $svg->xmlify;

Some kind of SVG display in Kegg

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.