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

Annotation of /FigKernelScripts/CSA_get_close_strain_annotations.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (view) (download) (as text)

1 : overbeek 1.1 use strict;
2 : overbeek 1.3 #
3 :     # This is a SAS Component
4 :     #
5 : overbeek 1.1 use Proc::ParallelLoop;
6 :     use Data::Dumper;
7 :    
8 :     my $usage = "usage: CSA_get_close_strain_annotationsl AnnDir WorkingDirsD GenomeID Contigs RefDir1 RefDir2 ... ";
9 :    
10 :     my($annoD,$work_dirs,$genomeID,$contigs,@refD);
11 :    
12 :     (
13 :     ($annoD = shift @ARGV) &&
14 :     ($work_dirs = shift @ARGV) &&
15 :     ($genomeID = shift @ARGV) &&
16 :     ($contigs = shift @ARGV) &&
17 :     (@refD = @ARGV)
18 :     )
19 :     || die $usage;
20 :    
21 :     if (-d $annoD) { die "$annoD already exists; delete it if you want to generate a new copy" }
22 :     if (-d $work_dirs) { die "$work_dirs already exists; delete it if you want to generate a new copy" }
23 :     mkdir($work_dirs,0777) || die "could not make $work_dirs";
24 :     (-s $contigs) || die "you need to give contigs in fasta format";
25 :    
26 :     (@refD > 0) || die "you need to give one or more reference genomes";
27 :     my @tmp = grep { ! -d $_ } @refD;
28 :     if (@tmp > 0)
29 :     {
30 :     print STDERR join(",",@tmp), " do not exist; exiting";
31 :     exit;
32 :     }
33 :    
34 :     my @args = map { [$work_dirs,$genomeID,$contigs,$_] } @refD;
35 :     &pareach(\@args,\&do_one,{ Max_Workers => 4 });
36 :    
37 :     open(TMP,">tmp.$$") || die "aborted";
38 :     foreach $_ (@refD)
39 :     {
40 :     if ($_ =~ /(\d+\.\d+)$/)
41 :     {
42 :     (-s "$work_dirs/$1-$genomeID/mapped.features")
43 :     || die "$work_dirs/$1-$genomeID/mapped.features is missing";
44 :     print TMP "$work_dirs/$1-$genomeID\n";
45 :     }
46 :     }
47 :     close(TMP);
48 :     &run("CSA_merge_estimates $annoD $genomeID < tmp.$$");
49 :     unlink("tmp.$$");
50 : overbeek 1.4 # print STDERR "MADE IT\n";
51 : overbeek 1.1
52 :     sub do_one {
53 :     my($args) = @_;
54 :     my($work_dirs,$genomeID,$contigs,$refD) = @$args;
55 :     my $tmpF = "tmp.functions.$$";
56 :     if (-s "$refD/assigned_functions") { system "cat $refD/assigned_functions > $tmpF" }
57 :     else
58 :     {
59 :     if ((-s "$refD/proposed_functions") && (-s "$refD/proposed_non_ff_functions"))
60 :     {
61 :     system "cat $refD proposed_functions $refD/proposed_non_ff_functions > $tmpF";
62 :     }
63 :     else
64 :     {
65 :     die "missing annotations for $refD";
66 :     }
67 :     }
68 :     ($refD =~ /(\d+\.\d+)$/) || die "invalid reference directory";
69 : overbeek 1.2 &run("CSA_close_strains $refD/contigs $contigs $work_dirs/$1-$genomeID $refD/Features/peg/tbl $refD/Features/rna/tbl $tmpF $refD/Features/peg/fasta");
70 : overbeek 1.1 unlink($tmpF);
71 :     }
72 :    
73 :     sub run {
74 :     my($cmd) = @_;
75 :    
76 :     my $rc = system($cmd);
77 :     if ($rc)
78 :     {
79 :     die "$rc: $cmd failed";
80 :     }
81 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3