[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.3 - (view) (download) (as text)

1 : overbeek 1.2 # -*- perl -*-
2 : overbeek 1.1
3 :     use FIG;
4 :     my $fig = new FIG;
5 :    
6 :     $usage = "usage: make_PHOBs_for_subsystems Dir < FileOf_SS-Role-PEG-Func";
7 :    
8 :     (
9 :     ($dir = shift @ARGV) && (! -d $dir)
10 :     )
11 :     || die $usage;
12 :    
13 :     mkdir($dir,0777) || die "could not make $dir";
14 :     while (defined($_ = <STDIN>))
15 :     {
16 :     chop;
17 :     ($ss,$role,$peg) = split(/\t/,$_);
18 :     push(@{$subH{$ss}->{$role}},$peg);
19 :     }
20 :    
21 :     $tmpF = "/tmp/pegs$$.fasta";
22 :    
23 :     open(INDEXSS,">$dir/index") || die "could not open $dir/index";
24 :     $ssN = 0;
25 :     foreach $ss (sort keys(%subH))
26 :     {
27 :     ++$ssN;
28 :     mkdir("$dir/$ssN",0777) || die "could not make $dir/$ssN";
29 :     print INDEXSS "$ssN\t$ss\n";
30 :    
31 :     open(INDEXR,">$dir/$ssN/index") || die "could not open $dir/$ssN/index";
32 :     $roleN = 0;
33 :     foreach $role (sort keys(%{$subH{$ss}}))
34 :     {
35 :     ++$roleN;
36 :     print INDEXR "$roleN\t$role\n";
37 : overbeek 1.2
38 : overbeek 1.1 $pegs = $subH{$ss}->{$role};
39 : overbeek 1.2 if (@$pegs < 4)
40 :     {
41 :     print STDERR "Skipping $dir/$ssN/$roleN, role $role --- only ", (scalar @$pegs), " pegs\n";
42 :     next;
43 :     }
44 :    
45 : overbeek 1.1 open(TMP,">$tmpF") || die "could not open $tmpF";
46 :     foreach $peg (@$pegs)
47 :     {
48 :     if ($pseq = $fig->get_translation($peg))
49 :     {
50 :     print TMP ">$peg\n$pseq\n";
51 :     }
52 :     else
53 :     {
54 :     print STDERR "failed to get translation for $peg\n";
55 :     }
56 :     }
57 :     close(TMP);
58 :    
59 :     mkdir("$dir/$ssN/$roleN",0777) || die "could not make $dir/$ssN/$roleN";
60 :     &FIG::run("split_and_trim_sequences $dir/$ssN/$roleN/split_info < $tmpF");
61 :    
62 : overbeek 1.3 if (-s "$dir/$ssN/$roleN/split_info/set.sizes")
63 : overbeek 1.1 {
64 : overbeek 1.3 open(SZ,"<$dir/$ssN/$roleN/split_info/set.sizes") || die " could not open $dir/$ssN/$roleN/split_info/set.sizes";
65 : overbeek 1.2 while (defined($_ = <SZ>))
66 : overbeek 1.1 {
67 : overbeek 1.2 if (($_ =~ /^(\d+)\t(\d+)/) && ($2 > 3))
68 :     {
69 :     $n = $1;
70 :     &FIG::run("make_phob_from_seqs $dir/$ssN/$roleN/$n < $dir/$ssN/$roleN/split_info/$n");
71 :     }
72 : overbeek 1.1 }
73 : overbeek 1.2 close(SZ);
74 :     }
75 :     else
76 :     {
77 :     system("rmdir $dir/$ssN/$roleN") && warn "Could not rmdir $dir/$ssN/$roleN";
78 :     print STDERR "Skipping role $role in $dir/$ssN/$roleN\n";
79 : overbeek 1.1 }
80 :     }
81 :     close(INDEXR);
82 :     }
83 :     close(INDEXSS);
84 :     unlink($tmpF);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3