annotate hmmpress_wrapper.pl @ 1:66f8262e1686

add datatype
author eskirton@lbl.gov
date Mon, 05 Mar 2012 22:51:04 -0800
parents c16d8db9338a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
1 #!/usr/bin/perl
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
2
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
3 use warnings;
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
4 use strict;
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
5
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
6 die("Infile, outfile, outdir required\n") unless @ARGV == 3;
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
7 my ($infile, $outfile, $outdir)=@ARGV;
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
8
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
9 # setup
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
10 -d $outdir or mkdir($outdir) or die($!);
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
11 symlink($infile,"$outdir/hmm");
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
12
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
13 # create output header file
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
14 open(IN, "<$infile") or die($!);
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
15 open(OUT, ">$outfile") or die($!);
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
16 my $ok=0;
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
17 while (my $line=<IN>) {
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
18 if (!$ok) {
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
19 die("Invalid input file (HMMER3 format required)\n") unless $line =~ /^HMMER3/;
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
20 $ok=1;
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
21 } elsif ($line =~ /^HMM/) {
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
22 last;
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
23 } else {
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
24 print OUT $line;
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
25 }
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
26 }
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
27 close IN;
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
28 close OUT;
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
29
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
30 # hmmpress
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
31 my $output=`hmmpress $outdir/hmm 2>&1`;
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
32 if ($? != 0) {
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
33 $output="FAILED\n" unless $output;
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
34 die($output);
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
35 }
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
36 unlink("$outdir/hmm");
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
37 my @output=split(/\n/, $output);
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
38 print $output[1], "\n";
c16d8db9338a init repo
eskirton@lbl.gov
parents:
diff changeset
39 exit;