use strict;
use warnings;
use File::Basename;
use Carp;
use Cwd 'abs_path';

my $rr_dir = shift; #"/home/siva/Documents/programs/CNN/CAMEO_test/casp12fm/nr90_rr";
my $pdb_dir = shift; #"/home/siva/Documents/programs/CNN/CAMEO_test/casp12fm/target";

my $src = abs_path(dirname($0));

my @pdb_dir = glob "$pdb_dir/*.pdb";
#my @rr_files = glob "$rr_dir/*.dncon2.rr";
my @rr_files = glob "$rr_dir/*";
my $rr_file;

foreach my $file(@pdb_dir){
    my $pdb_file = $file;
    my $pdb = basename($file);
    $pdb =substr($pdb,0,index($pdb,'.pdb'));
    my @spl = split('-', $pdb);
    my $id = $spl[0];

    foreach $file (@rr_files){
      my $seq_id= basename($file);

      if($seq_id =~ /^$id/){
            #print $pdb_file."\n";
            print $seq_id." evaluated\n";
            print `perl $src/coneva-lite.pl -rr $file -pdb $pdb_file >> $rr_dir/results.txt`;
         }
      }
    }

    # my $dist_path=join("",$dist_dir,$seq_name,".dist");
    # print $rr_file," ", $dist_path," ",$length," ",$seq,"\n";
