File: reset_psi.c

package info (click to toggle)
garlic 1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 4,516 kB
  • sloc: ansic: 52,465; makefile: 2,254
file content (111 lines) | stat: -rw-r--r-- 3,051 bytes parent folder | download | duplicates (5)
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
/* Copyright (C) 2001 Damir Zucic */

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

				reset_psi.c

Purpose:
	Reset the psi angle in each residue. Each psi angle will be changed
	to +180 degrees.  The chain will be messed up!  Please note that if
	you modify  default angle you will also have to modify the function
	ApplyStructure_ (),  because  it assumes  that you  are using  +180
	degrees here.

Input:
	(1) Pointer to MolComplexS structure, with macromolecular data.

Output:
	(1) Psi angle changed to -180 degrees (in each residue).
	(2) Return value.

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

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

#include <stdio.h>

#include <string.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:=================================================*/

int		ExtractNCACO_ (VectorS *, VectorS *, VectorS *, VectorS *,
			       AtomS *, size_t, size_t);
double		PsiFromNCACO_ (VectorS *, VectorS *, VectorS *, VectorS *);
int		RotateAtom_ (AtomS *, VectorS *, VectorS *, double);

/*======change psi angle to +180 degrees; do it for each residue:============*/

int ResetPsi_ (MolComplexS *mol_complexSP)
{
int			residuesN;
int			residueI;
ResidueS		*curr_residueSP;
size_t			atom_startI, atom_endI, atomI;
AtomS			*atomSP;
int			n;
static VectorS		N_vectorS, CA_vectorS, C_vectorS, O_vectorS;
double			psi, delta_psi;

/* Prepare the number of residues: */
residuesN = mol_complexSP->residuesN;

/* Scan the macromolecular complex: */
for (residueI = 0; residueI < residuesN; residueI++)
	{
	/* Pointer to the current residue: */
	curr_residueSP = mol_complexSP->residueSP + residueI;

	/* Prepare the atomic index range: */
	atom_startI = curr_residueSP->residue_startI;
	atom_endI   = curr_residueSP->residue_endI;

	/* Extract N, CA, C and O coordinates: */
	n = ExtractNCACO_ (&N_vectorS, &CA_vectorS, &C_vectorS, &O_vectorS,
			   mol_complexSP->atomSP, atom_startI, atom_endI);

	/* All four atoms are required to reset the psi angle: */
	if (n < 4) continue;

	/* If this point  is reached,  the coordinates */
	/* for all four required atoms were retrieved. */

	/* Calculate the psi angle (radians): */
	psi =  PsiFromNCACO_ (&N_vectorS, &CA_vectorS, &C_vectorS, &O_vectorS);

	/* Prepare the rotation angle: */
	delta_psi = 3.1415927 - psi;

	/* Now rotate the O atom about the CA-C bond: */
	for (atomI = atom_startI; atomI <= atom_endI; atomI++)
		{
		/* Pointer to the current atom: */
		atomSP = mol_complexSP->atomSP + atomI;

		/* Check is it the O atom: */
		if (strcmp (atomSP->raw_atomS.pure_atom_nameA, "O") != 0)
			{
			continue;
			}

		/* Rotate the O atom about CA-C bond: */
		RotateAtom_ (atomSP, &CA_vectorS, &C_vectorS, delta_psi);
		}
	}

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

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