-
Notifications
You must be signed in to change notification settings - Fork 7
/
hmm2gff.pl
executable file
·47 lines (37 loc) · 1.3 KB
/
hmm2gff.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
#!/usr/bin/perl -w
sub nameonly { my $path = shift; $path =~ s/.*\/([^\/]+)$/$1/; return $path }
#require glob("~ihh/perl/standard.pl");
my $usage = "";
$usage .= "$0 -- convert hmmsearch output to GFF\n";
$usage .= "\n";
$usage .= "Usage: $0 [-m hmmfile] [-r rndfile] [-p program] [-f feature] [files...]\n";
$usage .= "\n";
$usage .= "hmmfile, rndfile, program, feature used for labelling purposes only\n";
$usage .= "\n";
my $program = "HMMer";
my $feature = "similarity";
my $hmmfile = "unknown";
my $rndfile;
while (@ARGV) {
last unless ($ARGV[0] =~ /^-/);
my $arg = shift;
if ($arg eq "-m") { $hmmfile = nameonly(shift) }
elsif ($arg eq "-r") { $rndfile = nameonly(shift) }
elsif ($arg eq "-p") { $program = nameonly(shift) }
elsif ($arg eq "-f") { $feature = shift }
else { die "Unknown option $arg\n\n$usage" }
}
$group = ($rndfile) ? "$hmmfile;$rndfile" : $hmmfile;
while (<>) {
last if /Parsed for domains/;
}
my $dummy;
$dummy = <>;
$dummy = <>;
while (<>) {
last unless /\S/;
my ($seqname,$domain,$start,$end,$dummy1,$hmmstart,$hmmend,$dummy2,$score,$evalue) = split;
if ($end>=$start) { $strand = "+" }
else { $strand = "-"; ($start,$end) = ($end,$start) }
print "$seqname\t$program\t$feature\t$start\t$end\t$score\t$strand\t.\t$group $hmmstart $hmmend\n";
}