5 * Created by westcott on 7/7/10.
6 * Copyright 2010 Schloss Lab. All rights reserved.
10 #include "sffinfocommand.h"
11 #include "endiannessmacros.h"
13 //**********************************************************************************************************************
14 vector<string> SffInfoCommand::getValidParameters(){
16 string Array[] = {"sff","qfile","fasta","flow","trim","accnos","sfftxt","outputdir","inputdir", "outputdir"};
17 vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
21 m->errorOut(e, "SffInfoCommand", "getValidParameters");
25 //**********************************************************************************************************************
26 SffInfoCommand::SffInfoCommand(){
29 //initialize outputTypes
30 vector<string> tempOutNames;
31 outputTypes["fasta"] = tempOutNames;
32 outputTypes["flow"] = tempOutNames;
33 outputTypes["sfftxt"] = tempOutNames;
34 outputTypes["qual"] = tempOutNames;
37 m->errorOut(e, "SffInfoCommand", "SffInfoCommand");
41 //**********************************************************************************************************************
42 vector<string> SffInfoCommand::getRequiredParameters(){
44 string Array[] = {"sff"};
45 vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
49 m->errorOut(e, "SffInfoCommand", "getRequiredParameters");
53 //**********************************************************************************************************************
54 vector<string> SffInfoCommand::getRequiredFiles(){
56 vector<string> myArray;
60 m->errorOut(e, "SffInfoCommand", "getRequiredFiles");
64 //**********************************************************************************************************************
66 SffInfoCommand::SffInfoCommand(string option) {
71 //allow user to run help
72 if(option == "help") { help(); abort = true; }
75 //valid paramters for this command
76 string Array[] = {"sff","qfile","fasta","flow","trim","accnos","sfftxt","outputdir","inputdir", "outputdir"};
77 vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
79 OptionParser parser(option);
80 map<string, string> parameters = parser.getParameters();
82 ValidParameters validParameter;
83 //check to make sure all parameters are valid for command
84 for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) {
85 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
88 //initialize outputTypes
89 vector<string> tempOutNames;
90 outputTypes["fasta"] = tempOutNames;
91 outputTypes["flow"] = tempOutNames;
92 outputTypes["sfftxt"] = tempOutNames;
93 outputTypes["qual"] = tempOutNames;
95 //if the user changes the output directory command factory will send this info to us in the output parameter
96 outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = ""; }
98 //if the user changes the input directory command factory will send this info to us in the output parameter
99 string inputDir = validParameter.validFile(parameters, "inputdir", false); if (inputDir == "not found"){ inputDir = ""; }
101 sffFilename = validParameter.validFile(parameters, "sff", false);
102 if (sffFilename == "not found") { m->mothurOut("sff is a required parameter for the sffinfo command."); m->mothurOutEndLine(); abort = true; }
104 m->splitAtDash(sffFilename, filenames);
106 //go through files and make sure they are good, if not, then disregard them
107 for (int i = 0; i < filenames.size(); i++) {
108 if (inputDir != "") {
109 string path = m->hasPath(filenames[i]);
110 //if the user has not given a path then, add inputdir. else leave path alone.
111 if (path == "") { filenames[i] = inputDir + filenames[i]; }
115 int ableToOpen = m->openInputFile(filenames[i], in, "noerror");
117 //if you can't open it, try default location
118 if (ableToOpen == 1) {
119 if (m->getDefaultPath() != "") { //default path is set
120 string tryPath = m->getDefaultPath() + m->getSimpleName(filenames[i]);
121 m->mothurOut("Unable to open " + filenames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
123 ableToOpen = m->openInputFile(tryPath, in2, "noerror");
125 filenames[i] = tryPath;
129 //if you can't open it, try default location
130 if (ableToOpen == 1) {
131 if (m->getOutputDir() != "") { //default path is set
132 string tryPath = m->getOutputDir() + m->getSimpleName(filenames[i]);
133 m->mothurOut("Unable to open " + filenames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
135 ableToOpen = m->openInputFile(tryPath, in2, "noerror");
137 filenames[i] = tryPath;
143 if (ableToOpen == 1) {
144 m->mothurOut("Unable to open " + filenames[i] + ". It will be disregarded."); m->mothurOutEndLine();
145 //erase from file list
146 filenames.erase(filenames.begin()+i);
151 //make sure there is at least one valid file left
152 if (filenames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
155 accnosName = validParameter.validFile(parameters, "accnos", false);
156 if (accnosName == "not found") { accnosName = ""; }
159 m->splitAtDash(accnosName, accnosFileNames);
161 //go through files and make sure they are good, if not, then disregard them
162 for (int i = 0; i < accnosFileNames.size(); i++) {
163 if (inputDir != "") {
164 string path = m->hasPath(accnosFileNames[i]);
165 //if the user has not given a path then, add inputdir. else leave path alone.
166 if (path == "") { accnosFileNames[i] = inputDir + accnosFileNames[i]; }
170 int ableToOpen = m->openInputFile(accnosFileNames[i], in, "noerror");
172 //if you can't open it, try default location
173 if (ableToOpen == 1) {
174 if (m->getDefaultPath() != "") { //default path is set
175 string tryPath = m->getDefaultPath() + m->getSimpleName(accnosFileNames[i]);
176 m->mothurOut("Unable to open " + accnosFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
178 ableToOpen = m->openInputFile(tryPath, in2, "noerror");
180 accnosFileNames[i] = tryPath;
183 //if you can't open it, try default location
184 if (ableToOpen == 1) {
185 if (m->getOutputDir() != "") { //default path is set
186 string tryPath = m->getOutputDir() + m->getSimpleName(accnosFileNames[i]);
187 m->mothurOut("Unable to open " + accnosFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
189 ableToOpen = m->openInputFile(tryPath, in2, "noerror");
191 accnosFileNames[i] = tryPath;
196 if (ableToOpen == 1) {
197 m->mothurOut("Unable to open " + accnosFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine();
198 //erase from file list
199 accnosFileNames.erase(accnosFileNames.begin()+i);
204 //make sure there is at least one valid file left
205 if (accnosFileNames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
209 if (accnosFileNames.size() != filenames.size()) { abort = true; m->mothurOut("If you provide a accnos file, you must have one for each sff file."); m->mothurOutEndLine(); }
212 string temp = validParameter.validFile(parameters, "qfile", false); if (temp == "not found"){ temp = "T"; }
213 qual = m->isTrue(temp);
215 temp = validParameter.validFile(parameters, "fasta", false); if (temp == "not found"){ temp = "T"; }
216 fasta = m->isTrue(temp);
218 temp = validParameter.validFile(parameters, "flow", false); if (temp == "not found"){ temp = "F"; }
219 flow = m->isTrue(temp);
221 temp = validParameter.validFile(parameters, "trim", false); if (temp == "not found"){ temp = "T"; }
222 trim = m->isTrue(temp);
224 temp = validParameter.validFile(parameters, "sfftxt", false); if (temp == "not found"){ temp = "F"; }
225 sfftxt = m->isTrue(temp);
228 catch(exception& e) {
229 m->errorOut(e, "SffInfoCommand", "SffInfoCommand");
233 //**********************************************************************************************************************
235 void SffInfoCommand::help(){
237 m->mothurOut("The sffinfo command reads a sff file and extracts the sequence data.\n");
238 m->mothurOut("The sffinfo command parameters are sff, fasta, qfile, accnos, flow, sfftxt, and trim. sff is required. \n");
239 m->mothurOut("The sff parameter allows you to enter the sff file you would like to extract data from. You may enter multiple files by separating them by -'s.\n");
240 m->mothurOut("The fasta parameter allows you to indicate if you would like a fasta formatted file generated. Default=True. \n");
241 m->mothurOut("The qfile parameter allows you to indicate if you would like a quality file generated. Default=True. \n");
242 m->mothurOut("The flow parameter allows you to indicate if you would like a flowgram file generated. Default=False. \n");
243 m->mothurOut("The sfftxt parameter allows you to indicate if you would like a sff.txt file generated. Default=False. \n");
244 m->mothurOut("The trim parameter allows you to indicate if you would like a sequences and quality scores trimmed to the clipQualLeft and clipQualRight values. Default=True. \n");
245 m->mothurOut("The accnos parameter allows you to provide a accnos file containing the names of the sequences you would like extracted. You may enter multiple files by separating them by -'s. \n");
246 m->mothurOut("Example sffinfo(sff=mySffFile.sff, trim=F).\n");
247 m->mothurOut("Note: No spaces between parameter labels (i.e. sff), '=' and parameters (i.e.yourSffFileName).\n\n");
249 catch(exception& e) {
250 m->errorOut(e, "SffInfoCommand", "help");
254 //**********************************************************************************************************************
256 SffInfoCommand::~SffInfoCommand(){}
258 //**********************************************************************************************************************
259 int SffInfoCommand::execute(){
262 if (abort == true) { return 0; }
264 for (int s = 0; s < filenames.size(); s++) {
266 if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
268 int start = time(NULL);
270 m->mothurOut("Extracting info from " + filenames[s] + " ..." ); m->mothurOutEndLine();
273 if (hasAccnos) { accnos = accnosFileNames[s]; }
275 int numReads = extractSffInfo(filenames[s], accnos);
277 m->mothurOut("It took " + toString(time(NULL) - start) + " secs to extract " + toString(numReads) + ".");
280 if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
282 //report output filenames
283 m->mothurOutEndLine();
284 m->mothurOut("Output File Names: "); m->mothurOutEndLine();
285 for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
286 m->mothurOutEndLine();
290 catch(exception& e) {
291 m->errorOut(e, "SffInfoCommand", "execute");
295 //**********************************************************************************************************************
296 int SffInfoCommand::extractSffInfo(string input, string accnos){
299 if (outputDir == "") { outputDir += m->hasPath(input); }
301 if (accnos != "") { readAccnosFile(accnos); }
302 else { seqNames.clear(); }
304 ofstream outSfftxt, outFasta, outQual, outFlow;
305 string outFastaFileName, outQualFileName;
306 string sfftxtFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "sff.txt";
307 string outFlowFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "flow";
309 outFastaFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "fasta";
310 outQualFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "qual";
312 outFastaFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "raw.fasta";
313 outQualFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "raw.qual";
316 if (sfftxt) { m->openOutputFile(sfftxtFileName, outSfftxt); outSfftxt.setf(ios::fixed, ios::floatfield); outSfftxt.setf(ios::showpoint); outputNames.push_back(sfftxtFileName); outputTypes["sfftxt"].push_back(sfftxtFileName); }
317 if (fasta) { m->openOutputFile(outFastaFileName, outFasta); outputNames.push_back(outFastaFileName); outputTypes["fasta"].push_back(outFastaFileName); }
318 if (qual) { m->openOutputFile(outQualFileName, outQual); outputNames.push_back(outQualFileName); outputTypes["qual"].push_back(outQualFileName); }
319 if (flow) { m->openOutputFile(outFlowFileName, outFlow); outputNames.push_back(outFlowFileName); outputTypes["flow"].push_back(outFlowFileName); }
322 in.open(input.c_str(), ios::binary);
325 readCommonHeader(in, header);
329 //check magic number and version
330 if (header.magicNumber != 779314790) { m->mothurOut("Magic Number is not correct, not a valid .sff file"); m->mothurOutEndLine(); return count; }
331 if (header.version != "0001") { m->mothurOut("Version is not supported, only support version 0001."); m->mothurOutEndLine(); return count; }
333 //print common header
334 if (sfftxt) { printCommonHeader(outSfftxt, header); }
336 //read through the sff file
343 readHeader(in, readheader);
347 readSeqData(in, read, header.numFlowsPerRead, readheader.numBases);
349 //if you have provided an accosfile and this seq is not in it, then dont print
350 if (seqNames.size() != 0) { if (seqNames.count(readheader.name) == 0) { print = false; } }
354 if (sfftxt) { printHeader(outSfftxt, readheader); printSffTxtSeqData(outSfftxt, read, readheader); }
355 if (fasta) { printFastaSeqData(outFasta, read, readheader); }
356 if (qual) { printQualSeqData(outQual, read, readheader); }
357 if (flow) { printFlowSeqData(outFlow, read, readheader); }
363 if((count+1) % 10000 == 0){ m->mothurOut(toString(count+1)); m->mothurOutEndLine(); }
365 if (m->control_pressed) { count = 0; break; }
367 if (count >= header.numReads) { break; }
371 if (!m->control_pressed) { if((count) % 10000 != 0){ m->mothurOut(toString(count)); m->mothurOutEndLine(); } }
375 if (sfftxt) { outSfftxt.close(); }
376 if (fasta) { outFasta.close(); }
377 if (qual) { outQual.close(); }
378 if (flow) { outFlow.close(); }
382 catch(exception& e) {
383 m->errorOut(e, "SffInfoCommand", "extractSffInfo");
387 //**********************************************************************************************************************
388 int SffInfoCommand::readCommonHeader(ifstream& in, CommonHeader& header){
396 header.magicNumber = be_int4(*(unsigned int *)(&buffer));
402 for (int i = 0; i < 4; i++) { header.version += toString((int)(buffer9[i])); }
407 header.indexOffset = be_int8(*(unsigned long int *)(&buffer2));
412 header.indexLength = be_int4(*(unsigned int *)(&buffer3));
417 header.numReads = be_int4(*(unsigned int *)(&buffer4));
422 header.headerLength = be_int2(*(unsigned short *)(&buffer5));
427 header.keyLength = be_int2(*(unsigned short *)(&buffer6));
429 //read number of flow reads
432 header.numFlowsPerRead = be_int2(*(unsigned short *)(&buffer7));
437 header.flogramFormatCode = (int)(buffer8[0]);
440 char* tempBuffer = new char[header.numFlowsPerRead];
441 in.read(&(*tempBuffer), header.numFlowsPerRead);
442 header.flowChars = tempBuffer;
443 if (header.flowChars.length() > header.numFlowsPerRead) { header.flowChars = header.flowChars.substr(0, header.numFlowsPerRead); }
447 char* tempBuffer2 = new char[header.keyLength];
448 in.read(&(*tempBuffer2), header.keyLength);
449 header.keySequence = tempBuffer2;
450 if (header.keySequence.length() > header.keyLength) { header.keySequence = header.keySequence.substr(0, header.keyLength); }
451 delete[] tempBuffer2;
454 unsigned long int spotInFile = in.tellg();
455 unsigned long int spot = (spotInFile + 7)& ~7; // ~ inverts
459 m->mothurOut("Error reading sff common header."); m->mothurOutEndLine();
464 catch(exception& e) {
465 m->errorOut(e, "SffInfoCommand", "readCommonHeader");
469 //**********************************************************************************************************************
470 int SffInfoCommand::readHeader(ifstream& in, Header& header){
478 header.headerLength = be_int2(*(unsigned short *)(&buffer));
483 header.nameLength = be_int2(*(unsigned short *)(&buffer2));
488 header.numBases = be_int4(*(unsigned int *)(&buffer3));
490 //read clip qual left
493 header.clipQualLeft = be_int2(*(unsigned short *)(&buffer4));
494 header.clipQualLeft = 5;
496 //read clip qual right
499 header.clipQualRight = be_int2(*(unsigned short *)(&buffer5));
501 //read clipAdapterLeft
504 header.clipAdapterLeft = be_int2(*(unsigned short *)(&buffer6));
506 //read clipAdapterRight
509 header.clipAdapterRight = be_int2(*(unsigned short *)(&buffer7));
512 char* tempBuffer = new char[header.nameLength];
513 in.read(&(*tempBuffer), header.nameLength);
514 header.name = tempBuffer;
515 if (header.name.length() > header.nameLength) { header.name = header.name.substr(0, header.nameLength); }
518 //extract info from name
519 decodeName(header.timestamp, header.region, header.xy, header.name);
522 unsigned long int spotInFile = in.tellg();
523 unsigned long int spot = (spotInFile + 7)& ~7;
527 m->mothurOut("Error reading sff header info."); m->mothurOutEndLine();
532 catch(exception& e) {
533 m->errorOut(e, "SffInfoCommand", "readHeader");
537 //**********************************************************************************************************************
538 int SffInfoCommand::readSeqData(ifstream& in, seqRead& read, int numFlowReads, int numBases){
544 read.flowgram.resize(numFlowReads);
545 for (int i = 0; i < numFlowReads; i++) {
548 read.flowgram[i] = be_int2(*(unsigned short *)(&buffer));
552 read.flowIndex.resize(numBases);
553 for (int i = 0; i < numBases; i++) {
556 read.flowIndex[i] = be_int1(*(unsigned char *)(&temp));
560 char* tempBuffer = new char[numBases];
561 in.read(&(*tempBuffer), numBases);
562 read.bases = tempBuffer;
563 if (read.bases.length() > numBases) { read.bases = read.bases.substr(0, numBases); }
567 read.qualScores.resize(numBases);
568 for (int i = 0; i < numBases; i++) {
571 read.qualScores[i] = be_int1(*(unsigned char *)(&temp));
575 unsigned long int spotInFile = in.tellg();
576 unsigned long int spot = (spotInFile + 7)& ~7;
580 m->mothurOut("Error reading."); m->mothurOutEndLine();
585 catch(exception& e) {
586 m->errorOut(e, "SffInfoCommand", "readSeqData");
590 //**********************************************************************************************************************
591 int SffInfoCommand::decodeName(string& timestamp, string& region, string& xy, string name) {
594 string time = name.substr(0, 6);
595 unsigned int timeNum = m->fromBase36(time);
597 int q1 = timeNum / 60;
598 int sec = timeNum - 60 * q1;
600 int minute = q1 - 60 * q2;
602 int hr = q2 - 24 * q3;
604 int day = q3 - 32 * q4;
606 int mon = q4 - 13 * q5;
607 int year = 2000 + q5;
609 timestamp = toString(year) + "_" + toString(mon) + "_" + toString(day) + "_" + toString(hr) + "_" + toString(minute) + "_" + toString(sec);
611 region = name.substr(7, 2);
613 string xyNum = name.substr(9);
614 unsigned int myXy = m->fromBase36(xyNum);
618 xy = toString(x) + "_" + toString(y);
622 catch(exception& e) {
623 m->errorOut(e, "SffInfoCommand", "decodeName");
627 //**********************************************************************************************************************
628 int SffInfoCommand::printCommonHeader(ofstream& out, CommonHeader& header) {
631 out << "Common Header:\nMagic Number: " << header.magicNumber << endl;
632 out << "Version: " << header.version << endl;
633 out << "Index Offset: " << header.indexOffset << endl;
634 out << "Index Length: " << header.indexLength << endl;
635 out << "Number of Reads: " << header.numReads << endl;
636 out << "Header Length: " << header.headerLength << endl;
637 out << "Key Length: " << header.keyLength << endl;
638 out << "Number of Flows: " << header.numFlowsPerRead << endl;
639 out << "Format Code: " << header.flogramFormatCode << endl;
640 out << "Flow Chars: " << header.flowChars << endl;
641 out << "Key Sequence: " << header.keySequence << endl << endl;
645 catch(exception& e) {
646 m->errorOut(e, "SffInfoCommand", "printCommonHeader");
650 //**********************************************************************************************************************
651 int SffInfoCommand::printHeader(ofstream& out, Header& header) {
654 out << ">" << header.name << endl;
655 out << "Run Prefix: " << header.timestamp << endl;
656 out << "Region #: " << header.region << endl;
657 out << "XY Location: " << header.xy << endl << endl;
659 out << "Run Name: " << endl;
660 out << "Analysis Name: " << endl;
661 out << "Full Path: " << endl << endl;
663 out << "Read Header Len: " << header.headerLength << endl;
664 out << "Name Length: " << header.nameLength << endl;
665 out << "# of Bases: " << header.numBases << endl;
666 out << "Clip Qual Left: " << header.clipQualLeft << endl;
667 out << "Clip Qual Right: " << header.clipQualRight << endl;
668 out << "Clip Adap Left: " << header.clipAdapterLeft << endl;
669 out << "Clip Adap Right: " << header.clipAdapterRight << endl << endl;
673 catch(exception& e) {
674 m->errorOut(e, "SffInfoCommand", "printHeader");
679 //**********************************************************************************************************************
680 int SffInfoCommand::printSffTxtSeqData(ofstream& out, seqRead& read, Header& header) {
684 for (int i = 0; i < read.flowgram.size(); i++) { out << setprecision(2) << (read.flowgram[i]/(float)100) << '\t'; }
686 out << endl << "Flow Indexes: ";
688 for (int i = 0; i < read.flowIndex.size(); i++) { sum += read.flowIndex[i]; out << sum << '\t'; }
690 //make the bases you want to clip lowercase and the bases you want to keep upper case
691 if(header.clipQualRight == 0){ header.clipQualRight = read.bases.length(); }
692 for (int i = 0; i < (header.clipQualLeft-1); i++) { read.bases[i] = tolower(read.bases[i]); }
693 for (int i = (header.clipQualLeft-1); i < (header.clipQualRight-1); i++) { read.bases[i] = toupper(read.bases[i]); }
694 for (int i = (header.clipQualRight-1); i < read.bases.length(); i++) { read.bases[i] = tolower(read.bases[i]); }
696 out << endl << "Bases: " << read.bases << endl << "Quality Scores: ";
697 for (int i = 0; i < read.qualScores.size(); i++) { out << read.qualScores[i] << '\t'; }
704 catch(exception& e) {
705 m->errorOut(e, "SffInfoCommand", "printSffTxtSeqData");
709 //**********************************************************************************************************************
710 int SffInfoCommand::printFastaSeqData(ofstream& out, seqRead& read, Header& header) {
713 string seq = read.bases;
716 if(header.clipQualRight < header.clipQualLeft){
719 else if((header.clipQualRight != 0) && ((header.clipQualRight-header.clipQualLeft) >= 0)){
720 seq = seq.substr((header.clipQualLeft-1), (header.clipQualRight-header.clipQualLeft));
723 seq = seq.substr(header.clipQualLeft-1);
726 //if you wanted the sfftxt then you already converted the bases to the right case
728 //make the bases you want to clip lowercase and the bases you want to keep upper case
729 if(header.clipQualRight == 0){ header.clipQualRight = seq.length(); }
730 for (int i = 0; i < (header.clipQualLeft-1); i++) { seq[i] = tolower(seq[i]); }
731 for (int i = (header.clipQualLeft-1); i < (header.clipQualRight-1); i++) { seq[i] = toupper(seq[i]); }
732 for (int i = (header.clipQualRight-1); i < seq.length(); i++) { seq[i] = tolower(seq[i]); }
736 out << ">" << header.name << " xy=" << header.xy << endl;
741 catch(exception& e) {
742 m->errorOut(e, "SffInfoCommand", "printFastaSeqData");
747 //**********************************************************************************************************************
748 int SffInfoCommand::printQualSeqData(ofstream& out, seqRead& read, Header& header) {
752 if(header.clipQualRight < header.clipQualLeft){
755 else if((header.clipQualRight != 0) && ((header.clipQualRight-header.clipQualLeft) >= 0)){
756 out << ">" << header.name << " xy=" << header.xy << " length=" << (header.clipQualRight-header.clipQualLeft) << endl;
757 for (int i = (header.clipQualLeft-1); i < (header.clipQualRight-1); i++) { out << read.qualScores[i] << '\t'; }
760 out << ">" << header.name << " xy=" << header.xy << " length=" << (header.clipQualRight-header.clipQualLeft) << endl;
761 for (int i = (header.clipQualLeft-1); i < read.qualScores.size(); i++) { out << read.qualScores[i] << '\t'; }
764 out << ">" << header.name << " xy=" << header.xy << " length=" << read.qualScores.size() << endl;
765 for (int i = 0; i < read.qualScores.size(); i++) { out << read.qualScores[i] << '\t'; }
772 catch(exception& e) {
773 m->errorOut(e, "SffInfoCommand", "printQualSeqData");
778 //**********************************************************************************************************************
779 int SffInfoCommand::printFlowSeqData(ofstream& out, seqRead& read, Header& header) {
782 out << ">" << header.name << " xy=" << header.xy << endl;
783 for (int i = 0; i < read.flowgram.size(); i++) { out << setprecision(2) << (read.flowgram[i]/(float)100) << '\t'; }
788 catch(exception& e) {
789 m->errorOut(e, "SffInfoCommand", "printFlowSeqData");
793 //**********************************************************************************************************************
794 int SffInfoCommand::readAccnosFile(string filename) {
800 m->openInputFile(filename, in);
804 in >> name; m->gobble(in);
806 seqNames.insert(name);
808 if (m->control_pressed) { seqNames.clear(); break; }
814 catch(exception& e) {
815 m->errorOut(e, "SffInfoCommand", "readAccnosFile");
819 //**********************************************************************************************************************/