1 | #include "muscle.h" |
---|
2 | #include "msa.h" |
---|
3 | #include "params.h" |
---|
4 | #include "textfile.h" |
---|
5 | |
---|
6 | static void DoOutput(MSA &msa) |
---|
7 | { |
---|
8 | bool AnyOutput = false; |
---|
9 | |
---|
10 | // Value options |
---|
11 | if (g_pstrFASTAOutFileName) |
---|
12 | { |
---|
13 | TextFile File(g_pstrFASTAOutFileName, true); |
---|
14 | msa.ToFASTAFile(File); |
---|
15 | AnyOutput = true; |
---|
16 | } |
---|
17 | |
---|
18 | if (g_pstrMSFOutFileName) |
---|
19 | { |
---|
20 | TextFile File(g_pstrMSFOutFileName, true); |
---|
21 | msa.ToMSFFile(File); |
---|
22 | AnyOutput = true; |
---|
23 | } |
---|
24 | |
---|
25 | if (g_pstrClwOutFileName) |
---|
26 | { |
---|
27 | TextFile File(g_pstrClwOutFileName, true); |
---|
28 | msa.ToAlnFile(File); |
---|
29 | AnyOutput = true; |
---|
30 | } |
---|
31 | |
---|
32 | if (g_pstrClwStrictOutFileName) |
---|
33 | { |
---|
34 | g_bClwStrict = true; |
---|
35 | TextFile File(g_pstrClwStrictOutFileName, true); |
---|
36 | msa.ToAlnFile(File); |
---|
37 | AnyOutput = true; |
---|
38 | } |
---|
39 | |
---|
40 | if (g_pstrHTMLOutFileName) |
---|
41 | { |
---|
42 | TextFile File(g_pstrHTMLOutFileName, true); |
---|
43 | msa.ToHTMLFile(File); |
---|
44 | AnyOutput = true; |
---|
45 | } |
---|
46 | |
---|
47 | if (g_pstrPHYIOutFileName) |
---|
48 | { |
---|
49 | TextFile File(g_pstrPHYIOutFileName, true); |
---|
50 | msa.ToPhyInterleavedFile(File); |
---|
51 | AnyOutput = true; |
---|
52 | } |
---|
53 | |
---|
54 | if (g_pstrPHYSOutFileName) |
---|
55 | { |
---|
56 | TextFile File(g_pstrPHYSOutFileName, true); |
---|
57 | msa.ToPhySequentialFile(File); |
---|
58 | AnyOutput = true; |
---|
59 | } |
---|
60 | |
---|
61 | // Flag options, at most one used (because only one -out filename) |
---|
62 | TextFile fileOut(g_pstrOutFileName, true); |
---|
63 | if (g_bFASTA) |
---|
64 | { |
---|
65 | msa.ToFASTAFile(fileOut); |
---|
66 | AnyOutput = true; |
---|
67 | } |
---|
68 | else if (g_bMSF) |
---|
69 | { |
---|
70 | msa.ToMSFFile(fileOut); |
---|
71 | AnyOutput = true; |
---|
72 | } |
---|
73 | else if (g_bAln) |
---|
74 | { |
---|
75 | msa.ToAlnFile(fileOut); |
---|
76 | AnyOutput = true; |
---|
77 | } |
---|
78 | else if (g_bHTML) |
---|
79 | { |
---|
80 | msa.ToHTMLFile(fileOut); |
---|
81 | AnyOutput = true; |
---|
82 | } |
---|
83 | else if (g_bPHYI) |
---|
84 | { |
---|
85 | msa.ToPhyInterleavedFile(fileOut); |
---|
86 | AnyOutput = true; |
---|
87 | } |
---|
88 | else if (g_bPHYS) |
---|
89 | { |
---|
90 | msa.ToPhySequentialFile(fileOut); |
---|
91 | AnyOutput = true; |
---|
92 | } |
---|
93 | |
---|
94 | // If -out option was given but no flags, output as FASTA |
---|
95 | if (!AnyOutput) |
---|
96 | msa.ToFASTAFile(fileOut); |
---|
97 | |
---|
98 | fileOut.Close(); |
---|
99 | |
---|
100 | if (0 != g_pstrScoreFileName) |
---|
101 | WriteScoreFile(msa); |
---|
102 | } |
---|
103 | |
---|
104 | void MuscleOutput(MSA &msa) |
---|
105 | { |
---|
106 | MHackEnd(msa); |
---|
107 | if (g_bStable) |
---|
108 | { |
---|
109 | MSA msaStable; |
---|
110 | Stabilize(msa, msaStable); |
---|
111 | msa.Clear(); // save memory |
---|
112 | DoOutput(msaStable); |
---|
113 | } |
---|
114 | else |
---|
115 | DoOutput(msa); |
---|
116 | } |
---|