#!/usr/bin/perl
use Parallel::ForkManager;
# inicializa el paralelizador a 8 procesos
my $pm = new Parallel::ForkManager(15);

$path="/home/jairo/SCOP1.73";

open(LIST,$ARGV[0]);
@x=<LIST>;
close(LIST);
$size=$#x+1;

for ($i=0;$i<$size;$i++) {
   @names=split(/\s/,$x[$i]);
   $prot1=$names[0];
    $dir1 = substr($prot1,2,2);

   for ($j=$i+1;$j<$size;$j++) {
   @names2=split(/\s/,$x[$j]);
   $prot2=$names2[0];
    $dir2 = substr($prot2,2,2);

    # inicializa cada proceso a paralelizar
    $pm -> start and next;
  $Y=`./ProtDeform P -A ../ScoreTest/bssp/$prot1.bssp -B ../ScoreTest/bssp/$prot2.bssp -O -  |tail -1`;
   @lineY=split(/[\s=,]+/,$Y);
 $X=`../TMalign/TMscore $prot1-$prot2.ali $path/$dir2/$prot2.ent | perl ../TMalign/filterPDtm.pl `;
  system("echo $prot1 $prot2 $X $lineY[3] >> ../TMalign/RESPlos/PDresTM");

#  system("/bin/rm $prot1-$prot2.ali");
    # finaliza cada proceso a finalizar
    $pm -> finish;
}
}

# espera a que hayan acabado todos
$pm -> wait_all_children; 


