@@ -6,32 +6,44 @@ use Bio::SeqIO;
66use Data::Dumper;
77use File::Temp qw( tempdir) ;
88
9- my (@Options , $verbose , $datadir , $hypo , $sep , $blank , $pseudo , $minlen );
9+ my (@Options , $verbose , $datadir , $hypo , $sep , $blank ,
10+ $pseudo , $minlen , $seeds , $index , $rules );
1011setOptions();
1112
1213$datadir or die " please specify HAMAP --datadir" ;
1314-d $datadir or die " --datadir $datadir is not a valid folder" ;
15+ $seeds or die " need --seeds .tgz file" ;
16+ $index or die " need --index .dat file" ;
17+ $rules or die " need --rules .dat file" ;
1418
1519my $dir = tempdir(CLEANUP => 1);
1620print STDERR " Using $dir as temp folder.\n " ;
1721
22+
1823my %DESC ;
19- my $ali_fh = get_file(" alignment_id.dat " , " alignment /gene /product info" );
24+ my $ali_fh = get_file($index , " alignment /gene /product info" );
2025while (<$ali_fh >) {
26+ # 0 MF_00001
27+ # 1 MF_00001
28+ # 2 28
29+ # 3 PYRB
30+ # 4 pyrB
31+ # 5 Aspartate carbamoyltransferase [pyrB]
2132 chomp ;
2233 my @x = split m /\t / ;
23- next if $x [5] =~ m / UPF\d +|homolog|[@<\[ ] / ;
34+ $x [5] =~ s /\s\[\w +\] $// ;
35+ next if $x [5] =~ m / UPF\d +|homolog/ ;
2436 $x [5] =~ s / ^probable\s +// gi ;
2537 $DESC { $x [0] } = " $sep$x [4]$sep$x [5]" ;
2638}
27- printf STDERR " Accepted descriptions for %d families\n " , scalar keys %DESC ;
39+ printf STDERR " Accepted descriptions for %d families\n " , scalar keys %DESC ;;
2840
29- my $fam_fh = get_file(" hamap_families.dat " , " alignment /EC_number" );
41+ my $fam_fh = get_file($rules , " alignment /EC_number" );
3042my ($AC ,$EC ,$Bac );
3143while (<$fam_fh >) {
3244 chomp ;
3345 if (m { ^//} ) {
34- # print STDERR "AC=$AC EC=$EC Bac=$Bac\n";
46+ print STDERR " AC=$AC EC=$EC Bac=$Bac \n " ;
3547 if ($AC and $EC and exists $DESC {$AC }) {
3648 $DESC {$AC } = $EC .$DESC {$AC };
3749 }
@@ -53,7 +65,7 @@ while (<$fam_fh>) {
5365}
5466printf STDERR " %d models made it through filtering\n " , scalar keys %DESC ;
5567
56- my $aln_file = " $datadir /hamap_seed_alignments.tar.gz " ;
68+ my $aln_file = $seeds ;
5769if (-r $aln_file ) {
5870 print STDERR " Extracting $aln_file .\n " ;
5971 system (" tar -C $dir --strip-components 1 -zxf $aln_file " )==0 or die " ERROR: $? " ;
@@ -83,23 +95,24 @@ else {
8395}
8496
8597my $dest = ' HAMAP.hmm' ;
86- print STDERR " Combining into $dest \n " ;
87- system (" cat $dir /*.hmm > $dest " );
88-
98+ print STDERR " Combining into $dest .ascii\n " ;
99+ system (" cat $dir /*.hmm > $dest .ascii" );
100+ print STDERR " Converting to binary $dest \m " ;
101+ system (" hmmconvert -b $dest .ascii > $dest .hmm" );
89102
90103print STDERR " Done.\n " ;
91104
92105# ----------------------------------------------------------------------
93106
94107sub get_file {
95108 my ($pattern , $desc ) = @_ ;
96- my ($first ) = glob (" $datadir / $ pattern" );
109+ my ($first ) = glob (" $pattern " );
97110 if ($first and -r $first ) {
98111 print STDERR " Found $desc : $first \n " ;
99112 open my $fh , ' <' , $first ;
100113 return $fh ;
101114 }
102- die " Problem finding $pattern in $datadir ( $desc ) " ;
115+ die " Problem finding ' $pattern ' " ;
103116}
104117
105118# ----------------------------------------------------------------------
@@ -111,7 +124,10 @@ sub setOptions {
111124 @Options = (
112125 {OPT => " help" , VAR => \&usage, DESC => " This help" },
113126 {OPT => " verbose!" , VAR => \$verbose , DEFAULT => 0, DESC => " Verbose progress" },
114- {OPT => " datadir=s" , VAR => \$datadir , DEFAULT => ' ' , DESC => " Path to downloaded HAMAP folder (ftp://ftp.expasy.org/databases/hamap/)" },
127+ {OPT => " datadir=s" , VAR => \$datadir , DEFAULT => ' hamap_seed_alignments' , DESC => " Path to downloaded HAMAP folder (ftp://ftp.expasy.org/databases/hamap/)" },
128+ {OPT => " seeds=s" , VAR => \$seeds , DEFAULT => ' hamap_seed_alignments.tar.gz' , DESC => " Seed alignments .tgz" },
129+ {OPT => " index=s" , VAR => \$index , DEFAULT => ' rules_index.dat' , DESC => " Index file" },
130+ {OPT => " rules=s" , VAR => \$rules , DEFAULT => ' hamap_rules.dat' , DESC => " Rules file" },
115131 {OPT => " sep=s" , VAR => \$sep , DEFAULT => ' ~~~' , DESC => " Separator between EC/gene/product" },
116132 {OPT => " blank=s" , VAR => \$blank , DEFAULT => ' ' , DESC => " Replace empty EC/gene/product with this" },
117133# {OPT=>"pseudo!", VAR=>\$pseudo, DEFAULT=>0, DESC=>"Include /pseudo genes"},
0 commit comments