]> git.donarmstrong.com Git - mothur.git/blob - sffinfocommand.h
added load.logfile command. changed summary.single output for subsample=t.
[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
16 /**********************************************************/
17 struct CommonHeader {
18         unsigned int magicNumber;
19         string version;
20         unsigned long long indexOffset;
21         unsigned int indexLength;
22         unsigned int numReads;
23         unsigned short headerLength;
24         unsigned short keyLength;
25         unsigned short numFlowsPerRead;
26         int flogramFormatCode;
27         string flowChars; //length depends on number flow reads
28         string keySequence; //length depends on key length
29         
30         CommonHeader(){ magicNumber=0; indexOffset=0; indexLength=0; numReads=0; headerLength=0; keyLength=0; numFlowsPerRead=0; flogramFormatCode='s'; } 
31         ~CommonHeader() { }
32 };
33 /**********************************************************/
34 struct Header {
35         unsigned short headerLength;
36         unsigned short nameLength;
37         unsigned int numBases;
38         unsigned short clipQualLeft;
39         unsigned short clipQualRight;
40         unsigned short clipAdapterLeft;
41         unsigned short clipAdapterRight;
42         string name; //length depends on nameLength
43         string timestamp;
44         string region;
45         string xy;
46         
47         Header() { headerLength=0; nameLength=0; numBases=0; clipQualLeft=0; clipQualRight=0; clipAdapterLeft=0; clipAdapterRight=0; }
48         ~Header() { } 
49 };
50 /**********************************************************/
51 struct seqRead {
52         vector<unsigned short> flowgram;
53         vector<unsigned int> flowIndex;
54         string bases;
55         vector<unsigned int> qualScores;
56         
57         seqRead() { } 
58         ~seqRead() { } 
59 };
60 /**********************************************************/
61
62 class SffInfoCommand : public Command {
63         
64 public:
65         SffInfoCommand(string);
66         SffInfoCommand();
67         ~SffInfoCommand(){}
68         
69         vector<string> setParameters();
70         string getCommandName()                 { return "sffinfo";                                     }
71         string getCommandCategory()             { return "Sequence Processing";         }
72         string getOutputFileNameTag(string, string);
73         string getHelpString(); 
74         string getCitation() { return "http://www.mothur.org/wiki/Sffinfo"; }
75         string getDescription()         { return "extract sequences reads from a .sff file"; }
76
77         int execute(); 
78         void help() { m->mothurOut(getHelpString()); }  
79         
80 private:
81         string sffFilename, sfftxtFilename, outputDir, accnosName;
82         vector<string> filenames, outputNames, accnosFileNames;
83         bool abort, fasta, qual, trim, flow, sfftxt, hasAccnos;
84         int mycount;
85         set<string> seqNames;
86     
87         //extract sff file functions
88         int extractSffInfo(string, string);
89         int readCommonHeader(ifstream&, CommonHeader&);
90         int readHeader(ifstream&, Header&);
91         int readSeqData(ifstream&, seqRead&, int, int);
92         int decodeName(string&, string&, string&, string);
93         
94         int printCommonHeader(ofstream&, CommonHeader&); 
95         int printHeader(ofstream&, Header&);
96         int printSffTxtSeqData(ofstream&, seqRead&, Header&);
97         int printFlowSeqData(ofstream&, seqRead&, Header&);
98         int printFastaSeqData(ofstream&, seqRead&, Header&);
99         int printQualSeqData(ofstream&, seqRead&, Header&);
100         int readAccnosFile(string);
101         int parseSffTxt();
102         bool sanityCheck(Header&, seqRead&);
103     
104         //parsesfftxt file functions
105         int parseHeaderLineToInt(ifstream&);
106         vector<unsigned short> parseHeaderLineToFloatVector(ifstream&, int);
107         vector<unsigned int> parseHeaderLineToIntVector(ifstream&, int);
108         string parseHeaderLineToString(ifstream&);
109 };
110
111 /**********************************************************/
112  
113 #endif
114
115