1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| for (;;) {
my $ongoing = scalar(keys %pidsprots);
last if !@prots_todo && !$ongoing;
if ($ongoing >= $PARALLELISM || !@prots_todo) {
my $donepid = wait;
next if $donepid < 0; # should never happen?
my $prot = delete($pidsprots{$donepid}) || next;
my $start = $protstarttime{$prot};
info "INFO: Processing of protein '$prot' completed in ",(time-$start)," seconds.\n";
next;
}
my $prot = shift(@prots_todo);
my ($cnt,$fasta) = &ExtractLibSeqs($prot,$SPECIES_LIST,1);
# Filenames
my $protin = "XXXX/$prot.seq";
my $protout = "YYYY/$prot.pir";
my $aliout = "$TMPDIR/ZZZZ/${prot}_1.ali";
# Create input file (.seq)
my $infh = new IO::File ">$protin"
or die "Can't write to file '$protin': $!\n";
print $infh $fasta;
$infh->close();
# Manage child subprocesses.
if (my $pid = fork()) {
$pidsprots{$pid}=$prot;
$protstarttime{$prot}=time;
info "INFO: Starting processing of '$prot' (with $cnt sequences)\n";
next;
}
# Child starts here
if ($cnt == 1) {
system("/bin/cp",$protin,$protout);
}
else {
system("/bin/sh","-c","$YYYY_EXE -in '$protin' -out '$protout' 1>'Outputs/\LYYYY\E.$prot.out' 2>&1");
die "Error in processing protein '$prot' with program 'YYYY'; check diagnostic file 'Outputs/\LYYYY\E.$prot.out'.\n"
if (! -e $protout);
}
# Run umac
system("/bin/sh","-c","$UMAC_EXE -i '$protout' -o '$aliout' -f stockholm 1>'Outputs/\LUMAC\E.$prot.out' 2>&1");
die "Error in processing protein '$prot' with program 'UMAC'; check diagnostic file 'Outputs/\LUMAC\E.$prot.out'.\n"
if (! -e $aliout);
# Make iteration
my $i = 0;
my $ResQuali = ();
my $aliForHmm = $aliout;
for ( ;; ) {
$i++;
my $prothmm = "$TMPDIR/DDDD/${prot}_$i.hmm";
unlink($prothmm) if (-e $prothmm);
system("/bin/sh","-c","$EEEE_EXE $prothmm $aliForHmm 1>'Outputs/\LEEEE\E.${prot}_$i.out' 2>&1");
die "Error in processing protein '$prot' with program 'EEEE' iteration $i; check diagnostic file 'Outputs/\LEEEE\E.${prot}_$i.out'.\n"
if (! -e $prothmm);
my $protaln = "$TMPDIR/ZZZZ/${prot}_$i.aln";
unlink($protaln) if (-e $protaln);
system("/bin/sh","-c","$ZZZZ_EXE --outformat stockholm -o $protaln $prothmm $protin 1>'Outputs/\LZZZZ\E.${prot}_$i.out' 2>&1");
die "Error in processing protein '$prot' with program 'ZZZZ' iteration $i; check diagnostic file 'Outputs/\LZZZZ\E.${prot}_$i.out'.\n"
if (! -e $protaln);
my $quality = &DefQuality($protaln);
$ResQuali->{$prot}->{$i} = $quality;
$aliForHmm = $protaln;
last if $i == $MaxIteration;
}
my $BestIteration = &SelectBestIteration($ResQuali->{$prot});
system("/bin/cp","$TMPDIR/DDDD/${prot}_$BestIteration.hmm","DDDD/${prot}.hmm");
system("/bin/cp","$TMPDIR/ZZZZ/${prot}_$BestIteration.aln","ZZZZ/${prot}.aln");
exit 0;
} |