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

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3