1
/* $Id: raw_scoremat.c,v 1.3 2003/12/29 21:25:50 ucko Exp $
2
* ===========================================================================
5
* National Center for Biotechnology Information
7
* This software/database is a "United States Government Work" under the
8
* terms of the United States Copyright Act. It was written as part of
9
* the author's official duties as a United States Government employee and
10
* thus cannot be copyrighted. This software/database is freely available
11
* to the public for use. The National Library of Medicine and the U.S.
12
* Government have not placed any restriction on its use or reproduction.
14
* Although all reasonable efforts have been taken to ensure the accuracy
15
* and reliability of the software and data, the NLM and the U.S.
16
* Government do not and cannot warrant the performance or results that
17
* may be obtained by using this software or data. The NLM and the U.S.
18
* Government disclaim all warranties, express or implied, including
19
* warranties of performance, merchantability or fitness for any particular
22
* Please cite the author in any work or product based on this material.
24
* ===========================================================================
29
* Protein alignment score matrices; shared between the two toolkits.
33
#include <util/tables/raw_scoremat.h>
38
#include "sm_blosum45.c"
39
#include "sm_blosum62.c"
40
#include "sm_blosum80.c"
43
#include "sm_pam250.c"
45
static const char kNCBIstdaa[] = "-ABCDEFGHIKLMNPQRSTVWXYZU*";
48
int NCBISM_GetIndex(const SNCBIPackedScoreMatrix* sm, int aa)
52
/* Translate to NCBIeaa */
53
if (aa >= 0 && aa < sizeof(kNCBIstdaa)) {
55
} else if (islower(aa)) {
59
p = strchr(sm->symbols, aa);
60
return p ? p - sm->symbols : -1;
64
TNCBIScore NCBISM_GetScore(const SNCBIPackedScoreMatrix* sm,
68
i1 = NCBISM_GetIndex(sm, aa1);
69
i2 = NCBISM_GetIndex(sm, aa2);
70
if (i1 >=0 && i2 >= 0) {
71
return sm->scores[i1 * strlen(sm->symbols) + i2];
78
void NCBISM_Unpack(const SNCBIPackedScoreMatrix* psm,
79
SNCBIFullScoreMatrix* fsm)
82
int dim, i, j, aa1, aa2;
86
/* fill with default */
87
memset(&fsm->s, psm->defscore, NCBI_FSM_DIM * NCBI_FSM_DIM);
88
for (i = 0; i < dim; ++i) {
90
/* get core (NCBIeaa x NCBIeaa) */
91
for (j = 0; j < dim; ++j) {
93
fsm->s[aa1][aa2] = psm->scores[i * dim + j];
95
/* extend horizontally */
96
for (aa2 = 0; aa2 < sizeof(kNCBIstdaa); ++aa2) {
97
fsm->s[aa1][aa2] = fsm->s[aa1][(int)kNCBIstdaa[aa2]];
99
for (aa2 = 'a'; aa2 <= 'z'; ++aa2) {
100
fsm->s[aa1][aa2] = fsm->s[aa1][toupper(aa2)];
103
/* extend vertically */
104
for (aa1 = 0; aa1 < sizeof(kNCBIstdaa); ++aa1) {
105
memcpy(fsm->s[aa1], fsm->s[(int)kNCBIstdaa[aa1]], NCBI_FSM_DIM);
107
for (aa1 = 'a'; aa1 <= 'z'; ++aa1) {
108
memcpy(fsm->s[aa1], fsm->s[toupper(aa1)], NCBI_FSM_DIM);
114
* ===========================================================================
115
* $Log: raw_scoremat.c,v $
116
* Revision 1.3 2003/12/29 21:25:50 ucko
119
* Revision 1.2 2003/10/02 15:37:34 ivanov
120
* Get rid of compilation warnings
122
* Revision 1.1 2003/08/21 19:48:20 ucko
123
* Add tables library (shared with C) for raw score matrices, etc.
125
* ===========================================================================