File: protein.c

package info (click to toggle)
squizz 0.99d%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 6,772 kB
  • sloc: sh: 4,799; ansic: 2,640; lex: 1,992; yacc: 1,650; makefile: 123
file content (50 lines) | stat: -rw-r--r-- 1,203 bytes parent folder | download | duplicates (3)
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
/* protein.c - Protein sequence functions */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <ctype.h>

#include "extern/file.h"
#include "sequence/protein.h"

/* Global variables */     /* FIXME: To be loaded from external file ... */
/* ??? X = 118.8860 */

/* Average isotopic masses of amino acids, from
   <URL:http://www.expasy.org/tools/findmod/findmod_masses.html#AA>

   Some guessed values from
   <URL:http://web.expasy.org/compute_pi/>

   X = ???
   B = D or N ... 114.6532
   Z = E or Q ... 128.7473
*/

static double aaw[26] = {
  071.0788, 114.6532, 103.1388, 115.0886, 129.1155, 147.1766, 057.0519, /*A-G*/
  137.1411, 113.1594, 000.0000, 128.1741, 113.1594, 131.1926, 114.1038, /*H-N*/
  237.3018, 097.1167, 128.1307, 156.1875, 087.0782, 101.1051, 150.0388, /*O-U*/
  099.1326, 186.2132, 111.3316, 163.1760, 128.7473 };                   /*V-Z*/


/* Get Molecular Weigth */
double protein_weight(char *seq) {
  char *p;
  double w;
  int i;

  /* Water average mass (H + OH) ... */
  w = 18.0152;

  p = seq;
  while (*p) {
    if (! isalpha((unsigned char)*p)) {
      p++; continue; }
    i = toupper((unsigned char)*p) - 'A';
    w += aaw[i];
    p++; }

  return w; }