diff --git a/regtest/analysis/rt-calc-dissims/Makefile b/regtest/analysis/rt-calc-dissims/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..3703b27cea227aa053fb6d1d73f861e4384dbcee --- /dev/null +++ b/regtest/analysis/rt-calc-dissims/Makefile @@ -0,0 +1 @@ +include ../../scripts/test.make diff --git a/regtest/analysis/rt-calc-dissims/analysis.0.mymatrix3.dat.reference b/regtest/analysis/rt-calc-dissims/analysis.0.mymatrix3.dat.reference new file mode 100644 index 0000000000000000000000000000000000000000..964f0140e8c2167fe941708048cc98c5a18bf19e --- /dev/null +++ b/regtest/analysis/rt-calc-dissims/analysis.0.mymatrix3.dat.reference @@ -0,0 +1,6 @@ + 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 + 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 + 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 + 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 + 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 + 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 diff --git a/regtest/analysis/rt-calc-dissims/colv_in b/regtest/analysis/rt-calc-dissims/colv_in new file mode 100644 index 0000000000000000000000000000000000000000..bbcb4dd1b881d802ba5739da0aecf12848617971 --- /dev/null +++ b/regtest/analysis/rt-calc-dissims/colv_in @@ -0,0 +1,14 @@ +#! FIELDS time data +0 0 +1 0 +2 1 +3 2 +4 3 +5 4 +6 5 +7 6 +8 7 +9 8 +10 9 +11 10 +12 11 diff --git a/regtest/analysis/rt-calc-dissims/config b/regtest/analysis/rt-calc-dissims/config new file mode 100644 index 0000000000000000000000000000000000000000..73d164c9563b29348f4ad678148013dc849d7154 --- /dev/null +++ b/regtest/analysis/rt-calc-dissims/config @@ -0,0 +1,3 @@ +type=driver +arg="--noatoms --plumed plumed.dat" + diff --git a/regtest/analysis/rt-calc-dissims/mymatrix.dat.reference b/regtest/analysis/rt-calc-dissims/mymatrix.dat.reference new file mode 100644 index 0000000000000000000000000000000000000000..e7c6219200c2527789efe28e8e248687c0686c60 --- /dev/null +++ b/regtest/analysis/rt-calc-dissims/mymatrix.dat.reference @@ -0,0 +1,13 @@ + 0.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 49.0000 64.0000 81.0000 100.0000 121.0000 + 0.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 49.0000 64.0000 81.0000 100.0000 121.0000 + 1.0000 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 49.0000 64.0000 81.0000 100.0000 + 4.0000 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 49.0000 64.0000 81.0000 + 9.0000 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 49.0000 64.0000 + 16.0000 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 49.0000 + 25.0000 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 + 36.0000 36.0000 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 + 49.0000 49.0000 36.0000 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 + 64.0000 64.0000 49.0000 36.0000 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 + 81.0000 81.0000 64.0000 49.0000 36.0000 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 + 100.0000 100.0000 81.0000 64.0000 49.0000 36.0000 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 + 121.0000 121.0000 100.0000 81.0000 64.0000 49.0000 36.0000 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 diff --git a/regtest/analysis/rt-calc-dissims/mymatrix2.dat.reference b/regtest/analysis/rt-calc-dissims/mymatrix2.dat.reference new file mode 100644 index 0000000000000000000000000000000000000000..5ed581592c5380c3d7e69b9b450150c554650b00 --- /dev/null +++ b/regtest/analysis/rt-calc-dissims/mymatrix2.dat.reference @@ -0,0 +1,5 @@ + 0.0000 1.0000 9.0000 25.0000 49.0000 + 1.0000 0.0000 4.0000 16.0000 36.0000 + 9.0000 4.0000 0.0000 4.0000 16.0000 + 25.0000 16.0000 4.0000 0.0000 4.0000 + 49.0000 36.0000 16.0000 4.0000 0.0000 diff --git a/regtest/analysis/rt-calc-dissims/mymatrix3.dat.reference b/regtest/analysis/rt-calc-dissims/mymatrix3.dat.reference new file mode 100644 index 0000000000000000000000000000000000000000..964f0140e8c2167fe941708048cc98c5a18bf19e --- /dev/null +++ b/regtest/analysis/rt-calc-dissims/mymatrix3.dat.reference @@ -0,0 +1,6 @@ + 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 + 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 + 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 + 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 + 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 + 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 diff --git a/regtest/analysis/rt-calc-dissims/output-fps.pdb.reference b/regtest/analysis/rt-calc-dissims/output-fps.pdb.reference new file mode 100644 index 0000000000000000000000000000000000000000..02b2c082ddda04b9c65f1060bebaf720978f5b29 --- /dev/null +++ b/regtest/analysis/rt-calc-dissims/output-fps.pdb.reference @@ -0,0 +1,15 @@ +DESCRIPTION: analysis data from calculation done at time 12.000000 +REMARK WEIGHT=6.000000 +REMARK ARG=d1 +REMARK d1=7.000000 +END +DESCRIPTION: analysis data from calculation done at time 12.000000 +REMARK WEIGHT=5.000000 +REMARK ARG=d1 +REMARK d1=0.000000 +END +DESCRIPTION: analysis data from calculation done at time 12.000000 +REMARK WEIGHT=2.000000 +REMARK ARG=d1 +REMARK d1=11.000000 +END diff --git a/regtest/analysis/rt-calc-dissims/output-stride.pdb.reference b/regtest/analysis/rt-calc-dissims/output-stride.pdb.reference new file mode 100644 index 0000000000000000000000000000000000000000..607e10619a20af49b374f51db634e9af605f4751 --- /dev/null +++ b/regtest/analysis/rt-calc-dissims/output-stride.pdb.reference @@ -0,0 +1,25 @@ +DESCRIPTION: analysis data from calculation done at time 12.000000 +REMARK WEIGHT=2.000000 +REMARK ARG=d1 +REMARK d1=0.000000 +END +DESCRIPTION: analysis data from calculation done at time 12.000000 +REMARK WEIGHT=2.000000 +REMARK ARG=d1 +REMARK d1=1.000000 +END +DESCRIPTION: analysis data from calculation done at time 12.000000 +REMARK WEIGHT=2.000000 +REMARK ARG=d1 +REMARK d1=3.000000 +END +DESCRIPTION: analysis data from calculation done at time 12.000000 +REMARK WEIGHT=2.000000 +REMARK ARG=d1 +REMARK d1=5.000000 +END +DESCRIPTION: analysis data from calculation done at time 12.000000 +REMARK WEIGHT=5.000000 +REMARK ARG=d1 +REMARK d1=7.000000 +END diff --git a/regtest/analysis/rt-calc-dissims/plumed.dat b/regtest/analysis/rt-calc-dissims/plumed.dat new file mode 100644 index 0000000000000000000000000000000000000000..e1f37516f336443365ad7af34836819be4030afd --- /dev/null +++ b/regtest/analysis/rt-calc-dissims/plumed.dat @@ -0,0 +1,15 @@ +d1: READ FILE=colv_in VALUES=data + +ss1: EUCLIDEAN_DISSIMILARITIES STRIDE=1 USE_ALL_DATA ARG=d1 +PRINT_DISSIMILARITY_MATRIX USE_OUTPUT_DATA_FROM=ss1 FILE=mymatrix.dat FMT=%8.4f + +ll1: LANDMARK_SELECT_STRIDE ARG=d1 USE_OUTPUT_DATA_FROM=ss1 NLANDMARKS=5 +ss2: EUCLIDEAN_DISSIMILARITIES USE_OUTPUT_DATA_FROM=ll1 +OUTPUT_ANALYSIS_DATA_TO_PDB USE_OUTPUT_DATA_FROM=ll1 FILE=output-stride.pdb +PRINT_DISSIMILARITY_MATRIX USE_OUTPUT_DATA_FROM=ll1 FILE=mymatrix2.dat FMT=%8.4f + +ll2: LANDMARK_SELECT_FPS USE_OUTPUT_DATA_FROM=ss1 NLANDMARKS=3 +OUTPUT_ANALYSIS_DATA_TO_PDB USE_OUTPUT_DATA_FROM=ll2 FILE=output-fps.pdb + +ss3: EUCLIDEAN_DISSIMILARITIES STRIDE=1 RUN=6 ARG=d1 +oo: PRINT_DISSIMILARITY_MATRIX USE_OUTPUT_DATA_FROM=ss3 FILE=mymatrix3.dat FMT=%8.4f diff --git a/regtest/analysis/rt-read-dissims/Makefile b/regtest/analysis/rt-read-dissims/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..3703b27cea227aa053fb6d1d73f861e4384dbcee --- /dev/null +++ b/regtest/analysis/rt-read-dissims/Makefile @@ -0,0 +1 @@ +include ../../scripts/test.make diff --git a/regtest/analysis/rt-read-dissims/config b/regtest/analysis/rt-read-dissims/config new file mode 100644 index 0000000000000000000000000000000000000000..73d164c9563b29348f4ad678148013dc849d7154 --- /dev/null +++ b/regtest/analysis/rt-read-dissims/config @@ -0,0 +1,3 @@ +type=driver +arg="--noatoms --plumed plumed.dat" + diff --git a/regtest/analysis/rt-read-dissims/mymatrix.dat b/regtest/analysis/rt-read-dissims/mymatrix.dat new file mode 100644 index 0000000000000000000000000000000000000000..f2292edb988d895bd4362621c2b1373fd50bc248 --- /dev/null +++ b/regtest/analysis/rt-read-dissims/mymatrix.dat @@ -0,0 +1,13 @@ + 0.0000 1.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 49.0000 64.0000 81.0000 100.0000 121.0000 + 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 49.0000 64.0000 81.0000 100.0000 121.0000 + 1.0000 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 49.0000 64.0000 81.0000 100.0000 + 4.0000 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 49.0000 64.0000 81.0000 + 9.0000 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 49.0000 64.0000 + 16.0000 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 49.0000 + 25.0000 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 + 36.0000 36.0000 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 + 49.0000 49.0000 36.0000 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 + 64.0000 64.0000 49.0000 36.0000 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 + 81.0000 81.0000 64.0000 49.0000 36.0000 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 + 100.0000 100.0000 81.0000 64.0000 49.0000 36.0000 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 + 121.0000 121.0000 100.0000 81.0000 64.0000 49.0000 36.0000 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 diff --git a/regtest/analysis/rt-read-dissims/mymatrix_out.dat.reference b/regtest/analysis/rt-read-dissims/mymatrix_out.dat.reference new file mode 100644 index 0000000000000000000000000000000000000000..f2292edb988d895bd4362621c2b1373fd50bc248 --- /dev/null +++ b/regtest/analysis/rt-read-dissims/mymatrix_out.dat.reference @@ -0,0 +1,13 @@ + 0.0000 1.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 49.0000 64.0000 81.0000 100.0000 121.0000 + 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 49.0000 64.0000 81.0000 100.0000 121.0000 + 1.0000 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 49.0000 64.0000 81.0000 100.0000 + 4.0000 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 49.0000 64.0000 81.0000 + 9.0000 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 49.0000 64.0000 + 16.0000 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 49.0000 + 25.0000 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 36.0000 + 36.0000 36.0000 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 25.0000 + 49.0000 49.0000 36.0000 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 16.0000 + 64.0000 64.0000 49.0000 36.0000 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 9.0000 + 81.0000 81.0000 64.0000 49.0000 36.0000 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 4.0000 + 100.0000 100.0000 81.0000 64.0000 49.0000 36.0000 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 1.0000 + 121.0000 121.0000 100.0000 81.0000 64.0000 49.0000 36.0000 25.0000 16.0000 9.0000 4.0000 1.0000 0.0000 diff --git a/regtest/analysis/rt-read-dissims/mymatrix_stride.dat.reference b/regtest/analysis/rt-read-dissims/mymatrix_stride.dat.reference new file mode 100644 index 0000000000000000000000000000000000000000..5ed581592c5380c3d7e69b9b450150c554650b00 --- /dev/null +++ b/regtest/analysis/rt-read-dissims/mymatrix_stride.dat.reference @@ -0,0 +1,5 @@ + 0.0000 1.0000 9.0000 25.0000 49.0000 + 1.0000 0.0000 4.0000 16.0000 36.0000 + 9.0000 4.0000 0.0000 4.0000 16.0000 + 25.0000 16.0000 4.0000 0.0000 4.0000 + 49.0000 36.0000 16.0000 4.0000 0.0000 diff --git a/regtest/analysis/rt-read-dissims/plumed.dat b/regtest/analysis/rt-read-dissims/plumed.dat new file mode 100644 index 0000000000000000000000000000000000000000..f28f96fdc9a406d7f629976fc051e6c1142cb8b8 --- /dev/null +++ b/regtest/analysis/rt-read-dissims/plumed.dat @@ -0,0 +1,5 @@ +r1: READ_DISSIMILARITY_MATRIX FILE=mymatrix.dat +PRINT_DISSIMILARITY_MATRIX USE_OUTPUT_DATA_FROM=r1 FILE=mymatrix_out.dat FMT=%8.4f + +l1: LANDMARK_SELECT_STRIDE USE_OUTPUT_DATA_FROM=r1 NLANDMARKS=5 +PRINT_DISSIMILARITY_MATRIX USE_OUTPUT_DATA_FROM=l1 FILE=mymatrix_stride.dat FMT=%8.4f diff --git a/regtest/analysis/rt-store-print/Makefile b/regtest/analysis/rt-store-print/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..3703b27cea227aa053fb6d1d73f861e4384dbcee --- /dev/null +++ b/regtest/analysis/rt-store-print/Makefile @@ -0,0 +1 @@ +include ../../scripts/test.make diff --git a/regtest/analysis/rt-store-print/analysis.0.output-half.pdb.reference b/regtest/analysis/rt-store-print/analysis.0.output-half.pdb.reference new file mode 100644 index 0000000000000000000000000000000000000000..bf99439cf74b2563e4e1d30e92e3c20d14199c82 --- /dev/null +++ b/regtest/analysis/rt-store-print/analysis.0.output-half.pdb.reference @@ -0,0 +1,7 @@ +#! FIELDS d1 +0.000000 +1.000000 +2.000000 +3.000000 +4.000000 +5.000000 diff --git a/regtest/analysis/rt-store-print/analysis.0.output-stride2.pdb.reference b/regtest/analysis/rt-store-print/analysis.0.output-stride2.pdb.reference new file mode 100644 index 0000000000000000000000000000000000000000..59f916c90079db43135ad0b155387f1faac29313 --- /dev/null +++ b/regtest/analysis/rt-store-print/analysis.0.output-stride2.pdb.reference @@ -0,0 +1,4 @@ +#! FIELDS d1 +0.000000 +2.000000 +4.000000 diff --git a/regtest/analysis/rt-store-print/colv_in b/regtest/analysis/rt-store-print/colv_in new file mode 100644 index 0000000000000000000000000000000000000000..bbcb4dd1b881d802ba5739da0aecf12848617971 --- /dev/null +++ b/regtest/analysis/rt-store-print/colv_in @@ -0,0 +1,14 @@ +#! FIELDS time data +0 0 +1 0 +2 1 +3 2 +4 3 +5 4 +6 5 +7 6 +8 7 +9 8 +10 9 +11 10 +12 11 diff --git a/regtest/analysis/rt-store-print/config b/regtest/analysis/rt-store-print/config new file mode 100644 index 0000000000000000000000000000000000000000..73d164c9563b29348f4ad678148013dc849d7154 --- /dev/null +++ b/regtest/analysis/rt-store-print/config @@ -0,0 +1,3 @@ +type=driver +arg="--noatoms --plumed plumed.dat" + diff --git a/regtest/analysis/rt-store-print/output-all.pdb.reference b/regtest/analysis/rt-store-print/output-all.pdb.reference new file mode 100644 index 0000000000000000000000000000000000000000..28cf6f1a23b24dfc22ed57587cdf10b36ca69a0a --- /dev/null +++ b/regtest/analysis/rt-store-print/output-all.pdb.reference @@ -0,0 +1,14 @@ +#! FIELDS d1 +0.000000 +0.000000 +1.000000 +2.000000 +3.000000 +4.000000 +5.000000 +6.000000 +7.000000 +8.000000 +9.000000 +10.000000 +11.000000 diff --git a/regtest/analysis/rt-store-print/output-half.pdb.reference b/regtest/analysis/rt-store-print/output-half.pdb.reference new file mode 100644 index 0000000000000000000000000000000000000000..894fea15fcb0ad0949d484b0e12e2a981f26c41c --- /dev/null +++ b/regtest/analysis/rt-store-print/output-half.pdb.reference @@ -0,0 +1,7 @@ +#! FIELDS d1 +6.000000 +7.000000 +8.000000 +9.000000 +10.000000 +11.000000 diff --git a/regtest/analysis/rt-store-print/output-reuse.pdb.reference b/regtest/analysis/rt-store-print/output-reuse.pdb.reference new file mode 100644 index 0000000000000000000000000000000000000000..28cf6f1a23b24dfc22ed57587cdf10b36ca69a0a --- /dev/null +++ b/regtest/analysis/rt-store-print/output-reuse.pdb.reference @@ -0,0 +1,14 @@ +#! FIELDS d1 +0.000000 +0.000000 +1.000000 +2.000000 +3.000000 +4.000000 +5.000000 +6.000000 +7.000000 +8.000000 +9.000000 +10.000000 +11.000000 diff --git a/regtest/analysis/rt-store-print/output-stride.pdb.reference b/regtest/analysis/rt-store-print/output-stride.pdb.reference new file mode 100644 index 0000000000000000000000000000000000000000..9af0c7c91dc443faf6ef5ab71aed39e67ced3cb5 --- /dev/null +++ b/regtest/analysis/rt-store-print/output-stride.pdb.reference @@ -0,0 +1,6 @@ +#! FIELDS d1 +0.000000 +1.000000 +3.000000 +5.000000 +7.000000 diff --git a/regtest/analysis/rt-store-print/output-stride2.pdb.reference b/regtest/analysis/rt-store-print/output-stride2.pdb.reference new file mode 100644 index 0000000000000000000000000000000000000000..4e9c140cda4f2303e8b1e90804a8e55a3c90b5f0 --- /dev/null +++ b/regtest/analysis/rt-store-print/output-stride2.pdb.reference @@ -0,0 +1,4 @@ +#! FIELDS d1 +6.000000 +8.000000 +10.000000 diff --git a/regtest/analysis/rt-store-print/plumed.dat b/regtest/analysis/rt-store-print/plumed.dat new file mode 100644 index 0000000000000000000000000000000000000000..89c6f78faa26f503a317300c4bd553b1c4c185a1 --- /dev/null +++ b/regtest/analysis/rt-store-print/plumed.dat @@ -0,0 +1,11 @@ +d1: READ FILE=colv_in VALUES=data + +ss1: OUTPUT_ANALYSIS_DATA_TO_COLVAR STRIDE=1 RUN=6 ARG=d1 FILE=output-half.pdb +ss2: OUTPUT_ANALYSIS_DATA_TO_COLVAR STRIDE=1 USE_ALL_DATA ARG=d1 FILE=output-all.pdb +ss3: OUTPUT_ANALYSIS_DATA_TO_COLVAR REUSE_INPUT_DATA_FROM=ss2 FILE=output-reuse.pdb + +ll1: LANDMARK_SELECT_STRIDE ARG=d1 REUSE_INPUT_DATA_FROM=ss3 NLANDMARKS=5 NOVORONOI +OUTPUT_ANALYSIS_DATA_TO_COLVAR USE_OUTPUT_DATA_FROM=ll1 FILE=output-stride.pdb + +ll2: LANDMARK_SELECT_STRIDE ARG=d1 REUSE_INPUT_DATA_FROM=ss1 NLANDMARKS=3 NOVORONOI +OUTPUT_ANALYSIS_DATA_TO_COLVAR USE_OUTPUT_DATA_FROM=ll2 FILE=output-stride2.pdb diff --git a/src/analysis/EuclideanDissimilarityMatrix.cpp b/src/analysis/EuclideanDissimilarityMatrix.cpp new file mode 100644 index 0000000000000000000000000000000000000000..468b81efbc43ac0b4160b7c66fa9bd239d061b63 --- /dev/null +++ b/src/analysis/EuclideanDissimilarityMatrix.cpp @@ -0,0 +1,73 @@ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Copyright (c) 2013,2014 The plumed team + (see the PEOPLE file at the root of the distribution for a list of names) + + See http://www.plumed-code.org for more information. + + This file is part of plumed, version 2. + + plumed is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + plumed is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with plumed. If not, see <http://www.gnu.org/licenses/>. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +#include "AnalysisWithDataCollection.h" +#include "core/ActionRegister.h" +#include "reference/ReferenceConfiguration.h" + +namespace PLMD { +namespace analysis { + +class EuclideanDissimilarityMatrix : public AnalysisWithDataCollection { +private: + Matrix<double> dissimilarities; +public: + static void registerKeywords( Keywords& keys ); + EuclideanDissimilarityMatrix( const ActionOptions& ao ); +/// Do the analysis + void performAnalysis(); +/// This ensures that classes that use this data know that dissimilarities were set + bool dissimilaritiesWereSet() const { return true; } +/// Get the squared dissimilarity between two reference configurations + double getDissimilarity( const unsigned& i, const unsigned& j ); +/// This is just to deal with ActionWithVessel + void performTask( const unsigned& , const unsigned& , MultiValue& ) const { plumed_error(); } +}; + +PLUMED_REGISTER_ACTION(EuclideanDissimilarityMatrix,"EUCLIDEAN_DISSIMILARITIES") + +void EuclideanDissimilarityMatrix::registerKeywords( Keywords& keys ){ + AnalysisWithDataCollection::registerKeywords( keys ); +} + +EuclideanDissimilarityMatrix::EuclideanDissimilarityMatrix( const ActionOptions& ao ): +Action(ao), +AnalysisWithDataCollection(ao) +{ +} + +void EuclideanDissimilarityMatrix::performAnalysis(){ + // Resize dissimilarities matrix and set all elements to zero + dissimilarities.resize( getNumberOfDataPoints(), getNumberOfDataPoints() ); dissimilarities=0; +} + +double EuclideanDissimilarityMatrix::getDissimilarity( const unsigned& iframe, const unsigned& jframe ){ + plumed_dbg_assert( iframe<dissimilarities.nrows() && jframe<dissimilarities.ncols() ); + if( dissimilarities(iframe,jframe)>0. ){ return dissimilarities(iframe,jframe); } + if( iframe!=jframe ){ + dissimilarities(iframe,jframe) = dissimilarities(jframe,iframe) = distance( getPbc(), getArguments(), getReferenceConfiguration(iframe), getReferenceConfiguration(jframe), true ); + return dissimilarities(iframe,jframe); + } + return 0.0; +} + +} +} diff --git a/src/analysis/FarthestPointSampling.cpp b/src/analysis/FarthestPointSampling.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7b2465af78d240c46648a35d4385d143209791ec --- /dev/null +++ b/src/analysis/FarthestPointSampling.cpp @@ -0,0 +1,82 @@ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Copyright (c) 2012-2014 The plumed team + (see the PEOPLE file at the root of the distribution for a list of names) + + See http://www.plumed-code.org for more information. + + This file is part of plumed, version 2. + + plumed is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + plumed is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with plumed. If not, see <http://www.gnu.org/licenses/>. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +#include "LandmarkSelectionBase.h" +#include "core/ActionRegister.h" +#include "tools/Random.h" + +namespace PLMD { +namespace analysis { + +class FarthestPointSampling : public LandmarkSelectionBase { +private: + unsigned seed; +public: + static void registerKeywords( Keywords& keys ); + FarthestPointSampling( const ActionOptions& ao ); + void selectLandmarks(); +}; + +PLUMED_REGISTER_ACTION(FarthestPointSampling,"LANDMARK_SELECT_FPS") + +void FarthestPointSampling::registerKeywords( Keywords& keys ){ + LandmarkSelectionBase::registerKeywords(keys); + keys.add("compulsory","SEED","1234","a random number seed"); +} + +FarthestPointSampling::FarthestPointSampling( const ActionOptions& ao ): +Action(ao), +LandmarkSelectionBase(ao) +{ + if( !dissimilaritiesWereSet() ) error("dissimilarities have not been calcualted in input action"); + parse("SEED",seed); +} + +void FarthestPointSampling::selectLandmarks(){ + std::vector<unsigned> landmarks( getNumberOfDataPoints() ); + + // Select first point at random + Random random; random.setSeed(-seed); double rand=random.RandU01(); + landmarks[0] = std::floor( mydata->getNumberOfDataPoints()*rand ); + selectFrame( landmarks[0] ); + + // Now find distance to all other points (N.B. We can use squared distances here for speed) + Matrix<double> distances( getNumberOfDataPoints(), mydata->getNumberOfDataPoints() ); + for(unsigned i=0;i<mydata->getNumberOfDataPoints();++i) distances(0,i) = mydata->getDissimilarity( landmarks[0], i ); + + // Now find all other landmarks + for(unsigned i=1;i<getNumberOfDataPoints();++i){ + // Find point that has the largest minimum distance from the landmarks selected thus far + double maxd=0; + for(unsigned j=0;j<mydata->getNumberOfDataPoints();++j){ + double mind=distances(0,j); + for(unsigned k=1;k<i;++k){ + if( distances(k,j)<mind ){ mind=distances(k,j); } + } + if( mind>maxd ){ maxd=mind; landmarks[i]=j; } + } + selectFrame( landmarks[i] ); + for(unsigned k=0;k<mydata->getNumberOfDataPoints();++k) distances(i,k) = mydata->getDissimilarity( landmarks[i], k ); + } +} + +} +} diff --git a/src/analysis/LandmarkSelectionBase.cpp b/src/analysis/LandmarkSelectionBase.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d694abf17995b366cf84dbbf84e3a7d9af9f31e2 --- /dev/null +++ b/src/analysis/LandmarkSelectionBase.cpp @@ -0,0 +1,76 @@ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Copyright (c) 2012-2015 The plumed team + (see the PEOPLE file at the root of the distribution for a list of names) + + See http://www.plumed-code.org for more information. + + This file is part of plumed, version 2. + + plumed is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + plumed is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with plumed. If not, see <http://www.gnu.org/licenses/>. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +#include "LandmarkSelectionBase.h" + +namespace PLMD { +namespace analysis { + +void LandmarkSelectionBase::registerKeywords( Keywords& keys ){ + AnalysisWithDataCollection::registerKeywords( keys ); + keys.add("compulsory","NLANDMARKS","the number of landmarks that you would like to select"); + keys.addFlag("NOVORONOI",false,"do not do a Voronoi analysis of the data to determine weights of final points"); + keys.addFlag("IGNORE_WEIGHTS",false,"ignore the weights in the underlying analysis object"); +} + +LandmarkSelectionBase::LandmarkSelectionBase( const ActionOptions& ao ): +Action(ao), +AnalysisWithDataCollection(ao) +{ + parse("NLANDMARKS",nlandmarks); + log.printf(" selecting %d landmark points \n",nlandmarks); + lweights.resize( nlandmarks ); + + parseFlag("NOVORONOI",novoronoi); + if( !novoronoi && !dissimilaritiesWereSet() ) error("cannot calculate voronoi weights without dissimilarity mesaure"); + + if( !novoronoi ) log.printf(" ascribing weights to landmarks using voronoi analysis\n"); + else log.printf(" ascribing weights of original points to landmark\n"); +} + +void LandmarkSelectionBase::selectFrame( const unsigned& iframe ){ + landmark_indices.push_back( iframe ); +} + +void LandmarkSelectionBase::performAnalysis(){ + landmark_indices.resize(0); selectLandmarks(); + plumed_dbg_assert( nlandmarks==getNumberOfDataPoints() ); + + if( !novoronoi ){ + lweights.assign(lweights.size(),0.0); + unsigned rank=comm.Get_rank(), size=comm.Get_size(); + for(unsigned i=rank;i<mydata->getNumberOfDataPoints();i+=size){ + unsigned closest=0; + double mindist=mydata->getDissimilarity( i, landmark_indices[0] ); + for(unsigned j=1;j<nlandmarks;++j){ + double dist=mydata->getDissimilarity( i, landmark_indices[j] ); + if( dist<mindist ){ mindist=dist; closest=j; } + } + lweights[closest] += mydata->getWeight(i); + } + comm.Sum( &lweights[0], lweights.size() ); + } else { + for(unsigned i=0;i<nlandmarks;++i) lweights[i]=getWeight( landmark_indices[i] ); + } +} + +} +} diff --git a/src/analysis/LandmarkSelectionBase.h b/src/analysis/LandmarkSelectionBase.h new file mode 100644 index 0000000000000000000000000000000000000000..ce9723c1fb023f5dbad07a97273ecec4b5dc0b1e --- /dev/null +++ b/src/analysis/LandmarkSelectionBase.h @@ -0,0 +1,97 @@ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Copyright (c) 2013,2014 The plumed team + (see the PEOPLE file at the root of the distribution for a list of names) + + See http://www.plumed-code.org for more information. + + This file is part of plumed, version 2. + + plumed is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + plumed is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with plumed. If not, see <http://www.gnu.org/licenses/>. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +#ifndef __PLUMED_analysis_LandmarkSelectionBase_h +#define __PLUMED_analysis_LandmarkSelectionBase_h + +#include "AnalysisWithDataCollection.h" + +namespace PLMD { +namespace analysis { + +class LandmarkSelectionBase : public AnalysisWithDataCollection { +private: +/// The number of landmarks we are selecting + unsigned nlandmarks; +/// The weights of the landmark points + std::vector<double> lweights; +/// The indices of the landmarks in the original data set + std::vector<unsigned> landmark_indices; +/// How do we treat weights + bool novoronoi, noweights; +protected: +/// Transfer frame i in the underlying action to the object we are going to analyze + void selectFrame( const unsigned& ); +public: + static void registerKeywords( Keywords& keys ); + LandmarkSelectionBase( const ActionOptions& ao ); +/// Return the number of data points + unsigned getNumberOfDataPoints() const ; +/// Return the index of the data point in the base class + unsigned getDataPointIndexInBase( const unsigned& idata ) const ; +/// Get the weight + double getWeight( const unsigned& idata ) const ; +/// Get the ith data point + void getDataPoint( const unsigned& idata, std::vector<double>& point, double& weight ) const ; +/// Get a reference configuration + ReferenceConfiguration* getReferenceConfiguration( const unsigned& idat ); +/// Select landmark configurations + void performAnalysis(); + virtual void selectLandmarks()=0; +/// Get the squared dissimilarity between two reference configurations + double getDissimilarity( const unsigned& i, const unsigned& j ); +/// This does nothing - it just ensures the final class is not abstract + void performTask( const unsigned& , const unsigned& , MultiValue& ) const { plumed_error(); } +}; + +inline +unsigned LandmarkSelectionBase::getNumberOfDataPoints() const { + return nlandmarks; +} + +inline +unsigned LandmarkSelectionBase::getDataPointIndexInBase( const unsigned& idata ) const { + return AnalysisWithDataCollection::getDataPointIndexInBase( landmark_indices[idata] ); +} + +inline +double LandmarkSelectionBase::getWeight( const unsigned& idata ) const { + return lweights[idata]; +} + +inline +void LandmarkSelectionBase::getDataPoint( const unsigned& idata, std::vector<double>& point, double& weight ) const { + AnalysisWithDataCollection::getDataPoint( landmark_indices[idata], point, weight ); +} + +inline +ReferenceConfiguration* LandmarkSelectionBase::getReferenceConfiguration( const unsigned& idat ){ + return AnalysisWithDataCollection::getReferenceConfiguration( landmark_indices[idat] ); +} + +inline +double LandmarkSelectionBase::getDissimilarity( const unsigned& i, const unsigned& j ){ + return AnalysisBase::getDissimilarity( landmark_indices[i], landmark_indices[j] ); +} + +} +} +#endif diff --git a/src/analysis/OutputColvarFile.cpp b/src/analysis/OutputColvarFile.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d858320c226f8a0fe5be87c7280649f2b11274ed --- /dev/null +++ b/src/analysis/OutputColvarFile.cpp @@ -0,0 +1,101 @@ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Copyright (c) 2012 The plumed team + (see the PEOPLE file at the root of the distribution for a list of names) + + See http://www.plumed-code.org for more information. + + This file is part of plumed, version 2.0. + + plumed is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + plumed is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with plumed. If not, see <http://www.gnu.org/licenses/>. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +#include "AnalysisWithDataCollection.h" +#include "reference/ReferenceAtoms.h" +#include "reference/ReferenceArguments.h" +#include "core/ActionRegister.h" +#include "core/PlumedMain.h" +#include "core/Atoms.h" + +namespace PLMD { +namespace analysis { + +//+PLUMEDOC ANALYSIS OUTPUT_ANALYSIS_DATA_TO_COLVAR +/* +This can be used to output the data that has been stored in an Analysis object. + +The most useful application of this method is to output all projections of all the +points that were stored in an analysis object that performs some form of dimensionality +reduction. If you use the USE_DIMRED_DATA_FROM option below projections of all the +stored points will be output to a file. The positions of these projections will be calculated +using that dimensionality reduction algorithms out-of-sample extension algorithm. + +\par Examples + +*/ +//+ENDPLUMEDOC + +class OutputColvarFile : public AnalysisWithDataCollection { +private: + std::string fmt; + std::string filename; +public: + static void registerKeywords( Keywords& keys ); + OutputColvarFile( const ActionOptions& ); + void performTask( const unsigned& , const unsigned& , MultiValue& ) const { plumed_error(); } + void performAnalysis(); +}; + +PLUMED_REGISTER_ACTION(OutputColvarFile,"OUTPUT_ANALYSIS_DATA_TO_COLVAR") + +void OutputColvarFile::registerKeywords( Keywords& keys ){ + AnalysisWithDataCollection::registerKeywords( keys ); + keys.add("compulsory","FILE","the name of the file to output to"); + keys.add("optional","FMT","the format to output the data using"); +} + +OutputColvarFile::OutputColvarFile( const ActionOptions& ao ): +Action(ao), +AnalysisWithDataCollection(ao), +fmt("%f") +{ + parse("FILE",filename); parse("FMT",fmt); + if( !getRestart() ){ OFile ofile; ofile.link(*this); ofile.setBackupString("analysis"); ofile.backupAllFiles(filename); } + log.printf(" printing data to file named %s \n",filename.c_str() ); +} + +void OutputColvarFile::performAnalysis(){ + + // Output the embedding as long lists of data + OFile gfile; gfile.link(*this); + gfile.setBackupString("analysis"); + gfile.fmtField(fmt+" "); + gfile.open( filename.c_str() ); + + // Can't print out all landmark data if we have reference atom positions + ReferenceAtoms* myat=dynamic_cast<ReferenceAtoms*>( getReferenceConfiguration(0) ); + plumed_assert( !myat ); + + // Print embedding coordinates + for(unsigned i=0;i<getNumberOfDataPoints();++i){ + ReferenceArguments* myref=dynamic_cast<ReferenceArguments*>( getReferenceConfiguration(i) ); + plumed_assert( myref ); + for(unsigned j=0;j<myref->getReferenceArguments().size();++j){ + gfile.printField( myref->getArgumentNames()[j], myref->getReferenceArgument(j) ); + } + gfile.printField(); + } + gfile.close(); +} + +} +} diff --git a/src/analysis/OutputPDBFile.cpp b/src/analysis/OutputPDBFile.cpp new file mode 100644 index 0000000000000000000000000000000000000000..23548dc2f3b1e16edd58c492988be4d9d864a461 --- /dev/null +++ b/src/analysis/OutputPDBFile.cpp @@ -0,0 +1,84 @@ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Copyright (c) 2012 The plumed team + (see the PEOPLE file at the root of the distribution for a list of names) + + See http://www.plumed-code.org for more information. + + This file is part of plumed, version 2.0. + + plumed is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + plumed is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with plumed. If not, see <http://www.gnu.org/licenses/>. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +#include "AnalysisWithDataCollection.h" +#include "reference/ReferenceAtoms.h" +#include "reference/ReferenceArguments.h" +#include "core/ActionRegister.h" +#include "core/PlumedMain.h" +#include "core/Atoms.h" + +namespace PLMD { +namespace analysis { + +//+PLUMEDOC ANALYSIS OUTPUT_ANALYSIS_DATA_TO_PDB +/* +This can be used to output the data that has been stored in an Analysis object. + +\par Examples + +*/ +//+ENDPLUMEDOC + +class OutputPDBFile : public AnalysisWithDataCollection { +private: + std::string fmt; + std::string filename; +public: + static void registerKeywords( Keywords& keys ); + OutputPDBFile( const ActionOptions& ); + void performTask( const unsigned& , const unsigned& , MultiValue& ) const { plumed_error(); } + void performAnalysis(); +}; + +PLUMED_REGISTER_ACTION(OutputPDBFile,"OUTPUT_ANALYSIS_DATA_TO_PDB") + +void OutputPDBFile::registerKeywords( Keywords& keys ){ + AnalysisWithDataCollection::registerKeywords( keys ); + keys.add("compulsory","FILE","the name of the file to output to"); + keys.add("optional","FMT","the format to use in the output file"); +} + +OutputPDBFile::OutputPDBFile( const ActionOptions& ao ): +Action(ao), +AnalysisWithDataCollection(ao), +fmt("%f") +{ + parse("FILE",filename); parse("FMT",fmt); + if( !getRestart() ){ OFile ofile; ofile.link(*this); ofile.setBackupString("analysis"); ofile.backupAllFiles(filename); } + log.printf(" printing data to file named %s \n",filename.c_str() ); +} + +void OutputPDBFile::performAnalysis(){ + // Output the embedding in plumed pdb format + OFile afile; afile.link(*this); afile.setBackupString("analysis"); std::size_t psign=fmt.find("%"); + afile.open( filename.c_str() ); std::string descr="REMARK WEIGHT=%-" + fmt.substr(psign+1) + "\n"; + for(unsigned j=0;j<getNumberOfDataPoints();++j){ + afile.printf("DESCRIPTION: analysis data from calculation done at time %f \n",getLabel().c_str(),getTime() ); + afile.printf(descr.c_str(),getWeight(j) ); + if( plumed.getAtoms().usingNaturalUnits() ) getReferenceConfiguration(j)->print( 1.0, afile, fmt ); + else getReferenceConfiguration(j)->print( plumed.getAtoms().getUnits().getLength()/0.1, afile, fmt ); + } + afile.close(); +} + +} +} diff --git a/src/analysis/PrintDissimilarityMatrix.cpp b/src/analysis/PrintDissimilarityMatrix.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1b76c3bb66dc0339dabe1727ea5b196acce04673 --- /dev/null +++ b/src/analysis/PrintDissimilarityMatrix.cpp @@ -0,0 +1,71 @@ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Copyright (c) 2013,2014 The plumed team + (see the PEOPLE file at the root of the distribution for a list of names) + + See http://www.plumed-code.org for more information. + + This file is part of plumed, version 2. + + plumed is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + plumed is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with plumed. If not, see <http://www.gnu.org/licenses/>. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +#include "tools/OFile.h" +#include "AnalysisBase.h" +#include "core/ActionRegister.h" + +namespace PLMD { +namespace analysis { + +class PrintDissimilarityMatrix : public AnalysisBase { +private: + std::string fmt; + std::string fname; +public: + static void registerKeywords( Keywords& keys ); + PrintDissimilarityMatrix( const ActionOptions& ao ); + void performAnalysis(); + void performTask( const unsigned& , const unsigned& , MultiValue& ) const { plumed_error(); } +}; + +PLUMED_REGISTER_ACTION(PrintDissimilarityMatrix,"PRINT_DISSIMILARITY_MATRIX") + +void PrintDissimilarityMatrix::registerKeywords( Keywords& keys ){ + AnalysisBase::registerKeywords( keys ); + keys.add("compulsory","FILE","name of file on which to output the data"); + keys.add("optional","FMT","the format to use for the output of numbers"); +} + +PrintDissimilarityMatrix::PrintDissimilarityMatrix( const ActionOptions& ao ): +Action(ao), +AnalysisBase(ao), +fmt("%f") +{ + if( !dissimilaritiesWereSet() ) error("dissimilarities have not been set in base classes"); + + parse("FILE",fname); parse("FMT",fmt); + if( !getRestart() ){ OFile ofile; ofile.link(*this); ofile.setBackupString("analysis"); ofile.backupAllFiles(fname); } + log.printf(" printing to file named %s with formt %s \n",fname.c_str(), fmt.c_str() ); +} + +void PrintDissimilarityMatrix::performAnalysis(){ + std::string ofmt=" "+fmt; + OFile ofile; ofile.setBackupString("analysis"); ofile.open(fname); + for(unsigned i=0;i<getNumberOfDataPoints();++i){ + for(unsigned j=0;j<getNumberOfDataPoints();++j) ofile.printf(ofmt.c_str(), mydata->getDissimilarity( i,j ) ); + ofile.printf("\n"); + } + ofile.close(); +} + +} +} diff --git a/src/analysis/ReadDissimilarityMatrix.cpp b/src/analysis/ReadDissimilarityMatrix.cpp new file mode 100644 index 0000000000000000000000000000000000000000..935a7de8fb6db0fdf0abe7d6301684aa3b0e99f9 --- /dev/null +++ b/src/analysis/ReadDissimilarityMatrix.cpp @@ -0,0 +1,131 @@ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Copyright (c) 2013,2014 The plumed team + (see the PEOPLE file at the root of the distribution for a list of names) + + See http://www.plumed-code.org for more information. + + This file is part of plumed, version 2. + + plumed is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + plumed is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with plumed. If not, see <http://www.gnu.org/licenses/>. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +#include "AnalysisBase.h" +#include "core/PlumedMain.h" +#include "core/ActionSet.h" +#include "core/ActionRegister.h" +#include "tools/IFile.h" + +namespace PLMD { +namespace analysis { + +class ReadDissimilarityMatrix : public AnalysisBase { +private: + unsigned nnodes; + std::string fname, wfile; + Matrix<double> dissimilarities; + std::vector<double> weights; +public: + static void registerKeywords( Keywords& keys ); + ReadDissimilarityMatrix( const ActionOptions& ao ); + unsigned getNumberOfDataPoints() const { return nnodes; } +/// This gives an error as if we read in the matrix we dont have the coordinates + ReferenceConfiguration* getReferenceConfiguration( const unsigned& idata ); +/// This gives an error as if we read in the matrix we dont have the coordinates + void getDataPoint( const unsigned& idata, std::vector<double>& point, double& weight ) const ; +/// Tell everyone we have dissimilarities + bool dissimilaritiesWereSet() const { return true; } +/// Get the dissimilarity between two data points + double getDissimilarity( const unsigned& , const unsigned& ); +/// Get the weight from the input file + double getWeight( const unsigned& idata ) const ; +/// Just tell plumed to stop + void update(); +/// Read in the dissimilarity matrix + void performAnalysis(); +/// Overwrite virtual function in base class + void performTask( const unsigned& , const unsigned& , MultiValue& ) const { plumed_error(); } +}; + +PLUMED_REGISTER_ACTION(ReadDissimilarityMatrix,"READ_DISSIMILARITY_MATRIX") + +void ReadDissimilarityMatrix::registerKeywords( Keywords& keys ){ + AnalysisBase::registerKeywords( keys ); keys.remove("USE_OUTPUT_DATA_FROM"); + keys.add("compulsory","FILE","an input file containing the matrix of dissimilarities"); + keys.add("optional","WFILE","input file containing weights of points"); +} + +ReadDissimilarityMatrix::ReadDissimilarityMatrix( const ActionOptions& ao ): +Action(ao), +AnalysisBase(ao), +nnodes(1) +{ + if( plumed.getActionSet().size()!=0 ) error("read dissimilarity matrix command must be at top of input file"); + + parse("FILE",fname); + log.printf(" reading dissimilarity matrix from file %s \n",fname.c_str() ); + parse("WFILE",wfile); + if( wfile.length()>0 ) log.printf(" reading weights of nodes from file named %s \n",wfile.c_str() ); + else log.printf(" setting weights of all nodes equal to one\n"); + + // We have to set the information on how often we are reading data from the trajectory and how + // often we are running here so that the code behaves + use_all_data=true; freq=1; setStride(1); +} + +void ReadDissimilarityMatrix::update(){ plumed.stop(); } + +void ReadDissimilarityMatrix::performAnalysis(){ + IFile mfile; mfile.open(fname); + // Read in first line + std::vector<std::string> words; Tools::getParsedLine( mfile, words ); + nnodes=words.size(); dissimilarities.resize( nnodes, nnodes ); + for(unsigned j=0;j<nnodes;++j) Tools::convert( words[j], dissimilarities(0,j) ); + + for(unsigned i=1;i<nnodes;++i){ + Tools::getParsedLine( mfile, words ); + if( words.size()!=nnodes ) error("bad formatting in matrix file"); + for(unsigned j=0;j<nnodes;++j) Tools::convert( words[j], dissimilarities(i,j) ); + } + mfile.close(); + + weights.resize( nnodes ); + if( wfile.length()>0 ){ + IFile wfilef; wfilef.open(wfile); + for(unsigned i=0;i<nnodes;++i){ + Tools::getParsedLine( wfilef, words ); Tools::convert( words[0], weights[i] ); + } + wfilef.close(); + } else { + weights.assign(weights.size(),1.0); + } +} + +double ReadDissimilarityMatrix::getDissimilarity( const unsigned& iframe, const unsigned& jframe ){ + return dissimilarities( iframe, jframe ); +} + +ReferenceConfiguration* ReadDissimilarityMatrix::getReferenceConfiguration( const unsigned& idata ){ + plumed_merror("cannot get reference configurations from read in dissimilarity matrix"); + return NULL; +} + +void ReadDissimilarityMatrix::getDataPoint( const unsigned& idata, std::vector<double>& point, double& weight ) const { + plumed_merror("cannot get data points from read in dissmimilarity matrix"); +} + +double ReadDissimilarityMatrix::getWeight( const unsigned& idata ) const { + plumed_assert( idata<nnodes ); return weights[idata]; +} + +} +} diff --git a/src/analysis/SelectWithStride.cpp b/src/analysis/SelectWithStride.cpp new file mode 100644 index 0000000000000000000000000000000000000000..12a2ef97077b3cbc6bb68e3fbff6634b11a5091b --- /dev/null +++ b/src/analysis/SelectWithStride.cpp @@ -0,0 +1,53 @@ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Copyright (c) 2012-2014 The plumed team + (see the PEOPLE file at the root of the distribution for a list of names) + + See http://www.plumed-code.org for more information. + + This file is part of plumed, version 2. + + plumed is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + plumed is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with plumed. If not, see <http://www.gnu.org/licenses/>. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +#include "LandmarkSelectionBase.h" +#include "core/ActionRegister.h" + +namespace PLMD { +namespace analysis { + +class SelectWithStride : public LandmarkSelectionBase { +public: + static void registerKeywords( Keywords& keys ); + SelectWithStride( const ActionOptions& ao ); + void selectLandmarks(); +}; + +PLUMED_REGISTER_ACTION(SelectWithStride,"LANDMARK_SELECT_STRIDE") + +void SelectWithStride::registerKeywords( Keywords& keys ){ + LandmarkSelectionBase::registerKeywords( keys ); +} + +SelectWithStride::SelectWithStride( const ActionOptions& ao ): +Action(ao), +LandmarkSelectionBase(ao) +{ +} + +void SelectWithStride::selectLandmarks(){ + unsigned stride = std::floor( mydata->getNumberOfDataPoints() / getNumberOfDataPoints() ), max=stride*getNumberOfDataPoints(); + for(unsigned i=0;i<max;i+=stride) selectFrame( i ); +} + +} +}