File: generate_phi_psi.c

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

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

			    generate_phi_psi.c

Purpose:
	Generate the angles phi and psi. Use the specified secondary
	structure code. The pseudo-random seed should be initialized
	somewhere else (check the function ApplyStructure_ ()). Note
	that small deviations from ideal values are introduced. This
	is good if you want to prepare the Ramachandran plot for the
	new structure.

Input:
	(1) Pointer to double, where phi angle will be stored.
	(2) Pointer to double, where psi angle will be stored.
	(3) Secondary structure one letter code.

Output:
	(1) Angles psi and psi generated.
	(2) Return value.

Return value:
	(1) Positive if code is recognized.
	(2) Negative if code is not recognized.

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

#include <stdio.h>

#include <stdlib.h>
#include <math.h>

#include "defines.h"

/*======generate angles phi and psi:=========================================*/

int GeneratePhiAndPsi_ (double *phiP, double *psiP, int sec_structure_code)
{
double		phi0, psi0;
double		max_value, reciprocal_denominator;
double		radius, angle;
double		delta_phi, delta_psi;

/* Prepare the mean values: */
switch (sec_structure_code)
	{
	/* Beta sheet, coil, turn: */
	case 'E':
	case 'C':
	case 'T':
		phi0 = -2.426008;	/* -139.0 degrees */
		psi0 =  2.356195;	/* +135.0 degrees */
		break;

	/* Alpha helix: */
	case 'H':
		phi0 = -0.994838;	/* -57.0 degrees */
		psi0 = -0.820305;	/* -47.0 degrees */
		break;

	/* 3-10 helix: */
	case 'G':
		phi0 = -1.239184;	/* -71.0 degrees */
		psi0 = -0.314159;	/* -18.0 degrees */
		break;

	/* Do not change phi and psi if code is not recognized: */
	default:
		return -1;
	}

/* Prepare denominator: */
max_value = (double) RAND_MAX;
if (max_value != 0.0) reciprocal_denominator = 1.0 / max_value;
else reciprocal_denominator = 1.0;

/* Generate small deviations: */
radius = (double) rand () * reciprocal_denominator;
angle = 6.2831853 * ((double) rand () * reciprocal_denominator);
delta_phi = 0.087266463 * radius * cos (angle);
delta_psi = 0.087266463 * radius * sin (angle);

/* Combine mean values and deviations: */
*phiP = phi0 + delta_phi;
*psiP = psi0 + delta_psi;

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

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