Skip to content
This repository has been archived by the owner on Jul 27, 2020. It is now read-only.

Commit

Permalink
(issue #64) Changes to the python script and the .cfg file are done. …
Browse files Browse the repository at this point in the history
…As soon as testing is done I'll merge with master.
  • Loading branch information
kozlac committed Jan 13, 2016
1 parent 250d16c commit af2c9fe
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 50 deletions.
109 changes: 109 additions & 0 deletions apbs/tests/apbs_check_intermediate_energies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#!/usr/bin/env python

"""
Check intermediate computed energies form an APBS run
"""

import sys, re
from apbs_logger import Logger

error_tolerance = 1e-6

class ElecEnergy:
"""
extracts and compares computed intermediate energies
"""

pattern = r'\s(?P<label>[a-zA-Z]+ [a-zA-Z]+ = )[\-]?(?P<x>[0-9]+(\.[0-9]+)?(E[\+,\-][0-9]+)?)'

def __init__(self, label, x):
"""
creates an elecEnergy from supplies values
"""
self.label = label
self.x = x

def __init__(self, line):
"""
extract energy results from a file at a given line
"""
m = re.search(self.pattern, line)
self.label = m.group('label')
self.x = float(m.group('x'))

def __repr__(self):
return "ElecEnergy{ label:%S, x:%g" % (self.label, self.x)

def diff(self, other):
"""
compares the value of two energy calculations
"""

return abs( getattr(self, d) - getattr(other, d) )

def short(self):
return self.label


def extract_energy(energy_class, lines, start_pattern, ):
"""
extracts intermediate energies
"""
energy_list = []

for line_number, line_text in enumerate(lines):

if line_text.lstrip().startswith(start_pattern):
if re.search(energy_class.pattern, line_text):
energy_list.append(parse_energy(energy_class, line_text))


return energy_list


def parse_energy( energy_class, lines):

energy_item = energy_class(lines)

return energy_item.x


def check_energies(input_file):

print "Checking for intermidiate energies in input file %s" % input_file

f = None
try:
f = open(input_file, 'r')
except IOError:
print >> sys.stderr, "Couldn't read from energy file %s" % input_file

input_lines = f.readlines()

energy_list = extract_energy(ElecEnergy, input_lines, 'Total electrostatic energy')
energy_list += extract_energy(ElecEnergy, input_lines, 'Mobile charge energy')
energy_list += extract_energy(ElecEnergy, input_lines, 'Fixed charge energy')
energy_list += extract_energy(ElecEnergy, input_lines, 'Dielectric energy')

return energy_list

def test():

l = open('energy.log', 'w')
logger = Logger(sys.stderr, l)
energy_list = check_energies('actio_stdout.txt')
print energy_list


if __name__ == '__main__':
print >> sys.stderr, "The python source files %s is a module and not runnable" % sys.argv[0]
sys.exit(1)









8 changes: 7 additions & 1 deletion apbs/tests/apbs_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from apbs_check_forces import check_forces
from apbs_check_results import check_results
from apbs_check_intermediate_energies import check_energies
from apbs_logger import Logger

# Matches a floating point number such as -1.23456789E-20
Expand Down Expand Up @@ -70,8 +71,13 @@ def process_serial( binary, input_file ):
output_file = open( output_name, 'r' )
output_text = output_file.read()

# Look for intermidiate energy results
output_results = check_energies(output_name)

output_pattern = r'Global net (?:ELEC|APOL) energy \= ' + float_pattern
output_results = [ float( r ) for r in re.findall( output_pattern, output_text ) ]
output_results2 =[float( r ) for r in re.findall( output_pattern, output_text )]

output_results += output_results2


# Return all the matched results as a list of floating point numbers
Expand Down
98 changes: 49 additions & 49 deletions apbs/tests/test_cases.cfg
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
[born]
input_dir : ../examples/born
apbs-forces : forces
apbs-mol-auto : -2.297735411962E+02
apbs-smol-auto : -2.290124171992E+02
apbs-mol-parallel : -2.304918086635E+02
apbs-smol-parallel : -2.293871354771E+02
apbs-mol-auto : 9.607073836227E+02 2.2002665679710E+03 4.732245131587E+03 1.190871482831E+03 2.4308740497350E+03 4.962018684215E+03 -2.297735411962E+02
apbs-smol-auto : 9.532928767450E+02 2.2012438800850E+03 4.733006258977E+03 1.190871482831E+03 2.4308740497350E+03 4.962018684215E+03 -2.290124171992E+02
apbs-mol-parallel : 9.607073836226E+02 3.2571427835732E+03 5.941003947871E+03 1.190871482831E+03 3.5197218230368E+03 6.171495796544E+03 -2.304918086635E+02
apbs-smol-parallel : 9.532928767450E+02 3.2581578983733E+03 5.942108652590E+03 1.190871482831E+03 3.5197218230368E+03 6.171495796544E+03 -2.293871354771E+02

[actin-dimer]
input_dir : ../examples/actin-dimer
apbs-mol-auto : 1.048683060915E+02
apbs-smol-auto : 1.095841074454E+02
apbs-mol-parallel : 9.817462910199E+01
apbs-smol-parallel : 1.155422164152E+02
apbs-mol-auto : 1.52761785034200E+05 2.91951075419600E+05 1.52767184488000E+05 2.91546885927800E+05 3.0563178076110E+05 5.8360282965320E+05 1.048683060915E+02
apbs-smol-auto : 1.52863242182500E+05 2.92061866232000E+05 1.52929790057200E+05 2.91659220283500E+05 3.0592442625350E+05 5.8383067062320E+05 1.095841074454E+02
apbs-mol-parallel : 3.58912964547657E+04 2.87987762245115E+05 3.60030631059603E+04 2.88016885299934E+05 7.2040017332199E+04 5.7610282210669E+05 9.817462910199E+01
apbs-smol-parallel : 3.65759576645280E+04 2.88119689243832E+05 3.66915279438399E+04 2.88125915810145E+05 7.3413596046999E+04 5.7636114712166E+05 1.155422164152E+02

[alkanes]
input_dir : ../examples/alkanes
alkanes : 1.439739455792E+01 1.208346456826E+01 1.354016672221E+01 9.363673200142E+00 9.422717598546E+00 1.640068943201E+01 1.323144287435E+01 7.894367190329E+00 1.449633815052E+01 1.447900211546E+01 1.192358496286E+01

[FKBP]
input_dir : ../examples/FKBP
1d7h-dmso-mol : * * * 1.500810086371E+01
1d7h-dmso-smol : * * * 1.624454192072E+01
1d7i-dss-mol : * * * 1.442500529301E+01
1d7i-dss-smol : * * * 1.545150009785E+01
1d7h-dmso-mol : 1.060899690259E+04 4.276523673491E+04 1.399234956777E+04 4.610066575192E+04 3.961107503213E+01 7.121048606059E+02 6.751571424823E+01 7.339101343121E+02 1.058410584089E+04 4.205385249581E+04 1.395961902233E+04 4.538248433997E+04 * * * 1.500810086371E+01
1d7h-dmso-smol : 1.074948704824E+04 4.289487256481E+04 1.399234956777E+04 4.610066575192E+04 3.719709905887E+01 7.125747080979E+02 6.751571424823E+01 7.339101343121E+02 1.071654753674E+04 4.218178203716E+04 1.395961902233E+04 4.538248433997E+04 * * * 1.624454192072E+01
1d7i-dss-mol : 9.160578033846E+03 3.955701871716E+04 1.264965939588E+04 4.301801664829E+04 9.431133325426E+01 1.677348113184E+03 1.171079106781E+02 1.697869784185E+03 9.040108332204E+03 3.787747796627E+04 1.252495566243E+04 4.133237922574E+04 * * * 1.442500529301E+01
1d7i-dss-smol : 9.634884642408E+03 4.003177540425E+04 1.264965939588E+04 4.301801664829E+04 7.942232645345E+01 1.677798535473E+03 1.171079106781E+02 1.697869784185E+03 9.507068451372E+03 3.835075772299E+04 1.252495566243E+04 4.133237922574E+04 * * * 1.545150009785E+01

[hca-bind]
input_dir : ../examples/hca-bind
apbs-mol : -5.246475812665E+01
apbs-smol : -5.405977880082E+01
apbs-mol : 2.213600726771E+02 1.825764811255E+03 6.458471211905E+03 2.093606095527E+04 1.515433544464E+05 1.786369323561E+05 2.105322784838E+04 1.533304996252E+05 1.850429388099E+05 -5.246475812665E+01
apbs-smol : 1.884888131017E+02 1.820045922544E+03 6.460002606908E+03 2.189161497021E+04 1.520000494925E+05 1.790436191580E+05 2.195842512312E+04 1.537771604355E+05 1.854495619747E+05 -5.405977880082E+01

[ionize]
input_dir : ../examples/ionize
apbs-mol : -2.267881997628E+01 -1.997462580204E+02 -2.974598331751E+02 -4.745272868358E+02
apbs-smol : -2.233050451129E+01 -1.984883191396E+02 -2.959668653531E+02 -4.721247084138E+02
apbs-mol : 5.823898055191E+03 9.793274462353E+03 5.846917564309E+03 9.815953282539E+03 8.219846763777E+03 1.392741988698E+04 8.420373979905E+03 1.412716615065E+04 3.862359524598E+03 6.288156251610E+03 4.162533113906E+03 6.585616091973E+03 -2.267881997628E+01 -1.997462580204E+02 -2.974598331751E+02 -4.745272868358E+02
apbs-smol : 5.824172730822E+03 9.793622759239E+03 5.846917564309E+03 9.815953282539E+03 8.221328580569E+03 1.392867783119E+04 8.420373979905E+03 1.412716615065E+04 3.863066835285E+03 6.289649216644E+03 4.162533113906E+03 6.585616091973E+03 -2.233050451129E+01 -1.984883191396E+02 -2.959668653531E+02 -4.721247084138E+02

[ion-pmf]
input_dir : ../examples/ion-pmf
ion-pmf : -1.125192402906E+03 *
ion-pmf : 7.839535983197E+03 8.964727588811E+03 -1.125192402906E+03 *

[ion-protein]
input_dir : ../examples/ion-protein
apbs-mol-pdiel2 : 1.559159533685E+01
apbs-smol-pdiel2 : 2.355542126580E+01
apbs-mol-pdiel12 : 1.802722643122E+01
apbs-smol-pdiel12 : 1.928245019838E+01
apbs-mol-pdiel2 : 7.525554553704E+03 2.967613272771E+03 1.050875942181E+04 1.559159533685E+01
apbs-smol-pdiel2 : 7.561237446444E+03 2.974076897757E+03 1.055886976547E+04 2.355542126580E+01
apbs-mol-pdiel12 : 1.363584355927E+03 5.110802147229E+02 1.892691797082E+03 1.802722643122E+01
apbs-smol-pdiel12 : 1.366571366426E+03 5.108315415905E+02 1.896685358215E+03 1.928245019838E+01

[pka-lig]
input_dir : ../examples/pka-lig
apbs-mol-vdw : 8.083515648730E+00
apbs-smol-vdw : 2.096296139195E+01
apbs-mol-surf : 1.192608095265E+02
apbs-smol-surf : 1.088773280806E+02
apbs-mol-vdw : 2.224988750664E+03 1.049695084686E+04 1.818450789522E+05 3.008254338259E+05 1.840918409896E+05 3.113304681884E+05 8.083515648730E+00
apbs-smol-vdw : 2.226793167046E+03 1.050504485887E+04 1.827976621645E+05 3.017228546773E+05 1.850819075387E+05 3.122488625388E+05 2.096296139195E+01
apbs-mol-surf : 2.244350164274E+03 1.052149475373E+04 1.862615690066E+05 3.051810884053E+05 1.886625455219E+05 3.158218439277E+05 1.192608095265E+02
apbs-smol-surf : 2.251466789420E+03 1.052814502873E+04 1.864071689626E+05 3.053319953673E+05 1.888027142979E+05 3.159690177241E+05 1.088773280806E+02

[point-pmf]
input_dir : ../examples/point-pmf
complex-0_1 : 1.830820736656E+01
complex-0_2 : 8.906693911567E+00
complex-0_3 : 5.909599752197E+00
complex-0_4 : 4.430144912287E+00
complex-0_1 : 9.776035707281E+01 8.975920687031E+01 2.058277719334E+02 * * * 97.7604 89.7592 205.828 96.5336 88.6151 201.106 1.830820799027E+01
complex-0_2 : 9.776035707281E+01 1.017611498797E+02 2.084282010393E+02 * * * 97.7604 101.761 208.428 96.5336 100.656 203.83 8.906694086750E+00
complex-0_3 : 9.776035707281E+01 1.337661883222E+02 2.374361452120E+02 * * * 97.7604 133.766 237.436 96.5336 132.672 232.924 5.909599816984E+00
complex-0_4 : 9.776035707281E+01 1.017611498797E+02 2.039516519000E+02 * * * 97.7604 101.761 203.952 96.5336 100.654 199.493 4.430144947418E+00

# Uses untested and unimplemented parts of APBS that will probably be deprecated
# [smpbe]
Expand All @@ -68,8 +68,8 @@ complex-0_4 : 4.430144912287E+00
[solv]
input_dir : ../examples/solv
# methanol methoxide difference
apbs-mol : -3.624863445503E+01 -3.904121297757E+02 -3.541635359318E+02
apbs-smol : -3.757593797629E+01 -3.912388198513E+02 -3.536628818750E+02
apbs-mol : 1.847663548071E+03 1.883912182952E+03 2.732623683321E+03 3.123035854133E+03 -3.624863445503E+01 -3.904121297757E+02 -3.541635359318E+02
apbs-smol : 1.847860440020E+03 1.885436377745E+03 2.734040568569E+03 3.125279428954E+03 -3.757593797629E+01 -3.912388198513E+02 -3.536628818750E+02

[geoflow]
input_dir : ../examples/geoflow
Expand All @@ -78,21 +78,21 @@ imidazole : -1.030222099963E+01 5.417419E-01
[protein-rna]
input_dir : ../examples/protein-rna
setup : python apbs_unix_dx.py
apbs-0.025 : 8.674116429353E+01
apbs-0.050 : 9.606836713866E+01
apbs-0.075 : 1.011537214883E+02
apbs-0.100 : 1.046142116108E+02
apbs-0.125 : 1.072226817610E+02
apbs-0.150 : 1.093084123761E+02
apbs-0.175 : 1.110412443877E+02
apbs-0.200 : 1.125199716537E+02
apbs-0.225 : 1.138070465620E+02
apbs-0.250 : 1.149444369078E+02
apbs-0.275 : 1.159616972338E+02
apbs-0.300 : 1.168804254687E+02
apbs-0.325 : 1.177168854906E+02
apbs-0.400 : 1.198456038803E+02
apbs-0.500 : 1.220607673699E+02
apbs-0.600 : 1.238080564885E+02
apbs-0.700 : 1.252364090878E+02
apbs-0.800 : 1.264340604647E+02
apbs-0.025 : 3.186122223752E+04 3.662855899462E+04 8.477786964834E+03 1.000545153104E+04 2.329205982055E+04 2.653636629928E+04 8.674116429353E+01
apbs-0.050 : 3.184763478312E+04 3.661493366846E+04 8.475252516617E+03 1.000292179294E+04 2.327168361816E+04 2.651594350839E+04 9.606836713866E+01
apbs-0.075 : 3.184033569905E+04 3.660761530545E+04 8.473669396547E+03 1.000134276339E+04 2.326088212207E+04 2.650511882057E+04 1.011537214883E+02
apbs-0.100 : 3.183548000794E+04 3.660274809589E+04 8.472507235893E+03 1.000018407412E+04 2.325372656922E+04 2.649794981016E+04 1.046142116108E+02
apbs-0.125 : 3.183190100647E+04 3.659916161996E+04 8.471585837513E+03 9.999265654586E+03 2.324845847155E+04 2.649267328362E+04 1.072226817610E+02
apbs-0.150 : 3.182909678356E+04 3.659635228953E+04 8.470821300868E+03 9.998503715551E+03 2.324433086171E+04 2.648854016160E+04 1.093084123761E+02
apbs-0.175 : 3.182680817429E+04 3.659406006570E+04 8.470167484600E+03 9.997852199372E+03 2.324096101131E+04 2.648516662194E+04 1.110412443877E+02
apbs-0.200 : 3.182488501939E+04 3.659213428941E+04 8.469596195763E+03 9.997282974485E+03 2.323812822097E+04 2.648233134327E+04 1.125199716537E+02
apbs-0.225 : 3.182323306491E+04 3.659048040133E+04 8.469088900775E+03 9.996777552566E+03 2.323569434544E+04 2.647989580221E+04 1.138070465620E+02
apbs-0.250 : 3.182178954360E+04 3.658903543806E+04 8.468632740499E+03 9.996323108319E+03 2.323356752071E+04 2.647776789284E+04 1.149444369078E+02
apbs-0.275 : 3.182051070674E+04 3.658775551975E+04 8.468218414737E+03 9.995910367297E+03 2.323168374787E+04 2.647588345522E+04 1.159616972338E+02
apbs-0.300 : 3.181936493519E+04 3.658660893678E+04 8.467838971928E+03 9.995532397856E+03 2.322999676177E+04 2.647419611346E+04 1.168804254687E+02
apbs-0.325 : 3.181832869046E+04 3.658557208654E+04 8.467489074881E+03 9.995183878464E+03 2.322847209567E+04 2.647267132259E+04 1.177168854906E+02
apbs-0.400 : 3.181571629593E+04 3.658295870300E+04 8.466578740909E+03 9.994277216885E+03 2.322463613929E+04 2.646883588223E+04 1.198456038803E+02
apbs-0.500 : 3.181302243781E+04 3.658026461575E+04 8.465598755475E+03 9.993301332440E+03 2.322070101887E+04 2.646490251594E+04 1.220607673699E+02
apbs-0.600 : 3.181090090954E+04 3.657814345443E+04 8.464799341688E+03 9.992505379555E+03 2.321762631365E+04 2.646183001839E+04 1.238080564885E+02
apbs-0.700 : 3.180915789156E+04 3.657640108752E+04 8.464126109756E+03 9.991835140855E+03 2.321512352191E+04 2.645932953757E+04 1.252364090878E+02
apbs-0.800 : 3.180768241803E+04 3.657492640520E+04 8.463546035019E+03 9.991257699113E+03 2.321302636223E+04 2.645723464562E+04 1.264340604647E+02

0 comments on commit af2c9fe

Please sign in to comment.