]> git.donarmstrong.com Git - mothur.git/blob - sffinfocommand.h
started work on sffinfo command. fixed bug across all paralellized commands if the...
[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         uint32_t magicNumber;
21         char* version;
22         uint64_t indexOffset;
23         uint32_t indexLength;
24         uint32_t numReads;
25         uint16_t headerLength;
26         uint16_t keyLength;
27         uint16_t numFlowsPerRead;
28         uint8_t flogramFormatCode;
29         char* flowChars; //length depends on number flow reads
30         char* keySequence; //length depends on key length
31         
32         CommonHeader() { magicNumber=0; indexOffset=0; indexLength=0; numReads=0; headerLength=0; keyLength=0; numFlowsPerRead=0; flogramFormatCode='s'; }
33 };
34 /**********************************************************/
35 struct Header {
36         unsigned short headerLength;
37         unsigned short nameLength;
38         unsigned int numBases;
39         unsigned short clipQualLeft;
40         unsigned short clipQualRight;
41         unsigned short clipAdapterLeft;
42         unsigned short clipAdapterRight;
43         char* name; //length depends on nameLength
44
45         Header() { headerLength=0; nameLength=0; numBases=0; clipQualLeft=0; clipQualRight=0; clipAdapterLeft=0; clipAdapterRight=0; }
46 };
47 /**********************************************************/
48 struct seqRead {
49         vector<unsigned short> flowgram;
50         vector<unsigned int> flowIndex;
51         char* bases;
52         vector<unsigned int> qualScores;
53 };
54 /**********************************************************/
55
56 class SffInfoCommand : public Command {
57         
58 public:
59         SffInfoCommand(string);
60         ~SffInfoCommand();
61         int execute();
62         void help();
63         
64 private:
65         string sffFilename, outputDir;
66         vector<string> filenames, outputNames;
67         bool abort;
68         
69         int extractSffInfo(string, string);
70         CommonHeader* readCommonHeader(ifstream&);
71         Header* readHeader(ifstream&);
72         seqRead* readSeqData(ifstream&, int, int);
73         
74         int printCommonHeader(ofstream&, CommonHeader*, bool); //bool is debug mode
75         int printHeader(ofstream&, Header*, bool);
76         int printSeqData(ofstream&, seqRead*, bool);
77                 
78 };
79
80 /**********************************************************/
81  
82 #endif
83
84