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

Annotation of /FigKernelScripts/generate_subsys_tables_for_sprout.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : olson 1.8 #
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.7 $usage = "usage: generate_subsys_tables_for_sprout RelationsDir GenomesF TrustedSubsystems";
19 : overbeek 1.1
20 : overbeek 1.2 (
21 : overbeek 1.7 ($dir = shift @ARGV) &&
22 :     ($genomes = shift @ARGV) && (-s $genomes) &&
23 :     ($subsystems = shift @ARGV) && (-s $subsystems)
24 : overbeek 1.2 )
25 : overbeek 1.1 || die $usage;
26 :    
27 :     (-d $dir) || mkdir($dir,0777) || die "could not make $dir";
28 :    
29 :     open(SUBSYS,">$dir/Subsystem") || die "could not open $dir/Subsystem";
30 : overbeek 1.4 open(HASSSCELL,">$dir/HasSSCell") || die "could not open $dir/HasSSCell";
31 : overbeek 1.1 open(OCCURSIN,">$dir/OccursInSubsystem") || die "could not open $dir/OccursInSubsystem";
32 :     open(OCCURSIN2,">$dir/ParticipatesIn") || die "could not open $dir/ParticipatesIn";
33 :     open(SSCELL,">$dir/SSCell") || die "could not open $dir/SSCell";
34 :     open(CONTAINSFEATURE,">$dir/ContainsFeature") || die "could not open ContainsFeature";
35 : overbeek 1.4 open(ISROLEOF,">$dir/IsRoleOf") || die "could not open $dir/IsRoleOf";
36 :     open(ISGENOMEOF,">$dir/IsGenomeOf") || die "could not open $dir/IsGenomeOf";
37 :     open(ROLE,">$dir/Role") || die "could not open $dir/Role";
38 :     open(DIAGRAM,">$dir/Diagram") || die "could not open $dir/Diagram";
39 :     open(ROLEOCCURSIN,">$dir/RoleOccursIn") || die "could not open $dir/RoleOccursIn";
40 : overbeek 1.6 #open(ROLENAME,">$dir/RoleName") || die "could not open $dir/RoleName";
41 : overbeek 1.4
42 : overbeek 1.1
43 :     use FIG;
44 :     my $fig = new FIG;
45 :    
46 : overbeek 1.2 %genomes = map { $_ =~ /^(\d+\.\d+)/; $1 => 1 } `cat $genomes`;
47 : overbeek 1.1
48 : overbeek 1.7 @sub = map { ($_ =~ /(\S.*\S)/) ? $1 : () } `cat $subsystems`;
49 :    
50 : overbeek 1.1 for ($subN=0; ($subN < @sub); $subN++)
51 :     {
52 :     $sub = $sub[$subN];
53 :     print SUBSYS "$sub\n";
54 :     @genomes = map { $_->[0] } grep { $genomes{$_->[0]} } @{$fig->subsystem_genomes($sub)};
55 :     @roles = $fig->subsystem_to_roles($sub);
56 : overbeek 1.3
57 : overbeek 1.1 foreach $genome (@genomes)
58 :     {
59 :     print OCCURSIN2 join("\t",($genome,$sub)),"\n";
60 :     }
61 :    
62 :     foreach $role (@roles)
63 : overbeek 1.3 {
64 :     $roles{$role} = 1;
65 : overbeek 1.1 print OCCURSIN join("\t",($role,$sub)),"\n";
66 :     }
67 :    
68 :     for ($genomeN=0; ($genomeN < @genomes); $genomeN++)
69 :     {
70 :     $genome = $genomes[$genomeN];
71 :    
72 :     for ($roleN=0; ($roleN < @roles); $roleN++)
73 :     {
74 :     $role = $roles[$roleN];
75 :     @pegs = $fig->pegs_in_subsystem_cell($sub,$genome,$role);
76 :     if (@pegs > 0)
77 :     {
78 :     $id = join(":",($subN,$genomeN,$roleN));
79 :     print SSCELL "$id\n";
80 :     print ISROLEOF "$role\t$id\n";
81 :     print ISGENOMEOF "$genome\t$id\n";
82 : overbeek 1.4 print HASSSCELL "$sub\t$id\n";
83 : overbeek 1.1 foreach $peg (@pegs)
84 :     {
85 :     print CONTAINSFEATURE "$id\t$peg\n";
86 :     }
87 :     }
88 :     }
89 :     }
90 :     }
91 : overbeek 1.3
92 :     foreach $role (sort keys(%roles))
93 :     {
94 :     print ROLE "$role\n";
95 :     }
96 : overbeek 1.4
97 :     foreach $map ($fig->all_maps)
98 :     {
99 :     $name = $fig->map_name($map);
100 :     foreach $ec ($fig->map_to_ecs($map))
101 :     {
102 :     $ec_in_map{$ec} = 1;
103 :     print ROLEOCCURSIN "$ec\t$map\n";
104 :     }
105 :     print DIAGRAM "$map\t$name\n";
106 :     }
107 :    
108 :     foreach $ec (sort keys(%ec_in_map))
109 :     {
110 :     print ROLE "$ec\n";
111 :     }
112 :    
113 : overbeek 1.6 #my $rdbH = $fig->db_handle;
114 :     #my $relational_db_response = $rdbH->SQL("SELECT ec,name FROM ec_names");
115 :     #if (@$relational_db_response > 0)
116 :     #{
117 :     # foreach $x (sort { $a->[0] cmp $b->[0] } @$relational_db_response)
118 :     # {
119 :     # ($ec,$name) = @$x;
120 :     # print ROLENAME "$ec\t$ec - $name\n";
121 :     # }
122 :     #}
123 :     #
124 : overbeek 1.5

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3