source: branches/profile/GDE/MUSCLE/src/mhack.cpp

Last change on this file was 10390, checked in by aboeckma, 11 years ago

added muscle sourcles amd makefile

File size: 1.3 KB
Line 
1#include "muscle.h"
2#include "seqvect.h"
3#include "msa.h"
4
5/***
6Methionine hack.
7Most proteins start with M.
8This results in odd-looking alignments with the terminal Ms aligned followed
9immediately by gaps.
10Hack this by treating terminal M like X.
11***/
12
13static bool *M;
14
15void MHackStart(SeqVect &v)
16        {
17        if (ALPHA_Amino != g_Alpha)
18                return;
19
20        const unsigned uSeqCount = v.Length();
21        M = new bool[uSeqCount];
22        memset(M, 0, uSeqCount*sizeof(bool));
23        for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex)
24                {
25                Seq &s = v.GetSeq(uSeqIndex);
26                if (0 == s.Length())
27                        continue;
28                unsigned uId = s.GetId();
29                if (s[0] == 'M' || s[0] == 'm')
30                        {
31                        M[uId] = true;
32                        s[0] = 'X';
33                        }
34                }
35        }
36
37void MHackEnd(MSA &msa)
38        {
39        if (ALPHA_Amino != g_Alpha)
40                return;
41        if (0 == M)
42                return;
43
44        const unsigned uSeqCount = msa.GetSeqCount();
45        const unsigned uColCount = msa.GetColCount();
46        for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex)
47                {
48                unsigned uId = msa.GetSeqId(uSeqIndex);
49                if (M[uId])
50                        {
51                        for (unsigned uColIndex = 0; uColIndex < uColCount; ++uColIndex)
52                                {
53                                if (!msa.IsGap(uSeqIndex, uColIndex))
54                                        {
55                                        msa.SetChar(uSeqIndex, uColIndex, 'M');
56                                        break;
57                                        }
58                                }
59                        }
60                }
61
62        delete[] M;
63        M = 0;
64        }
Note: See TracBrowser for help on using the repository browser.