ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/scripts/splign.psx
Revision: 24
Committed: Tue Jul 26 21:46:39 2011 UTC (8 years, 1 month ago) by gpertea
File size: 2119 byte(s)
Log Message:
Line File contents
1 #!/usr/bin/perl
2 use strict;
3 use FindBin;
4
5 umask 0002;
6 #the line below is needed if pvmsx is used
7 # also, the error condition is set only by the presence of $file
8 $ENV{'PATH'}=$FindBin::Bin.':'.$ENV{'PATH'};
9
10 #so for pvmsx to consider the task was successful, $file must be deleted!
11 #==============
12 # 1 is the name of the fasta sequence input file
13 # 2 is the # of sequences in ${1} should = 1 for this script
14 # 3 is the slice no. being processed by sx
15 # 4 is 0 if not the last file, 1 if the last file
16 # 5 is the # of sequences skipped initially
17 # 6 is the # of sequences to be processed (-1 = ALL)
18 # 7 user parameter
19 # 1 2 3 4 5 6
20 my ($file, $numpass, $slice_num, $last, $skipped, $total, $dbfile)=@ARGV;
21 my $splign_res=$file.'.splign1';
22 my $splign_allres='worker.splign';
23 my $log_file='log_std';
24 my $err_file='err_log';
25 open(STDERR, '>>'.$err_file);
26 open(STDOUT, '>>'.$log_file);
27
28 #my $toskip=($file =~ m/_\@(\d+)_v\d+\.\d+/) ? $1 : $skipped+$numpass*($slice_num-1);
29 #my $fmasked=$file.'_msk.fa';
30 #my $ftrimcoords=$file.'_msk.trim';
31 #my $prepcmd="mdust -v32 -mN < $file | trimpoly -n30.00 -o $fmasked > $ftrimcoords";
32 #&runCmd($prepcmd);
33 my $cmd="splign -query $file -subj $dbfile -W 20 > $splign_res";
34 my $slno=sprintf("slice:%09d",$slice_num);
35 print STDERR ">>$slno: $cmd\n";
36 &runCmd($cmd, $splign_res);
37 if (-s $splign_res) {
38 system("cat $splign_res >> $splign_allres") &&
39 die ("Error at appending $splign_res to $splign_allres !\n");
40 }
41 unlink ($splign_res);
42 print STDERR "<<$slno: done.\n";
43
44
45
46 #$cmd="sort -k11,11g -k10,10nr -k9,9nr $mgblast_res | bzip2 -cf > $mgblast_res.bz2";
47 #my $r=system($cmd);
48 #if ($r && ($r>>8 != 2) ) {
49 # die "Error sorting/compressing the results file '$mgblast_res'\n$cmd\n";
50 # }
51 unlink($file);
52 #unlink($fmasked);
53 exit 0;
54
55 sub runCmd {
56 my ($docmd, @todel) = @_;
57 my $errmsg = `($docmd) 2>&1`;
58 if ($? || ($errmsg=~/ERROR/si) || ($errmsg=~/Segmentation/si) || ($errmsg=~/Failed/s) || $errmsg=~/Invalid/s) {
59 print STDERR "!Error at:\n$docmd\n";
60 print STDERR "$errmsg\n";
61 foreach (@todel) {
62 unlink($_);
63 }
64 exit(1);
65 }
66 }

Properties

Name Value
svn:executable *