1 #ifndef SFFINFOCOMMAND_H
2 #define SFFINFOCOMMAND_H
8 * Created by westcott on 7/7/10.
9 * Copyright 2010 Schloss Lab. All rights reserved.
13 #include "command.hpp"
16 /**********************************************************/
18 unsigned int magicNumber;
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
30 CommonHeader(){ magicNumber=0; indexOffset=0; indexLength=0; numReads=0; headerLength=0; keyLength=0; numFlowsPerRead=0; flogramFormatCode='s'; }
33 /**********************************************************/
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
47 Header() { headerLength=0; nameLength=0; numBases=0; clipQualLeft=0; clipQualRight=0; clipAdapterLeft=0; clipAdapterRight=0; }
50 /**********************************************************/
52 vector<unsigned short> flowgram;
53 vector<unsigned int> flowIndex;
55 vector<unsigned int> qualScores;
60 /**********************************************************/
62 class SffInfoCommand : public Command {
65 SffInfoCommand(string);
69 vector<string> setParameters();
70 string getCommandName() { return "sffinfo"; }
71 string getCommandCategory() { return "Sequence Processing"; }
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"; }
79 void help() { m->mothurOut(getHelpString()); }
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;
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;
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);
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);
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);
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&);
121 /**********************************************************/