1 /**
2  * Author: Mark Larkin
3  *
4  * Copyright (c) 2007 Des Higgins, Julie Thompson and Toby Gibson.
5  */
6 /*
7  * The class AlignmentOutput is used to output the Alignment in all the different
8  * formats that have been selected. It will output all the different file types if
9  * these have been selected from the menu or the commandline.
10  * To use this class we must call openAlignmentOutput first. Then we call the function
11  * createAlignmentOutput with an Alignment to be output and the first and last sequence
12  * to be output as well.
13  */
14 #ifndef ALIGNMENTOUTPUT_H
15 #define ALIGNMENTOUTPUT_H
16 
17 #include <string>
18 #include <vector>
19 #include <fstream>
20 #include <memory>
21 #include <sstream>
22 #include <exception>
23 #include <cassert>
24 #include "Alignment.h"
25 
26 
27 namespace clustalw
28 {
29 
30 typedef struct rangeNum
31 {
32     int start;
33     int end;
34 } rangeNum;
35 
36 typedef struct outputRegion
37 {
38     int _firstSeq;
39     int _lastSeq;
40     int _firstRes;
41     int _lastRes;
42 } outputRegion;
43 
44 class AlignmentOutput
45 {
46     public:
47         /* Functions */
48         AlignmentOutput();
49         bool openAlignmentOutput(string path);
50         bool QTOpenFilesForOutput(AlignmentFileNames fileNames);
51         void createAlignmentOutput(Alignment* alignPtr, int firstSeq, int lastSeq);
52         void printSecStructMask(int prfLength, vector<char>* mask, vector<char>* structMask);
53         /* Attributes */
54 
55     private:
56         /* Functions */
57         void fastaOut(Alignment* alignPtr, outputRegion partToOutput);
58         void clustalOut(Alignment* alignPtr, outputRegion partToOutput);
59         void gcgOut(Alignment* alignPtr, outputRegion partToOutput);
60         void nexusOut(Alignment* alignPtr, outputRegion partToOutput);
61         void phylipOut(Alignment* alignPtr, outputRegion partToOutput);
62         void nbrfOut(Alignment* alignPtr, outputRegion partToOutput);
63         void gdeOut(Alignment* alignPtr, outputRegion partToOutput);
64         string nameonly(string s);
65 
66         void findRangeValues(Alignment* alignPtr, rangeNum *rnum, int firstRes, int lastRes,
67                              int firstSeq);
68         bool openExplicitFile(auto_ptr<ofstream>& outFile, string fileName);
69         string openOutputFile(auto_ptr<ofstream>& outFile, string prompt, string path,
70                               string fileExtension);
71         int SeqGCGCheckSum(vector<char>* sequence, int length);
72         void showAlign();
73         /* Attributes */
74 
75         auto_ptr<ofstream> clustalOutFile;
76         auto_ptr<ofstream> gcgOutFile;
77         auto_ptr<ofstream> nbrfOutFile;
78         auto_ptr<ofstream> phylipOutFile;
79         auto_ptr<ofstream> gdeOutFile;
80         auto_ptr<ofstream> nexusOutFile;
81         auto_ptr<ofstream> fastaOutFile;
82 
83         string clustalOutName;
84         string gcgOutName;
85         string phylipOutName;
86         string nbrfOutName;
87         string gdeOutName;
88         string nexusOutName;
89         string fastaOutName;
90         vector<string> strongGroup;
91         vector<string> weakGroup;
92         int clusSecStructOffset;
93         int clusSequenceOffset;
94 };
95 
96 }
97 #endif
98 
99