/
stockfilm.pl
executable file
·47 lines (36 loc) · 946 Bytes
/
stockfilm.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
#!/usr/bin/perl
use Getopt::Long;
use Time::HiRes qw(usleep);
use Stockholm;
use Stockholm::Database;
# Options
my $delay = .01;
my $usage = "";
$usage .= "$0 -- page through Stockholm alignments in a database\n";
$usage .= "\n";
$usage .= "Usage: cat <filename> | $0 [-delay <seconds>] [filename(s)]\n";
$usage .= "\n";
$usage .= "Default delay is $delay seconds\n";
$usage .= "\n";
GetOptions ("delay=i" => \$delay) or die $usage;
# Process
unless (@ARGV) {
@ARGV = qw(-);
warn "[waiting for alignments on standard input]\n";
}
for my $filename (@ARGV) {
my $db = Stockholm::Database->from_file ($filename);
for my $stock (@$db) {
# Get terminal size
my $screenColumns = (`tput cols` + 0) || 80;
# prepare text
my $stockText = $stock->to_string ("MAXCOLS" => $screenColumns,
"COLOR" => "AMINO");
# clear screen
system "clear";
# print
print $stockText;
# delay
usleep ($delay * 1e6);
}
}