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

Diff of /FigKernelScripts/pg_roles_in_some_but_not_X.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Tue Feb 26 23:21:06 2013 UTC revision 1.2, Wed Feb 27 17:30:38 2013 UTC
# Line 1  Line 1 
1  use strict;  use strict;
2  use Data::Dumper;  use Data::Dumper;
3  use Getopt::Long;  use Getopt::Long;
4    use SeedEnv;
5    
6  my $usage = "usage: pg_in_some_but_not_X -d Data\n";  my $usage = "usage: pg_in_some_but_not_X -d Data\n";
7  my $dataD;  my $dataD;
# Line 8  Line 9 
9    
10  if ((! $rc) || (! -d $dataD)) { print STDERR $usage; exit }  if ((! $rc) || (! -d $dataD)) { print STDERR $usage; exit }
11    
12    my %anno = map { chop; ($_ => 1) } `cat $dataD/anno.seed`;
13    
14  my$peg_to_func                = &load_funcs($dataD);  my$peg_to_func                = &load_funcs($dataD);
15  my($peg_to_seq,$seq_to_pegs)  = &load_seqs($dataD);  my($peg_to_seq,$seq_to_pegs)  = &load_seqs($dataD);
16  my($peg_to_fam,$fam_to_pegs) = &load_fams($dataD);  my($peg_to_fam,$fam_to_pegs) = &load_fams($dataD);
# Line 19  Line 22 
22      my($name,undef,$rast_job,$rast_genome) = @$tuple;      my($name,undef,$rast_job,$rast_genome) = @$tuple;
23      if (open(BINDINGS,"<","/vol/rast-prod/jobs/$rast_job/rp/$rast_genome/Subsystems/bindings"))      if (open(BINDINGS,"<","/vol/rast-prod/jobs/$rast_job/rp/$rast_genome/Subsystems/bindings"))
24      {      {
25          &process_genome($peg_to_func,$peg_to_seq,$seq_to_pegs,$peg_to_fam,$fam_to_pegs,\%seen,\*OUT,\*BINDINGS);          &process_genome($peg_to_func,$peg_to_seq,$seq_to_pegs,$peg_to_fam,$fam_to_pegs,\%seen,\*OUT,\*BINDINGS,\%anno);
26          close(BINDINGS);          close(BINDINGS);
27      }      }
28  }  }
29  close(OUT);  close(OUT);
30    
31  sub process_genome {  sub process_genome {
32      my($peg_to_func,$peg_to_seq,$seq_to_pegs,$peg_to_fam,$fam_to_pegs,$seen,$fhO,$fhB) = @_;      my($peg_to_func,$peg_to_seq,$seq_to_pegs,$peg_to_fam,$fam_to_pegs,$seen,$fhO,$fhB,$anno) = @_;
33      while (defined($_ = <$fhB>))      while (defined($_ = <$fhB>))
34      {      {
35          chop;          chop;
# Line 65  Line 68 
68                              if (! ($seen->{"$func1\t$func2"} || $seen->{"$func2\t$func1"}))                              if (! ($seen->{"$func1\t$func2"} || $seen->{"$func2\t$func1"}))
69                              {                              {
70                                  $seen->{"$func1\t$func2"} = 1;                                  $seen->{"$func1\t$func2"} = 1;
71                                  print OUT join("\t",($peg,$func1,$peg2,$func2,$role,$subsys)),"\n";                                  my @anno_pegs = &get_anno_pegs([$peg,$peg2],$anno,$peg_to_seq,$seq_to_pegs);
72                                    print OUT join("\t",($peg,$func1,$peg2,$func2,join(",",@anno_pegs),$role,$subsys)),"\n";
73                                }
74                            }
75                              }                              }
76                          }                          }
77                      }                      }
78                  }                  }
79              }              }
80          }          }
81    
82    sub get_anno_pegs {
83        my($initial_pegs,$anno,$peg_to_seq,$seq_to_pegs) = @_;
84    
85        my %anno_pegs;
86        foreach my $peg (@$initial_pegs)
87        {
88            my $same_seq = $seq_to_pegs->{$peg_to_seq->{$peg}};
89            my @apegs    = grep { $anno->{&SeedUtils::genome_of($_)} } @$same_seq;
90            foreach $_ (@apegs) { $anno_pegs{$_} = 1 }
91      }      }
92        return keys(%anno_pegs);
93  }  }
94    
95  sub load_funcs {  sub load_funcs {

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3