Index: tests/regression/Potential/FitPartialCharges/post/water.particles
===================================================================
--- tests/regression/Potential/FitPartialCharges/post/water.particles	(revision f33ef915fce26ae43109c53c58932747bc589748)
+++ tests/regression/Potential/FitPartialCharges/post/water.particles	(revision 1ab6fcf0c622bf44ea21393926d24127e2bb6628)
@@ -1,3 +1,2 @@
 	particle:	particle_type=H1,	element_name=H,	sigma=0,	epsilon=0,	sigma14=0,	epsilon14=0,	mass=0,	free=3,	charge=0.3682424148;
-	particle:	particle_type=H2,	element_name=H,	sigma=0,	epsilon=0,	sigma14=0,	epsilon14=0,	mass=0,	free=3,	charge=0.368536001;
 	particle:	particle_type=O1,	element_name=O,	sigma=0,	epsilon=0,	sigma14=0,	epsilon14=0,	mass=0,	free=3,	charge=-0.7367784158;
Index: tests/regression/Potential/FitPartialCharges/pre/atomfragments.dat
===================================================================
--- tests/regression/Potential/FitPartialCharges/pre/atomfragments.dat	(revision 1ab6fcf0c622bf44ea21393926d24127e2bb6628)
+++ tests/regression/Potential/FitPartialCharges/pre/atomfragments.dat	(revision 1ab6fcf0c622bf44ea21393926d24127e2bb6628)
@@ -0,0 +1,1 @@
+22 serialization::archive 10 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 3 0 0 1 2
Index: tests/regression/Potential/FitPartialCharges/testsuite-potential-fit-partial-charges.at
===================================================================
--- tests/regression/Potential/FitPartialCharges/testsuite-potential-fit-partial-charges.at	(revision f33ef915fce26ae43109c53c58932747bc589748)
+++ tests/regression/Potential/FitPartialCharges/testsuite-potential-fit-partial-charges.at	(revision 1ab6fcf0c622bf44ea21393926d24127e2bb6628)
@@ -18,22 +18,43 @@
 ### fit partial particle charges
 
-# the potential has been generated by:
-# ./molecuilder -i pre/water.pdb --center-in-box "8,0,8,0,0,8" --select-all-atoms --fragment-molecule BondFragment --distance 2 --order 1 --fragment-automation --server-address 127.0.0.1 --server-port 1026 --DoLongrange 1 --grid 4 --DoPrintDebug 1 --DoValenceOnly 0 --analyse-fragment-results --store-grids 1 --save-homologies homology_grid_4_full.dat
+AT_SETUP([Potential - Fit partial charges - atomfragment check])
+AT_KEYWORDS([potential parse-homologies fit-partial-charges save-particle-parameters])
+AT_SKIP_IF([../../molecuilder --help fit-partial-charges; if test $? -eq 5; then /bin/true; else /bin/false; fi])
+
+input=water.pdb
+homologyfile=homology_grid.dat
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPartialCharges/pre/$input $input], 0)
+AT_CHECK([chmod u+w $input], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPartialCharges/pre/$homologyfile $homologyfile], 0)
+AT_CHECK([chmod u+w $homologyfile], 0, [ignore], [ignore])
+# fails because atomFragments has not been parsed
+AT_CHECK([../../molecuilder -l $input --select-all-atoms --parse-homologies $homologyfile --fit-partial-charges --radius 1.5 --save-particle-parameters water.particles], 5, [stdout], [ignore])
+
+AT_CLEANUP
 
 AT_SETUP([Potential - Fit partial charges to water])
 AT_KEYWORDS([potential parse-homologies fit-partial-charges save-particle-parameters])
 AT_SKIP_IF([../../molecuilder --help fit-partial-charges; if test $? -eq 5; then /bin/true; else /bin/false; fi])
-AT_XFAIL_IF([/bin/true])
 
 # homology file created with water.pdb and as follows:
-# molecuilder -i water.pdb --select-all-atoms --fragment-molecule --distance 2 --order 1 --fragment-automation --server-address 127.0.0.1 --server-port 1026 --DoLongrange 1 --grid 5 --store-grids 1 --analyse-fragment-results --save-homologies homology_grid.dat
-file=homology_grid.dat
-AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPartialCharges/pre/$file $file], 0)
-AT_CHECK([chmod u+w $file], 0, [ignore], [ignore])
-AT_CHECK([../../molecuilder --parse-homologies $file --fit-partial-charges --fragment-charges 8 1 1 --radius 1.5 --save-particle-parameters water.particles], 0, [stdout], [ignore])
+# molecuilder -i water.pdb --select-all-atoms --fragment-molecule --distance 2 --order 1 --fragment-automation --server-address 127.0.0.1 --server-port 1026 --DoLongrange 1 --grid 5 --store-grids 1 --analyse-fragment-results --save-homologies homology_grid.dat --save-atom-fragments atomfragments.dat
+input=water.pdb
+homologyfile=homology_grid.dat
+atomfragmentsfile=atomfragments.dat
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPartialCharges/pre/$input $input], 0)
+AT_CHECK([chmod u+w $input], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPartialCharges/pre/$homologyfile $homologyfile], 0)
+AT_CHECK([chmod u+w $homologyfile], 0, [ignore], [ignore])
+AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPartialCharges/pre/$atomfragmentsfile $atomfragmentsfile], 0)
+AT_CHECK([chmod u+w $atomfragmentsfile], 0, [ignore], [ignore])
+AT_CHECK([../../molecuilder -l $input --select-all-atoms --parse-homologies $homologyfile --parse-atom-fragments $atomfragmentsfile --fit-partial-charges --radius 1.5 --save-particle-parameters water.particles], 0, [stdout], [ignore])
 # check that L_2 error is below 1e-6
 AT_CHECK([grep "L2-Norm" stdout | awk '{if ($6 > 1e1) exit 1}'], 0, [ignore], [ignore])
 AT_CHECK([grep "L1-Norm" stdout | awk '{if ($6 > 1e0) exit 1}'], 0, [ignore], [ignore])
-AT_CHECK([grep "We have fitted the following charges ( -0.73.*; 0.36.*; 0.36.*; )." stdout], 0, [ignore], [ignore])
+AT_CHECK([grep "Adding particle O1.*-0.73" stdout], 0, [ignore], [ignore])
+AT_CHECK([grep "Adding particle H1.*0.36" stdout], 0, [ignore], [ignore])
+AT_CHECK([grep "atom O1.*received .*O1" stdout], 0, [ignore], [ignore])
+AT_CHECK([grep "atom H2.*received .*H1" stdout], 0, [ignore], [ignore])
+AT_CHECK([grep "atom H3.*received .*H1" stdout], 0, [ignore], [ignore])
 AT_CHECK([diff water.particles ${abs_top_srcdir}/tests/regression/Potential/FitPartialCharges/post/water.particles], 0)
 
