File: align_complexes.c

package info (click to toggle)
garlic 1.1-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,492 kB
  • ctags: 1,013
  • sloc: ansic: 29,925; makefile: 753
file content (114 lines) | stat: -rw-r--r-- 3,496 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* Copyright (C) 2000 Damir Zucic */

/*=============================================================================

				align_complexes.c

Purpose:
	Align two macromolecular complexes vertically. The first complex
	will be placed at the bottom, while the second will be placed at
	the top. A small separation will be left between them.

Input:
	(1) Pointer to MolComplexS structure, with the first complex.
	(2) Pointer to MolComplexS structure, with the second complex.
	(3) Pointer to ConfigS structure.

Output:
	(1) Two macromolecular complexes will be translated.
	(2) Return value.

Return value:
	(1) Positive on success.
	(2) Negative on failure.

========includes:============================================================*/

#include <stdio.h>

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/Xatom.h>

#include "defines.h"
#include "typedefs.h"

/*======function prototypes:=================================================*/

void		TranslateComplex_ (MolComplexS *, VectorS *, ConfigS *);
void		TranslatePlane_ (MolComplexS *, VectorS *);

/*======align two complexes vertically:======================================*/

int AlignComplexes_ (MolComplexS *mol_complex1SP, MolComplexS *mol_complex2SP,
		     ConfigS *configSP)
{
size_t		atomI;
AtomS		*curr_atomSP;
double		y, y1_min, y2_max;
VectorS		shift_vectorS;

/* Check pointers: */
if (!mol_complex1SP) return -1;
if (!mol_complex2SP) return -2;

/* Both complexes should contain at least one atom: */
if (mol_complex1SP->atomsN == 0) return -3;
if (mol_complex2SP->atomsN == 0) return -4;

/* For the first complex, find the minimal y: */
y1_min = mol_complex1SP->atomSP->raw_atomS.y;
for (atomI = 0; atomI < mol_complex1SP->atomsN; atomI++)
	{
	/* Pointer to the current atom: */
	curr_atomSP = mol_complex1SP->atomSP + atomI;

	/* The y coordinate of the current atom: */
	y = curr_atomSP->raw_atomS.y;

	/* Compare y with y1_min: */
	if (y < y1_min) y1_min = y;
	}

/* For the second complex, find the maximal y: */
y2_max = mol_complex2SP->atomSP->raw_atomS.y;
for (atomI = 0; atomI < mol_complex2SP->atomsN; atomI++)
	{
	/* Pointer to the current atom: */
	curr_atomSP = mol_complex2SP->atomSP + atomI;

	/* The y coordinate of the current atom: */
	y = curr_atomSP->raw_atomS.y;

	/* Compare y with y2_max: */
	if (y > y2_max) y2_max = y;
	}

/* Prepare the translation vector for the first complex. The geometric */
/* center should be moved to y axis, slightly below the system origin: */
shift_vectorS.x = -1.0 * mol_complex1SP->geometric_center_vectorS.x;
shift_vectorS.y = -1.0 *(y1_min - 0.5 * DOCKING_GAP);
shift_vectorS.z = -1.0 * mol_complex1SP->geometric_center_vectorS.z;

/* Translate the first complex and its associated plane: */
TranslateComplex_ (mol_complex1SP, &shift_vectorS, configSP);
TranslatePlane_ (mol_complex1SP, &shift_vectorS);

/* Prepare the translation vector for the second complex. The geometric */
/* center should be moved to y axis,  slightly above the system origin: */
shift_vectorS.x = -1.0 * mol_complex2SP->geometric_center_vectorS.x;
shift_vectorS.y = -1.0 *(y2_max + 0.5 * DOCKING_GAP);
shift_vectorS.z = -1.0 * mol_complex2SP->geometric_center_vectorS.z;

/* Translate the second complex: */
TranslateComplex_ (mol_complex2SP, &shift_vectorS, configSP);
TranslatePlane_ (mol_complex2SP, &shift_vectorS);

/* Return positive value on success: */
return 1;
}

/*===========================================================================*/