[Bio] / FigKernelScripts / bbhs.pl Repository:
ViewVC logotype

Annotation of /FigKernelScripts/bbhs.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (view) (download) (as text)

1 : olson 1.7 #
2 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
3 :     # for Interpretations of Genomes. All Rights Reserved.
4 :     #
5 :     # This file is part of the SEED Toolkit.
6 :     #
7 :     # The SEED Toolkit is free software. You can redistribute
8 :     # it and/or modify it under the terms of the SEED Toolkit
9 :     # Public License.
10 :     #
11 :     # You should have received a copy of the SEED Toolkit Public License
12 :     # along with this program; if not write to the University of Chicago
13 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
14 :     # Genomes at veronika@thefig.info or download a copy from
15 :     # http://www.theseed.org/LICENSE.TXT.
16 :     #
17 :    
18 : overbeek 1.1 use FIG;
19 :     my $fig = new FIG;
20 :    
21 : overbeek 1.6 my $usage = "usage: bbhs [CutOff] [iterate] < PEG > PEG1-Sc-PEG";
22 : overbeek 1.1
23 :     my($cutoff,$pair,$peg);
24 : overbeek 1.4
25 :     my $iterate = 0;
26 :     my $i;
27 :     for ($i=0; ($i < @ARGV) && ($ARGV[$i] !~ /iterate/i); $i++) {}
28 :     if ($i < @ARGV)
29 :     {
30 :     $iterate = 1;
31 :     splice(@ARGV,$i,1);
32 :     }
33 :    
34 : overbeek 1.1 $cutoff = shift @ARGV;
35 :     $cutoff = defined($cutoff) ? $cutoff : 1.0e-10;
36 :    
37 : overbeek 1.3 my $id;
38 :     @pegs = map { chop; $_ =~ /(\S+)$/;
39 :     $id = $1;
40 :     if ($id =~ /^fig\|/)
41 :     {
42 :     $id;
43 :     }
44 :     else
45 :     {
46 :     if ($peg = $fig->by_alias($id))
47 :     {
48 :     $peg;
49 :     }
50 :     else
51 :     {
52 :     ();
53 :     }
54 :     }
55 :     } <STDIN>;
56 :    
57 : overbeek 1.2 %pegs = map { $_ => 1 } @pegs;
58 : overbeek 1.1
59 : overbeek 1.4 my @to_process = keys(%pegs);
60 :     my %seenG = map { ("$_," . &FIG::genome_of($_) ) => 1 } @to_process;
61 :     my %from = map { $_ => $_ } @to_process;
62 :     my %seenP = map { $_ => 1 } @to_process;
63 :    
64 : overbeek 1.6 my $i;
65 : overbeek 1.4 for ($i=0; ($i < @to_process); $i++)
66 : overbeek 1.1 {
67 : overbeek 1.4 $peg = $to_process[$i];
68 : overbeek 1.5
69 : overbeek 1.6 foreach $pair ($fig->bbhs($peg,$cutoff))
70 : overbeek 1.1 {
71 : overbeek 1.4 ($peg1,$sc) = @$pair;
72 :     if ((! $seenP{$peg1}) && (! $seenG{$from{$peg} . "," . &FIG::genome_of($peg1)}))
73 :     {
74 :     $seenP{$peg1} = 1;
75 :     $from{$peg1} = $from{$peg};
76 :     $seenG{$from{$peg} . "," . &FIG::genome_of($peg1)} = 1;
77 :    
78 :     push(@hits,[$peg,$sc,$peg1]);
79 :     if ($iterate)
80 :     {
81 :     push(@to_process,$peg1);
82 :     }
83 :     }
84 : overbeek 1.1 }
85 :     }
86 :    
87 :     foreach $x (sort { $a->[1] <=> $b->[1] } @hits)
88 :     {
89 :     print join("\t",@$x),"\n";
90 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3