]> git.donarmstrong.com Git - mothur.git/blob - sffinfocommand.h
e33bd59b8559bfda513c07d29f2356831e5cd4c8
[mothur.git] / sffinfocommand.h
1 #ifndef SFFINFOCOMMAND_H
2 #define SFFINFOCOMMAND_H
3
4 /*
5  *  sffinfocommand.h
6  *  Mothur
7  *
8  *  Created by westcott on 7/7/10.
9  *  Copyright 2010 Schloss Lab. All rights reserved.
10  *
11  */
12
13 #include "command.hpp"
14
15 #define SFF_MAGIC   0x2e736666 /* ".sff" */
16 #define SFF_VERSION "\0\0\0\1"
17
18 /**********************************************************/
19 struct CommonHeader {
20         unsigned int magicNumber;
21         char* version;
22         unsigned long int indexOffset;
23         unsigned int indexLength;
24         unsigned int numReads;
25         unsigned short headerLength;
26         unsigned short keyLength;
27         unsigned short numFlowsPerRead;
28         char flogramFormatCode;
29         char* flowChars; //length depends on number flow reads
30         char* keySequence; //length depends on key length
31         
32         CommonHeader(){ magicNumber=0; version=NULL; indexOffset=0; indexLength=0; numReads=0; headerLength=0; keyLength=0; numFlowsPerRead=0; flogramFormatCode='s'; flowChars=NULL; keySequence=NULL; }
33         ~CommonHeader() { if (version != NULL) { delete [] version; } if (flowChars != NULL) { delete [] flowChars; } if (keySequence != NULL) { delete [] keySequence; } }
34 };
35 /**********************************************************/
36 struct Header {
37         unsigned short headerLength;
38         unsigned short nameLength;
39         unsigned int numBases;
40         unsigned short clipQualLeft;
41         unsigned short clipQualRight;
42         unsigned short clipAdapterLeft;
43         unsigned short clipAdapterRight;
44         char* name; //length depends on nameLength
45         
46         Header() { headerLength=0; nameLength=0; numBases=0; clipQualLeft=0; clipQualRight=0; clipAdapterLeft=0; clipAdapterRight=0; name=NULL; }
47         ~Header() { if (name != NULL) { delete [] name; } }
48 };
49 /**********************************************************/
50 struct seqRead {
51         vector<unsigned short> flowgram;
52         vector<unsigned int> flowIndex;
53         char* bases;
54         vector<unsigned int> qualScores;
55         
56         seqRead() { bases=NULL; }
57         ~seqRead() { if (bases != NULL) { delete [] bases; } }
58 };
59 /**********************************************************/
60
61 class SffInfoCommand : public Command {
62         
63 public:
64         SffInfoCommand(string);
65         ~SffInfoCommand();
66         int execute();
67         void help();
68         
69 private:
70         string sffFilename, outputDir;
71         vector<string> filenames, outputNames;
72         bool abort;
73         
74         int extractSffInfo(string, string);
75         int readCommonHeader(ifstream&, CommonHeader*);
76         int readHeader(ifstream&, Header*);
77         int readSeqData(ifstream&, seqRead*, int, int);
78         
79         int printCommonHeader(ofstream&, CommonHeader*, bool); //bool is debug mode
80         int printHeader(ofstream&, Header*, bool);
81         int printSeqData(ofstream&, seqRead*, bool);
82                 
83 };
84
85 /**********************************************************/
86  
87 #endif
88
89