-
Notifications
You must be signed in to change notification settings - Fork 0
/
getSchematic.pl
executable file
·78 lines (63 loc) · 2.19 KB
/
getSchematic.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/perl -w
use strict;
use FindBin;
use lib $FindBin::Bin;
use DrawUtils::Schematic;
$| = 1;
main:
{
my $id = $ARGV[0];
my $OB = {};
getDataFromFile($OB, $id);
createImage($OB, $id);
printImage($OB, $id);
}
sub getDataFromFile
{
my ($OBJ, $id) = @_;
open(IN, "<", "$id.featcfg") or die "can't open featcfg";
my ($seqid, $seq) = split(/\t/,<IN>);
$OBJ->{'LEN'} = length $seq;
while (<IN>)
{
chomp $_;
my @tmp = split(/\t/,$_);
# Next line edited in this web server version in order to be compatible
# with FFPred 3, see "/webdata/binaries/current/FFPred3/README".
if ((@tmp == 5) && ($tmp[0] !~ /SP/))
{
my ($name, $type, $from, $to, $score) = @tmp;
my $i = defined($OBJ->{'FEAT_ARRAY'}{$name}) ? scalar(@{$OBJ->{'FEAT_ARRAY'}{$name}}) : 0;
$OBJ->{'FEAT_ARRAY'}{$name}[$i]{'from'} = $from;
$OBJ->{'FEAT_ARRAY'}{$name}[$i]{'to'} = $to;
$OBJ->{'FEAT_ARRAY'}{$name}[$i]{'val'} = $score;
$OBJ->{'FEAT_ARRAY'}{$name}[$i]{'type'} = $type;
$OBJ->{'FEAT_ARRAY'}{$name}[$i]{'name'} = $name;
}
}
close(IN);
}
sub createImage
{
my ($OBJ, $id) = @_;
$OBJ->{'IMG'} = new Schematic(
-vertical_padding => 50,
-horizontal_padding => 8,
-offset => 0,
-max_height => 500,
-max_width => 720,
-feat_hash => $OBJ->{'FEAT_ARRAY'},
-len => $OBJ->{'LEN'},
-color_scheme => 'default',
-fonts => $FindBin::Bin.'/DrawUtils/fonts/',
-ttf_font => 'Verdana',
-ttf_font_size => 8
);
}
sub printImage
{
my ($OBJ, $id)= @_;
my $fhPNG = new FileHandle("${id}_sch.png", 'w');
print $fhPNG $OBJ->{'IMG'}->png;
$fhPNG->close;
}