1 |
|
#!@PERLINTERP@ -w |
2 |
|
|
3 |
|
# program that scales an OOPSE .in or .eor file to a new volume |
4 |
– |
# written by Chris Fennell |
4 |
|
|
5 |
+ |
# author = "Chris Fennell |
6 |
+ |
# version = "$Revision: 1.4 $" |
7 |
+ |
# date = "$Date: 2006-09-01 19:22:06 $" |
8 |
+ |
# copyright = "Copyright (c) 2006 by the University of Notre Dame" |
9 |
+ |
# license = "OOPSE" |
10 |
+ |
|
11 |
+ |
|
12 |
|
use Getopt::Std; |
13 |
|
|
14 |
|
# some variables to get things going |
15 |
< |
$line1 = 1; |
16 |
< |
$line2 = 0; |
15 |
> |
$startSnap = 0; |
16 |
> |
$startFrame = 0; |
17 |
> |
$startStunts = 0; |
18 |
|
|
19 |
|
# get our options |
20 |
|
getopts('hv', \%opts); |
24 |
|
|
25 |
|
# our option output |
26 |
|
if ($opts{h}){ |
27 |
< |
print "affineScale: performs an affine transform on an OOPSE .in or .eor\n"; |
28 |
< |
print "\tand writes to a new file named [file name].scale\n\n"; |
29 |
< |
print "usage: affineScale [-hv] [file name] [new volume (Ang^3)]\n\n"; |
30 |
< |
print " -h : show this message\n"; |
31 |
< |
die " -v : more verbose output\n"; |
27 |
> |
print "affineScale: performs an affine transform on an OOPSE .in or .eor\n"; |
28 |
> |
print "\tand writes to a new file named [file name].scale\n\n"; |
29 |
> |
print "usage: affineScale [-hv] [file name] [new volume (Ang^3)]\n\n"; |
30 |
> |
print " -h : show this message\n"; |
31 |
> |
die " -v : more verbose output\n"; |
32 |
|
} |
33 |
|
|
34 |
|
# set some variables to be used in the code |
38 |
|
# some crazy input checking |
39 |
|
if ($newVolume =~ /^[0-9]/){ |
40 |
|
} else { |
41 |
< |
die "\t[new volume] value ($newVolume) is not a valid number\n\tPlease choose a non-negative numeric value for [new volume]\n"; |
41 |
> |
die "\t[new volume] value ($newVolume) is not a valid number\n\tPlease choose a non-negative numeric value for [new volume]\n"; |
42 |
|
} |
43 |
|
|
44 |
|
# split up the name to obtain an output filename |
50 |
|
open (SCALEFILE, ">./$outName") || die "\tError: can't open $outName"; |
51 |
|
|
52 |
|
while (<STATFILE>){ |
53 |
< |
if ($line1 == 1){ |
54 |
< |
print SCALEFILE; |
55 |
< |
$line1 = 0; |
49 |
< |
$line2 = 1; |
53 |
> |
$startSnap = 0 if /\/Snapshot/; |
54 |
> |
$startFrame = 0 if /\/FrameData/; |
55 |
> |
$startStunts = 0 if /\/StuntDoubles/; |
56 |
|
|
57 |
< |
} elsif ($line2 == 1){ |
58 |
< |
@line = split; |
59 |
< |
chop $line[9]; |
60 |
< |
$oldVolume = $line[1]*$line[5]*$line[9]; |
61 |
< |
|
62 |
< |
$scale = ($newVolume/$oldVolume)**0.333333333333333; |
63 |
< |
# scale the hmat vectors (only orthorhombic) |
64 |
< |
$line[1] *= $scale; |
65 |
< |
$line[5] *= $scale; |
66 |
< |
$line[9] *= $scale; |
67 |
< |
$volume = $line[1]*$line[5]*$line[9]; |
68 |
< |
|
69 |
< |
print SCALEFILE "$line[0]"; |
70 |
< |
for ($i=1; $i<=$#line; $i++) { |
71 |
< |
print SCALEFILE "\t$line[$i]"; |
72 |
< |
if ($i == 9) {print SCALEFILE ";";} |
73 |
< |
} |
74 |
< |
print SCALEFILE "\n"; |
75 |
< |
$line2 = 0; |
76 |
< |
|
77 |
< |
} else { |
78 |
< |
@line = split /\s+/; |
79 |
< |
$line[1] *= $scale; |
80 |
< |
$line[2] *= $scale; |
81 |
< |
$line[3] *= $scale; |
76 |
< |
print SCALEFILE "$line[0]"; |
77 |
< |
for ($i=1; $i<=$#line; $i++) { |
78 |
< |
print SCALEFILE "\t$line[$i]"; |
79 |
< |
} |
80 |
< |
print SCALEFILE "\n"; |
57 |
> |
if ($startSnap == 1){ |
58 |
> |
if ($startFrame == 1){ |
59 |
> |
if (/Hmat/){ |
60 |
> |
@line = split; |
61 |
> |
|
62 |
> |
chop $line[2]; |
63 |
> |
chop $line[8]; |
64 |
> |
$oldVolume = $line[2]*$line[8]*$line[14]; |
65 |
> |
|
66 |
> |
$scale = ($newVolume/$oldVolume)**0.333333333333333; |
67 |
> |
# scale the hmat vectors (only orthorhombic) |
68 |
> |
$line[2] *= $scale; |
69 |
> |
$line[8] *= $scale; |
70 |
> |
$line[14] *= $scale; |
71 |
> |
$volume = $line[2]*$line[8]*$line[14]; |
72 |
> |
|
73 |
> |
print SCALEFILE "\t$line[0]"; |
74 |
> |
for ($i=1; $i<=$#line; $i++) { |
75 |
> |
print SCALEFILE " $line[$i]"; |
76 |
> |
if ($i == 2 || $i == 8) {print SCALEFILE ",";} |
77 |
> |
} |
78 |
> |
print SCALEFILE "\n"; |
79 |
> |
} else { |
80 |
> |
print SCALEFILE; |
81 |
> |
} |
82 |
|
} |
83 |
+ |
if ($startStunts == 1){ |
84 |
+ |
@line = split; |
85 |
+ |
$line[2] *= $scale; |
86 |
+ |
$line[3] *= $scale; |
87 |
+ |
$line[4] *= $scale; |
88 |
+ |
print SCALEFILE "$line[0]\t$line[1]\t"; |
89 |
+ |
for ($i=2; $i<=$#line; $i++) { |
90 |
+ |
print SCALEFILE "$line[$i] "; |
91 |
+ |
} |
92 |
+ |
print SCALEFILE "\n"; |
93 |
+ |
} |
94 |
+ |
if ($startFrame == 0 && $startStunts == 0) { |
95 |
+ |
print SCALEFILE; |
96 |
+ |
} |
97 |
+ |
} else { |
98 |
+ |
print SCALEFILE; |
99 |
+ |
} |
100 |
+ |
$startSnap = 1 if /Snapshot/; |
101 |
+ |
$startFrame = 1 if /FrameData/; |
102 |
+ |
$startStunts = 1 if /StuntDoubles/; |
103 |
+ |
# check again since "/value" contains "value" |
104 |
+ |
$startSnap = 0 if /\/Snapshot/; |
105 |
+ |
$startFrame = 0 if /\/FrameData/; |
106 |
+ |
$startStunts = 0 if /\/StuntDoubles/; |
107 |
|
} |
108 |
|
|
109 |
|
print "Affine transformed configuration written to $outName\n"; |
110 |
|
|
111 |
|
if (defined($opts{v})){ |
112 |
< |
print "New Volume : $volume\n"; |
113 |
< |
print "Old Volume : $oldVolume\n"; |
114 |
< |
print "Scale Factor : $scale\n"; |
112 |
> |
print "New Volume : $volume\n"; |
113 |
> |
print "Old Volume : $oldVolume\n"; |
114 |
> |
print "Scale Factor : $scale\n"; |
115 |
|
} |
116 |
|
|