X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=sffinfocommand.h;h=b304e485c1270aba1b4b761dc9e7b66af54dcfcf;hb=fefd5ee1517abd3bc38b469cb2dffc85a1571c7e;hp=e33bd59b8559bfda513c07d29f2356831e5cd4c8;hpb=cf9a187f89caf821e454d1547d9b3893e17a1e76;p=mothur.git diff --git a/sffinfocommand.h b/sffinfocommand.h index e33bd59..b304e48 100644 --- a/sffinfocommand.h +++ b/sffinfocommand.h @@ -11,75 +11,71 @@ */ #include "command.hpp" +#include "groupmap.h" +#include "oligos.h" +#include "trimoligos.h" -#define SFF_MAGIC 0x2e736666 /* ".sff" */ -#define SFF_VERSION "\0\0\0\1" - -/**********************************************************/ -struct CommonHeader { - unsigned int magicNumber; - char* version; - unsigned long int indexOffset; - unsigned int indexLength; - unsigned int numReads; - unsigned short headerLength; - unsigned short keyLength; - unsigned short numFlowsPerRead; - char flogramFormatCode; - char* flowChars; //length depends on number flow reads - char* keySequence; //length depends on key length - - CommonHeader(){ magicNumber=0; version=NULL; indexOffset=0; indexLength=0; numReads=0; headerLength=0; keyLength=0; numFlowsPerRead=0; flogramFormatCode='s'; flowChars=NULL; keySequence=NULL; } - ~CommonHeader() { if (version != NULL) { delete [] version; } if (flowChars != NULL) { delete [] flowChars; } if (keySequence != NULL) { delete [] keySequence; } } -}; -/**********************************************************/ -struct Header { - unsigned short headerLength; - unsigned short nameLength; - unsigned int numBases; - unsigned short clipQualLeft; - unsigned short clipQualRight; - unsigned short clipAdapterLeft; - unsigned short clipAdapterRight; - char* name; //length depends on nameLength - - Header() { headerLength=0; nameLength=0; numBases=0; clipQualLeft=0; clipQualRight=0; clipAdapterLeft=0; clipAdapterRight=0; name=NULL; } - ~Header() { if (name != NULL) { delete [] name; } } -}; -/**********************************************************/ -struct seqRead { - vector flowgram; - vector flowIndex; - char* bases; - vector qualScores; - - seqRead() { bases=NULL; } - ~seqRead() { if (bases != NULL) { delete [] bases; } } -}; /**********************************************************/ class SffInfoCommand : public Command { public: SffInfoCommand(string); - ~SffInfoCommand(); - int execute(); - void help(); + SffInfoCommand(); + ~SffInfoCommand(){} -private: - string sffFilename, outputDir; - vector filenames, outputNames; - bool abort; + vector setParameters(); + string getCommandName() { return "sffinfo"; } + string getCommandCategory() { return "Sequence Processing"; } - int extractSffInfo(string, string); - int readCommonHeader(ifstream&, CommonHeader*); - int readHeader(ifstream&, Header*); - int readSeqData(ifstream&, seqRead*, int, int); + string getHelpString(); + string getOutputPattern(string); + string getCitation() { return "http://www.mothur.org/wiki/Sffinfo"; } + string getDescription() { return "extract sequences reads from a .sff file"; } + + int execute(); + void help() { m->mothurOut(getHelpString()); } + +private: + string sffFilename, sfftxtFilename, outputDir, accnosName, currentFileName, oligosfile, noMatchFile, groupfile; + vector filenames, outputNames, accnosFileNames, oligosFileNames, groupFileNames; + bool abort, fasta, qual, trim, flow, sfftxt, hasAccnos, hasOligos, hasGroup, reorient, pairedOligos; + int mycount, split, numBarcodes, numFPrimers, numLinkers, numSpacers, numRPrimers, pdiffs, bdiffs, ldiffs, sdiffs, tdiffs, numNoMatch; + set seqNames; + GroupMap* groupMap; + vector > numSplitReads; + vector > filehandles; + vector > filehandlesHeaders; + Oligos* oligosObject; + + //extract sff file functions + int extractSffInfo(string, string, string); + int readCommonHeader(ifstream&, CommonHeader&); + int readHeader(ifstream&, Header&); + bool readSeqData(ifstream&, seqRead&, int, Header&, TrimOligos*&, TrimOligos*&); + int decodeName(string&, string&, string&, string); + bool readOligos(string oligosFile); + bool readGroup(string oligosFile); - int printCommonHeader(ofstream&, CommonHeader*, bool); //bool is debug mode - int printHeader(ofstream&, Header*, bool); - int printSeqData(ofstream&, seqRead*, bool); - + int printCommonHeader(ofstream&, CommonHeader&); + int printHeader(ofstream&, Header&); + int printSffTxtSeqData(ofstream&, seqRead&, Header&); + int printFlowSeqData(ofstream&, seqRead&, Header&); + int printFastaSeqData(ofstream&, seqRead&, Header&); + int printQualSeqData(ofstream&, seqRead&, Header&); + int readAccnosFile(string); + int parseSffTxt(); + bool sanityCheck(Header&, seqRead&); + int adjustCommonHeader(CommonHeader); + int findGroup(Header header, seqRead read, int& barcode, int& primer, TrimOligos*&, TrimOligos*&); + int findGroup(Header header, seqRead read, int& barcode, int& primer, string); + string reverseOligo(string oligo); + + //parsesfftxt file functions + int parseHeaderLineToInt(ifstream&); + vector parseHeaderLineToFloatVector(ifstream&, int); + vector parseHeaderLineToIntVector(ifstream&, int); + string parseHeaderLineToString(ifstream&); }; /**********************************************************/