1 | #include "muscle.h" |
---|
2 | #include "textfile.h" |
---|
3 | #include "msa.h" |
---|
4 | #include "tree.h" |
---|
5 | #include "profile.h" |
---|
6 | #include "objscore.h" |
---|
7 | |
---|
8 | bool g_bTracePPScore = false; |
---|
9 | MSA *g_ptrPPScoreMSA1 = 0; |
---|
10 | MSA *g_ptrPPScoreMSA2 = 0; |
---|
11 | |
---|
12 | static ProfPos *ProfileFromMSALocal(MSA &msa, Tree &tree) |
---|
13 | { |
---|
14 | const unsigned uSeqCount = msa.GetSeqCount(); |
---|
15 | for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex) |
---|
16 | msa.SetSeqId(uSeqIndex, uSeqIndex); |
---|
17 | |
---|
18 | TreeFromMSA(msa, tree, g_Cluster2, g_Distance2, g_Root1); |
---|
19 | SetMuscleTree(tree); |
---|
20 | return ProfileFromMSA(msa); |
---|
21 | } |
---|
22 | |
---|
23 | void PPScore() |
---|
24 | { |
---|
25 | if (0 == g_pstrFileName1 || 0 == g_pstrFileName2) |
---|
26 | Quit("-ppscore needs -in1 and -in2"); |
---|
27 | |
---|
28 | SetSeqWeightMethod(g_SeqWeight1); |
---|
29 | |
---|
30 | TextFile file1(g_pstrFileName1); |
---|
31 | TextFile file2(g_pstrFileName2); |
---|
32 | |
---|
33 | MSA msa1; |
---|
34 | MSA msa2; |
---|
35 | |
---|
36 | msa1.FromFile(file1); |
---|
37 | msa2.FromFile(file2); |
---|
38 | |
---|
39 | const unsigned uLength1 = msa1.GetColCount(); |
---|
40 | const unsigned uLength2 = msa2.GetColCount(); |
---|
41 | |
---|
42 | if (uLength1 != uLength2) |
---|
43 | Quit("Profiles must have the same length"); |
---|
44 | |
---|
45 | ALPHA Alpha = ALPHA_Undefined; |
---|
46 | switch (g_SeqType) |
---|
47 | { |
---|
48 | case SEQTYPE_Auto: |
---|
49 | Alpha = msa1.GuessAlpha(); |
---|
50 | break; |
---|
51 | |
---|
52 | case SEQTYPE_Protein: |
---|
53 | Alpha = ALPHA_Amino; |
---|
54 | break; |
---|
55 | |
---|
56 | case SEQTYPE_DNA: |
---|
57 | Alpha = ALPHA_DNA; |
---|
58 | break; |
---|
59 | |
---|
60 | case SEQTYPE_RNA: |
---|
61 | Alpha = ALPHA_RNA; |
---|
62 | break; |
---|
63 | |
---|
64 | default: |
---|
65 | Quit("Invalid SeqType"); |
---|
66 | } |
---|
67 | SetAlpha(Alpha); |
---|
68 | |
---|
69 | msa1.FixAlpha(); |
---|
70 | msa2.FixAlpha(); |
---|
71 | |
---|
72 | if (ALPHA_DNA == Alpha || ALPHA_RNA == Alpha) |
---|
73 | SetPPScore(PPSCORE_SPN); |
---|
74 | |
---|
75 | const unsigned uSeqCount1 = msa1.GetSeqCount(); |
---|
76 | const unsigned uSeqCount2 = msa2.GetSeqCount(); |
---|
77 | const unsigned uMaxSeqCount = (uSeqCount1 > uSeqCount2 ? uSeqCount1 : uSeqCount2); |
---|
78 | MSA::SetIdCount(uMaxSeqCount); |
---|
79 | |
---|
80 | Tree tree1; |
---|
81 | Tree tree2; |
---|
82 | ProfPos *Prof1 = ProfileFromMSALocal(msa1, tree1); |
---|
83 | ProfPos *Prof2 = ProfileFromMSALocal(msa2, tree2); |
---|
84 | |
---|
85 | g_bTracePPScore = true; |
---|
86 | g_ptrPPScoreMSA1 = &msa1; |
---|
87 | g_ptrPPScoreMSA2 = &msa2; |
---|
88 | |
---|
89 | SCORE Score = ObjScoreDP_Profs(Prof1, Prof2, uLength1); |
---|
90 | |
---|
91 | Log("Score=%.4g\n", Score); |
---|
92 | printf("Score=%.4g\n", Score); |
---|
93 | } |
---|