]> git.donarmstrong.com Git - mothur.git/blob - sffinfocommand.h
changed how rarefaction commands find the lci and hci. they now save values from...
[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         
73         string getHelpString(); 
74     string getOutputPattern(string);    
75         string getCitation() { return "http://www.mothur.org/wiki/Sffinfo"; }
76         string getDescription()         { return "extract sequences reads from a .sff file"; }
77
78         int execute(); 
79         void help() { m->mothurOut(getHelpString()); }  
80         
81 private:
82         string sffFilename, sfftxtFilename, outputDir, accnosName, currentFileName, oligosfile, noMatchFile;
83         vector<string> filenames, outputNames, accnosFileNames, oligosFileNames;
84         bool abort, fasta, qual, trim, flow, sfftxt, hasAccnos, hasOligos;
85         int mycount, split, numFPrimers, numLinkers, numSpacers, pdiffs, bdiffs, ldiffs, sdiffs, tdiffs;
86         set<string> seqNames;
87     map<string, int> barcodes;
88     map<string, int> primers;
89     vector<string> linker, spacer, primerNameVector, barcodeNameVector, revPrimer;
90     vector<vector<int> > numSplitReads;
91     vector<vector<string> > filehandles, filehandlesHeaders;
92     
93         //extract sff file functions
94         int extractSffInfo(string, string, string);
95         int readCommonHeader(ifstream&, CommonHeader&);
96         //int readHeader(ifstream&, Header&);
97         int readSeqData(ifstream&, seqRead&, int, Header&);
98         int decodeName(string&, string&, string&, string);
99     bool readOligos(string oligosFile);
100         
101         int printCommonHeader(ofstream&, CommonHeader&); 
102         int printHeader(ofstream&, Header&);
103         int printSffTxtSeqData(ofstream&, seqRead&, Header&);
104         int printFlowSeqData(ofstream&, seqRead&, Header&);
105         int printFastaSeqData(ofstream&, seqRead&, Header&);
106         int printQualSeqData(ofstream&, seqRead&, Header&);
107         int readAccnosFile(string);
108         int parseSffTxt();
109         bool sanityCheck(Header&, seqRead&);
110     int adjustCommonHeader(CommonHeader);
111     int findGroup(Header header, seqRead read, int& barcode, int& primer);
112     string reverseOligo(string oligo);
113     
114         //parsesfftxt file functions
115         int parseHeaderLineToInt(ifstream&);
116         vector<unsigned short> parseHeaderLineToFloatVector(ifstream&, int);
117         vector<unsigned int> parseHeaderLineToIntVector(ifstream&, int);
118         string parseHeaderLineToString(ifstream&);
119 };
120
121 /**********************************************************/
122  
123 #endif
124
125