#!/usr/bin/perl
use strict;
use warnings;

my $DEBUG = 0;

my $TARGET = $ARGV[0];
my $pml_script = "/tmp/tmp.pml"; # pymol script
my $PSE_FILE = "/local/CASP13/ASSESSORS/PSE/"; # pymol session file
my @colors =qw/red blue green yellow cyan magenta/;


$PSE_FILE .= "$TARGET.pse";

if (-f $pml_script){
   system("touch $pml_script; chgrp casp $pml_script; chmod g+w $pml_script");
}
open P, "> $pml_script";
print P "# set background color to white:\n";
print P "bg_color black\n";
print P "load /local/CASP13/Targets_oligo/$TARGET.pdb, $TARGET\n";
print P "preset.pretty(\"$TARGET\")\n";
print P "util.cbc\n";
print P "save $PSE_FILE\n";
print P "orient\n";
#print P "ray 120, 120\n";
#print P "png /local/CASP13/PLOTS/STR/$TARGET.small.png, dpi=300\n";
print P "ray 500, 500\n";
print P "png /local/CASP13/PLOTS/STR/$TARGET.big.png, dpi=300\n";
print P "quit\n";

close(P);
#exit;

system("pymol -c $pml_script >/dev/null 2>/dev/null");
exit;
sleep(1);
if (-f $PSE_FILE){
        system("chgrp casp $PSE_FILE; chmod g+w $PSE_FILE");
}

