Prerelease statgen 1.0.1

This commit is contained in:
arcan1s
2013-07-22 19:20:19 +04:00
parent 694751ce09
commit 7af8a487c1
10 changed files with 92 additions and 1317 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +0,0 @@
Mask: meth
Trajectory step: 1 3 (first; last)
Cell dimention: 24.42 24.40 24.49 (a; b; c)
Parametr: 2 (0 - gen.stat; 1 - gen.stat and bonds length; 2 - gen.stat and bonds length and form of agl; 3 - stat for once molecule)
Interaction: 2 (1 - mono; 2 - di)
Atom types: 6 21 (1st atom, 2nd atom; or atom)
Criteria: 3.2 2.4 (1-1 criterion, 1-2 criterion; or 1-1 criterion)
Num of mol.for stat: 4
Output: out_all.dat

View File

@ -6,6 +6,7 @@ int error_checking (const float *, const int, const char *, const int, const int
int printing_head (const char *, const int, const int, const char *, const int,
const int, const float *, const int, const int *, const int,
const float *, const int);
int print_message (const int, FILE *, const int, FILE *, const int, const char *);
int set_defaults (float *, int *, char *, int *, int *, int *, char *, int *,
int *, int *);

View File

@ -13,15 +13,7 @@ set (PRIVATE_CLASSES)
# headers only files
SET (HEADERS_ONLY)
# public srcs
set (PUBLIC_CLASSES add_main
coords
graph
int2char
messages
stat_print
stat_select
stat_sort
summary_stat)
set (PUBLIC_CLASSES)
# public headers
set (PUBLIC_HEADERS)
# shared libraries
@ -31,6 +23,17 @@ else ()
set (ADDITIONAL_LIB)
endif()
set (SOURCES)
# for library
set (LIBRARY_NAME stat)
set (LIB_SOURCES add_main
coords
graph
int2char
messages
stat_print
stat_select
stat_sort
summary_stat)
# append list
foreach (class ${PRIVATE_CLASSES})
@ -49,12 +52,15 @@ foreach (class ${PUBLIC_CLASSES})
endforeach ()
# link libraries and compile
add_library (${LIBRARY_NAME} SHARED ${LIB_SOURCES})
add_executable (${PROJECT} ${MAIN_SOURCES} ${SOURCES})
target_link_libraries (${PROJECT} ${ADDITIONAL_LIB})
target_link_libraries (${PROJECT} ${ADDITIONAL_LIB} ${LIBRARY_NAME})
# install properties
INSTALL (TARGETS ${PROJECT}
DESTINATION bin)
INSTALL (TARGETS ${LIBRARY_NAME}
DESTINATION lib${LIB_SUFFIX})
if (ADD_INCLUDE)
INSTALL (FILES ${PUBLIC_HEADERS}
DESTINATION include/${PROJECT})

View File

@ -2,6 +2,9 @@
*/
#include <stdio.h>
#include <string.h>
// #include "messages.h"
int error_checking (const float *cell, const int from, const char *input,
@ -36,7 +39,7 @@ int printing_head (const char *output, const int log, const int quiet,
FILE *f_out;
f_out = fopen (output, "w");
fprintf (f_out, "statgen ::: V.1.0.0 ::: 2013-07-17\n\n");
fprintf (f_out, "statgen ::: V.1.0.1 ::: 2013-07-23\n\n");
fprintf (f_out, "CONFIGURATION\n");
fprintf (f_out, "LOG=%i\nQUIET=%i\n", log, quiet);
@ -64,6 +67,18 @@ int printing_head (const char *output, const int log, const int quiet,
}
int print_message (const int quiet, FILE *std_output, const int log, FILE *f_log,
const int mode, const char *str)
{
if (quiet != 1)
message (0, mode, str, std_output);
if (log == 1)
message (1, mode, str, f_log);
return 0;
}
int set_defaults (float *cell, int *from, char *input, int *log, int *max_depth,
int *num_of_inter, char *output, int *to, int *type_inter, int *quiet)
{

View File

@ -105,6 +105,9 @@ int graph_analyze (const int N, const int *matrix, const int max_depth, int *iso
// convert to matrix of weight
pn = (int *) malloc (N * sizeof (int));
n_cycle = (int *) malloc ((depth - 2) * sizeof (int));
if ((pn == NULL) ||
(n_cycle == NULL))
return 1;
for (i=0; i<N; i++)
pn[i] = 0;
for (i=0; i<N; i++)
@ -129,5 +132,5 @@ int graph_analyze (const int N, const int *matrix, const int max_depth, int *iso
free (n_cycle);
free (pn);
return 1;
return 0;
}

View File

@ -78,7 +78,7 @@ int main (int argc, char *argv[])
{
sprintf (tmp_str, " statgen\n");
sprintf (tmp_str, "%sProgram for analyze molecular dynamic trajectories\n", tmp_str);
sprintf (tmp_str, "%sVersion : 1.0.0 License : GPL\n", tmp_str);
sprintf (tmp_str, "%sVersion : 1.0.1 License : GPL\n", tmp_str);
sprintf (tmp_str, "%s Evgeniy Alekseev aka arcanis\n", tmp_str);
sprintf (tmp_str, "%s E-mail : esalexeev@gmail.com\n\n", tmp_str);
sprintf (tmp_str, "%sUsage:\n", tmp_str);
@ -132,6 +132,8 @@ int main (int argc, char *argv[])
type_inter++;
label_atom = (int *) malloc (type_inter * sizeof (int));
if (label_atom == NULL)
return 1;
switch (type_inter)
{
case 1:
@ -198,16 +200,8 @@ int main (int argc, char *argv[])
if (log == 1)
f_log = fopen (logfile, "w");
if (quiet != 1)
{
message (0, 0, argv[0], stdout);
message (0, 1, argv[0], stdout);
}
if (log == 1)
{
message (1, 0, argv[0], f_log);
message (1, 1, argv[0], f_log);
}
print_message (quiet, stdout, log, f_log, 0, argv[0]);
print_message (quiet, stdout, log, f_log, 1, argv[0]);
// error checking
error = error_checking (cell, from, input, max_depth, num_of_inter, output, to,
@ -221,10 +215,7 @@ int main (int argc, char *argv[])
return 1;
}
if (quiet != 1)
message (0, 2, argv[0], stdout);
if (log == 1)
message (1, 2, argv[0], f_log);
print_message (quiet, stdout, log, f_log, 2, argv[0]);
// processing
// initial variables
@ -235,10 +226,7 @@ int main (int argc, char *argv[])
filename[k+2] = conv (from, 2);
filename[k+3] = conv (from, 1);
filename[k+4] = '\0';
if (quiet != 1)
message (0, 3, filename, stdout);
if (log == 1)
message (1, 3, filename, f_log);
print_message (quiet, stdout, log, f_log, 3, filename);
f_inp = fopen (filename, "r");
if (f_inp == NULL)
{
@ -282,58 +270,31 @@ int main (int argc, char *argv[])
// set type_agl to zero
for (i=0; i<max_depth+2; i++)
type_agl[i] = 0;
if (quiet != 1)
{
sprintf (tmp_str, "%6cOutput file: '%s';\n%6cLog: %i;\n%6cQuiet: %i;\n\
sprintf (tmp_str, "%6cOutput file: '%s';\n%6cLog: %i;\n%6cQuiet: %i;\n\
%6cMask: %s;\n%6cFirst step: %i;\n%6cLast step: %i;\n%6cCell size: %.4f, %.4f, %.4f;\n\
%6cSelect atoms: %i", ' ', output, ' ', log, ' ', quiet, ' ', input, ' ', from,
' ' , to, ' ', cell[0], cell[1], cell[2], ' ' , label_atom[0]);
for (i=1; i<type_inter; i++)
sprintf (tmp_str, "%s,%i", tmp_str, label_atom[i]);
sprintf (tmp_str, "%s;\n", tmp_str);
for (i=0; i<num_of_inter; i++)
{
sprintf (tmp_str, "%s%6cInteraction: ", tmp_str, ' ');
for (j=0; j<16; j++)
if ((crit[16*i+j] != 0.0) &&
((j != 4) && (j != 8) && (j != 9) && (j != 12) && (j != 13) && (j != 14)))
sprintf (tmp_str, "%s%i-%i:%4.2f,", tmp_str, j/4, j%4, crit[16*i+j]);
sprintf (tmp_str, "%s;\n", tmp_str);
}
sprintf (tmp_str, "%s%6cIsomorphism check: %i\n", tmp_str, ' ', max_depth);
message (0, 5, tmp_str, stdout);
}
if (log == 1)
for (i=1; i<type_inter; i++)
sprintf (tmp_str, "%s,%i", tmp_str, label_atom[i]);
sprintf (tmp_str, "%s;\n", tmp_str);
for (i=0; i<num_of_inter; i++)
{
sprintf (tmp_str, "%34cOutput file: '%s';\n%34cLog: %i;\n%34cQuiet: %i;\n\
%34cMask: %s;\n%34cFirst step: %i;\n%34cLast step: %i;\n%34cCell size: %.4f, %.4f, %.4f;\n\
%34cSelect atoms: %i", ' ', output, ' ', log, ' ', quiet, ' ', input, ' ', from,
' ' , to, ' ', cell[0], cell[1], cell[2], ' ' , label_atom[0]);
for (i=1; i<type_inter; i++)
sprintf (tmp_str, "%s,%i", tmp_str, label_atom[i]);
sprintf (tmp_str, "%s%6cInteraction: ", tmp_str, ' ');
for (j=0; j<16; j++)
if ((crit[16*i+j] != 0.0) &&
((j != 4) && (j != 8) && (j != 9) && (j != 12) && (j != 13) && (j != 14)))
sprintf (tmp_str, "%s%i-%i:%4.2f,", tmp_str, j/4, j%4, crit[16*i+j]);
sprintf (tmp_str, "%s;\n", tmp_str);
for (i=0; i<num_of_inter; i++)
{
sprintf (tmp_str, "%s%34cInteraction: ", tmp_str, ' ');
for (j=0; j<16; j++)
if ((crit[16*i+j] != 0.0) &&
((j != 4) && (j != 8) && (j != 9) && (j != 12) && (j != 13) && (j != 14)))
sprintf (tmp_str, "%s%i-%i:%4.2f,", tmp_str, j/4, j%4, crit[16*i+j]);
sprintf (tmp_str, "%s;\n", tmp_str);
}
sprintf (tmp_str, "%s%34cIsomorphism check: %i\n", tmp_str, ' ', max_depth);
message (1, 5, tmp_str, f_log);
}
sprintf (tmp_str, "%s%6cIsomorphism check: %i\n", tmp_str, ' ', max_depth);
print_message (quiet, stdout, log, f_log, 5, tmp_str);
// head
printing_head (output, log, quiet, input, from, to, cell, type_inter, label_atom,
num_of_inter, crit, max_depth);
// main cycle
if (quiet != 1)
message (0, 6, argv[0], stdout);
if (log == 1)
message (1, 6, argv[0], f_log);
print_message (quiet, stdout, log, f_log, 6, argv[0]);
for (i=from; i<to+1; i++)
{
// reading coordinates
@ -341,26 +302,14 @@ int main (int argc, char *argv[])
filename[k+2] = conv (i, 2);
filename[k+3] = conv (i, 1);
filename[k+4] = '\0';
if (quiet != 1)
message (0, 7, filename, stdout);
if (log == 1)
message (1, 7, filename, f_log);
print_message (quiet, stdout, log, f_log, 7, filename);
error = reading_coords (filename, type_inter, label_atom, cell, &num_mol,
&num_atoms, true_label_mol, label_mol, type_atoms, coords);
if (error != 1)
{
if (quiet != 1)
{
sprintf (tmp_str, "%6cNumber of molecules: %i\n%6cNumber of atoms: %i\n",
sprintf (tmp_str, "%6cNumber of molecules: %i; %6cNumber of atoms: %i\n",
' ', num_mol, ' ', num_atoms);
message (0, 8, tmp_str, stdout);
}
if (log == 1)
{
sprintf (tmp_str, "%6cNumber of molecules: %i\n%34cNumber of atoms: %i\n",
' ', num_mol, ' ', num_atoms);
message (1, 8, tmp_str, f_log);
}
print_message (quiet, stdout, log, f_log, 8, tmp_str);
}
// resize dynamic arrays
@ -387,62 +336,37 @@ int main (int argc, char *argv[])
fputs (tmp_str, f_log);
return 18;
}
if (quiet != 1)
message (0, 9, argv[0], stdout);
if (log == 1)
message (1, 9, argv[0], f_log);
print_message (quiet, stdout, log, f_log, 9, argv[0]);
// analyze
if (error == 0)
{
error = 1;
error = create_matrix (num_mol, num_atoms, label_mol, type_atoms, coords,
num_of_inter, crit, connect);
num_of_inter, crit, connect);
if (error == 0)
{
if (quiet != 1)
message (0, 10, argv[0], stdout);
if (log == 1)
message (1, 10, argv[0], f_log);
print_message (quiet, stdout, log, f_log, 10, argv[0]);
error = 1;
error = proc_matrix (num_mol, connect, num_mol_agl, agl, stat, stat_all);
if (error == 0)
{
if (quiet != 1)
message (0, 11, argv[0], stdout);
if (log == 1)
message (1, 11, argv[0], f_log);
print_message (quiet, stdout, log, f_log, 11, argv[0]);
error = printing_agl (filename, output, connect, num_mol, true_label_mol,
num_mol_agl, agl, stat, max_depth, type_agl);
if (error == 0)
{
if (quiet != 1)
message (0, 12, output, stdout);
if (log == 1)
message (1, 12, output, f_log);
}
print_message (quiet, stdout, log, f_log, 12, output);
}
}
}
}
if (quiet != 1)
{
message (0, 13, argv[0], stdout);
message (0, 14, output, stdout);
}
if (log == 1)
{
message (1, 13, argv[0], f_log);
message (1, 14, output, f_log);
}
print_message (quiet, stdout, log, f_log, 13, argv[0]);
print_message (quiet, stdout, log, f_log, 14, output);
// tail
summary_statistic (output, step, num_mol, max_depth, type_agl, stat_all);
if (quiet != 1)
message (0, 15, argv[0], stdout);
if (log == 1)
message (1, 15, argv[0], f_log);
print_message (quiet, stdout, log, f_log, 15, argv[0]);
// free memory
free (agl);
free (connect);
@ -456,10 +380,7 @@ int main (int argc, char *argv[])
free (type_agl);
free (type_atoms);
if (quiet != 1)
message (0, 16, argv[0], stdout);
if (log == 1)
message (1, 16, argv[0], f_log);
print_message (quiet, stdout, log, f_log, 16, argv[0]);
if (log == 1)
fclose (f_log);

View File

@ -1,14 +1,14 @@
/* Library for printing messages at stdout
/* Library for printing messages at output
*
* Usage:
* message (log, mode, text, stdout)
* message (log, mode, text, output)
*/
#include <stdio.h>
#include <time.h>
int message (const int log, const int mode, const char *text, FILE *stdout)
int message (const int log, const int mode, const char *text, FILE *output)
/* mode - number of message
* text - additional text
*/
@ -18,17 +18,17 @@ int message (const int log, const int mode, const char *text, FILE *stdout)
if (log == 1)
{
char time_str[256];
time_t t = time(NULL);
struct tm* aTm = localtime(&t);
sprintf(time_str, "[%04d-%02d-%02d %02d:%02d:%02d] [%2i]: ", aTm->tm_year+1900,
time_t t = time (NULL);
struct tm* aTm = localtime (&t);
sprintf (time_str, "[%04d-%02d-%02d %02d:%02d:%02d] [%2i]: ", aTm->tm_year+1900,
aTm->tm_mon+1, aTm->tm_mday, aTm->tm_hour, aTm->tm_min, aTm->tm_sec, mode);
fputs (time_str, stdout);
fputs (time_str, output);
}
switch (mode)
{
case 0:
sprintf (out, "Starting program: '%s' (Ver.1.0.0)\n", text);
sprintf (out, "Starting program: '%s'\n", text);
break;
case 1:
sprintf (out, "Checking errors\n");
@ -79,6 +79,6 @@ int message (const int log, const int mode, const char *text, FILE *stdout)
break;
}
fputs (out, stdout);
fputs (out, output);
return 0;
}

View File

@ -27,7 +27,7 @@ int printing_agl (const char *input, const char *output, const int *connect,
* type_agl - massive of numbers of aglomerate types
*/
{
int i, *iso, j, k, *label_matrix, *matrix;
int error, i, *iso, j, k, *label_matrix, *matrix;
FILE *f_out;
/* iso - isomorphic graph in database
* label_matrix - massive of indexes of molecule
@ -36,6 +36,8 @@ int printing_agl (const char *input, const char *output, const int *connect,
*/
iso = (int *) malloc (max_depth * sizeof (int));
if (iso == NULL)
return 1;
f_out = fopen (output, "a");
// head
@ -50,14 +52,14 @@ int printing_agl (const char *input, const char *output, const int *connect,
if (num_mol_agl[i] > 0)
{
// creating connectivity graph
matrix = (int *) malloc (num_mol_agl[i] * num_mol_agl[i] * sizeof (int));
for (j=0; j<num_mol_agl[i]; j++)
for (k=0; k<num_mol_agl[i]; k++)
matrix[num_mol_agl[i]*j+k] = 0;
label_matrix = (int *) malloc (num_mol * sizeof (int));
matrix = (int *) malloc (num_mol_agl[i] * num_mol_agl[i] * sizeof (int));
if ((matrix == NULL) ||
(label_matrix == NULL))
return 1;
for (j=0; j<num_mol_agl[i]; j++)
for (k=0; k<num_mol_agl[i]; k++)
matrix[num_mol_agl[i]*j+k] = 0;
for (j=0; j<num_mol_agl[i]; j++)
label_matrix[agl[num_mol*i+j]] = j;
@ -71,7 +73,9 @@ int printing_agl (const char *input, const char *output, const int *connect,
// graph topology analyze
if (max_depth > 0)
graph_analyze (num_mol_agl[i], matrix, max_depth, iso);
error = graph_analyze (num_mol_agl[i], matrix, max_depth, iso);
if (error > 0)
return 1;
// printing class of aglomerate
fprintf (f_out, "AGL=%i=", num_mol_agl[i]);

View File

@ -1,13 +1,12 @@
# set directories
set ("${PROJECT}_BINARY_DIR" bin)
set ("${PROJECT}_SOURCE_DIR" src:include)
set ("${PROJECT}_LIB_DIR" lib)
set (${PROJECT}_BINARY_DIR bin)
set (${PROJECT}_SOURCE_DIR src:include)
set (${PROJECT}_LIB_DIR lib)
set (CMAKE_INCLUDE_PATH ${${PROJECT}_SOURCE_DIR})
set (CMAKE_LIBRARY_PATH ${${PROJECT}_LIB_DIR})
set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/${${PROJECT}_BINARY_DIR})
set (CMAKE_VERBOSE_MAKEFILE ON)
set (CMAKE_BUILD_TYPE Debug)
if ( WITH_DEBUG_MODE )
ADD_DEFINITIONS ( -DDEBUG_MODE=1 )
@ -18,5 +17,5 @@ if ( CMAKE_COMPILER_IS_GNUCXX )
set (CMAKE_CXX_FLAGS "-O0 ${ADD_CXX_FLAGS}")
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
else ()
message ("not yet")
message ("Not enabled")
endif ()