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

#1j2xA00 1wq2B00 1.10.10.10 1.10.10.10 d1j2xa_ d1wq2b1 a.4.5.30 a.4.5.45
#1j2xA00 2aduA02 1.10.10.10 1.10.10.10 d1j2xa_ d2adua1 a.4.5.30 a.4.5.25

$path="/mnt/disk/public/SCOP1.7/pdbstyle-1.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[4];
    $dir1 = substr($prot1,2,2);

   $prot2=$names[5];
    $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/GergeSamePDresTM");

  system("/bin/rm $prot1-$prot2.ali");

# finaliza cada proceso a finalizar
    $pm -> finish;
}

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


