#!/usr/bin/perl
#runs pdbset to expand the asymetric unit to whole unit cell with given pdb file
#reads the cell and symmetry from input pdb file
#syntax: run_pdbset
$found = 0;
open(PDBIN,$ARGV[0]);
while ($line=) {
if ( $line =~ /CRYST1\s+(\d+\.*\d*)\s+(\d+\.*\d*)\s+(\d+\.*\d*)\s+(\d+\.*\d*)\s+(\d+\.*\d*)\s+(\d+\.*\d*)\s+((\S+\s?)+)/ ) {
$cell = "$1 $2 $3 $4 $5 $6";
$sym = $7;
#print "*$1*$2*$3*$4*$5*$6*$7";
while ( $sym =~ /(.*)(\s)(.*)/ ) { $sym = "$1$3"; }
$found = 1;
# print "$cell $sym\n";
}
}
close(PDBIN);
if (!$found) { die "run_pdbset: Error reading cell parameters or spacegroup from $ARGV[0]\n"; }
if ($sym =~ /^$/) { die "run_pdbset: No spacegroup read from $ARGV[0]\n"; }
$pdbset = "XYZIN $ARGV[0] XYZOUT $ARGV[1] << EOI \nCELL $cell \nSYMGEN $sym \nEOI\n";
print("pdbset $pdbset > /dev/null");
system("pdbset $pdbset > /dev/null");