-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgen_logos.pl
executable file
·54 lines (45 loc) · 1.29 KB
/
gen_logos.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
#! /usr/bin/perl
####################
# gen_logos.pl - given a file with motifs from cisfinder, generate logos and create an html doc
# By Madelaine Gogol
# 12/2011
####################
use strict;
my $motif_file = $ARGV[0];
my $file = get_file_data($motif_file);
my @lines = split("\n",$file);
print "<html>\n";
print "<body>\n";
`mkdir gif`;
my $i = 0;
foreach my $line (@lines)
{
if($line =~ /^>/)
{
my ($name,$pat,$revpat,$freq,$ratio,$info,$score,$pval,$fdr,$pal,$nmem,$method,$motifname) = split(" ",$line);
$name =~ s/^>//g;
`motiflogo $motif_file gif/$i.gif -num $i`;
$i++;
print "<p>$name<br>$pat<br>score=$score<br>pval=$pval<br>fdr=$fdr<br><img src=\"gif/$i.gif\"><br> <br> <br>\n";
}
}
print "</body></html>";
######################################################
# subroutine get_file_data
# arguments: filename
# purpose: gets data from file given filename;
# returns file contents
######################################################
sub get_file_data
{
my($filename) = @_;
my @filedata = ();
unless( open(GET_FILE_DATA, $filename))
{
print STDERR "Cannot open file \"$filename\": $!\n\n";
exit;
}
@filedata = <GET_FILE_DATA>;
close GET_FILE_DATA;
return join('',@filedata);
}