new file: cell2loc.py
[GalaxyCodeBases.git] / perl / etc / WoodyMiaoLin / Tiger / draw_linkagemap.pl
blob66c21084856b0e0782f163fded423139ef8d1bb4
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
5 open I75, "<", "scaffold188SNP.16.gt";
6 open O, ">", "scaffold188_linkage_map.svg";
8 my @ra75;
9 while (<I75>) {
10 chomp;
11 my @a = split /\t/;
12 my @b;
13 $b[0] = $a[0];
14 $b[1] = $a[1];
15 foreach (4..12) {
16 my ($a1, $a2) = split /\//, $a[$_];
17 if (($a1 eq "N") and ($a2 eq "A")) {
18 push @b, "none";
19 } elsif (($a1 eq "0") and ($a2 eq "0")) {
20 push @b, $a[2];
21 } elsif (($a1 eq "1") and ($a2 eq "1")) {
22 push @b, $a[3];
23 } else {
24 push @b, "$a[2]$a[3]";
27 my $b0 = 0;
28 my $b1 = 0;
29 foreach (13..19) {
30 my ($a1, $a2) = split /\//, $a[$_];
31 if (($a1 eq "N") and ($a2 eq "A")) {
32 push @b, "none";
33 } elsif (($a1 eq "0") and ($a2 eq "0")) {
34 ++$b0;
35 push @b, $a[2];
36 } elsif (($a1 eq "1") and ($a2 eq "1")) {
37 ++$b1;
38 push @b, $a[3];
39 } else {
40 push @b, "$a[2]$a[3]";
43 if ($b0 > $b1) {
44 push @b, $a[2];
45 } elsif ($b0 < $b1) {
46 push @b, $a[3];
47 } else {
48 push @b, "equal"
50 push @ra75, \@b;
52 close I75;
54 print O "<?xml version=\"1.0\"?>\n\n<svg xmlns=\"http://www.w3.org/2000/svg\">\n\n";
56 my $yy;
57 foreach my $a (@ra75) {
58 ++$yy;
59 my $y = 10*$yy;
60 print O "<text x=\"0\" y=\"$y\" font-family=\"Courier\" font-size=\"8\" fill=\"black\">${$a}[0]</text>\n";
61 print O "<text x=\"70\" y=\"$y\" font-family=\"Courier\" font-size=\"8\" fill=\"black\">${$a}[1]</text>\n";
62 foreach (2..17) {
63 my $xt = 30*$_ + 60;
64 my $yt = 10*$yy;
65 my $xr = 30*$_ + 50;
66 my $yr = 10*$yy - 8;
67 my $h = length ${$a}[$_];
68 my $color;
69 if ($h == 2) {
70 $color = "green";
71 } elsif ($h == 1) {
72 if (${$a}[18] eq "equal") {
73 $color = "pink";
74 } elsif (${$a}[18] eq ${$a}[$_]) {
75 $color = "yellow";
76 } else {
77 $color = "blue";
79 } else {
80 $color = "white";
82 print O "<rect x=\"$xr\" y=\"$yr\" width=\"30\" height=\"10\" fill=\"$color\" stroke-width=\"0.5\" stroke=\"black\"/>\n";
83 print O "<text x=\"$xt\" y=\"$yt\" font-family=\"Courier\" font-size=\"8\" fill=\"black\">${$a}[$_]</text>\n";
87 print O "\n</svg>\n";
88 close O;