-
Notifications
You must be signed in to change notification settings - Fork 7
/
cluster2gff.pl
executable file
·32 lines (27 loc) · 965 Bytes
/
cluster2gff.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
#!/usr/bin/perl
select STDERR; $| = 1; select STDOUT;
$prefix = $feature = "cluster";
($prog = $0) =~ s/^.*\/([^\/]+)$/$1/;
$usage .= "$0 - make GFF output from single-line cluster input\n";
$usage .= "\n";
$usage .= "Usage: $0 [-prefix prefix] [<cluster files>]\n";
$usage .= "\n";
$usage .= "Default prefix is '$prefix'.\n";
$usage .= "\n";
$usage .= "Each cluster should be a line of space-separated fields like 'name/start-end'.\n";
$usage .= "\n";
while (@ARGV) {
last unless $ARGV[0] =~ /^-/;
$opt = lc shift;
if ($opt eq "-prefix") { defined($prefix = shift) or die $usage }
else { die "$usage\nUnknown option: $opt" }
}
while (<>) {
@members = split;
$group = $prefix.++$n." clustersize=".scalar(@members);
foreach $nse (@members) {
die "Bad name/start-end format" unless $nse =~ /^(\S+)\/(\d+)-(\d+)$/;
($name,$start,$end) = ($1,$2,$3);
print join("\t",$name,$feature,$prog,$start,$end,".","+",".",$group),"\n";
}
}