mirror of
https://github.com/arcan1s/moldyn.git
synced 2025-07-22 18:19:58 +00:00
Prerelease mm_trj
edited logo edited Makefile's
This commit is contained in:
29
mm_trj/src/CMakeLists.txt
Normal file
29
mm_trj/src/CMakeLists.txt
Normal file
@ -0,0 +1,29 @@
|
||||
set ("${PROJECT}_VERSION_MAJOR" 1)
|
||||
set ("${PROJECT}_VERSION_MINOR" 0)
|
||||
set ("${PROJECT}_VERSION_PATCH" 1)
|
||||
set ("${PROJECT}_VERSION" ${${PROJECT}_VERSION_MAJOR}.${${PROJECT}_VERSION_MINOR}.${${PROJECT}_VERSION_PATCH})
|
||||
|
||||
message (STATUS "${PROJECT}: Version ${${PROJECT}_VERSION}")
|
||||
|
||||
# set files
|
||||
aux_source_directory (. SOURCES)
|
||||
|
||||
# set library
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
set (ADDITIONAL_LIB m)
|
||||
else ()
|
||||
set (ADDITIONAL_LIB)
|
||||
endif()
|
||||
|
||||
# message
|
||||
message (STATUS "SOURCES: ${SOURCES}")
|
||||
|
||||
# link libraries and compile
|
||||
add_executable (${PROJECT} ${SOURCES})
|
||||
target_link_libraries (${PROJECT} ${ADDITIONAL_LIB})
|
||||
|
||||
# install properties
|
||||
INSTALL (TARGETS ${PROJECT} DESTINATION bin)
|
||||
if (ADD_INCLUDE)
|
||||
INSTALL (FILES ${PUBLIC_HEADERS} DESTINATION include/${PROJECT})
|
||||
endif ()
|
21
mm_trj/src/Makefile
Normal file
21
mm_trj/src/Makefile
Normal file
@ -0,0 +1,21 @@
|
||||
PROJECT=TRJ
|
||||
|
||||
CC=gcc
|
||||
CFLAGS=-c -Wall -fPIC
|
||||
LDFLAGS=-lm
|
||||
SOURCES_DIR=src
|
||||
SOURCES=main.c add_main.c atom_types.c messages.c read_gmx.c read_puma.c print_trj.c
|
||||
OBJECTS=$(SOURCES:.c=.o)
|
||||
EXECUTABLE=mm_trj
|
||||
|
||||
$(PROJECT): $(SOURCES) $(EXECUTABLE)
|
||||
|
||||
$(EXECUTABLE): $(OBJECTS)
|
||||
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f *.o test*
|
||||
|
113
mm_trj/src/add_main.c
Normal file
113
mm_trj/src/add_main.c
Normal file
@ -0,0 +1,113 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "messages.h"
|
||||
|
||||
|
||||
/**
|
||||
* @fn error_checking
|
||||
*/
|
||||
int error_checking (const char *input, const char *input_at, const char *output,
|
||||
const int step, const int type)
|
||||
/**
|
||||
* @brief function that checks errors in input variables
|
||||
* @code
|
||||
* error_checking (cell, from, input, num_needed_at, needed_at, output, to);
|
||||
* @endcode
|
||||
*
|
||||
* @param input input file name
|
||||
* @param input_at input file name with atom types
|
||||
* @param output output file name
|
||||
* @param step number of trajectory steps
|
||||
* @param type type of trajectory
|
||||
*
|
||||
* @return 11 - error in 'input_at'
|
||||
* @return 12 - error in 'input'
|
||||
* @return 13 - error in 'output'
|
||||
* @return 14 - error in 'step'
|
||||
* @return 15 - error in 'type'
|
||||
* @return 0 - exit without errors
|
||||
*/
|
||||
{
|
||||
if (input_at[0] == '#')
|
||||
return 11;
|
||||
if (input[0] == '#')
|
||||
return 12;
|
||||
if (output[0] == '#')
|
||||
return 13;
|
||||
if (step == 0)
|
||||
return 14;
|
||||
if (type == -1)
|
||||
return 15;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn print_message
|
||||
*/
|
||||
int print_message (const int quiet, FILE *std_output, const int log, FILE *f_log,
|
||||
const int mode, const char *str)
|
||||
/**
|
||||
* @brief function that prints message in log and stdout
|
||||
* @code
|
||||
* print_message (quiet, stdout, log, f_log, 0, str);
|
||||
* @endcode
|
||||
*
|
||||
* @param quiet status of quiet-mode
|
||||
* @param std_output stdout
|
||||
* @param log status of log-mode
|
||||
* @param f_log log file
|
||||
* @param mode number of message in "messages.c"
|
||||
* @param str additional text in message
|
||||
*
|
||||
* @return 0 - exit without errors
|
||||
*/
|
||||
{
|
||||
if ((quiet != 1) && (std_output != stderr))
|
||||
message (0, mode, str, std_output);
|
||||
if (log == 1)
|
||||
message (1, mode, str, f_log);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn set_defaults
|
||||
*/
|
||||
int set_defaults (char *input, char *input_at, int *log, char *output, int *step,
|
||||
int *total_types, int *type, int *quiet)
|
||||
/**
|
||||
* @brief function that sets default values of variables
|
||||
* @code
|
||||
* set_defaults (input, input_at, &log, output, &step, &type, &quiet);
|
||||
* @endcode
|
||||
*
|
||||
* @param input input file name
|
||||
* @param input_at input file name with atom types
|
||||
* @param log status of log-mode
|
||||
* @param output output file name
|
||||
* @param step number of trajectory steps
|
||||
* @param total_types number of different atom types
|
||||
* @param type type of trajectory
|
||||
* @param quiet status of quiet-mode
|
||||
*
|
||||
* @return 0 - exit without errors
|
||||
*/
|
||||
{
|
||||
input[0] = '#';
|
||||
input_at[0] = '#';
|
||||
*log = 0;
|
||||
output[0] = '#';
|
||||
*step = 0;
|
||||
*total_types = 1024;
|
||||
*type = -1;
|
||||
*quiet = 0;
|
||||
|
||||
return 0;
|
||||
}
|
22
mm_trj/src/add_main.h
Normal file
22
mm_trj/src/add_main.h
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#ifndef ADD_MAIN_H
|
||||
#define ADD_MAIN_H
|
||||
|
||||
/**
|
||||
* @fn error_checking
|
||||
*/
|
||||
/**
|
||||
* @fn print_message
|
||||
*/
|
||||
/**
|
||||
* @fn set_defaults
|
||||
*/
|
||||
|
||||
int error_checking (const char *, const char *, const char *, const int, const int);
|
||||
int print_message (const int, FILE *, const int, FILE *, const int, const char *);
|
||||
int set_defaults (char *, char *, int *, char *, int *, int *, int *, int *);
|
||||
|
||||
#endif /* ADD_MAIN_H */
|
87
mm_trj/src/atom_types.c
Normal file
87
mm_trj/src/atom_types.c
Normal file
@ -0,0 +1,87 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/**
|
||||
* @fn reading_atoms
|
||||
*/
|
||||
int reading_atoms (const char *input_at, int *num_types, int *num_mol, int *num_atoms,
|
||||
char *ch_atom_types, int *atom_types, const int total_types)
|
||||
/**
|
||||
* @brief function that reads atom types from input file
|
||||
* @code
|
||||
* reading_atoms (input_at, &num_types, num_mol, num_atoms, ch_atom_types, atom_types,
|
||||
* total_types);
|
||||
* @endcode
|
||||
*
|
||||
* @param input_at input file name with atom types
|
||||
* @param num_types number of molecule types
|
||||
* @param num_mol massive of number of molecules of selected type
|
||||
* @param num_atoms massive of number of atoms of selected molecule
|
||||
* @param ch_atom_types massive of char atom types
|
||||
* @param atom_types massive of atom types
|
||||
* @param total_types number of different atom types
|
||||
*
|
||||
* @return 1 - error in opening file
|
||||
* @return 2 - error in file format
|
||||
* @return 3 - memory error
|
||||
* @return 0 - exit without errors
|
||||
*/
|
||||
{
|
||||
char at_symb[2], tmp_str[256];
|
||||
int at_ndx, i, j, total_atoms;
|
||||
FILE *f_inp;
|
||||
|
||||
/* at_* temp variables
|
||||
* total_atoms total atom types
|
||||
* f_inp input file
|
||||
*/
|
||||
|
||||
f_inp = fopen (input_at, "r");
|
||||
if (f_inp == NULL)
|
||||
return 1;
|
||||
|
||||
fgets (tmp_str, 256, f_inp);
|
||||
sscanf (tmp_str, "NUMTYPES=%i", num_types);
|
||||
if (*num_types == 0)
|
||||
return 2;
|
||||
else if (*num_types > total_types)
|
||||
return 3;
|
||||
|
||||
total_atoms = 0;
|
||||
for (i=0; i<*num_types; i++)
|
||||
{
|
||||
// read constants
|
||||
fgets (tmp_str, 256, f_inp);
|
||||
sscanf (tmp_str, "NUMMOL=%i", &num_mol[i]);
|
||||
if (num_mol[i] == 0)
|
||||
return 2;
|
||||
fgets (tmp_str, 256, f_inp);
|
||||
sscanf (tmp_str, "NUMAT=%i", &num_atoms[i]);
|
||||
if (num_atoms[i] == 0)
|
||||
return 2;
|
||||
else if ((total_atoms + num_atoms[i]) > total_types)
|
||||
return 2;
|
||||
|
||||
// read atoms
|
||||
for (j=0; j<num_atoms[i]; j++)
|
||||
{
|
||||
fgets (tmp_str, 256, f_inp);
|
||||
at_ndx = -1;
|
||||
sscanf (tmp_str, "%2s=%i", at_symb, &at_ndx);
|
||||
if (at_ndx == -1)
|
||||
return 2;
|
||||
ch_atom_types[2*total_atoms+2*j+0] = at_symb[0];
|
||||
ch_atom_types[2*total_atoms+2*j+1] = at_symb[1];
|
||||
atom_types[total_atoms+j] = at_ndx;
|
||||
}
|
||||
total_atoms += num_atoms[i];
|
||||
}
|
||||
|
||||
fclose (f_inp);
|
||||
|
||||
return 0;
|
||||
}
|
14
mm_trj/src/atom_types.h
Normal file
14
mm_trj/src/atom_types.h
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#ifndef ATOM_TYPES_H
|
||||
#define ATOM_TYPES_H
|
||||
|
||||
/**
|
||||
* @fn reading_atoms
|
||||
*/
|
||||
|
||||
int reading_atoms (const char *, int *, int *, int *, char *, int *, const int);
|
||||
|
||||
#endif /* ATOM_TYPES_H */
|
313
mm_trj/src/main.c
Normal file
313
mm_trj/src/main.c
Normal file
@ -0,0 +1,313 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
/**
|
||||
* @mainpage mm_trj
|
||||
* @image latex ./logo.png
|
||||
*
|
||||
* @section intro_sec Introduction
|
||||
*
|
||||
* <b>About this program</b>:
|
||||
* <ul>
|
||||
* <li>Program that generates trajectory files
|
||||
* </ul>
|
||||
*
|
||||
* <b>Developer</b>:
|
||||
* <ul>
|
||||
* <li>Evgeniy Alekseev aka arcanis <pre><esalexeev (at) gmail (dot) com></pre>
|
||||
*</ul>
|
||||
* <b>License</b>:
|
||||
* <ul>
|
||||
* <li>GPL
|
||||
* </ul>
|
||||
*
|
||||
* @section How-To-Use How to use
|
||||
* Usage:
|
||||
* <pre>
|
||||
* mm_radf -i INPUT -s FIRST,LAST -c X,Y,Z -a ... -o OUTPUT [ -r MIN,MAX ] [ -rs R_STEP ]
|
||||
* [ -a MIN,MAX ] [ -as ANG_STEP ] [ -m ] [ -l LOGFILE ] [ -q ] [ -h ]
|
||||
* Parametrs:
|
||||
* -i - mask of input files
|
||||
* -s - trajectory steps (integer)
|
||||
* -c - cell size (float), A
|
||||
* -a - atom types (integer). Format: 'ATOM1-ATOM2' or 'A1,A2,A3-B1,B2,B3'
|
||||
* (will enable RDF calculation for center mass automaticaly)
|
||||
* -o - output file name
|
||||
* -r - minimal and maximal radii for analyze (float), A. Default is '2.0,15.0'
|
||||
* -rs - radius step for analyze (float), A. Default is '0.2'
|
||||
* -a - minimal and maximal angles for analyze (float), deg. Default is '0.0,90.0'
|
||||
* -as - angle step for analyze (float), deg. This option will enable RADF
|
||||
* calculation automaticaly
|
||||
* -m - matrix output enable
|
||||
* -l - log enable
|
||||
* -q - quiet enable
|
||||
* -h - show this help and exit
|
||||
* </pre>
|
||||
*
|
||||
* @page Install
|
||||
*
|
||||
* @section Requirements Requirements
|
||||
* The application mm_trj requires the following external stuff:
|
||||
* - cmake >= 2.8
|
||||
* - gcc >= 4.8
|
||||
*
|
||||
* @section How-To How to install
|
||||
*
|
||||
* @subsection Linux Linux
|
||||
* @code
|
||||
* mkdir build && cd build
|
||||
* cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release ../
|
||||
* make
|
||||
* make install
|
||||
* @endcode
|
||||
*
|
||||
* @subsection Windows Windows
|
||||
* @code
|
||||
* create project file using 'cmake'
|
||||
* compile project
|
||||
* @endcode
|
||||
* You may also download compiled executable file for Win_x86.
|
||||
*
|
||||
* @page Changelog
|
||||
* V.1.0.1 (2013-07-27)
|
||||
* * initial release
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "add_main.h"
|
||||
#include "atom_types.h"
|
||||
#include "messages.h"
|
||||
#include "print_trj.h"
|
||||
#include "read_gmx.h"
|
||||
#include "read_puma.h"
|
||||
|
||||
|
||||
/**
|
||||
* @fn main
|
||||
*/
|
||||
int main(int argc, char *argv[])
|
||||
/**
|
||||
* @return 1 - error in error_checking
|
||||
* @return 2 - input file does not exist
|
||||
* @return 3 - memory error
|
||||
* @return 4 - unknown flag
|
||||
* @return 0 - exit without errors
|
||||
*/
|
||||
{
|
||||
char tmp_str[2048];
|
||||
int error, i;
|
||||
FILE *f_inp, *f_log;
|
||||
|
||||
char *ch_atom_types, input[256], input_at[256], logfile[256], output[256];
|
||||
float *coords;
|
||||
int *atom_types, log, *num_atoms, *num_mol, num_types, quiet, step, total_types, type;
|
||||
|
||||
/* ch_atom_types massive of char atom types
|
||||
* input input file name
|
||||
* input_at input file name with atom types
|
||||
* logfile log file name
|
||||
* output mask of output files
|
||||
*
|
||||
* coords massive of coordinates
|
||||
*
|
||||
* atom_types massive of atom types
|
||||
* log status of log-mode
|
||||
* num_atoms massive of number of atoms of selected molecule
|
||||
* num_mol massive of number of molecule of selected type
|
||||
* num_types number of molecule types
|
||||
* quiet status of quiet-mode
|
||||
* step number of trajectory steps
|
||||
* total_types number of different atom types
|
||||
* type type of trajectory
|
||||
*/
|
||||
|
||||
set_defaults (input, input_at, &log, output, &step, &total_types, &type, &quiet);
|
||||
|
||||
for (i=1; i<argc; i++)
|
||||
{
|
||||
if ((argv[i][0] == '-') && (argv[i][1] == 'h') && (argv[i][2] == '\0'))
|
||||
{
|
||||
sprintf (tmp_str, " mm_trj\n");
|
||||
sprintf (tmp_str, "%sProgram that generates trajectory files\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);
|
||||
sprintf (tmp_str, "%smm_trj -i INPUT_TRJ -t INPUT_TYPE -s NUMBER -a INPUT_ATOMS -o OUTPUT [ -tt TOTAL_TYPES ]\n", tmp_str);
|
||||
sprintf (tmp_str, "%s [ -l LOGFILE ] [ -q ] [ -h ]\n\n", tmp_str);
|
||||
sprintf (tmp_str, "%sParametrs:\n", tmp_str);
|
||||
sprintf (tmp_str, "%s -i - input file name\n", tmp_str);
|
||||
sprintf (tmp_str, "%s -t - type of trajectory. Supported formats: gmx, puma\n", tmp_str);
|
||||
sprintf (tmp_str, "%s -s - number of trajectory steps (integer)\n", tmp_str);
|
||||
sprintf (tmp_str, "%s -a - input file with atom types. See file format in manual\n", tmp_str);
|
||||
sprintf (tmp_str, "%s -o - mask of output files\n", tmp_str);
|
||||
sprintf (tmp_str, "%s -tt - number of different atom types. Default is 1024\n", tmp_str);
|
||||
sprintf (tmp_str, "%s -l - log enable\n", tmp_str);
|
||||
sprintf (tmp_str, "%s -q - quiet enable\n", tmp_str);
|
||||
sprintf (tmp_str, "%s -h - show this help and exit\n", tmp_str);
|
||||
fputs (tmp_str, stdout);
|
||||
return 0;
|
||||
}
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == 'i') && (argv[i][2] == '\0'))
|
||||
// input file
|
||||
{
|
||||
strcpy (input, argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == 't') && (argv[i][2] == '\0'))
|
||||
// type
|
||||
{
|
||||
if ((argv[i+1][0] == 'g') && (argv[i+1][1] == 'm') && (argv[i+1][2] == 'x') &&
|
||||
(argv[i+1][3] == '\0'))
|
||||
// gromacs text file
|
||||
type = 0;
|
||||
else if ((argv[i+1][0] == 'p') && (argv[i+1][1] == 'u') && (argv[i+1][2] == 'm') &&
|
||||
(argv[i+1][3] == 'a') && (argv[i+1][4] == '\0'))
|
||||
// puma
|
||||
type = 1;
|
||||
i++;
|
||||
}
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == 's') && (argv[i][2] == '\0'))
|
||||
// steps
|
||||
{
|
||||
sscanf (argv[i+1], "%i", &step);
|
||||
i++;
|
||||
}
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == 'a') && (argv[i][2] == '\0'))
|
||||
// atom types
|
||||
{
|
||||
strcpy (input_at, argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == 'o') && (argv[i][2] == '\0'))
|
||||
// output file
|
||||
{
|
||||
strcpy (output, argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == 't') && (argv[i][1] == 't') && (argv[i][2] == '\0'))
|
||||
// number of atom types
|
||||
{
|
||||
sscanf (argv[i+1], "%i", &total_types);
|
||||
i++;
|
||||
}
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == 'l') && (argv[i][2] == '\0'))
|
||||
// log mode
|
||||
{
|
||||
log = 1;
|
||||
strcpy (logfile, argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == 'q') && (argv[i][2] == '\0'))
|
||||
// quiet mode
|
||||
{
|
||||
quiet = 1;
|
||||
}
|
||||
else
|
||||
// unknown flag
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (log == 1)
|
||||
f_log = fopen (logfile, "w");
|
||||
|
||||
print_message (quiet, stdout, log, f_log, 0, argv[0]);
|
||||
print_message (quiet, stdout, log, f_log, 1, argv[0]);
|
||||
|
||||
// error check
|
||||
error = error_checking (input, input_at, output, step, type);
|
||||
if (error != 0)
|
||||
{
|
||||
print_message (quiet, stderr, log, f_log, 17, argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
print_message (quiet, stdout, log, f_log, 2, argv[0]);
|
||||
|
||||
// processing
|
||||
// initial variables
|
||||
print_message (quiet, stdout, log, f_log, 3, input);
|
||||
f_inp = fopen (input, "r");
|
||||
if (f_inp == NULL)
|
||||
return 2;
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
fgets (tmp_str, 256, f_inp);
|
||||
fgets (tmp_str, 256, f_inp);
|
||||
sscanf (tmp_str, " natoms=%i%s", &i, tmp_str);
|
||||
break;
|
||||
case 1:
|
||||
fgets (tmp_str, 256, f_inp);
|
||||
sscanf (tmp_str, "%s%s%i%s", tmp_str, tmp_str, &i, tmp_str);
|
||||
break;
|
||||
}
|
||||
fclose (f_inp);
|
||||
atom_types = (int *) malloc (total_types * sizeof (int));
|
||||
ch_atom_types = (char *) malloc (2 * total_types * sizeof (char));
|
||||
coords = (float *) malloc (3 * i * sizeof (float));
|
||||
num_atoms = (int *) malloc (total_types * sizeof (int));
|
||||
num_mol = (int *) malloc (total_types * sizeof (int));
|
||||
num_types = 0;
|
||||
if ((atom_types == NULL) ||
|
||||
(ch_atom_types == NULL) ||
|
||||
(coords == NULL) ||
|
||||
(num_atoms == NULL) ||
|
||||
(num_mol == NULL))
|
||||
{
|
||||
print_message (quiet, stderr, log, f_log, 19, argv[0]);
|
||||
return 3;
|
||||
}
|
||||
print_message (quiet, stdout, log, f_log, 6, argv[0]);
|
||||
// read atom types
|
||||
error = 1;
|
||||
error = reading_atoms (input_at, &num_types, num_mol, num_atoms, ch_atom_types,
|
||||
atom_types, total_types);
|
||||
if (error == 0)
|
||||
{
|
||||
sprintf (tmp_str, "%6cLog: %i;\n%6cQuiet: %i;\n%6cInput file: %s;\n%6cTrajectory type: %i;\n\
|
||||
%6cNumber of trajectory step: %i;\n%6cInput file with atom types: %s;\n%6cMask of output file: %s;\n\
|
||||
%6cNumber of different atom types: %i;\n%6cNumber of different molecules: %i;\n%6cNumber of atoms in system: %i\n",
|
||||
' ', log, ' ', quiet, ' ', input, ' ', type, ' ', step, ' ', input_at, ' ', output,
|
||||
' ', total_types, ' ', num_types, ' ', i);
|
||||
print_message (quiet, stdout, log, f_log, 5, tmp_str);
|
||||
}
|
||||
else
|
||||
return 2;
|
||||
|
||||
print_message (quiet, stdout, log, f_log, 6, argv[0]);
|
||||
// main cycle
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
rw_gmx (input, step, output, num_types, num_mol, num_atoms, ch_atom_types,
|
||||
atom_types, coords);
|
||||
break;
|
||||
case 1:
|
||||
rw_puma (input, step, output, num_types, num_mol, num_atoms, ch_atom_types,
|
||||
atom_types, coords);
|
||||
break;
|
||||
}
|
||||
|
||||
print_message (quiet, stdout, log, f_log, 13, argv[0]);
|
||||
|
||||
print_message (quiet, stdout, log, f_log, 15, argv[0]);
|
||||
// free memory
|
||||
free (atom_types);
|
||||
free (ch_atom_types);
|
||||
free (coords);
|
||||
free (num_atoms);
|
||||
free (num_mol);
|
||||
|
||||
print_message (quiet, stdout, log, f_log, 16, argv[0]);
|
||||
|
||||
if (log == 1)
|
||||
fclose (f_log);
|
||||
return 0;
|
||||
}
|
119
mm_trj/src/messages.c
Normal file
119
mm_trj/src/messages.c
Normal file
@ -0,0 +1,119 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
/**
|
||||
* @fn message
|
||||
*/
|
||||
int message (const int log, const int mode, const char *text, FILE *output)
|
||||
/**
|
||||
* @brief function that prints messages to output
|
||||
* @code
|
||||
* message (log, mode, text, output);
|
||||
* @endcode
|
||||
*
|
||||
* @param log equal to 1 if print to logfile
|
||||
* @param mode number of message
|
||||
* @param text additional text
|
||||
* @param output output file (may be stdout)
|
||||
*
|
||||
* @return 1 - unknown mode
|
||||
* @return 0 - exit without errors
|
||||
*/
|
||||
{
|
||||
char out[4096];
|
||||
|
||||
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,
|
||||
aTm->tm_mon+1, aTm->tm_mday, aTm->tm_hour, aTm->tm_min, aTm->tm_sec, mode);
|
||||
fputs (time_str, output);
|
||||
}
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
sprintf (out, "Start program: '%s'\n", text);
|
||||
break;
|
||||
case 1:
|
||||
sprintf (out, "Checking errors\n");
|
||||
break;
|
||||
case 2:
|
||||
sprintf (out, "Errors are not detected\n");
|
||||
break;
|
||||
case 3:
|
||||
sprintf (out, "Initialization of variables from file '%s'\n", text);
|
||||
break;
|
||||
case 4:
|
||||
sprintf (out, "%6cAglomerate was selected successfully\n", ' ');
|
||||
break;
|
||||
case 5:
|
||||
sprintf (out, "Initial parametrs: \n%s", text);
|
||||
break;
|
||||
case 6:
|
||||
sprintf (out, "Processing\n");
|
||||
break;
|
||||
case 7:
|
||||
sprintf (out, "Open file: '%s'\n", text);
|
||||
break;
|
||||
case 8:
|
||||
sprintf (out, "%s", text);
|
||||
break;
|
||||
case 9:
|
||||
sprintf (out, "%6cSize of variables was changed successfully\n", ' ');
|
||||
break;
|
||||
case 10:
|
||||
sprintf (out, "%6cConnectivity matrix was created successfully\n", ' ');
|
||||
break;
|
||||
case 11:
|
||||
sprintf (out, "%6cConnectivity matrix was processed successfully\n", ' ');
|
||||
break;
|
||||
case 12:
|
||||
sprintf (out, "%6cResult was printed to file '%s' successfully\n", ' ', text);
|
||||
break;
|
||||
case 13:
|
||||
sprintf (out, "End of processing\n");
|
||||
break;
|
||||
case 14:
|
||||
sprintf (out, "Print result to file '%s'\n", text);
|
||||
break;
|
||||
case 15:
|
||||
sprintf (out, "Free memory\n");
|
||||
break;
|
||||
case 16:
|
||||
sprintf (out, "Exiting without errors\n");
|
||||
break;
|
||||
case 17:
|
||||
sprintf (out, "Something wrong!\nSee '%s -h' for more details\n", text);
|
||||
break;
|
||||
case 18:
|
||||
sprintf (out, "File '%s' not found\nError\n", text);
|
||||
break;
|
||||
case 19:
|
||||
sprintf (out, "Memory error\n");
|
||||
break;
|
||||
case 20:
|
||||
sprintf (out, "%6cCenter of molecules was set successfully\n", ' ');
|
||||
break;
|
||||
case 21:
|
||||
sprintf (out, "%6cEnvironment was selected successfully\n", ' ');
|
||||
break;
|
||||
case 22:
|
||||
sprintf (out, "%6cRADF was appended successfully\n", ' ');
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
|
||||
fputs (out, output);
|
||||
return 0;
|
||||
}
|
14
mm_trj/src/messages.h
Normal file
14
mm_trj/src/messages.h
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#ifndef MESSAGES_H
|
||||
#define MESSAGES_H
|
||||
|
||||
/**
|
||||
* @fn message
|
||||
*/
|
||||
|
||||
int message (const int, const int, const char *, FILE *);
|
||||
|
||||
#endif /* MESSAGES_H */
|
BIN
mm_trj/src/mm_trj
Executable file
BIN
mm_trj/src/mm_trj
Executable file
Binary file not shown.
71
mm_trj/src/print_trj.c
Normal file
71
mm_trj/src/print_trj.c
Normal file
@ -0,0 +1,71 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/**
|
||||
* @fn printing_trj
|
||||
*/
|
||||
int printing_trj (const char *filename, const int atoms, const int num_types, const int *num_mol,
|
||||
const int *num_atoms, const char *ch_atom_types, const int *atom_types,
|
||||
const float *coords)
|
||||
/**
|
||||
* @brief function that prints trajectory snapshots
|
||||
* @code
|
||||
* printing_trj (filename, atoms, num_types, num_mol, num_atoms, ch_atom_types,
|
||||
* atom_types, coords);
|
||||
* @endcode
|
||||
*
|
||||
* @param filename output file name
|
||||
* @param atoms number of atoms in system
|
||||
* @param num_types number of molecule types
|
||||
* @param num_mol massive of number of molecule of selected type
|
||||
* @param num_atoms massive of number of atoms of selected molecule
|
||||
* @param ch_atom_types massive of char atom types
|
||||
* @param atom_types massive of atom types
|
||||
* @param coords massive of coordinates
|
||||
*
|
||||
* @return 0 - exit without errors
|
||||
*/
|
||||
{
|
||||
int cur_mol, cur_type[2], i, j, k, l;
|
||||
FILE *f_out;
|
||||
|
||||
/* cur_mol number of current molecule
|
||||
* cur_type number of current atom type
|
||||
* f_out output file
|
||||
*/
|
||||
|
||||
cur_mol = 1;
|
||||
f_out = fopen (filename, "w");
|
||||
fprintf (f_out, " %6i\n", atoms);
|
||||
|
||||
i = 0;
|
||||
while (i < atoms)
|
||||
{
|
||||
cur_type[0] = 0;
|
||||
for (j=0; j<num_types; j++)
|
||||
{
|
||||
for (k=0; k<num_mol[j]; k++)
|
||||
{
|
||||
cur_type[1] = cur_type[0];
|
||||
for (l=0; l<num_atoms[j]; l++)
|
||||
{
|
||||
fprintf (f_out, "%5i %c%c %12.6f%12.6f%12.6f %2i %4i\n", i+1,
|
||||
ch_atom_types[2*cur_type[1]+0], ch_atom_types[2*cur_type[1]+1], coords[3*i+0],
|
||||
coords[3*i+1], coords[3*i+2], atom_types[cur_type[1]], cur_mol);
|
||||
cur_type[1]++;
|
||||
i++;
|
||||
}
|
||||
cur_mol++;
|
||||
}
|
||||
cur_type[0] += num_atoms[j];
|
||||
}
|
||||
}
|
||||
|
||||
fclose (f_out);
|
||||
|
||||
return 0;
|
||||
}
|
15
mm_trj/src/print_trj.h
Normal file
15
mm_trj/src/print_trj.h
Normal file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#ifndef PRINT_TRJ_H
|
||||
#define PRINT_TRJ_H
|
||||
|
||||
/**
|
||||
* @fn printing_trj
|
||||
*/
|
||||
|
||||
int printing_trj (const char *, const int, const int, const int *, const int *,
|
||||
const char *, const int *, const float *);
|
||||
|
||||
#endif /* PRINT_TRJ_H */
|
38
mm_trj/src/read_gmx.c
Normal file
38
mm_trj/src/read_gmx.c
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "print_trj.h"
|
||||
|
||||
|
||||
/**
|
||||
* @fn rw_gmx
|
||||
*/
|
||||
int rw_gmx (const char *input, const int step, const char *output, const int num_types,
|
||||
const int *num_mol, const int *num_atoms, const char *ch_atom_types,
|
||||
const int *atom_types, float *coords)
|
||||
/**
|
||||
* @brief function that read GROMACS trajectory file and write to output
|
||||
* @code
|
||||
* rw_gmx (input, step, output, num_types, num_mol, num_atoms, ch_atom_types,
|
||||
* atom_types, coords);
|
||||
* @endcode
|
||||
*
|
||||
* @param input input file name
|
||||
* @param step number of trajectory steps
|
||||
* @param output mask of output files
|
||||
* @param num_types number of molecule types
|
||||
* @param num_mol massive of number of molecule of selected type
|
||||
* @param num_atoms massive of number of atoms of selected molecule
|
||||
* @param ch_atom_types massive of char atom types
|
||||
* @param atom_types massive of atom types
|
||||
* @param coords massive of coordinates
|
||||
*
|
||||
* @return 1 - file does not exist
|
||||
* @return 0 - exit without errors
|
||||
*/
|
||||
{
|
||||
return 0;
|
||||
}
|
15
mm_trj/src/read_gmx.h
Normal file
15
mm_trj/src/read_gmx.h
Normal file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#ifndef READ_GMX_H
|
||||
#define READ_GMX_H
|
||||
|
||||
/**
|
||||
* @fn rw_gmx
|
||||
*/
|
||||
|
||||
int rw_gmx (const char *, const int, const char *, const int, const int *,
|
||||
const int *, const char *, const int *, float *);
|
||||
|
||||
#endif /* READ_GMX_H */
|
87
mm_trj/src/read_puma.c
Normal file
87
mm_trj/src/read_puma.c
Normal file
@ -0,0 +1,87 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "print_trj.h"
|
||||
|
||||
|
||||
/**
|
||||
* @fn rw_puma
|
||||
*/
|
||||
int rw_puma (const char *input, const int step, const char *output, const int num_types,
|
||||
const int *num_mol, const int *num_atoms, const char *ch_atom_types,
|
||||
const int *atom_types, float *coords)
|
||||
/**
|
||||
* @brief function that read PUMA trajectory file and write to output
|
||||
* @code
|
||||
* rw_puma (input, step, output, num_types, num_mol, num_atoms, ch_atom_types,
|
||||
* atom_types, coords);
|
||||
* @endcode
|
||||
*
|
||||
* @param input input file name
|
||||
* @param step number of trajectory steps
|
||||
* @param output mask of output files
|
||||
* @param num_types number of molecule types
|
||||
* @param num_mol massive of number of molecule of selected type
|
||||
* @param num_atoms massive of number of atoms of selected molecule
|
||||
* @param ch_atom_types massive of char atom types
|
||||
* @param atom_types massive of atom types
|
||||
* @param coords massive of coordinates
|
||||
*
|
||||
* @return 1 - file does not exist
|
||||
* @return 0 - exit without errors
|
||||
*/
|
||||
{
|
||||
char filename[256], tmp_str[256];
|
||||
float cell[3];
|
||||
int atoms, i, j, k, l, m, n;
|
||||
FILE *f_inp;
|
||||
|
||||
f_inp = fopen (input, "r");
|
||||
if (f_inp == NULL)
|
||||
return 1;
|
||||
|
||||
for (i=0; i<step; i++)
|
||||
{
|
||||
// initial variables
|
||||
sprintf (filename, "%s.%03i", output, i+1);
|
||||
fgets (tmp_str, 256, f_inp);
|
||||
sscanf (tmp_str, "%s%s%i%s", tmp_str, tmp_str, &atoms, tmp_str);
|
||||
fgets (tmp_str, 256, f_inp);
|
||||
sscanf (tmp_str, "%f%f%f", &cell[0], &cell[1], &cell[2]);
|
||||
|
||||
for (j=0; j<atoms; j++)
|
||||
{
|
||||
fgets (tmp_str, 256, f_inp);
|
||||
sscanf (tmp_str, "%f%f%f", &coords[3*j+0], &coords[3*j+1], &coords[3*j+2]);
|
||||
}
|
||||
fgets (tmp_str, 256, f_inp);
|
||||
|
||||
// processing coordinates
|
||||
j = 0;
|
||||
while (j < atoms)
|
||||
for (k=0; k<num_types; k++)
|
||||
for (l=0; l<num_mol[k]; l++)
|
||||
{
|
||||
for (m=0; m<3; m++)
|
||||
{
|
||||
while (coords[3*j+m] > cell[m]/2)
|
||||
for (n=j; n<j+num_atoms[k]; n++)
|
||||
coords[3*n+m] -= cell[m];
|
||||
while (coords[3*j+m] < -cell[m]/2)
|
||||
for (n=j; n<j+num_atoms[k]; n++)
|
||||
coords[3*n+m] += cell[m];
|
||||
}
|
||||
j += num_atoms[k];
|
||||
}
|
||||
// write to output
|
||||
printing_trj (filename, atoms, num_types, num_mol, num_atoms, ch_atom_types,
|
||||
atom_types, coords);
|
||||
}
|
||||
|
||||
fclose (f_inp);
|
||||
|
||||
return 0;
|
||||
}
|
15
mm_trj/src/read_puma.h
Normal file
15
mm_trj/src/read_puma.h
Normal file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
#ifndef READ_PUMA_H
|
||||
#define READ_PUMA_H
|
||||
|
||||
/**
|
||||
* @fn rw_puma
|
||||
*/
|
||||
|
||||
int rw_puma (const char *, const int, const char *, const int, const int *,
|
||||
const int *, const char *, const int *, float *);
|
||||
|
||||
#endif /* READ_PUMA_H */
|
32
mm_trj/src/types
Normal file
32
mm_trj/src/types
Normal file
@ -0,0 +1,32 @@
|
||||
NUMTYPES=2
|
||||
NUMMOL=3
|
||||
NUMAT=12
|
||||
CL=5
|
||||
CA=2
|
||||
CA=2
|
||||
CA=2
|
||||
CA=2
|
||||
CA=2
|
||||
CA=2
|
||||
HC=3
|
||||
HC=3
|
||||
HC=3
|
||||
HC=3
|
||||
HC=3
|
||||
NUMMOL=97
|
||||
NUMAT=15
|
||||
CL=1
|
||||
CT=4
|
||||
CA=2
|
||||
CA=2
|
||||
CA=2
|
||||
CA=2
|
||||
CA=2
|
||||
CA=2
|
||||
HC=3
|
||||
HC=3
|
||||
HC=3
|
||||
HC=3
|
||||
HC=3
|
||||
HC=3
|
||||
HC=3
|
Reference in New Issue
Block a user