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

Annotation of /FigKernelScripts/make_PHOBs_for_subsystems.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : overbeek 1.2 # -*- perl -*-
2 : olson 1.5 #
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 : overbeek 1.1
20 :     use FIG;
21 :     my $fig = new FIG;
22 :    
23 : overbeek 1.4 $usage = "usage: make_PHOBs_for_subsystems Dir [SimilarityCutoff FracCoverage] < FileOf_SS-Role-PEG-Func";
24 : overbeek 1.1
25 :     (
26 :     ($dir = shift @ARGV) && (! -d $dir)
27 :     )
28 :     || die $usage;
29 :    
30 : overbeek 1.4 if (@ARGV == 2)
31 :     {
32 :     $sim_cutoff = shift @ARGV;
33 :     $frac_cov = shift @ARGV;
34 :     }
35 :    
36 : overbeek 1.1 mkdir($dir,0777) || die "could not make $dir";
37 :     while (defined($_ = <STDIN>))
38 :     {
39 :     chop;
40 :     ($ss,$role,$peg) = split(/\t/,$_);
41 :     push(@{$subH{$ss}->{$role}},$peg);
42 :     }
43 :    
44 :     $tmpF = "/tmp/pegs$$.fasta";
45 :    
46 :     open(INDEXSS,">$dir/index") || die "could not open $dir/index";
47 :     $ssN = 0;
48 :     foreach $ss (sort keys(%subH))
49 :     {
50 :     ++$ssN;
51 :     mkdir("$dir/$ssN",0777) || die "could not make $dir/$ssN";
52 :     print INDEXSS "$ssN\t$ss\n";
53 :    
54 :     open(INDEXR,">$dir/$ssN/index") || die "could not open $dir/$ssN/index";
55 :     $roleN = 0;
56 :     foreach $role (sort keys(%{$subH{$ss}}))
57 :     {
58 :     ++$roleN;
59 : overbeek 1.2
60 : overbeek 1.1 $pegs = $subH{$ss}->{$role};
61 : overbeek 1.4 if (@$pegs < 8)
62 : overbeek 1.2 {
63 :     print STDERR "Skipping $dir/$ssN/$roleN, role $role --- only ", (scalar @$pegs), " pegs\n";
64 :     next;
65 :     }
66 :    
67 : overbeek 1.4 print INDEXR "$roleN\t$role\n";
68 :    
69 : overbeek 1.1 open(TMP,">$tmpF") || die "could not open $tmpF";
70 :     foreach $peg (@$pegs)
71 :     {
72 :     if ($pseq = $fig->get_translation($peg))
73 :     {
74 :     print TMP ">$peg\n$pseq\n";
75 :     }
76 :     else
77 :     {
78 :     print STDERR "failed to get translation for $peg\n";
79 :     }
80 :     }
81 :     close(TMP);
82 :    
83 :     mkdir("$dir/$ssN/$roleN",0777) || die "could not make $dir/$ssN/$roleN";
84 : overbeek 1.4 &FIG::run("split_and_trim_sequences $dir/$ssN/$roleN/split_info $sim_cutoff $frac_cov < $tmpF");
85 : overbeek 1.1
86 : overbeek 1.3 if (-s "$dir/$ssN/$roleN/split_info/set.sizes")
87 : overbeek 1.1 {
88 : overbeek 1.3 open(SZ,"<$dir/$ssN/$roleN/split_info/set.sizes") || die " could not open $dir/$ssN/$roleN/split_info/set.sizes";
89 : overbeek 1.2 while (defined($_ = <SZ>))
90 : overbeek 1.1 {
91 : overbeek 1.2 if (($_ =~ /^(\d+)\t(\d+)/) && ($2 > 3))
92 :     {
93 :     $n = $1;
94 :     &FIG::run("make_phob_from_seqs $dir/$ssN/$roleN/$n < $dir/$ssN/$roleN/split_info/$n");
95 :     }
96 : overbeek 1.1 }
97 : overbeek 1.2 close(SZ);
98 :     }
99 :     else
100 :     {
101 :     system("rmdir $dir/$ssN/$roleN") && warn "Could not rmdir $dir/$ssN/$roleN";
102 :     print STDERR "Skipping role $role in $dir/$ssN/$roleN\n";
103 : overbeek 1.1 }
104 :     }
105 :     close(INDEXR);
106 :     }
107 :     close(INDEXSS);
108 :     unlink($tmpF);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3