[Bio] / MGRASTBackend / mg_check_sequence_distribution.pl Repository:
ViewVC logotype

Annotation of /MGRASTBackend/mg_check_sequence_distribution.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : arodri7 1.1
2 :     #
3 :     # dereplication of the input fasta.
4 :     #
5 :    
6 :     use strict;
7 :     use FIG;
8 :     use FIG_Config;
9 :     use File::Basename;
10 :     use GenomeMeta;
11 :     use Job48;
12 :     use JobStage;
13 :     use SGE;
14 :     use FortyEightMeta::SimDB;
15 :     use FortyEightMeta::SimStatusDB;
16 :    
17 :     my $STAGE = "dereplication";
18 :    
19 :     @ARGV == 1 or die "Usage: $0 job-dir\n";
20 :    
21 :     my $jobdir = shift;
22 :    
23 :     -d $jobdir or die "$0: job dir $jobdir does not exist\n";
24 :    
25 :     my $stage = new JobStage('Job48', $STAGE, $jobdir);
26 :     $stage or die "Cannot create job for $jobdir\n";
27 :    
28 :     my $job_id = basename($jobdir);
29 :     my $job = $stage->job();
30 :    
31 :     my $meta = $job->meta;
32 :    
33 :     print "Running job! $jobdir\n";
34 :    
35 :     $stage->set_status("in_progress");
36 :    
37 :     #
38 :     # Find needed executables
39 :     #
40 :    
41 :     #my $dereplication_exe = "/home/arodri7/public_html/FIGdisk/dist/releases/dev/MGRASTBackend/scripts/sequence_dereplication.pl";
42 :     my $dereplication_exe = "$FIG_Config::bin/sequence_dereplication";
43 :     -x $dereplication_exe or $stage->fatal("Executable missing: $dereplication_exe");
44 :    
45 :     my $proc = "$jobdir/proc";
46 :     chdir($proc) or $stage->fatal("cannot chdir $proc: $!");
47 :    
48 :     my $fasta = $meta->get_metadata("preprocess.fasta_file");
49 :     ($fasta and -f $fasta) or $stage->fatal("fasta not found: '$fasta'");
50 :    
51 :     my $new_fasta = "dereplication.fasta";
52 :    
53 :    
54 :     $stage->log("Dereplication original=$fasta new_fasta=$new_fasta");
55 :    
56 :     my $stderr = "$jobdir/errors/$STAGE.stderr";
57 :     my $cmd = "$dereplication_exe -f $fasta -o $new_fasta -v";
58 :     open(P, "$cmd |") or $stage->fatal("Failed pipe open: $!: $cmd");
59 :     open(E, ">$stderr") or $stage->fata("Failed stderr open $!: $stderr");
60 :     my($start, $end);
61 :     while (<P>)
62 :     {
63 :     print E $_;
64 :     }
65 :     close(P) or $stage->fatal("Error on close: \$!=$! \$?=$?: $cmd");
66 :     close(E);
67 :    
68 :     $stage->set_qualified_metadata("fasta_file", $new_fasta);
69 :     $stage->set_status("complete");
70 :     $stage->set_running("no");
71 :    
72 :    
73 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3