#! /usr/bin/perl -w

# IMPORTANT: model and target should be full paths


if($#ARGV<5) { die "Usage: lga_out_2_newGDTTS_uniformcuts_noneighb_1.pl -m <model pdb file> -t <target pdb file> -o <output dir>\n"; } 

my $lgadir = "/home/sadreyev_2/new_gdtts/LGA_package";
my @lgads = ("1.0", "2.0", "4.0", "8.0"); # used distances for LGA 


while (@ARGV and $ARGV[0] =~ /^-/) {
        $_ = shift;
        last if /^--$/;
        if (/^-m/) {$_ = shift; $model = $_;}
        if (/^-t/) {$_ = shift; $target = $_;}
        if (/^-o/) {$_ = shift; $outdir = $_;}
}

my @mpath = split /\//, $model;
my $mname = $mpath[$#mpath];
my @tpath = split /\//, $target;
my $tname = $tpath[$#tpath];

for $lgad(@lgads) {

#	system("cp $model $lgadir; cp $target $lgadir");
#	my $cmd = "./runlga.mol_mol.pl $mname $tname  -3  -ie  -o1  -sda  -d\:$lgad";
	my $cmd = "./runlga.mol_mol.pl $model $target  -3  -ie  -o1  -sda  -d\:$lgad";
	print STDERR "running LGA in $lgadir: $cmd\n";
	system("cd $lgadir; $cmd");
#	system("rm -f $mname $tname"); 

	my $lga_file = "$lgadir\/RESULTS\/$mname\.$tname\.res";
	my $outfile = "$outdir\/$mname\.$tname\.d$lgad\.res";
	system("mv $lga_file $outfile");

	print STDERR "Result in $outfile\n";
}
