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

Annotation of /FigKernelScripts/make_subsys_based_families.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : overbeek 1.1 ########################################################################
2 :     #
3 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
4 :     # for Interpretations of Genomes. All Rights Reserved.
5 :     #
6 :     # This file is part of the SEED Toolkit.
7 :     #
8 :     # The SEED Toolkit is free software. You can redistribute
9 :     # it and/or modify it under the terms of the SEED Toolkit
10 :     # Public License.
11 :     #
12 :     # You should have received a copy of the SEED Toolkit Public License
13 :     # along with this program; if not write to the University of Chicago
14 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
15 :     # Genomes at veronika@thefig.info or download a copy from
16 :     # http://www.theseed.org/LICENSE.TXT.
17 :     #
18 :     ########################################################################
19 :    
20 :    
21 :     use FIG;
22 :     my $fig = new FIG;
23 :    
24 :     use Subsystem;
25 :    
26 :     # usage: make_subsys_based_families [trusted] > subsys.based.families
27 :    
28 :     if (@ARGV > 0)
29 :     {
30 :     foreach $_ (`cat $ARGV[0]`)
31 :     {
32 :     if ($_ =~ /^(\S[^\t]+\S)/)
33 :     {
34 :     $trusted{$1} = 1;
35 :     }
36 :     }
37 :     }
38 :    
39 : overbeek 1.13 foreach $sub (grep { $fig->usable_subsystem($_) } $fig->all_subsystems)
40 : overbeek 1.1 {
41 : overbeek 1.5 if (((@ARGV == 0) && $fig->usable_subsystem($sub)) || $trusted{$sub})
42 : overbeek 1.1 {
43 : overbeek 1.13 foreach $role (grep { ! $fig->is_aux_role_in_subsystem($sub,$_) } $fig->subsystem_to_roles($sub))
44 : overbeek 1.1 {
45 :     push(@{$subs_for_role{$role}},$sub);
46 :     }
47 :     }
48 :     }
49 :    
50 :     $roleN = 1;
51 :     @roles = sort keys(%subs_for_role);
52 :     for ($i=0; ($i < @roles); $i++)
53 :     {
54 :     $role = $roles[$i];
55 :     $fam = "subsys$roleN";
56 :     $roleN++;
57 :    
58 :     undef %pegs;
59 :     $subs = $subs_for_role{$role};
60 :    
61 :     foreach $sub (sort @$subs)
62 :     {
63 : overbeek 1.6 $subO = new Subsystem($sub,$fig);
64 : overbeek 1.1 @genomes = map { $_->[0] } @{$fig->subsystem_genomes($sub)};
65 :     foreach $genome (@genomes)
66 :     {
67 : overbeek 1.6 my $vc = $subO->get_variant_code_for_genome($genome);
68 : overbeek 1.14
69 :     # On Sept 21, 2008 I added the filter for removing genomes with variants beginning with '*'.
70 :     # Until curators bless those additions by removing the '*', they should not be used to construct
71 :     # families (RAO)
72 :    
73 :     if (($vc ne '0') && ($vc ne '-1') && (substr($vc,0,1) ne "*"))
74 : overbeek 1.1 {
75 : overbeek 1.12 @pegs_in_subsystem = grep { $_ =~ /\.peg\./ } $fig->pegs_in_subsystem_cell($sub,$genome,$role);
76 :     foreach $peg (grep { $fig->is_real_feature($_) } @pegs_in_subsystem)
77 : overbeek 1.2 {
78 : overbeek 1.6 $func = $fig->function_of($peg);
79 : overbeek 1.12 if ((index($func,$role) >= 0) &&
80 :     (! $fig->possibly_truncated($peg)) &&
81 :     (! $fig->possible_frameshift($peg)))
82 : overbeek 1.6 {
83 :     $pegs{$peg} = 1;
84 :     }
85 : overbeek 1.2 }
86 : overbeek 1.1 }
87 :     }
88 :     }
89 :     my @pegs = sort { &FIG::by_fig_id($a,$b) } keys(%pegs);
90 :     if (@pegs > 1)
91 :     {
92 :     foreach $peg (@pegs)
93 :     {
94 : olson 1.7 $func = $fig->function_of_quick($peg);
95 : overbeek 1.1 @pieces = split(/(\s+\/\s+)|(\s*[;@]\s+)/,$func);
96 :     if (@pieces > 1)
97 :     {
98 :     $key = join("\t",@pieces);
99 :     $multi{$key}->{$peg} = 1;
100 :     }
101 :     else
102 :     {
103 : overbeek 1.2 print join("\t",($fam,$peg,$func,$role)),"\n";
104 : overbeek 1.1 }
105 :     }
106 :     }
107 :     }
108 :    
109 :     foreach $key (sort keys(%multi))
110 :     {
111 :     $x = $multi{$key};
112 :     @pegs = keys(%$x);
113 :     if (@pegs > 1)
114 :     {
115 :     $fam = "subsys$roleN";
116 :     $roleN++;
117 :    
118 :     foreach $peg (@pegs)
119 :     {
120 : olson 1.7 print join("\t",($fam,$peg,scalar $fig->function_of_quick($peg))),"\n";
121 : overbeek 1.1 }
122 :     }
123 :     }
124 :    
125 : overbeek 1.3
126 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3