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

Diff of /FigKernelScripts/FFB2_build_updated_FF.pl

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

revision 1.7, Wed Jun 23 21:16:51 2010 UTC revision 1.8, Mon Jul 12 19:30:27 2010 UTC
# Line 1  Line 1 
1  ########################################################################  ########################################################################
2    
3    use strict;
4  use FIG;  use FIG;
5    use IPC::Run qw(start finish);
6    use Cache::Memcached::Fast;
7    
8  my $usage = "usage: FFB2_build_updated_FF OldReleaseDir NewReleaseDir";  my $usage = "usage: FFB2_build_updated_FF OldReleaseDir NewReleaseDir memcache-host memcache-port [ssfam]";
9    
10  my($oldD,$newD);  my($oldD,$newD,$mchost, $mcport);
11    
12  (  (
13   ($oldD = shift @ARGV) && (-d $oldD) &&   ($oldD = shift @ARGV) && (-d $oldD) &&
14   ($newD = shift @ARGV)   ($newD = shift @ARGV) &&
15     ($mchost = shift @ARGV) &&
16     ($mcport = shift @ARGV)
17  )  )
18      || die $usage;      || die $usage;
19    
20    my $in_ssfam = shift;
21    
22  my $sort_args = "-T $FIG_Config::temp -S 4G";  my $sort_args = "-T $FIG_Config::temp -S 4G";
23    
24  mkdir($newD,0777) || die "You have an existing $newD; remove it and try again";  mkdir($newD,0777) || die "You have an existing $newD; remove it and try again";
25    
26  my $parallel = 0;  my $mc = new Cache::Memcached::Fast({ servers => ["$mchost:$mcport"] } );
27    $mc or die "Could not connect to memcached at $mchost:$mcport\n";
28    
29    #$mc->flush_all();
30    
31    #
32    # Do some work up front to ensure we can load the memcache with all the data we need.
33    #
34    
35    my $ssfam;
36    if (-f $in_ssfam)
37    {
38        $ssfam = $in_ssfam;
39    }
40    else
41    {
42        $ssfam = "$FIG_Config::temp/subsys.based.families.$$";
43        &FIG::run("FFB2_make_subsys_based_families > $ssfam");
44    }
45    
46    #&FIG::run("FFB2_load_memcache $ssfam $oldD/families.2c $mchost $mcport");
47    
48    my $parallel = 1;
49  my $child_pid;  my $child_pid;
50  if ($parallel)  if ($parallel)
51  {  {
# Line 37  Line 66 
66      figfam_processing();      figfam_processing();
67  }  }
68    
69  &FIG::run("FFB2_get_prots $newD/ProtsByGenomeSet $newD/setI");  #
70  &FIG::run("FFB2_get_prot_gs_oligos $newD/ProtsByGenomeSet 12 | sort $sort_args | FFB2_usable_motifs $newD/PhyloSigs");  # Run the new parallel get-prots
71    #
72    my $n_get_prots = 3;
73    
74    my @handles;
75    for my $i (0..$n_get_prots - 1)
76    {
77        my $outfile = "$FIG_Config::temp/ffb2_xx.$$.$i";
78    
79        my $h = start(['FFB2_xx', 12,  "$newD/setI", $n_get_prots, $i, $mchost, $mcport],
80                      "<", "/dev/null", ">", $outfile);
81        push(@handles, [$i, $h, $outfile]);
82    }
83    for my $e (@handles)
84    {
85        my($i, $h, $file) = @$e;
86        print "Wait for finish $i $file\n";
87        $h->finish();
88    }
89    
90    my @files = map { $_->[2] } @handles;
91    print STDERR "Merging phylo @files\n";
92    &FIG::run("sort -m @files | FFB2_usable_motifs $newD/PhyloSigs");
93    
94    #&FIG::run("FFB2_get_prots $newD/ProtsByGenomeSet $newD/setI");
95    #&FIG::run("FFB2_get_prot_gs_oligos $newD/ProtsByGenomeSet 12 | sort $sort_args | FFB2_usable_motifs $newD/PhyloSigs");
96    
97  if ($parallel)  if ($parallel)
98  {  {
# Line 51  Line 105 
105    
106    
107  mkdir("$newD/Merged",0777) || die "could not make $newD/Merged: $!";  mkdir("$newD/Merged",0777) || die "could not make $newD/Merged: $!";
108    
109    my @merge_handles;
110    
111  foreach my $i (7..12)  foreach my $i (7..12)
112  {  {
113      mkdir("$newD/Merged/$i",0777) || die "could not make $newD/Merged/$i: $!";      mkdir("$newD/Merged/$i",0777) || die "could not make $newD/Merged/$i: $!";
114      &FIG::run("FFB2_merge_oligos $newD/Kmers/$i/good.oligos $newD/PhyloSigs/$i/good.oligos > $newD/Merged/$i/merged.oligos");      my $h = start(["FFB2_merge_oligos $newD/Kmers/$i/good.oligos $newD/PhyloSigs/$i/good.oligos"], "|",
115                      ["FFB2_create_binary_kmers", "-l", $i, "-s", "4,2", "-", "$newD/Merged/$i/table.binary"]);
116    
117        push(@merge_handles, [$h, $i]);
118    
119    #    &FIG::run("FFB2_merge_oligos $newD/Kmers/$i/good.oligos $newD/PhyloSigs/$i/good.oligos > $newD/Merged/$i/merged.oligos");
120  }  }
 &FIG::run("FFB2_load_oligo_index $newD/function.index $newD/FRI.db");  
 &FIG::run("FFB2_load_oligo_index $newD/setI $newD/setI.db");  
121    
122  foreach my $i (7..12)  for my $ent (@merge_handles)
123  {  {
124      &FIG::run("FFB2_create_binary_kmers -s 4,2 $newD/Merged/$i/merged.oligos $newD/Merged/$i/table.binary");      my($h, $k) = @$ent;
125        print "Wait for finish for k=$k\n";
126        my $r = $h->finish();
127        print "done r=$r\n";
128  }  }
129    
130    my $load1 = start(["FFB2_load_oligo_index", "$newD/function.index",  "$newD/FRI.db"]);
131    my $load2 = start(["FFB2_load_oligo_index", "$newD/setI", "$newD/setI.db"]);
132    my $build = start(["build_prok_nonff_fasta $newD > $newD/extra_prok_seqs.fasta"]);
133    
134    
135    #foreach my $i (7..12)
136    #{
137    #    &FIG::run("FFB2_create_binary_kmers -s 4,2 $newD/Merged/$i/merged.oligos $newD/Merged/$i/table.binary");
138    #}
139    
140  system("FFB2_run_tests $newD");  system("FFB2_run_tests $newD");
141  system("FFB2_compare_tests $oldD $newD");  system("FFB2_compare_tests $oldD $newD");
142  &FIG::run("build_prok_nonff_fasta $newD > $newD/extra_prok_seqs.fasta");  $build->finish();
143  &FIG::run("formatdb -p T -i $newD/extra_prok_seqs.fasta");  &FIG::run("formatdb -p T -i $newD/extra_prok_seqs.fasta");
144    
145    $load1->finish();
146    $load2->finish();
147    
148  &FIG::run("FFB2_make_FF_index $newD $newD/fam.func.index $newD/FamFuncBlastD");  &FIG::run("FFB2_make_FF_index $newD $newD/fam.func.index $newD/FamFuncBlastD");
149  &FIG::run("FFB2_build_ff_indexes $newD");  &FIG::run("FFB2_build_ff_indexes $newD");
150    
151  sub figfam_processing  sub figfam_processing
152  {  {
153      &FIG::run("FFB2_update_FIGfams $newD/families.2c $newD/family.functions $oldD");      &FIG::run("FFB2_update_FIGfams -f $ssfam $newD/families.2c $newD/family.functions $oldD");
154      &FIG::run("FFB2_get_oligos $newD/families.2c $newD/family.functions 2> $newD/function.index |" .      &FIG::run("FFB2_get_oligos $newD/families.2c $newD/family.functions 2> $newD/function.index |" .
155                "sort $sort_args | FFB2_usable_motifs $newD/Kmers");                "sort $sort_args | FFB2_usable_motifs $newD/Kmers");
156  }  }

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3