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

Annotation of /FigKernelScripts/FFB2_make_subsys_based_families.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (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 : olson 1.2 use strict;
23 :    
24 : overbeek 1.1 my $fig = new FIG;
25 :    
26 :     # usage: FFB2_make_subsys_based_families > subsys.based.families
27 :    
28 :     my $pairsF = "$FIG_Config::temp/peg-func.$$";
29 : olson 1.2 #open(TMP1,"pegs_in_subsystems | cut -f2,3 | sort -u | function_of |")
30 :     # || die "could not get pegs";
31 :    
32 :     #
33 :     # TMP1 emits triples role, peg, assigned function
34 :     #
35 :    
36 :     #open(TMP1, "cut -f2,3 < /scratch/olson/pegs.in.subs | sort -u -S 3G | function_of |");
37 :     open(TMP2,"| sort -S 3G -u > $pairsF") || die "could not open $pairsF";
38 :    
39 :     #mysql> select si.subsystem, si.role, si.protein, f.assigned_function from subsystem_index si LEFT JOIN aux_roles ar ON si.subsystem = ar.subsystem AND si.role = ar.role JOIN subsystem_metadata m ON si.subsystem = m.subsystem JOIN assigned_functions f ON f.prot = si.protein LEFT JOIN deleted_fids df ON si.protein = df.fid WHERE df.fid IS NULL AND ar.role IS NULL and m.class_1 <> '' AND m.class_1 not like 'experimental%' COLLATE latin1_swedish_ci and m.class_1 not like '%delete%' AND si.variant != '0' AND si.variant != '-1' into outfile '/tmp/list6';
40 : overbeek 1.1
41 : olson 1.2
42 :     my $sth = $fig->db_handle->{_dbh}->prepare(qq(SELECT si.role, si.protein, f.assigned_function
43 :     FROM subsystem_index si
44 :     LEFT JOIN aux_roles ar ON si.subsystem = ar.subsystem AND si.role = ar.role
45 :     JOIN subsystem_metadata m ON si.subsystem = m.subsystem
46 :     JOIN assigned_functions f ON f.prot = si.protein
47 :     LEFT JOIN deleted_fids df ON si.protein = df.fid
48 :     WHERE df.fid IS NULL AND
49 :     ar.role IS NULL AND
50 :     m.class_1 <> '' AND
51 :     m.class_1 NOT LIKE 'experimental%' COLLATE latin1_swedish_ci AND
52 :     m.class_1 NOT LIKE '%delete%' COLLATE latin1_swedish_ci AND
53 :     si.variant != '0' AND
54 :     si.variant != '-1'),
55 :     { mysql_use_result => 1 });
56 :    
57 :     $sth->execute();
58 :    
59 :     while (my $row = $sth->fetchrow_arrayref())
60 : overbeek 1.1 {
61 : olson 1.2 my($role, $peg, $func) = @$row;
62 :    
63 :     #while (<TMP1>)
64 :     #{
65 :     # chomp;
66 :     # my($role, $peg, $func) = split(/\t/);
67 :     next if $peg !~ /\.peg\./;
68 : overbeek 1.1 next if ((! $func) || (length($func) < 2));
69 :     my @roles = $fig->roles_of_function($func);
70 :     my $i;
71 :     for ($i=0; ($i < @roles) && ($roles[$i] ne $role); $i++) {}
72 :     if ($i < @roles)
73 :     {
74 :     if ($func !~ /\#.*((trunca)|(framesh)|(fragment))/)
75 :     {
76 :     $func =~ s/\s*\#.*$//;
77 :     print TMP2 "$func\t$peg\n";
78 :     }
79 :     }
80 :     }
81 : olson 1.2 #$sth->finish();
82 :     #close(TMP1);
83 : overbeek 1.1 close(TMP2);
84 :    
85 :     my $n = 1;
86 :     open(TMP2,"<$pairsF") || die "could not open $pairsF";
87 :     my $x = <TMP2>;
88 :     while ($x && ($x =~ /(\S.*\S)\t(fig\|\d+\.\d+\.peg\.\d+)/))
89 :     {
90 :     my $func = $1;
91 :     my @set = ();
92 :     while ($x && ($x =~ /(\S.*\S)\t(fig\|\d+\.\d+\.peg\.\d+)/) && ($1 eq $func))
93 :     {
94 :     push(@set,$2);
95 :     $x = <TMP2>;
96 :     }
97 :    
98 :     if (@set > 1)
99 :     {
100 :     foreach $_ (@set)
101 :     {
102 :     print "$n\t$_\n";
103 :     }
104 :     $n++;
105 :     }
106 :     }
107 : olson 1.2 #unlink($pairsF);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3