[Bio] / FigKernelPackages / ExpressionDir.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/ExpressionDir.pm

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

revision 1.1, Wed Jan 5 21:38:44 2011 UTC revision 1.2, Thu Jan 6 22:57:32 2011 UTC
# Line 4  Line 4 
4  use strict;  use strict;
5  use SeedAware;  use SeedAware;
6  use File::Copy;  use File::Copy;
7    use File::Temp 'tempfile';
8  use File::Spec::Functions;  use File::Spec::Functions;
9  use base 'Class::Accessor';  use base 'Class::Accessor';
10  use Carp;  use Carp;
# Line 208  Line 209 
209      my $peg_probe_table = catfile($self->expr_dir, 'peg.probe.table');      my $peg_probe_table = catfile($self->expr_dir, 'peg.probe.table');
210      my $probe_occ_table = catfile($self->expr_dir, 'probe.occ.table');      my $probe_occ_table = catfile($self->expr_dir, 'probe.occ.table');
211    
212        my $feature_dir = catfile($self->genome_dir, "Features");
213        my @tbls;
214        for my $ftype (qw(peg rna))
215        {
216            my $tfile = catfile($feature_dir, $ftype, 'tbl');
217            if (-f $tfile)
218            {
219                push(@tbls, $tfile);
220            }
221        }
222        if (@tbls == 0)
223        {
224            confess "Could not find any tbl files in $feature_dir";
225        }
226    
227      system_with_redirect([executable_for("make_probes_to_genes"),      system_with_redirect([executable_for("make_probes_to_genes"),
228                            $probes_fasta,                            $probes_fasta,
229                            catfile($self->genome_dir, 'contigs'),                            catfile($self->genome_dir, 'contigs'),
230                            catfile($self->genome_dir, 'Features', 'peg', 'tbl'),                            $tbls[0],
231                            $peg_probe_table,                            $peg_probe_table,
232                            $probe_occ_table],                            $probe_occ_table,
233                              @tbls[1..$#tbls],
234                              ],
235                           { stderr => catfile($self->expr_dir, 'problems') });                           { stderr => catfile($self->expr_dir, 'problems') });
236    
237    
# Line 225  Line 243 
243      $self->make_missing_probes($peg_probe_table, $probes_fasta,      $self->make_missing_probes($peg_probe_table, $probes_fasta,
244                                 catfile($self->expr_dir, 'probe.no.match'));                                 catfile($self->expr_dir, 'probe.no.match'));
245  }  }
246    
247  sub make_missing_probes  sub make_missing_probes
248  {  {
249      my($self, $probe_table, $probes, $output) = @_;      my($self, $probe_table, $probes, $output) = @_;
# Line 250  Line 269 
269      close(OUTPUT);      close(OUTPUT);
270  }  }
271    
272    #
273    # we don't copy the experiment files in here because
274    # they may be very large. This may change.
275    #
276    # We do copy the cdf.
277    #
278    sub compute_rma_normalized
279    {
280        my($self, $cdf_file, $expt_dir) = @_;
281    
282        my $my_cdf = catfile($self->expr_dir, "expr.cdf");
283        copy($cdf_file, $my_cdf) or confess "Cannot copy $cdf_file to $my_cdf: $!";
284    
285        #
286        # We need to build the R library for this cdf.
287        #
288        my($fh, $tempfile) = tempfile();
289    #m = make.cdf.package("S_aureus.cdf", cdf.path="..",packagename="foo",package.path="/tmp")
290    
291        my $cdf_path = $self->expr_dir;
292        my $libdir = catfile($self->expr_dir, "r_lib");
293        -d $libdir or mkdir $libdir;
294        my $pkgdir = catfile($self->expr_dir, "r_pkg");
295        -d $pkgdir or mkdir $pkgdir;
296    
297        print $fh "library(makecdfenv);\n";
298        print $fh qq(make.cdf.package("expr.cdf", cdf.path="$cdf_path", packagename="datacdf", package.path="$pkgdir", species="genome name");\n);
299        close($fh);
300        system("cat", $tempfile);
301        system("Rscript", $tempfile);
302        system("R", "CMD", "INSTALL", "-l", $libdir, "$pkgdir/datacdf");
303    
304        local($ENV{R_LIBS}) = $libdir;
305        my @cmd = (executable_for("RunRMA"),
306                   "data",
307                   catfile($self->expr_dir, "peg.probe.table"),
308                   catfile($self->expr_dir, "probe.no.match"),
309                   $expt_dir,
310                   $self->expr_dir);
311    
312        my $rc = system_with_redirect(\@cmd);
313    #    my $rc = system_with_redirect(\@cmd, { stderr => "rma.stderr" });
314        if ($rc != 0)
315        {
316            confess("Error running RMA: rc=$rc cmd=@cmd");
317        }
318        my $output = catfile($self->expr_dir, "rma_normalized.tab");
319        if (! -f $output)
320        {
321            confess("Output file $output was not generated");
322        }
323    }
324    
325    sub compute_atomic_regulons
326    {
327        my($self) = @_;
328    
329        my $coreg_clusters = catfile($self->expr_dir, "coregulated.clusters");
330        my $coreg_subsys = catfile($self->expr_dir, "coregulated.subsys");
331        my $merged_clusters = catfile($self->expr_dir, "merged.clusters");
332    }
333    
334    
335  1;  1;
336    
337    

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3