Index: tests/regression/Potential/FitPotential/testsuite-potential-fit-potential.at
===================================================================
--- tests/regression/Potential/FitPotential/testsuite-potential-fit-potential.at	(revision 1dbbebbd0643e4b6a024acbe95232cacda8a7a10)
+++ tests/regression/Potential/FitPotential/testsuite-potential-fit-potential.at	(revision 9e1bfbc27ee42cdb562491c7e51fdb9da26faaf0)
@@ -26,9 +26,20 @@
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPotential/pre/$file $file], 0)
 AT_CHECK([chmod u+w $file], 0, [ignore], [ignore])
-AT_CHECK([../../molecuilder --parse-homologies $file --set-random-number-engine "lagged_fibonacci607" --random-number-engine-parameters "seed=1;" --set-random-number-distribution "uniform_real" --random-number-distribution-parameters "min=0;max=1;" --fit-potential --potential-type "morse" --potential-charges 8 1 --fragment-charges 1 8 1 --set-threshold 1e-6], 0, [stdout], [ignore])
+AT_CHECK([../../molecuilder \
+	--parse-homologies $file \
+	--set-random-number-engine "lagged_fibonacci607" \
+		--random-number-engine-parameters "seed=1;" \
+	--set-random-number-distribution "uniform_real" \
+		--random-number-distribution-parameters "min=0;max=1;" \
+	--fit-potential \
+		--potential-type "morse" \
+		--potential-charges 8 1 \
+		--fragment-charges 1 8 1 \
+		--set-threshold 1e-6 \
+	--save-potentials length.potentials], 0, [stdout], [ignore])
 # check that L_2 error is below 1e-6
 AT_CHECK([grep "Best parameters with L2 error" stdout | awk '{if ($8 > 1e-6) exit 1}'], 0, [ignore], [ignore])
 # check parameters to printed precision
-AT_CHECK([grep "morse:.*particle_type1=8,.*particle_type2=1,.*spring_constant=1.27.*,.*equilibrium_distance=1.78.*,.*dissociation_energy=0.19.*;" stdout], 0, [ignore], [ignore])
+AT_CHECK([grep "morse:.*particle_type1=8,.*particle_type2=1,.*spring_constant=1.27.*,.*equilibrium_distance=1.78.*,.*dissociation_energy=0.19.*;" length.potentials], 0, [ignore], [ignore])
 
 AT_CLEANUP
@@ -41,9 +52,20 @@
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPotential/pre/$file $file], 0)
 AT_CHECK([chmod u+w $file], 0, [ignore], [ignore])
-AT_CHECK([../../molecuilder --parse-homologies $file --set-random-number-engine "lagged_fibonacci607" --random-number-engine-parameters "seed=1;" --set-random-number-distribution "uniform_real" --random-number-distribution-parameters "min=0;max=1;" --fit-potential --potential-type "harmonic_bond" --potential-charges 8 1 --fragment-charges 1 8 1 --set-threshold 1e-6], 0, [stdout], [ignore])
+AT_CHECK([../../molecuilder \
+	--parse-homologies $file \
+	--set-random-number-engine "lagged_fibonacci607" \
+		--random-number-engine-parameters "seed=1;" \
+	--set-random-number-distribution "uniform_real" \
+		--random-number-distribution-parameters "min=0;max=1;" \
+	--fit-potential \
+		--potential-type "harmonic_bond" \
+		--potential-charges 8 1 \
+		--fragment-charges 1 8 1 \
+		--set-threshold 1e-6 \
+	--save-potentials harmonic.potentials], 0, [stdout], [ignore])
 # check that L_2 error is below 1e-6
 AT_CHECK([grep "Best parameters with L2 error" stdout | awk '{if ($8 > 1e-6) exit 1}'], 0, [ignore], [ignore])
 # check parameters to printed precision
-AT_CHECK([grep "harmonic_bond:.*particle_type1=8,.*particle_type2=1,.*spring_constant=0.29.*,.*equilibrium_distance=1.8.*;" stdout], 0, [ignore], [ignore])
+AT_CHECK([grep "harmonic_bond:.*particle_type1=8,.*particle_type2=1,.*spring_constant=0.29.*,.*equilibrium_distance=1.8.*;" harmonic.potentials], 0, [ignore], [ignore])
 
 AT_CLEANUP
@@ -56,9 +78,20 @@
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPotential/pre/$file $file], 0)
 AT_CHECK([chmod u+w $file], 0, [ignore], [ignore])
-AT_CHECK([../../molecuilder --parse-homologies $file --set-random-number-engine "lagged_fibonacci607" --random-number-engine-parameters "seed=1;" --set-random-number-distribution "uniform_real" --random-number-distribution-parameters "min=0;max=1;" --fit-potential --potential-type "harmonic_angle" --potential-charges 1 8 1 --fragment-charges 1 8 1 --set-threshold 1e-6], 0, [stdout], [ignore])
+AT_CHECK([../../molecuilder \
+	--parse-homologies $file \
+	--set-random-number-engine "lagged_fibonacci607" \
+		--random-number-engine-parameters "seed=1;" \
+	--set-random-number-distribution "uniform_real" \
+		--random-number-distribution-parameters "min=0;max=1;" \
+	--fit-potential \
+		--potential-type "harmonic_angle" \
+		--potential-charges 1 8 1 \
+		--fragment-charges 1 8 1 \
+		--set-threshold 1e-6 \
+	--save-potentials angle.potentials], 0, [stdout], [ignore])
 # check that L_2 error is below 1e-6
 AT_CHECK([grep "||e||_2:" stdout | awk '{if ($7 > 1e-6) exit 1}'], 0, [ignore], [ignore])
 # check parameters to printed precision
-AT_CHECK([grep "harmonic_angle:.*particle_type1=1,.*particle_type2=8,.*particle_type3=1,.*spring_constant=0.10.*,.*equilibrium_distance=-0.27.*;" stdout], 0, [ignore], [ignore])
+AT_CHECK([grep "harmonic_angle:.*particle_type1=1,.*particle_type2=8,.*particle_type3=1,.*spring_constant=0.10.*,.*equilibrium_distance=-0.27.*;" angle.potentials], 0, [ignore], [ignore])
 
 AT_CLEANUP
@@ -71,9 +104,20 @@
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPotential/pre/$file $file], 0)
 AT_CHECK([chmod u+w $file], 0, [ignore], [ignore])
-AT_CHECK([../../molecuilder --parse-homologies $file --set-random-number-engine "lagged_fibonacci607" --random-number-engine-parameters "seed=1;" --set-random-number-distribution "uniform_real" --random-number-distribution-parameters "min=0;max=1;" --fit-potential --potential-type "torsion" --potential-charges 6 6 6 6 --fragment-charges 6 6 6 6 1 1 1 1 1 1 1 1 1 1 --set-threshold 2e-10], 0, [stdout], [ignore])
+AT_CHECK([../../molecuilder \
+	--parse-homologies $file \
+	--set-random-number-engine "lagged_fibonacci607" \
+		--random-number-engine-parameters "seed=1;" \
+	--set-random-number-distribution "uniform_real" \
+		--random-number-distribution-parameters "min=0;max=1;" \
+	--fit-potential \
+		--potential-type "torsion" \
+		--potential-charges 6 6 6 6 \
+		--fragment-charges 6 6 6 6 1 1 1 1 1 1 1 1 1 1 \
+		--set-threshold 2e-10 \
+	--save-potentials torsion.potentials], 0, [stdout], [ignore])
 # check that L_2 error is below 9e-12 ... just 2e-10 otherwise test takes tooo long
 AT_CHECK([grep "Best parameters with L2 error" stdout | awk '{if ($8 > 2e-10) exit 1}'], 0, [ignore], [ignore])
-AT_CHECK([grep "torsion:.*particle_type1=6,.*particle_type2=6,.*particle_type3=6,.*particle_type4=6,.*spring_constant=.*,.*equilibrium_distance=.*;" stdout], 0, [ignore], [ignore])
-#AT_CHECK([grep "torsion:.*particle_type1=6,.*particle_type2=6,.*particle_type3=6,.*particle_type4=6,.*spring_constant=0.001.*,.*equilibrium_distance=0.99.*;" stdout], 0, [ignore], [ignore])
+AT_CHECK([grep "torsion:.*particle_type1=6,.*particle_type2=6,.*particle_type3=6,.*particle_type4=6,.*spring_constant=.*,.*equilibrium_distance=.*;" torsion.potentials], 0, [ignore], [ignore])
+#AT_CHECK([grep "torsion:.*particle_type1=6,.*particle_type2=6,.*particle_type3=6,.*particle_type4=6,.*spring_constant=0.001.*,.*equilibrium_distance=0.99.*;" torsion.potentials], 0, [ignore], [ignore])
 
 AT_CLEANUP
@@ -86,10 +130,21 @@
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPotential/pre/$file $file], 0)
 AT_CHECK([chmod u+w $file], 0, [ignore], [ignore])
-AT_CHECK([../../molecuilder --parse-homologies $file --set-random-number-engine "lagged_fibonacci607" --random-number-engine-parameters "seed=1;" --set-random-number-distribution "uniform_real" --random-number-distribution-parameters "min=0;max=1;" --fit-potential --potential-type "improper" --potential-charges 1 7 1 1 --fragment-charges 7 1 1 1 --set-threshold 3e-4], 0, [stdout], [ignore])
+AT_CHECK([../../molecuilder \
+	--parse-homologies $file \
+	--set-random-number-engine "lagged_fibonacci607" \
+		--random-number-engine-parameters "seed=1;" \
+	--set-random-number-distribution "uniform_real" \
+		--random-number-distribution-parameters "min=0;max=1;" \
+	--fit-potential \
+		--potential-type "improper" \
+		--potential-charges 1 7 1 1 \
+		--fragment-charges 7 1 1 1 \
+		--set-threshold 3e-4 \
+	--save-potentials improper.potentials], 0, [stdout], [ignore])
 # check that L_2 error is below 3e-4
 AT_CHECK([grep "Best parameters with L2 error" stdout | awk '{if ($8 > 3e-4) exit 1}'], 0, [ignore], [ignore])
 # check parameters to printed precision
-AT_CHECK([grep "improper:.*particle_type1=1,.*particle_type2=7,.*particle_type3=1,.*particle_type4=1,.*spring_constant=.*,.*equilibrium_distance=.*;" stdout], 0, [ignore], [ignore])
-#AT_CHECK([grep "improper:.*particle_type1=1,.*particle_type2=7,.*particle_type3=1,.*particle_type4=1,.*spring_constant=1.02.*,.*equilibrium_distance=0.85.*;" stdout], 0, [ignore], [ignore])
+AT_CHECK([grep "improper:.*particle_type1=1,.*particle_type2=7,.*particle_type3=1,.*particle_type4=1,.*spring_constant=.*,.*equilibrium_distance=.*;" improper.potentials], 0, [ignore], [ignore])
+#AT_CHECK([grep "improper:.*particle_type1=1,.*particle_type2=7,.*particle_type3=1,.*particle_type4=1,.*spring_constant=1.02.*,.*equilibrium_distance=0.85.*;" improper.potentials], 0, [ignore], [ignore])
 
 AT_CLEANUP
@@ -102,10 +157,21 @@
 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Potential/FitPotential/pre/$file $file], 0)
 AT_CHECK([chmod u+w $file], 0, [ignore], [ignore])
-AT_CHECK([../../molecuilder --parse-homologies $file --set-random-number-engine "lagged_fibonacci607" --random-number-engine-parameters "seed=5;" --set-random-number-distribution "uniform_real" --random-number-distribution-parameters "min=0;max=1;" --fit-potential --potential-type "lennardjones" --potential-charges 18 18 --fragment-charges 18 18 --set-threshold 7e-9], 0, [stdout], [ignore])
+AT_CHECK([../../molecuilder \
+	--parse-homologies $file \
+	--set-random-number-engine "lagged_fibonacci607" \
+		--random-number-engine-parameters "seed=5;" \
+	--set-random-number-distribution "uniform_real" \
+		--random-number-distribution-parameters "min=0;max=1;" \
+	--fit-potential \
+		--potential-type "lennardjones" \
+		--potential-charges 18 18 \
+		--fragment-charges 18 18 \
+		--set-threshold 7e-9 \
+	--save-potentials lj.potentials], 0, [stdout], [ignore])
 # check that L_2 error is below 7e-11 ... just 7e-9 otherwise test takes too long
 AT_CHECK([grep "Best parameters with L2 error" stdout | awk '{if ($8 > 7e-9) exit 1}'], 0, [ignore], [ignore])
 # check parameters to printed precision
-AT_CHECK([grep "lennardjones:.*particle_type1=18,.*particle_type2=18,.*epsilon=.*,.*sigma=.*;" stdout], 0, [ignore], [ignore])
-#AT_CHECK([grep "lennardjones:.*particle_type1=18,.*particle_type2=18,.*epsilon=1.*e-05,.*sigma=8.2.*;" stdout], 0, [ignore], [ignore])
+AT_CHECK([grep "lennardjones:.*particle_type1=18,.*particle_type2=18,.*epsilon=.*,.*sigma=.*;" lj.potentials], 0, [ignore], [ignore])
+#AT_CHECK([grep "lennardjones:.*particle_type1=18,.*particle_type2=18,.*epsilon=1.*e-05,.*sigma=8.2.*;" lj.potentials], 0, [ignore], [ignore])
 
 AT_CLEANUP
