File: ProfileStandard.cpp

package info (click to toggle)
clustalx 2.1%2Blgpl-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 3,324 kB
  • sloc: cpp: 40,050; sh: 163; xml: 102; makefile: 16
file content (117 lines) | stat: -rw-r--r-- 2,627 bytes parent folder | download | duplicates (12)
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
115
116
117
/**
 * Author: Mark Larkin
 * 
 * Copyright (c) 2007 Des Higgins, Julie Thompson and Toby Gibson.  
 */
#ifdef HAVE_CONFIG_H
    #include "config.h"
#endif
#include "ProfileStandard.h"

namespace clustalw
{

/**
 * 
 * @param prfLen 
 * @param firstS 
 * @param lastS 
 * @return 
 */
ProfileStandard::ProfileStandard(int prfLen, int firstS, int lastS)
 : ProfileBase(prfLen, firstS, lastS)
{

}

/**
 * 
 */
void ProfileStandard::resetPrf2()
{
    profile.clear();
}


/**
 * 
 * @param seqArray 
 * @param seqWeight 
 */
void ProfileStandard::calcStandardProfile(SeqArray* seqArray, vector<int>* seqWeight)
{
    /** DONT FORGET TO CHECK THE SIZES ARE CORRECT */
    
    int sum1, sum2;
    int i, d;
    int r;
    int _maxAA = userParameters->getMaxAA();
    profile.resize(prfLength + 2, vector<int>(LENCOL + 2));
    int _gapPos1 = userParameters->getGapPos1();
    int _gapPos2 = userParameters->getGapPos2();
    
    for (r = 0; r < prfLength; r++)
    {
        /*
         * calculate sum2 = number of residues found in this column
         */
        sum2 = 0;
        for (i = firstSeq; i < lastSeq; i++)
        {
            sum2 += (*seqWeight)[i];
        }
        /*
         * only include matrix comparison scores for those residue types found in this
         * column
         */
        if (sum2 == 0)
        {
            for (d = 0; d <= _maxAA; d++)
            {
                profile[r + 1][d] = 0;
            }

            profile[r + 1][_gapPos1] = 0;
            profile[r + 1][_gapPos2] = 0;
        }
        else
        {
            for (d = 0; d <= _maxAA; d++)
            {
                sum1 = 0;
                for (i = firstSeq; i < lastSeq; i++)
                {
                    if (d == (*seqArray)[i][r])
                    {
                        sum1 += (*seqWeight)[i];
                    }
                }
                profile[r + 1][d] = (int)(10 *(float)sum1 / (float)sum2);
            }
            sum1 = 0;

            for (i = firstSeq; i < lastSeq; i++)
            {
                if (_gapPos1 == (*seqArray)[i][r])
                {
                    sum1 += (*seqWeight)[i];
                }
            }
            profile[r + 1][_gapPos1] = (int)(10 *(float)sum1 / (float)sum2);
            sum1 = 0;

            for (i = firstSeq; i < lastSeq; i++)
            {
                if (_gapPos2 == (*seqArray)[i][r])
                {
                    sum1 += (*seqWeight)[i];
                }
            }
            profile[r + 1][_gapPos2] = (int)(10 *(float)sum1 / (float)sum2);
        }
    }

}
                      

}