mirror of
https://github.com/arcan1s/moldyn.git
synced 2025-06-29 15:15:47 +00:00
Release envir-1.0.1
* edited shared library - deleted binary file and archive
This commit is contained in:
3
envir/AUTHORS
Normal file
3
envir/AUTHORS
Normal file
@ -0,0 +1,3 @@
|
||||
Current developers:
|
||||
|
||||
Evgeniy Alekseev aka arcanis <esalexeev (at) gmail (dot) com>
|
31
envir/CMakeLists.txt
Normal file
31
envir/CMakeLists.txt
Normal file
@ -0,0 +1,31 @@
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
|
||||
cmake_policy(SET CMP0011 NEW)
|
||||
cmake_policy(SET CMP0003 OLD)
|
||||
|
||||
# set project name
|
||||
set (PROJECT envir)
|
||||
# set additional cmake file
|
||||
include (${PROJECT}.cmake)
|
||||
|
||||
|
||||
# additional options
|
||||
OPTION (WITH_DEBUG_MODE "Build with debug mode" OFF)
|
||||
OPTION (ADD_INCLUDE "Add include files" OFF)
|
||||
|
||||
# set libraries
|
||||
set (LIBRARIES)
|
||||
foreach (LIBRARY ${LIBRARIES})
|
||||
find_library ("${LIBRARY}_FOUND" ${LIBRARY})
|
||||
message (STATUS "Check the ${LIBRARY} is installed: " ${${LIBRARY}_FOUND})
|
||||
if ("${${LIBRARY}_FOUND}" STREQUAL "${LIBRARY}_FOUND-NOTFOUND")
|
||||
message (STATUS "Adding library sources")
|
||||
add_subdirectory (../${LIBRARY} lib/${LIBRARY})
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
# additional targets
|
||||
set (TARGETS "")
|
||||
set (HEADERS "")
|
||||
|
||||
add_subdirectory (src)
|
341
envir/COPYING
Normal file
341
envir/COPYING
Normal file
@ -0,0 +1,341 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
14
envir/INSTALL
Normal file
14
envir/INSTALL
Normal file
@ -0,0 +1,14 @@
|
||||
CMakeFlags:
|
||||
-DCMAKE_INSTALL_PREFIX= - install prefix (default is '/usr/local')
|
||||
-DADD_INCLUDE=1 - install include files (default is disable)
|
||||
-DWITH_DEBUG_MODE=1 - compile with flag '-g' (default is disable)
|
||||
|
||||
Install for Linux:
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release ../
|
||||
make
|
||||
make install
|
||||
Install for Windows:
|
||||
create project file using 'cmake'
|
||||
compile project
|
||||
You may also download compiled executable file for Win_x86.
|
16
envir/README
Normal file
16
envir/README
Normal file
@ -0,0 +1,16 @@
|
||||
envir - program for search environment for chosen molecule by geometric criterion
|
||||
Version: 1.0.1
|
||||
License: GPL
|
||||
|
||||
Usage:
|
||||
envir -i FILENAME -c X,Y,Z -o FILEMANE [ -n NUM_OF_MOLECULE ] [ -r RADIUS ] [ -l LOGFILE] [ -q ] [ -h ]
|
||||
|
||||
Parametrs:
|
||||
-i - input file with coordinates
|
||||
-c - cell size (float), A
|
||||
-o - output file with coordinates
|
||||
-n - number of molecule for search (integer). Default is 1
|
||||
-r - radius of environment (float). Default is 6.0
|
||||
-l - log enable
|
||||
-q - quiet enable
|
||||
-h - show this help and exit
|
219
envir/envir.c
219
envir/envir.c
@ -1,219 +0,0 @@
|
||||
/* envir
|
||||
* Version: 1.0
|
||||
* License: GPL
|
||||
* Author: Evgeniy Alexeev aka arcanis
|
||||
* Email: esalexeev@gmail.com
|
||||
*
|
||||
* 'envir' is a program for search environment for chosen molecule by geometric
|
||||
* criterion
|
||||
*
|
||||
* Usage:
|
||||
* envir -i FILENAME -o FILEMANE [ -n NUM_OF_MOLECULE ] [ -r RADIUS ] [ -h ]
|
||||
*
|
||||
* Compile:
|
||||
* gcc envir.c -o envir -lm
|
||||
* Dependence:
|
||||
* * gcc
|
||||
* * libs: stdio.h, stdlib.h, string.h, math.h
|
||||
*/
|
||||
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include<string.h>
|
||||
#include<math.h>
|
||||
|
||||
|
||||
char atom_type[5000][30][2];
|
||||
double centr_coord[5000][3], coord[5000][30][3], rad;
|
||||
int at_in_mol[5000], mol, needed_mol[50], num_of_mol;
|
||||
/* at_in_mol - number of atoms in molecules
|
||||
* atom_type - massive of atom names
|
||||
* centr_coord - coordinates of molecule mass center
|
||||
* coord - coordinates of atoms
|
||||
* mol - number of molecule in system
|
||||
* needed_mol - massive of mulecules found
|
||||
* num_of_mol - number of molecule for search
|
||||
* rad - geometric criterion
|
||||
*/
|
||||
|
||||
|
||||
void printing(char output_file[])
|
||||
{
|
||||
int cur_mol=0, i, j=1;
|
||||
FILE *out;
|
||||
|
||||
out = fopen (output_file, "w+");
|
||||
while (needed_mol[cur_mol] != 10000)
|
||||
{
|
||||
for (i=0; i<at_in_mol[needed_mol[cur_mol]]; i++)
|
||||
{
|
||||
fprintf(out, "ATOM %5i %c%c MOL %4i %8.3f%8.3f%8.3f\n", j, atom_type[needed_mol[cur_mol]][i][0], \
|
||||
atom_type[needed_mol[cur_mol]][i][1], cur_mol+1, coord[needed_mol[cur_mol]][i][0], \
|
||||
coord[needed_mol[cur_mol]][i][1], coord[needed_mol[cur_mol]][i][2]);
|
||||
j++;
|
||||
}
|
||||
cur_mol++;
|
||||
}
|
||||
fclose (out);
|
||||
}
|
||||
|
||||
|
||||
void search()
|
||||
{
|
||||
double r;
|
||||
int i, k=0;
|
||||
|
||||
for (i=0; i<50; i++)
|
||||
needed_mol[i] = 10000;
|
||||
|
||||
for (i=0; i<mol; i++)
|
||||
{
|
||||
r = sqrt(pow((centr_coord[i][0]-centr_coord[num_of_mol-1][0]), 2) + \
|
||||
pow((centr_coord[i][1]-centr_coord[num_of_mol-1][1]), 2) + \
|
||||
pow((centr_coord[i][2]-centr_coord[num_of_mol-1][2]), 2));
|
||||
if (r < rad)
|
||||
{
|
||||
needed_mol[k] = i;
|
||||
k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void set_center()
|
||||
{
|
||||
int i, j, k;
|
||||
|
||||
for (i=0; i<mol; i++)
|
||||
for (j=0; j<3; j++)
|
||||
centr_coord[i][j] = 0;
|
||||
|
||||
for (i=0; i<mol; i++)
|
||||
for (j=0; j<at_in_mol[i]; j++)
|
||||
for (k=0; k<3; k++)
|
||||
centr_coord[i][k] += coord[i][j][k] / at_in_mol[i];
|
||||
}
|
||||
|
||||
|
||||
void reading(char input_file[])
|
||||
{
|
||||
char tmp[256];
|
||||
int atom_num, cur_mol=0, i, summ;
|
||||
FILE *inp;
|
||||
|
||||
inp = fopen (input_file, "r+");
|
||||
fscanf (inp, "%i", &summ);
|
||||
fgets (tmp, 256, inp);
|
||||
printf ("Atoms in system: %i\n", summ);
|
||||
for (i=0; i<summ; i++)
|
||||
{
|
||||
fgets (tmp, 256, inp);
|
||||
if (atoi(&tmp[53]) != mol+1)
|
||||
{
|
||||
at_in_mol[mol] = cur_mol;
|
||||
mol++;
|
||||
cur_mol = 0;
|
||||
}
|
||||
|
||||
atom_type[mol][cur_mol][0] = tmp[7];
|
||||
atom_type[mol][cur_mol][1] = tmp[8];
|
||||
coord[mol][cur_mol][0] = atof(&tmp[10]);
|
||||
coord[mol][cur_mol][1] = atof(&tmp[22]);
|
||||
coord[mol][cur_mol][2] = atof(&tmp[34]);
|
||||
|
||||
cur_mol++;
|
||||
}
|
||||
fclose (inp);
|
||||
mol++;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char input_file[256], output_file[256];
|
||||
int error_label=0, i, j;
|
||||
FILE *f;
|
||||
|
||||
printf ("Starting program '%s'\n", argv[0]);
|
||||
mol = 0;
|
||||
rad = 6.0;
|
||||
num_of_mol = 1;
|
||||
|
||||
|
||||
printf ("\n1) Reading arguments\n");
|
||||
if (argc == 1)
|
||||
{
|
||||
printf ("Arguments are not set\nType 'envir -h' for help message\nExiting\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i=1; i<argc; i++)
|
||||
{
|
||||
if ((argv[i][0] == '-') && (argv[i][1] == 'i'))
|
||||
{
|
||||
strcpy(input_file, argv[i+1]);
|
||||
f = fopen (argv[i+1], "r+");
|
||||
if (f == NULL)
|
||||
{
|
||||
printf ("File '%s' does not exist!\nExiting\n", argv[i+1]);
|
||||
return 1;
|
||||
}
|
||||
fclose(f);
|
||||
printf ("Set input file to '%s'\n", input_file);
|
||||
i++;
|
||||
error_label++;
|
||||
}
|
||||
|
||||
if ((argv[i][0] == '-') && (argv[i][1] == 'o'))
|
||||
{
|
||||
strcpy(output_file, argv[i+1]);
|
||||
printf ("Set output file to '%s'\n", output_file);
|
||||
i++;
|
||||
error_label++;
|
||||
}
|
||||
|
||||
if ((argv[i][0] == '-') && (argv[i][1] == 'n'))
|
||||
{
|
||||
num_of_mol = atoi(argv[i+1]);
|
||||
printf ("Set number of molecule to '%i'\n", num_of_mol);
|
||||
i++;
|
||||
}
|
||||
|
||||
if ((argv[i][0] == '-') && (argv[i][1] == 'r'))
|
||||
{
|
||||
rad = atof(argv[i+1]);
|
||||
printf ("Set radius to '%lf' A\n", rad);
|
||||
i++;
|
||||
}
|
||||
|
||||
if ((argv[i][0] == '-') && (argv[i][1] == 'h'))
|
||||
{
|
||||
printf ("Usage: envir -i FILENAME -o FILEMANE [ -n NUM_OF_MOLECULE ] [ -r RADIUS ] [ -h ]\n\n");
|
||||
printf (" -i - input file with coordinates\n");
|
||||
printf (" -o - output file with coordinates\n");
|
||||
printf (" -n - number of molecule for search\n");
|
||||
printf (" -r - radius of environment\n");
|
||||
printf (" -h - show this help and exit\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// error check
|
||||
if (error_label < 2)
|
||||
{
|
||||
printf ("Input files aren't set\nType 'en_disp -h' for help message\nExiting\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf ("Reading file '%s'\n", input_file);
|
||||
reading (input_file);
|
||||
printf ("Set center of molecules\n");
|
||||
set_center ();
|
||||
printf ("Search environments\n");
|
||||
search ();
|
||||
printf ("Printing\n");
|
||||
printing (output_file);
|
||||
printf ("Exiting without errors\n");
|
||||
|
||||
return 0;
|
||||
}
|
22
envir/envir.cmake
Normal file
22
envir/envir.cmake
Normal file
@ -0,0 +1,22 @@
|
||||
# set directories
|
||||
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}_BINARY_DIR})
|
||||
set (CMAKE_VERBOSE_MAKEFILE ON)
|
||||
|
||||
if ( WITH_DEBUG_MODE )
|
||||
ADD_DEFINITIONS ( -DDEBUG_MODE=1 )
|
||||
endif ()
|
||||
|
||||
if ( CMAKE_COMPILER_IS_GNUCXX )
|
||||
set (ADD_CXX_FLAGS "-Wall")
|
||||
set (CMAKE_CXX_FLAGS "-O0 ${ADD_CXX_FLAGS}")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
||||
else ()
|
||||
message (STATUS "Flags not enabled")
|
||||
endif ()
|
8
envir/include/envir/add_main.h
Normal file
8
envir/include/envir/add_main.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef ADD_MAIN_H
|
||||
#define ADD_MAIN_H
|
||||
|
||||
int error_checking (const float *, const char *, const char *);
|
||||
int print_message (const int, FILE *, const int, FILE *, const int, const char *);
|
||||
int set_defaults (float *, char *, int *, int *, char *, int *, float *);
|
||||
|
||||
#endif /* ADD_MAIN_H */
|
8
envir/include/envir/coords.h
Normal file
8
envir/include/envir/coords.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef COORDS_H
|
||||
#define COORDS_H
|
||||
|
||||
int reading_coords (const int, const char *, const int, const int *,
|
||||
const float *, int *, int *, int *, int *, int *, float *,
|
||||
char *);
|
||||
|
||||
#endif /* COORDS_H */
|
6
envir/include/envir/envir_search.h
Normal file
6
envir/include/envir/envir_search.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef ENVIR_SEARCH_H
|
||||
#define ENVIR_SEARCH_H
|
||||
|
||||
int search_envir (const int, const int, const float *, const double, int *, int *);
|
||||
|
||||
#endif /* ENVIR_SEARCH_H */
|
6
envir/include/envir/messages.h
Normal file
6
envir/include/envir/messages.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef MESSAGES_H
|
||||
#define MESSAGES_H
|
||||
|
||||
int message (const int, const int, const char *, FILE *);
|
||||
|
||||
#endif /* MESSAGES_H */
|
7
envir/include/envir/print_struct.h
Normal file
7
envir/include/envir/print_struct.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef PRINT_STRUCTURE_H
|
||||
#define PRINT_STRUCTURE_H
|
||||
|
||||
int print_structure (const char *, const int, const int *, const int, const int *,
|
||||
const char *, const float *);
|
||||
|
||||
#endif /* PRINT_STRUCTURE_H */
|
6
envir/include/envir/set_center.h
Normal file
6
envir/include/envir/set_center.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef SET_CENTER_H
|
||||
#define SET_CENTER_H
|
||||
|
||||
int set_center (const int, const int, const int *, const float *, float *);
|
||||
|
||||
#endif /* SET_CENTER_H */
|
81
envir/src/1oct-1clb_clb1_150.pdb
Executable file
81
envir/src/1oct-1clb_clb1_150.pdb
Executable file
@ -0,0 +1,81 @@
|
||||
ATOM 1 CL MOL 1 -2.664 11.890 -17.525
|
||||
ATOM 2 CA MOL 1 -0.917 12.008 -17.545
|
||||
ATOM 3 CA MOL 1 -0.265 12.628 -16.449
|
||||
ATOM 4 CA MOL 1 1.141 12.679 -16.437
|
||||
ATOM 5 CA MOL 1 1.865 12.184 -17.521
|
||||
ATOM 6 CA MOL 1 1.222 11.648 -18.663
|
||||
ATOM 7 CA MOL 1 -0.191 11.514 -18.640
|
||||
ATOM 8 HC MOL 1 -0.936 12.995 -15.629
|
||||
ATOM 9 HC MOL 1 1.720 13.106 -15.622
|
||||
ATOM 10 HC MOL 1 2.954 12.258 -17.471
|
||||
ATOM 11 HC MOL 1 1.854 11.343 -19.523
|
||||
ATOM 12 HC MOL 1 -0.575 11.044 -19.540
|
||||
ATOM 13 CL MOL 2 -6.134 15.323 -13.160
|
||||
ATOM 14 CA MOL 2 -6.616 14.489 -14.639
|
||||
ATOM 15 CA MOL 2 -5.740 13.483 -15.125
|
||||
ATOM 16 CA MOL 2 -6.152 12.814 -16.307
|
||||
ATOM 17 CA MOL 2 -7.335 13.116 -16.943
|
||||
ATOM 18 CA MOL 2 -8.190 14.137 -16.492
|
||||
ATOM 19 CA MOL 2 -7.807 14.850 -15.301
|
||||
ATOM 20 HC MOL 2 -4.814 13.230 -14.622
|
||||
ATOM 21 HC MOL 2 -5.487 12.040 -16.714
|
||||
ATOM 22 HC MOL 2 -7.577 12.578 -17.866
|
||||
ATOM 23 HC MOL 2 -9.151 14.499 -16.876
|
||||
ATOM 24 HC MOL 2 -8.450 15.630 -14.941
|
||||
ATOM 25 CL MOL 3 -2.291 10.911 -13.849
|
||||
ATOM 26 CT MOL 3 -4.546 8.879 -13.092
|
||||
ATOM 27 CA MOL 3 -3.302 8.337 -13.634
|
||||
ATOM 28 CA MOL 3 -3.217 6.974 -13.798
|
||||
ATOM 29 CA MOL 3 -2.019 6.430 -14.303
|
||||
ATOM 30 CA MOL 3 -0.898 7.214 -14.678
|
||||
ATOM 31 CA MOL 3 -1.007 8.608 -14.483
|
||||
ATOM 32 CA MOL 3 -2.180 9.166 -13.977
|
||||
ATOM 33 HC MOL 3 -4.397 9.808 -12.580
|
||||
ATOM 34 HC MOL 3 -5.405 9.060 -13.843
|
||||
ATOM 35 HC MOL 3 -4.909 8.193 -12.354
|
||||
ATOM 36 HC MOL 3 -3.970 6.222 -13.557
|
||||
ATOM 37 HC MOL 3 -1.981 5.395 -14.406
|
||||
ATOM 38 HC MOL 3 -0.061 6.767 -15.059
|
||||
ATOM 39 HC MOL 3 -0.201 9.202 -14.754
|
||||
ATOM 40 CL MOL 4 2.265 8.067 -16.401
|
||||
ATOM 41 CT MOL 4 4.304 6.644 -14.331
|
||||
ATOM 42 CA MOL 4 4.338 6.294 -15.835
|
||||
ATOM 43 CA MOL 4 5.247 5.306 -16.251
|
||||
ATOM 44 CA MOL 4 5.322 4.933 -17.599
|
||||
ATOM 45 CA MOL 4 4.536 5.582 -18.550
|
||||
ATOM 46 CA MOL 4 3.626 6.566 -18.144
|
||||
ATOM 47 CA MOL 4 3.505 6.893 -16.799
|
||||
ATOM 48 HC MOL 4 4.424 5.830 -13.614
|
||||
ATOM 49 HC MOL 4 5.154 7.258 -14.121
|
||||
ATOM 50 HC MOL 4 3.454 7.240 -14.005
|
||||
ATOM 51 HC MOL 4 5.828 4.872 -15.488
|
||||
ATOM 52 HC MOL 4 5.986 4.115 -17.892
|
||||
ATOM 53 HC MOL 4 4.692 5.261 -19.616
|
||||
ATOM 54 HC MOL 4 2.976 7.091 -18.806
|
||||
ATOM 55 CL MOL 5 -2.477 15.433 -17.197
|
||||
ATOM 56 CA MOL 5 -3.971 16.235 -16.853
|
||||
ATOM 57 CA MOL 5 -4.072 17.013 -15.698
|
||||
ATOM 58 CA MOL 5 -5.276 17.755 -15.484
|
||||
ATOM 59 CA MOL 5 -6.309 17.673 -16.459
|
||||
ATOM 60 CA MOL 5 -6.182 16.896 -17.601
|
||||
ATOM 61 CA MOL 5 -5.009 16.172 -17.784
|
||||
ATOM 62 HC MOL 5 -3.234 17.123 -14.977
|
||||
ATOM 63 HC MOL 5 -5.390 18.375 -14.614
|
||||
ATOM 64 HC MOL 5 -7.255 18.222 -16.363
|
||||
ATOM 65 HC MOL 5 -7.001 16.802 -18.354
|
||||
ATOM 66 HC MOL 5 -5.054 15.588 -18.738
|
||||
ATOM 67 CL MOL 6 4.729 13.255 -14.510
|
||||
ATOM 68 CT MOL 6 4.715 14.006 -11.534
|
||||
ATOM 69 CA MOL 6 3.736 12.879 -11.996
|
||||
ATOM 70 CA MOL 6 2.904 12.242 -11.010
|
||||
ATOM 71 CA MOL 6 2.037 11.182 -11.384
|
||||
ATOM 72 CA MOL 6 1.961 10.754 -12.723
|
||||
ATOM 73 CA MOL 6 2.804 11.402 -13.660
|
||||
ATOM 74 CA MOL 6 3.692 12.421 -13.322
|
||||
ATOM 75 HC MOL 6 5.739 13.830 -11.938
|
||||
ATOM 76 HC MOL 6 4.503 15.011 -11.742
|
||||
ATOM 77 HC MOL 6 4.934 14.104 -10.476
|
||||
ATOM 78 HC MOL 6 2.865 12.507 -9.941
|
||||
ATOM 79 HC MOL 6 1.422 10.678 -10.663
|
||||
ATOM 80 HC MOL 6 1.383 9.975 -13.034
|
||||
ATOM 81 HC MOL 6 2.733 11.097 -14.681
|
61
envir/src/CMakeLists.txt
Normal file
61
envir/src/CMakeLists.txt
Normal file
@ -0,0 +1,61 @@
|
||||
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})
|
||||
|
||||
## set files
|
||||
# main files
|
||||
set (MAIN_SOURCES main)
|
||||
# not public srcs
|
||||
set (PRIVATE_CLASSES)
|
||||
# headers only files
|
||||
SET (HEADERS_ONLY)
|
||||
# public srcs
|
||||
set (PUBLIC_CLASSES add_main
|
||||
coords
|
||||
envir_search
|
||||
messages
|
||||
print_struct
|
||||
set_center)
|
||||
# public headers
|
||||
set (PUBLIC_HEADERS)
|
||||
# shared libraries
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
set (ADDITIONAL_LIB m)
|
||||
else ()
|
||||
set (ADDITIONAL_LIB)
|
||||
endif()
|
||||
set (SOURCES)
|
||||
|
||||
# append list
|
||||
foreach (class ${PRIVATE_CLASSES})
|
||||
LIST (APPEND SOURCES ${class}.c)
|
||||
LIST (APPEND HEADERS ${class}.h)
|
||||
endforeach ()
|
||||
|
||||
foreach (class ${HEADERS_ONLY})
|
||||
LIST (APPEND HEADERS ${class}.h)
|
||||
endforeach ()
|
||||
|
||||
foreach (class ${PUBLIC_CLASSES})
|
||||
LIST (APPEND SOURCES ${class}.c)
|
||||
LIST (APPEND HEADERS ../include/${PROJECT}/${class}.h)
|
||||
LIST (APPEND PUBLIC_HEADERS ../include/${PROJECT}/${class}.h)
|
||||
endforeach ()
|
||||
|
||||
# message
|
||||
message (STATUS "SOURCES: ${SOURCES}")
|
||||
|
||||
# link libraries and compile
|
||||
add_executable (${PROJECT} ${MAIN_SOURCES} ${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
envir/src/Makefile
Normal file
21
envir/src/Makefile
Normal file
@ -0,0 +1,21 @@
|
||||
PROJECT=ENVIR
|
||||
|
||||
CC=gcc
|
||||
CFLAGS=-c -Wall -fPIC
|
||||
LDFLAGS=-lm
|
||||
SOURCES_DIR=src
|
||||
SOURCES=main.c add_main.c coords.c envir_search.c messages.c print_struct.c set_center.c
|
||||
OBJECTS=$(SOURCES:.c=.o)
|
||||
EXECUTABLE=envir
|
||||
|
||||
$(PROJECT): $(SOURCES) $(EXECUTABLE)
|
||||
|
||||
$(EXECUTABLE): $(OBJECTS)
|
||||
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
|
49
envir/src/add_main.c
Normal file
49
envir/src/add_main.c
Normal file
@ -0,0 +1,49 @@
|
||||
/* Additional library for main.c (envir)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
// #include "messages.h"
|
||||
|
||||
|
||||
int error_checking (const float *cell, const char *input, const char *output)
|
||||
{
|
||||
if ((cell[0] == 0.0) || (cell[1] == 0.0) || (cell[2] == 0.0))
|
||||
return 11;
|
||||
if (input[0] == '#')
|
||||
return 12;
|
||||
if (output[0] == '#')
|
||||
return 13;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int print_message (const int quiet, FILE *std_output, const int log, FILE *f_log,
|
||||
const int mode, const char *str)
|
||||
{
|
||||
if ((quiet != 1) && (std_output != stderr))
|
||||
message (0, mode, str, std_output);
|
||||
if (log == 1)
|
||||
message (1, mode, str, f_log);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int set_defaults (float *cell, char *input, int *log, int *num_of_mol, char *output,
|
||||
int *quiet, float *rad)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<3; i++)
|
||||
cell[i] = 0.0;
|
||||
input[0] = '#';
|
||||
*log = 0;
|
||||
*num_of_mol = 1;
|
||||
output[0] = '#';
|
||||
*quiet = 0;
|
||||
*rad = 6.0;
|
||||
|
||||
return 0;
|
||||
}
|
313
envir/src/coords.c
Normal file
313
envir/src/coords.c
Normal file
@ -0,0 +1,313 @@
|
||||
/* Library for reading coordinates from input file
|
||||
*
|
||||
* Usage:
|
||||
* reading_coords (mode, filename, type_interaction, labels,
|
||||
* cell, &number_of_molecules, &number_of_atoms, true_label_molecule,
|
||||
* label_molecule, type_atoms, coords, char_type_atoms)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
const int *label_atom, const float *cell, int *num_mol,
|
||||
int *num_atoms, int *true_label_mol, int *label_mol,
|
||||
int *type_atoms, float *coords, char *ch_type_atoms)
|
||||
/* filename - name of file with coordinates
|
||||
* type_inter - type interaction (number of molecules for interaction)
|
||||
* label_atom - types of atom for interaction
|
||||
* cell - cell dimension
|
||||
* num_mol - number of molecules for writing coordinates
|
||||
* num_atoms - number of atoms for writing coordinates
|
||||
* true_label_mol - massive of true numbers of molecule for atoms
|
||||
* label_mol - massive of numbers of molecule for atoms
|
||||
* type_atoms - massive of atom types for atoms
|
||||
* coords - massive of coordinates
|
||||
* ch_type_atoms - massive of char types for atoms
|
||||
*/
|
||||
{
|
||||
char at_symb[32], file_string[256];
|
||||
int atoms, cur_at_num, cur_at_type, cur_mol, i, j, tr_num_atoms, ref_mol, x, y;
|
||||
float cur_coords[3], *not_tr_coords, ref[3];
|
||||
FILE *inp;
|
||||
/* cur_*, at_symb - temp variables
|
||||
* file_string - temp string variable
|
||||
* atoms - total number of atoms in system
|
||||
* tr_num_atoms - number of translated atoms for writing coordinates (m.b. 8*num_atoms)
|
||||
* ref_mol - number of molecule for reference
|
||||
* not_tr_coords - not translated coordinates
|
||||
* ref - coordinates of reference molecule
|
||||
* inp - file with input data
|
||||
*/
|
||||
|
||||
*num_atoms = 0;
|
||||
*num_mol = 0;
|
||||
|
||||
// Reading file
|
||||
inp = fopen (filename, "r");
|
||||
if (inp == NULL)
|
||||
return 1;
|
||||
|
||||
ref_mol = -1;
|
||||
fscanf (inp, "%i", &atoms);
|
||||
not_tr_coords = (float *) malloc (3 * atoms * sizeof (float));
|
||||
fgets (file_string, 256, inp);
|
||||
for (i=0; i<atoms; i++)
|
||||
{
|
||||
fgets (file_string, 256, inp);
|
||||
sscanf (file_string, "%i%s%f%f%f%i%i", &cur_at_num, at_symb, &cur_coords[0],
|
||||
&cur_coords[1], &cur_coords[2], &cur_at_type, &cur_mol);
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
// for statgen
|
||||
for (j=0; j<type_inter; j++)
|
||||
if (cur_at_type == label_atom[j])
|
||||
{
|
||||
not_tr_coords[3**num_atoms+0] = cur_coords[0];
|
||||
not_tr_coords[3**num_atoms+1] = cur_coords[1];
|
||||
not_tr_coords[3**num_atoms+2] = cur_coords[2];
|
||||
|
||||
if (ref_mol != cur_mol)
|
||||
{
|
||||
ref_mol = cur_mol;
|
||||
true_label_mol[*num_mol] = ref_mol;
|
||||
*num_mol = *num_mol + 1;
|
||||
}
|
||||
label_mol[*num_atoms] = *num_mol - 1;
|
||||
type_atoms[*num_atoms] = j;
|
||||
|
||||
*num_atoms = *num_atoms + 1;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
// for envir
|
||||
not_tr_coords[3**num_atoms+0] = cur_coords[0];
|
||||
not_tr_coords[3**num_atoms+1] = cur_coords[1];
|
||||
not_tr_coords[3**num_atoms+2] = cur_coords[2];
|
||||
ch_type_atoms[2**num_atoms+0] = at_symb[0];
|
||||
ch_type_atoms[2**num_atoms+1] = at_symb[1];
|
||||
|
||||
if (ref_mol != cur_mol)
|
||||
{
|
||||
ref_mol = cur_mol;
|
||||
true_label_mol[*num_mol] = ref_mol;
|
||||
*num_mol = *num_mol + 1;
|
||||
}
|
||||
label_mol[*num_atoms] = *num_mol - 1;
|
||||
type_atoms[*num_atoms] = j;
|
||||
|
||||
*num_atoms = *num_atoms + 1;
|
||||
break;
|
||||
default: return 1;
|
||||
}
|
||||
}
|
||||
fclose (inp);
|
||||
|
||||
// Translation
|
||||
tr_num_atoms = *num_atoms;
|
||||
for (i=0; i<*num_atoms; i++)
|
||||
for (j=0; j<3; j++)
|
||||
coords[3*i+j] = not_tr_coords[3*i+j];
|
||||
|
||||
// Assign initial value to reference coordinates
|
||||
ref_mol = label_mol[0];
|
||||
for (i=0; i<3; i++)
|
||||
ref[i] = coords[3*0+i];
|
||||
|
||||
for (i=0; i<*num_atoms; i++)
|
||||
{
|
||||
if (label_mol[i] != ref_mol)
|
||||
{
|
||||
ref_mol = label_mol[i];
|
||||
for (j=0; j<3; j++)
|
||||
ref[j] = not_tr_coords[3*i+j];
|
||||
}
|
||||
|
||||
for (x=0; x<3; x++)
|
||||
{
|
||||
if (ref[x] >= 0.0)
|
||||
// if xyz >= 0.0 A
|
||||
{
|
||||
for (j=0; j<3; j++)
|
||||
if (j == x)
|
||||
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j] - cell[j];
|
||||
else
|
||||
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j];
|
||||
|
||||
label_mol[tr_num_atoms] = label_mol[i];
|
||||
type_atoms[tr_num_atoms] = type_atoms[i];
|
||||
tr_num_atoms++;
|
||||
}
|
||||
else
|
||||
// if xyz < 0.0 A
|
||||
{
|
||||
for (j=0; j<3; j++)
|
||||
if (j == x)
|
||||
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j] + cell[j];
|
||||
else
|
||||
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j];
|
||||
|
||||
label_mol[tr_num_atoms] = label_mol[i];
|
||||
type_atoms[tr_num_atoms] = type_atoms[i];
|
||||
tr_num_atoms++;
|
||||
}
|
||||
}
|
||||
|
||||
for (x=0; x<3; x++)
|
||||
{
|
||||
for (y=x+1; y<3; y++)
|
||||
{
|
||||
if ((ref[x] >= 0.0) && (ref[y] >= 0.0))
|
||||
// if xyz and xyz >= 0.0 A
|
||||
{
|
||||
for (j=0; j<3; j++)
|
||||
if ((j == x) || (j == y))
|
||||
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j] - cell[j];
|
||||
else
|
||||
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j];
|
||||
|
||||
label_mol[tr_num_atoms] = label_mol[i];
|
||||
type_atoms[tr_num_atoms] = type_atoms[i];
|
||||
tr_num_atoms++;
|
||||
}
|
||||
|
||||
if ((ref[x] < 0.0) && (ref[y] < 0.0))
|
||||
// if xyz and xyz < 0.0 A
|
||||
{
|
||||
for (j=0; j<3; j++)
|
||||
if ((j == x) || (j == y))
|
||||
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j] + cell[j];
|
||||
else
|
||||
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j];
|
||||
|
||||
label_mol[tr_num_atoms] = label_mol[i];
|
||||
type_atoms[tr_num_atoms] = type_atoms[i];
|
||||
tr_num_atoms++;
|
||||
}
|
||||
}
|
||||
|
||||
for (y=0; y<3; y++)
|
||||
if ((ref[x] < 0.0) && (ref[y] >= 0.0))
|
||||
// if xyz OR xyz >= 0.0
|
||||
{
|
||||
for (j=0; j<3; j++)
|
||||
{
|
||||
if (j == x)
|
||||
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j] + cell[j];
|
||||
if (j == y)
|
||||
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j] - cell[j];
|
||||
if ((j != x) && (j != y))
|
||||
coords[3*tr_num_atoms+j] = not_tr_coords[3*i+j];
|
||||
}
|
||||
|
||||
label_mol[tr_num_atoms] = label_mol[i];
|
||||
type_atoms[tr_num_atoms] = type_atoms[i];
|
||||
tr_num_atoms++;
|
||||
}
|
||||
}
|
||||
|
||||
if ((ref[0] >= 0.0) && (ref[1] >= 0.0) && (ref[2] >= 0.0))
|
||||
// if x and y and z >= 0.0 A
|
||||
{
|
||||
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] - cell[0];
|
||||
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] - cell[1];
|
||||
coords[3*tr_num_atoms+2] = not_tr_coords[3*i+2] - cell[2];
|
||||
|
||||
label_mol[tr_num_atoms] = label_mol[i];
|
||||
type_atoms[tr_num_atoms] = type_atoms[i];
|
||||
tr_num_atoms++;
|
||||
}
|
||||
|
||||
if ((ref[0] >= 0.0) && (ref[1] >= 0.0) && (ref[2] < 0.0))
|
||||
// if x and y >= 0.0 A and z < 0.0 A
|
||||
{
|
||||
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] - cell[0];
|
||||
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] - cell[1];
|
||||
coords[3*tr_num_atoms+2] = not_tr_coords[3*i+2] + cell[2];
|
||||
|
||||
label_mol[tr_num_atoms] = label_mol[i];
|
||||
type_atoms[tr_num_atoms] = type_atoms[i];
|
||||
tr_num_atoms++;
|
||||
}
|
||||
|
||||
if ((ref[0] >= 0.0) && (ref[1] < 0.0) && (ref[2] >= 0.0))
|
||||
// if x and z >= 0.0 A and y < 0.0 A
|
||||
{
|
||||
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] - cell[0];
|
||||
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] + cell[1];
|
||||
coords[3*tr_num_atoms+2] = not_tr_coords[3*i+2] - cell[2];
|
||||
|
||||
label_mol[tr_num_atoms] = label_mol[i];
|
||||
type_atoms[tr_num_atoms] = type_atoms[i];
|
||||
tr_num_atoms++;
|
||||
}
|
||||
|
||||
if ((ref[0] < 0.0) && (ref[1] >= 0.0) && (ref[2] >= 0.0))
|
||||
// if y and z >= 0.0 A and x < 0.0 A
|
||||
{
|
||||
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] + cell[0];
|
||||
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] - cell[1];
|
||||
coords[3*tr_num_atoms+2] = not_tr_coords[3*i+2] - cell[2];
|
||||
|
||||
label_mol[tr_num_atoms] = label_mol[i];
|
||||
type_atoms[tr_num_atoms] = type_atoms[i];
|
||||
tr_num_atoms++;
|
||||
}
|
||||
|
||||
if ((ref[0] < 0.0) && (ref[1] < 0.0) && (ref[2] >= 0.0))
|
||||
// if x and y < 0.0 A and z >= 0.0 A
|
||||
{
|
||||
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] + cell[0];
|
||||
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] + cell[1];
|
||||
coords[3*tr_num_atoms+2] = not_tr_coords[3*i+2] - cell[2];
|
||||
|
||||
label_mol[tr_num_atoms] = label_mol[i];
|
||||
type_atoms[tr_num_atoms] = type_atoms[i];
|
||||
tr_num_atoms++;
|
||||
}
|
||||
|
||||
if ((ref[0] < 0.0) && (ref[1] >= 0.0) && (ref[2] < 0.0))
|
||||
// if x and z < 0.0 A and y >= 0.0 A
|
||||
{
|
||||
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] + cell[0];
|
||||
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] - cell[1];
|
||||
coords[3*tr_num_atoms+2] = not_tr_coords[3*i+2] + cell[2];
|
||||
|
||||
label_mol[tr_num_atoms] = label_mol[i];
|
||||
type_atoms[tr_num_atoms] = type_atoms[i];
|
||||
tr_num_atoms++;
|
||||
}
|
||||
|
||||
if ((ref[0] >= 0.0) && (ref[1] < 0.0) && (ref[2] < 0.0))
|
||||
// if x >= 0.0 A and y and z < 0.0 A
|
||||
{
|
||||
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] - cell[0];
|
||||
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] + cell[1];
|
||||
coords[3*tr_num_atoms+2] = not_tr_coords[3*i+2] + cell[2];
|
||||
|
||||
label_mol[tr_num_atoms] = label_mol[i];
|
||||
type_atoms[tr_num_atoms] = type_atoms[i];
|
||||
tr_num_atoms++;
|
||||
}
|
||||
|
||||
if ((ref[0] < 0.0) && (ref[1] < 0.0) && (ref[2] < 0.0))
|
||||
// if x and y and z < 0.0 A
|
||||
{
|
||||
coords[3*tr_num_atoms+0] = not_tr_coords[3*i+0] + cell[0];
|
||||
coords[3*tr_num_atoms+1] = not_tr_coords[3*i+1] + cell[1];
|
||||
coords[3*tr_num_atoms+2] = not_tr_coords[3*i+2] + cell[2];
|
||||
|
||||
label_mol[tr_num_atoms] = label_mol[i];
|
||||
type_atoms[tr_num_atoms] = type_atoms[i];
|
||||
tr_num_atoms++;
|
||||
}
|
||||
}
|
||||
|
||||
// free memory
|
||||
free (not_tr_coords);
|
||||
|
||||
return 0;
|
||||
}
|
40
envir/src/envir_search.c
Normal file
40
envir/src/envir_search.c
Normal file
@ -0,0 +1,40 @@
|
||||
/* Library for search environment
|
||||
*
|
||||
* Usage:
|
||||
* search_envir (number_of_molecule, num_mol, centr_coords, rad, needed_mol,
|
||||
* &num_needed_mol)
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
||||
int search_envir (const int num_of_mol, const int num_mol, const float *centr_coords,
|
||||
const double rad, int *needed_mol, int *num_needed_mol)
|
||||
/* num_of_mol - number of molecule for search
|
||||
* num_mol - number of molecules for writing coordinates
|
||||
* centr_coords - massive of centered coordinates
|
||||
* rad - criterion
|
||||
* needed_mol - massive of needed molecules
|
||||
* num_needed_mol - number of needed molecules
|
||||
*/
|
||||
{
|
||||
float r;
|
||||
int i;
|
||||
/* r - radius
|
||||
*/
|
||||
*num_needed_mol = 0;
|
||||
|
||||
for (i=0; i<8*num_mol; i++)
|
||||
{
|
||||
r = sqrt (pow ((centr_coords[3*i+0]-centr_coords[3*8*(num_of_mol-1)+0]), 2) +
|
||||
pow ((centr_coords[3*i+1]-centr_coords[3*8*(num_of_mol-1)+1]), 2) +
|
||||
pow ((centr_coords[3*i+2]-centr_coords[3*8*(num_of_mol-1)+2]), 2));
|
||||
if (r < rad)
|
||||
{
|
||||
needed_mol[*num_needed_mol] = i;
|
||||
*num_needed_mol = *num_needed_mol + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
220
envir/src/main.c
Normal file
220
envir/src/main.c
Normal file
@ -0,0 +1,220 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
// #include "add_main.h"
|
||||
// #include "coords.h"
|
||||
// #include "envir_search.h"
|
||||
// #include "messages.h"
|
||||
// #include "print_struct.h"
|
||||
// #include "set_center.h"
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char tmp_str[2048];
|
||||
int error, i, j, *tmp_int;
|
||||
FILE *f_inp, *f_log;
|
||||
|
||||
char *ch_type_atoms, input[256], logfile[256], output[256];
|
||||
float cell[3], *centr_coords, *coords, rad;
|
||||
int *label_mol, log, num_atoms, num_mol, num_needed_mol, num_of_mol,
|
||||
*needed_mol, quiet, *true_label_mol;
|
||||
/* ch_type_atoms - massive of char types for atoms
|
||||
* input - input file name
|
||||
* logfile - log file name
|
||||
* output - output file name
|
||||
*
|
||||
* cell - cell dimension
|
||||
* centr_coords - massive of coordinates of center molecules
|
||||
* coords - massive of coordinates
|
||||
* rad - criterion
|
||||
*
|
||||
* label_mol - massive of numbers of molecule for atoms
|
||||
* log - status of log-mode
|
||||
* num_atoms - number of atoms for writing coordinates
|
||||
* num_mol - number of molecules for writing coordinates
|
||||
* num_needed_mol - number of needed molecules
|
||||
* num_of_mol - number of molecule for search
|
||||
* needed_mol - massive of needed molecules
|
||||
* quiet - status of quiet-mode
|
||||
* true_label_mol - massive of true numbers of molecule for atoms
|
||||
*/
|
||||
|
||||
set_defaults (cell, input, &log, &num_of_mol, output, &quiet, &rad);
|
||||
|
||||
for (i=1; i<argc; i++)
|
||||
{
|
||||
if ((argv[i][0] == '-') && (argv[i][1] == 'h'))
|
||||
{
|
||||
sprintf (tmp_str, " envir\n");
|
||||
sprintf (tmp_str, "%sProgram for search environment for chosen molecule by geometric criterion\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, "%senvir -i FILENAME -c X,Y,Z -o FILEMANE [ -n NUM_OF_MOLECULE ] [ -r RADIUS ] [ -l LOGFILE] [ -q ] [ -h ]\n\n", tmp_str);
|
||||
sprintf (tmp_str, "%sParametrs:\n", tmp_str);
|
||||
sprintf (tmp_str, "%s -i - input file with coordinates\n", tmp_str);
|
||||
sprintf (tmp_str, "%s -c - cell size (float), A\n", tmp_str);
|
||||
sprintf (tmp_str, "%s -o - output file with coordinates\n", tmp_str);
|
||||
sprintf (tmp_str, "%s -n - number of molecule for search (integer). Default is 1\n", tmp_str);
|
||||
sprintf (tmp_str, "%s -r - radius of environment (float). Default is 6.0\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'))
|
||||
// input file
|
||||
{
|
||||
strcpy (input, argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == 'c'))
|
||||
// cell size
|
||||
{
|
||||
sscanf (argv[i+1], "%f,%f,%f", &cell[0], &cell[1], &cell[2]);
|
||||
i++;
|
||||
}
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == 'o'))
|
||||
// output file
|
||||
{
|
||||
strcpy (output, argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == 'n'))
|
||||
// number of molecule
|
||||
{
|
||||
sscanf (argv[i+1], "%i", &num_of_mol);
|
||||
i++;
|
||||
}
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == 'r'))
|
||||
// radius of environment
|
||||
{
|
||||
sscanf (argv[i+1], "%f", &rad);
|
||||
i++;
|
||||
}
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == 'l'))
|
||||
// log mode
|
||||
{
|
||||
log = 1;
|
||||
strcpy (logfile, argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == 'q'))
|
||||
// quiet mode
|
||||
{
|
||||
quiet = 1;
|
||||
}
|
||||
}
|
||||
|
||||
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 (cell, input, output);
|
||||
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)
|
||||
{
|
||||
print_message (quiet, stderr, log, f_log, 18, input);
|
||||
return 1;
|
||||
}
|
||||
fscanf (f_inp, "%i", &num_atoms);
|
||||
fclose (f_inp);
|
||||
ch_type_atoms = (char *) malloc (2 * num_atoms * sizeof (char));
|
||||
coords = (float *) malloc (3 * 8 * num_atoms * sizeof (float));
|
||||
label_mol = (int *) malloc (8 * num_atoms * sizeof (int));
|
||||
tmp_int = (int *) malloc (8 * num_atoms * sizeof (int));
|
||||
true_label_mol = (int *) malloc (num_atoms * sizeof (int));
|
||||
// error checking
|
||||
if ((ch_type_atoms == NULL) ||
|
||||
(coords == NULL) ||
|
||||
(label_mol == NULL) ||
|
||||
(tmp_int == NULL) ||
|
||||
(true_label_mol == NULL))
|
||||
{
|
||||
print_message (quiet, stderr, log, f_log, 19, argv[0]);
|
||||
return 17;
|
||||
}
|
||||
sprintf (tmp_str, "%6cInput file: '%s';\n%6cOutput file: '%s';\n%6cLog: %i;\n\
|
||||
%6cQuiet: %i;\n%6cCell size: %.4f, %.4f, %.4f;\n%6cSelect molecule: %i;\n\
|
||||
%6cCriterion: %.1f\n", ' ', input, ' ', output, ' ', log, ' ', quiet, ' ', cell[0],
|
||||
cell[1], cell[2], ' ' , num_of_mol, ' ', rad);
|
||||
print_message (quiet, stdout, log, f_log, 5, tmp_str);
|
||||
|
||||
print_message (quiet, stdout, log, f_log, 6, argv[0]);
|
||||
|
||||
// reading coordinates
|
||||
print_message (quiet, stdout, log, f_log, 7, input);
|
||||
error = reading_coords (1, input, tmp_int, tmp_int, cell, &num_mol, &num_atoms,
|
||||
true_label_mol, label_mol, tmp_int, coords, ch_type_atoms);
|
||||
centr_coords = (float *) malloc (3 * 8 * num_mol * sizeof (float));
|
||||
needed_mol = (int *) malloc (num_mol * sizeof (int));
|
||||
if (error == 0)
|
||||
{
|
||||
sprintf (tmp_str, "%6cNumber of molecules: %i; %6cNumber of atoms: %i\n",
|
||||
' ', num_mol, ' ', num_atoms);
|
||||
print_message (quiet, stdout, log, f_log, 8, tmp_str);
|
||||
}
|
||||
// error checking
|
||||
if ((centr_coords == NULL) ||
|
||||
(needed_mol == NULL))
|
||||
{
|
||||
print_message (quiet, stderr, log, f_log, 19, argv[0]);
|
||||
return 17;
|
||||
}
|
||||
|
||||
// analyze
|
||||
if (error == 0)
|
||||
{
|
||||
error = set_center (num_atoms, num_mol, label_mol, coords, centr_coords);
|
||||
if (error == 0)
|
||||
{
|
||||
print_message (quiet, stderr, log, f_log, 20, argv[0]);
|
||||
error = search_envir (num_of_mol, num_mol, centr_coords, rad, needed_mol,
|
||||
&num_needed_mol);
|
||||
if (error == 0)
|
||||
{
|
||||
print_message (quiet, stderr, log, f_log, 21, argv[0]);
|
||||
error = print_structure (output, num_needed_mol, needed_mol, num_atoms,
|
||||
label_mol, ch_type_atoms, coords);
|
||||
print_message (quiet, stderr, log, f_log, 12, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print_message (quiet, stdout, log, f_log, 13, argv[0]);
|
||||
|
||||
print_message (quiet, stdout, log, f_log, 15, argv[0]);
|
||||
// free memory
|
||||
free (ch_type_atoms);
|
||||
free (centr_coords);
|
||||
free (coords);
|
||||
free (label_mol);
|
||||
free (needed_mol);
|
||||
free (tmp_int);
|
||||
free (true_label_mol);
|
||||
|
||||
print_message (quiet, stdout, log, f_log, 16, argv[0]);
|
||||
|
||||
if (log == 1)
|
||||
fclose (f_log);
|
||||
return 0;
|
||||
}
|
99
envir/src/messages.c
Normal file
99
envir/src/messages.c
Normal file
@ -0,0 +1,99 @@
|
||||
/* Library for printing messages at output
|
||||
*
|
||||
* Usage:
|
||||
* message (log, mode, text, output)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
int message (const int log, const int mode, const char *text, FILE *output)
|
||||
/* mode - number of message
|
||||
* text - additional text
|
||||
*/
|
||||
{
|
||||
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, "Starting 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:
|
||||
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, "Printing summary statistic 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;
|
||||
}
|
||||
|
||||
fputs (out, output);
|
||||
return 0;
|
||||
}
|
3376
envir/src/oct-clb.150
Executable file
3376
envir/src/oct-clb.150
Executable file
File diff suppressed because it is too large
Load Diff
58
envir/src/print_struct.c
Normal file
58
envir/src/print_struct.c
Normal file
@ -0,0 +1,58 @@
|
||||
/* Library for printing structure to pdb file
|
||||
*
|
||||
* Usage:
|
||||
* print_structure (output, num_needed_mol, needed_mol, num_atoms,
|
||||
* label_mol, char_type_atoms, coords)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
int print_structure (const char *output, const int num_needed_mol, const int *needed_mol,
|
||||
const int num_atoms, const int *label_mol, const char *ch_type_atoms,
|
||||
const float *coords)
|
||||
/* output - output file name
|
||||
* num_needed_mol - number of needed molecules
|
||||
* needed_mol - massive of needed molecules
|
||||
* num_atoms - number of atoms
|
||||
* label_mol - massive of numbers of molecule for atoms
|
||||
* ch_type_atoms - massive of char types for atoms
|
||||
* coords - massive of coordinates
|
||||
*/
|
||||
{
|
||||
int cur_atom, cur_atom_num, cur_mol, i, j;
|
||||
FILE *f_out;
|
||||
/* cur_atom - current atom
|
||||
* cur_atom_num - true atom number
|
||||
* cur_mol - current molecule
|
||||
*/
|
||||
|
||||
cur_atom = 1;
|
||||
f_out = fopen (output, "w");
|
||||
|
||||
for (i=0; i<num_needed_mol; i++)
|
||||
for (j=0; j<8*num_atoms; j++)
|
||||
{
|
||||
if (j < num_atoms)
|
||||
{
|
||||
cur_mol = 0;
|
||||
cur_atom_num = j;
|
||||
}
|
||||
else
|
||||
{
|
||||
cur_mol = ((j - num_atoms) % 7) + 1;
|
||||
cur_atom_num = (j - num_atoms) / 7;
|
||||
}
|
||||
if (needed_mol[i] == (8*label_mol[j]+cur_mol))
|
||||
{
|
||||
fprintf(f_out, "ATOM %5i %c%c MOL %4i %8.3f%8.3f%8.3f\n", cur_atom,
|
||||
ch_type_atoms[2*cur_atom_num+0], ch_type_atoms[2*cur_atom_num+1],
|
||||
i+1, coords[3*j+0], coords[3*j+1], coords[3*j+2]);
|
||||
cur_atom++;
|
||||
}
|
||||
}
|
||||
|
||||
fclose (f_out);
|
||||
|
||||
return 0;
|
||||
}
|
52
envir/src/set_center.c
Normal file
52
envir/src/set_center.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* Library for search center mass of molecules
|
||||
*
|
||||
* Usage:
|
||||
* set_center (num_of_atoms, num_of_molecules, label_molecules, coords,
|
||||
* centr_coords)
|
||||
*/
|
||||
|
||||
|
||||
int set_center (const int num_atoms, const int num_mol, const int *label_mol,
|
||||
const float *coords, float *centr_coords)
|
||||
/* num_atoms - number of atoms for writing coordinates
|
||||
* num_mol - number of molecules for writing coordinates
|
||||
* label_mol - massive of numbers of molecule for atoms
|
||||
* coords - massive of coordinates
|
||||
* coords - massive of coordinates of center molecules
|
||||
*/
|
||||
{
|
||||
int at_in_mol, cur_mol, i, j, k;
|
||||
/* at_int_mol - number of atoms in molecule
|
||||
* cur_mol - current molecule
|
||||
*/
|
||||
|
||||
for (i=0; i<8*num_mol; i++)
|
||||
for (j=0; j<3; j++)
|
||||
centr_coords[i*3+j] = 0.0;
|
||||
|
||||
for (i=0; i<8*num_atoms; i++)
|
||||
{
|
||||
if (i < num_atoms)
|
||||
cur_mol = 0;
|
||||
else
|
||||
cur_mol = ((i - num_atoms) % 7) + 1;
|
||||
for (j=0; j<3; j++)
|
||||
centr_coords[3*(8*label_mol[i]+cur_mol)+j] += coords[3*i+j];
|
||||
}
|
||||
|
||||
at_in_mol = 0;
|
||||
cur_mol = 0;
|
||||
for (i=0; i<num_atoms; i++)
|
||||
if (cur_mol != label_mol[i])
|
||||
{
|
||||
for (j=0; j<8; j++)
|
||||
for (k=0; k<3; k++)
|
||||
centr_coords[3*(8*cur_mol+j)+k] = centr_coords[3*(8*cur_mol+j)+k] / at_in_mol;
|
||||
at_in_mol = 0;
|
||||
cur_mol = label_mol[i];
|
||||
}
|
||||
else
|
||||
at_in_mol++;
|
||||
|
||||
return 0;
|
||||
}
|
@ -17,5 +17,3 @@ Parametrs:
|
||||
-l - log enable
|
||||
-q - quiet enable
|
||||
-h - show this help and exit
|
||||
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
#ifndef COORDS_H
|
||||
#define COORDS_H
|
||||
|
||||
int reading_coords (const char *, const int, const int *, const float *, int *,
|
||||
int *, int *, int *, int *, float *);
|
||||
int reading_coords (const int, const char *, const int, const int *,
|
||||
const float *, int *, int *, int *, int *, int *, float *,
|
||||
char *);
|
||||
|
||||
#endif /* COORDS_H */
|
@ -2,7 +2,6 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
// #include "messages.h"
|
||||
|
||||
@ -70,7 +69,7 @@ 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)
|
||||
if ((quiet != 1) && (std_output != stderr))
|
||||
message (0, mode, str, std_output);
|
||||
if (log == 1)
|
||||
message (1, mode, str, f_log);
|
||||
|
@ -1,19 +1,19 @@
|
||||
/* Library for reading coordinates from input file
|
||||
*
|
||||
* Usage:
|
||||
* reading_coords (filename, type_interaction, labels, cell,
|
||||
* &number_of_molecules, &number_of_atoms, true_label_molecule, label_molecule,
|
||||
* type_atoms, coords)
|
||||
* reading_coords (mode, filename, type_interaction, labels,
|
||||
* cell, &number_of_molecules, &number_of_atoms, true_label_molecule,
|
||||
* label_molecule, type_atoms, coords, char_type_atoms)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
int reading_coords (const char *filename, const int type_inter,
|
||||
int reading_coords (const int mode, const char *filename, const int type_inter,
|
||||
const int *label_atom, const float *cell, int *num_mol,
|
||||
int *num_atoms, int *true_label_mol, int *label_mol,
|
||||
int *type_atoms, float *coords)
|
||||
int *type_atoms, float *coords, char *ch_type_atoms)
|
||||
/* filename - name of file with coordinates
|
||||
* type_inter - type interaction (number of molecules for interaction)
|
||||
* label_atom - types of atom for interaction
|
||||
@ -24,11 +24,12 @@ int reading_coords (const char *filename, const int type_inter,
|
||||
* label_mol - massive of numbers of molecule for atoms
|
||||
* type_atoms - massive of atom types for atoms
|
||||
* coords - massive of coordinates
|
||||
* ch_type_atoms - massive of char types for atoms
|
||||
*/
|
||||
{
|
||||
char at_symb[32], file_string[256];
|
||||
int atoms, cur_at_num, cur_at_type, cur_mol, i, j, tr_num_atoms, ref_mol, x, y;
|
||||
float cur_coords[3], not_tr_coords[750000], ref[3];
|
||||
float cur_coords[3], *not_tr_coords, ref[3];
|
||||
FILE *inp;
|
||||
/* cur_*, at_symb - temp variables
|
||||
* file_string - temp string variable
|
||||
@ -50,6 +51,7 @@ int reading_coords (const char *filename, const int type_inter,
|
||||
|
||||
ref_mol = -1;
|
||||
fscanf (inp, "%i", &atoms);
|
||||
not_tr_coords = (float *) malloc (3 * atoms * sizeof (float));
|
||||
fgets (file_string, 256, inp);
|
||||
for (i=0; i<atoms; i++)
|
||||
{
|
||||
@ -57,12 +59,36 @@ int reading_coords (const char *filename, const int type_inter,
|
||||
sscanf (file_string, "%i%s%f%f%f%i%i", &cur_at_num, at_symb, &cur_coords[0],
|
||||
&cur_coords[1], &cur_coords[2], &cur_at_type, &cur_mol);
|
||||
|
||||
for (j=0; j<type_inter; j++)
|
||||
if (cur_at_type == label_atom[j])
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
// for statgen
|
||||
for (j=0; j<type_inter; j++)
|
||||
if (cur_at_type == label_atom[j])
|
||||
{
|
||||
not_tr_coords[3**num_atoms+0] = cur_coords[0];
|
||||
not_tr_coords[3**num_atoms+1] = cur_coords[1];
|
||||
not_tr_coords[3**num_atoms+2] = cur_coords[2];
|
||||
|
||||
if (ref_mol != cur_mol)
|
||||
{
|
||||
ref_mol = cur_mol;
|
||||
true_label_mol[*num_mol] = ref_mol;
|
||||
*num_mol = *num_mol + 1;
|
||||
}
|
||||
label_mol[*num_atoms] = *num_mol - 1;
|
||||
type_atoms[*num_atoms] = j;
|
||||
|
||||
*num_atoms = *num_atoms + 1;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
// for envir
|
||||
not_tr_coords[3**num_atoms+0] = cur_coords[0];
|
||||
not_tr_coords[3**num_atoms+1] = cur_coords[1];
|
||||
not_tr_coords[3**num_atoms+2] = cur_coords[2];
|
||||
ch_type_atoms[2**num_atoms+0] = at_symb[0];
|
||||
ch_type_atoms[2**num_atoms+1] = at_symb[1];
|
||||
|
||||
if (ref_mol != cur_mol)
|
||||
{
|
||||
@ -74,7 +100,9 @@ int reading_coords (const char *filename, const int type_inter,
|
||||
type_atoms[*num_atoms] = j;
|
||||
|
||||
*num_atoms = *num_atoms + 1;
|
||||
}
|
||||
break;
|
||||
default: return 1;
|
||||
}
|
||||
}
|
||||
fclose (inp);
|
||||
|
||||
@ -87,7 +115,7 @@ int reading_coords (const char *filename, const int type_inter,
|
||||
// Assign initial value to reference coordinates
|
||||
ref_mol = label_mol[0];
|
||||
for (i=0; i<3; i++)
|
||||
ref[i] = coords[i];
|
||||
ref[i] = coords[3*0+i];
|
||||
|
||||
for (i=0; i<*num_atoms; i++)
|
||||
{
|
||||
@ -278,5 +306,8 @@ int reading_coords (const char *filename, const int type_inter,
|
||||
}
|
||||
}
|
||||
|
||||
// free memory
|
||||
free (not_tr_coords);
|
||||
|
||||
return 0;
|
||||
}
|
@ -208,10 +208,7 @@ int main (int argc, char *argv[])
|
||||
type_inter);
|
||||
if (error != 0)
|
||||
{
|
||||
sprintf (tmp_str, "Something wrong (error code: %i)!\nSee 'statgen -h' for more details\n", error);
|
||||
fputs (tmp_str, stderr);
|
||||
if (log == 1)
|
||||
fputs (tmp_str, f_log);
|
||||
print_message (quiet, stderr, log, f_log, 17, argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -230,17 +227,14 @@ int main (int argc, char *argv[])
|
||||
f_inp = fopen (filename, "r");
|
||||
if (f_inp == NULL)
|
||||
{
|
||||
sprintf (tmp_str, "\nFile '%s' not found\nError", filename);
|
||||
fputs (tmp_str, stderr);
|
||||
if (log == 1)
|
||||
fputs (tmp_str, f_log);
|
||||
print_message (quiet, stderr, log, f_log, 18, filename);
|
||||
return 1;
|
||||
}
|
||||
fscanf (f_inp, "%i", &num_atoms);
|
||||
fclose (f_inp);
|
||||
coords = (float *) malloc (3 * 8 * num_atoms * sizeof (float));
|
||||
label_mol = (int *) malloc (8 * num_atoms * sizeof (int));
|
||||
true_label_mol = (int *) malloc (8 * num_atoms * sizeof (int));
|
||||
true_label_mol = (int *) malloc (num_atoms * sizeof (int));
|
||||
type_agl = (int *) malloc ((max_depth + 2) * sizeof (int));
|
||||
type_atoms = (int *) malloc (8 * num_atoms * sizeof (int));
|
||||
// temporary declaration of variables
|
||||
@ -261,10 +255,7 @@ int main (int argc, char *argv[])
|
||||
(stat == NULL) ||
|
||||
(stat_all == NULL))
|
||||
{
|
||||
sprintf (tmp_str, "\nMemory error (error code: 17)\n");
|
||||
fputs (tmp_str, stderr);
|
||||
if (log == 1)
|
||||
fputs (tmp_str, f_log);
|
||||
print_message (quiet, stderr, log, f_log, 19, argv[0]);
|
||||
return 17;
|
||||
}
|
||||
// set type_agl to zero
|
||||
@ -303,12 +294,13 @@ int main (int argc, char *argv[])
|
||||
filename[k+3] = conv (i, 1);
|
||||
filename[k+4] = '\0';
|
||||
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);
|
||||
error = reading_coords (0, filename, type_inter, label_atom, cell, &num_mol,
|
||||
&num_atoms, true_label_mol, label_mol, type_atoms,
|
||||
coords, tmp_str);
|
||||
if (error != 1)
|
||||
{
|
||||
sprintf (tmp_str, "%6cNumber of molecules: %i; %6cNumber of atoms: %i\n",
|
||||
' ', num_mol, ' ', num_atoms);
|
||||
' ', num_mol, ' ', num_atoms);
|
||||
print_message (quiet, stdout, log, f_log, 8, tmp_str);
|
||||
}
|
||||
|
||||
@ -330,10 +322,7 @@ int main (int argc, char *argv[])
|
||||
(stat == NULL) ||
|
||||
(stat_all == NULL))
|
||||
{
|
||||
sprintf (tmp_str, "\nMemory error (error code: 18)\n");
|
||||
fputs (tmp_str, stderr);
|
||||
if (log == 1)
|
||||
fputs (tmp_str, f_log);
|
||||
print_message (quiet, stderr, log, f_log, 19, argv[0]);
|
||||
return 18;
|
||||
}
|
||||
print_message (quiet, stdout, log, f_log, 9, argv[0]);
|
||||
|
@ -77,6 +77,21 @@ int message (const int log, const int mode, const char *text, FILE *output)
|
||||
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;
|
||||
}
|
||||
|
||||
fputs (out, output);
|
||||
|
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user