]> git.donarmstrong.com Git - mothur.git/blob - sffinfocommand.cpp
added fasta, qfile, trim, accnos and sfftxt parameter to sffinfo command. added...
[mothur.git] / sffinfocommand.cpp
1 /*
2  *  sffinfocommand.cpp
3  *  Mothur
4  *
5  *  Created by westcott on 7/7/10.
6  *  Copyright 2010 Schloss Lab. All rights reserved.
7  *
8  */
9
10 #include "sffinfocommand.h"
11 #include "endiannessmacros.h"
12
13 //**********************************************************************************************************************
14
15 SffInfoCommand::SffInfoCommand(string option)  {
16         try {
17                 abort = false;
18                 hasAccnos = false;
19                 
20                 //allow user to run help
21                 if(option == "help") { help(); abort = true; }
22                 
23                 else {
24                         //valid paramters for this command
25                         string Array[] =  {"sff","qfile","fasta","flow","trim","accnos","sfftxt","outputdir","inputdir", "outputdir"};
26                         vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
27                         
28                         OptionParser parser(option);
29                         map<string, string> parameters = parser.getParameters();
30                         
31                         ValidParameters validParameter;
32                         //check to make sure all parameters are valid for command
33                         for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
34                                 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
35                         }
36                         
37                         //if the user changes the output directory command factory will send this info to us in the output parameter 
38                         outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
39                         
40                         //if the user changes the input directory command factory will send this info to us in the output parameter 
41                         string inputDir = validParameter.validFile(parameters, "inputdir", false);        if (inputDir == "not found"){ inputDir = "";          }
42
43                         sffFilename = validParameter.validFile(parameters, "sff", false);
44                         if (sffFilename == "not found") { m->mothurOut("sff is a required parameter for the sffinfo command."); m->mothurOutEndLine(); abort = true;  }
45                         else { 
46                                 splitAtDash(sffFilename, filenames);
47                                 
48                                 //go through files and make sure they are good, if not, then disregard them
49                                 for (int i = 0; i < filenames.size(); i++) {
50                                         if (inputDir != "") {
51                                                 string path = hasPath(filenames[i]);
52                                                 //if the user has not given a path then, add inputdir. else leave path alone.
53                                                 if (path == "") {       filenames[i] = inputDir + filenames[i];         }
54                                         }
55         
56                                         ifstream in;
57                                         int ableToOpen = openInputFile(filenames[i], in);
58                                         in.close();
59                                         
60                                         if (ableToOpen == 1) { 
61                                                 m->mothurOut(filenames[i] + " will be disregarded."); m->mothurOutEndLine(); 
62                                                 //erase from file list
63                                                 filenames.erase(filenames.begin()+i);
64                                                 i--;
65                                         }
66                                 }
67                                 
68                                 //make sure there is at least one valid file left
69                                 if (filenames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
70                         }
71                         
72                         accnosName = validParameter.validFile(parameters, "accnos", false);
73                         if (accnosName == "not found") { accnosName = "";  }
74                         else { 
75                                 hasAccnos = true;
76                                 splitAtDash(accnosName, accnosFileNames);
77                                 
78                                 //go through files and make sure they are good, if not, then disregard them
79                                 for (int i = 0; i < accnosFileNames.size(); i++) {
80                                         if (inputDir != "") {
81                                                 string path = hasPath(accnosFileNames[i]);
82                                                 //if the user has not given a path then, add inputdir. else leave path alone.
83                                                 if (path == "") {       accnosFileNames[i] = inputDir + accnosFileNames[i];             }
84                                         }
85         
86                                         ifstream in;
87                                         int ableToOpen = openInputFile(accnosFileNames[i], in);
88                                         in.close();
89                                         
90                                         if (ableToOpen == 1) { 
91                                                 m->mothurOut(accnosFileNames[i] + " will be disregarded."); m->mothurOutEndLine(); 
92                                                 //erase from file list
93                                                 accnosFileNames.erase(accnosFileNames.begin()+i);
94                                                 i--;
95                                         }
96                                 }
97                                 
98                                 //make sure there is at least one valid file left
99                                 if (accnosFileNames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
100                         }
101                         
102                         if (hasAccnos) {
103                                 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(); }
104                         }
105                         
106                         string temp = validParameter.validFile(parameters, "qfile", false);                     if (temp == "not found"){       temp = "T";                             }
107                         qual = isTrue(temp); 
108                         
109                         temp = validParameter.validFile(parameters, "fasta", false);                            if (temp == "not found"){       temp = "T";                             }
110                         fasta = isTrue(temp); 
111                         
112                         temp = validParameter.validFile(parameters, "flow", false);                                     if (temp == "not found"){       temp = "F";                             }
113                         flow = isTrue(temp); 
114                         
115                         temp = validParameter.validFile(parameters, "trim", false);                                     if (temp == "not found"){       temp = "T";                             }
116                         trim = isTrue(temp); 
117                         
118                         temp = validParameter.validFile(parameters, "sfftxt", false);                           if (temp == "not found"){       temp = "F";                             }
119                         sfftxt = isTrue(temp); 
120                 }
121         }
122         catch(exception& e) {
123                 m->errorOut(e, "SffInfoCommand", "SffInfoCommand");
124                 exit(1);
125         }
126 }
127 //**********************************************************************************************************************
128
129 void SffInfoCommand::help(){
130         try {
131                 m->mothurOut("The sffinfo command reads a sff file and outputs a .sff.txt file.\n");
132                 
133                 m->mothurOut("Example sffinfo(sff=...).\n");
134                 m->mothurOut("Note: No spaces between parameter labels (i.e. sff), '=' and parameters (i.e.yourSffFileName).\n\n");
135         }
136         catch(exception& e) {
137                 m->errorOut(e, "SffInfoCommand", "help");
138                 exit(1);
139         }
140 }
141 //**********************************************************************************************************************
142
143 SffInfoCommand::~SffInfoCommand(){}
144
145 //**********************************************************************************************************************
146 int SffInfoCommand::execute(){
147         try {
148                 
149                 if (abort == true) { return 0; }
150                 
151                 for (int s = 0; s < filenames.size(); s++) {
152                         
153                         if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str());         } return 0; }
154                         
155                         int start = time(NULL);
156                         
157                         m->mothurOut("Extracting info from " + filenames[s] + " ..." ); m->mothurOutEndLine();
158                         
159                         string accnos = "";
160                         if (hasAccnos) { accnos = accnosFileNames[s]; }
161                         
162                         int numReads = extractSffInfo(filenames[s], accnos);
163
164                         m->mothurOut("It took " + toString(time(NULL) - start) + " secs to extract " + toString(numReads) + ".");
165                 }
166                 
167                 if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str());         } return 0; }
168                 
169                 //report output filenames
170                 m->mothurOutEndLine();
171                 m->mothurOut("Output File Names: "); m->mothurOutEndLine();
172                 for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
173                 m->mothurOutEndLine();
174
175                 return 0;
176         }
177         catch(exception& e) {
178                 m->errorOut(e, "SffInfoCommand", "execute");
179                 exit(1);
180         }
181 }
182 //**********************************************************************************************************************
183 int SffInfoCommand::extractSffInfo(string input, string accnos){
184         try {
185                 
186                 if (outputDir == "") {  outputDir += hasPath(input); }
187                 
188                 if (accnos != "")       {  readAccnosFile(accnos);  }
189                 else                            {       seqNames.clear();               }
190
191                 ofstream outSfftxt, outFasta, outQual, outFlow;
192                 string outFastaFileName, outQualFileName;
193                 string sfftxtFileName = outputDir + getRootName(getSimpleName(input)) + "sff.txt";
194                 string outFlowFileName = outputDir + getRootName(getSimpleName(input)) + "flow";
195                 if (trim) {
196                         outFastaFileName = outputDir + getRootName(getSimpleName(input)) + "fasta";
197                         outQualFileName = outputDir + getRootName(getSimpleName(input)) + "qual";
198                 }else{
199                         outFastaFileName = outputDir + getRootName(getSimpleName(input)) + "raw.fasta";
200                         outQualFileName = outputDir + getRootName(getSimpleName(input)) + "raw.qual";
201                 }
202                 
203                 if (sfftxt) { openOutputFile(sfftxtFileName, outSfftxt); outSfftxt.setf(ios::fixed, ios::floatfield); outSfftxt.setf(ios::showpoint);  outputNames.push_back(sfftxtFileName); }
204                 if (fasta)      { openOutputFile(outFastaFileName, outFasta);   outputNames.push_back(outFastaFileName); }
205                 if (qual)       { openOutputFile(outQualFileName, outQual);             outputNames.push_back(outQualFileName);  }
206                 if (flow)       { openOutputFile(outFlowFileName, outFlow);             outputNames.push_back(outFlowFileName);  }
207                 
208                 ifstream in;
209                 in.open(input.c_str(), ios::binary);
210                 
211                 CommonHeader header; 
212                 readCommonHeader(in, header);
213                 
214                 int count = 0;
215                 
216                 //check magic number and version
217                 if (header.magicNumber != 779314790) { m->mothurOut("Magic Number is not correct, not a valid .sff file"); m->mothurOutEndLine(); return count; }
218                 if (header.version != "0001") { m->mothurOut("Version is not supported, only support version 0001."); m->mothurOutEndLine(); return count; }
219         
220                 //print common header
221                 if (sfftxt) { printCommonHeader(outSfftxt, header); }
222                 
223                 //read through the sff file
224                 while (!in.eof()) {
225                         
226                         bool print = true;
227                         
228                         //read header
229                         Header readheader;
230                         readHeader(in, readheader);
231                         
232                         //read data
233                         seqRead read; 
234                         readSeqData(in, read, header.numFlowsPerRead, readheader.numBases);
235                         
236                         //if you have provided an accosfile and this seq is not in it, then dont print
237                         if (seqNames.size() != 0) {   if (seqNames.count(readheader.name) == 0) { print = false; }  }
238                         
239                         //print 
240                         if (print) {
241                                 if (sfftxt) { printHeader(outSfftxt, readheader); printSffTxtSeqData(outSfftxt, read); }
242                                 if (fasta)      {       printFastaSeqData(outFasta, read, readheader);  }
243                                 if (qual)       {       printQualSeqData(outQual, read, readheader);    }
244                                 if (flow)       {       printFlowSeqData(outFlow, read, readheader);    }
245                         }
246                         
247                         count++;
248                         
249                         //report progress
250                         if((count+1) % 500 == 0){       m->mothurOut(toString(count+1)); m->mothurOutEndLine();         }
251                 
252                         if (m->control_pressed) { count = 0; break;   }
253                         
254                         if (count >= header.numReads) { break; }
255                 }
256                 
257                 //report progress
258                 if (!m->control_pressed) {   if((count) % 500 != 0){    m->mothurOut(toString(count)); m->mothurOutEndLine();           }  }
259                 
260                 in.close();
261                 
262                 if (sfftxt) {  outSfftxt.close();       }
263                 if (fasta)      {  outFasta.close();    }
264                 if (qual)       {  outQual.close();             }
265                 if (flow)       {  outFlow.close();             }
266                 
267                 return count;
268         }
269         catch(exception& e) {
270                 m->errorOut(e, "SffInfoCommand", "extractSffInfo");
271                 exit(1);
272         }
273 }
274 //**********************************************************************************************************************
275 int SffInfoCommand::readCommonHeader(ifstream& in, CommonHeader& header){
276         try {
277
278                 if (!in.eof()) {
279                 
280                         //read magic number
281                         char buffer[sizeof(header.magicNumber)];
282                         in.read(buffer, sizeof(header.magicNumber));
283                         header.magicNumber = be_int4(*(unsigned int *)(&buffer));
284                         
285                         //read version
286                         char buffer9[4];
287                         in.read(buffer9, 4);
288                         header.version = "";
289                         for (int i = 0; i < 4; i++) {  header.version += toString((int)(buffer9[i])); }
290                                 
291                         //read offset
292                         char buffer2 [sizeof(header.indexOffset)];
293                         in.read(buffer2, sizeof(header.indexOffset));
294                         header.indexOffset =  be_int8(*(unsigned long int *)(&buffer2));
295                         
296                         //read index length
297                         char buffer3 [sizeof(header.indexLength)];
298                         in.read(buffer3, sizeof(header.indexLength));
299                         header.indexLength =  be_int4(*(unsigned int *)(&buffer3));
300                         
301                         //read num reads
302                         char buffer4 [sizeof(header.numReads)];
303                         in.read(buffer4, sizeof(header.numReads));
304                         header.numReads =  be_int4(*(unsigned int *)(&buffer4));
305                                 
306                         //read header length
307                         char buffer5 [sizeof(header.headerLength)];
308                         in.read(buffer5, sizeof(header.headerLength));
309                         header.headerLength =  be_int2(*(unsigned short *)(&buffer5));
310                                         
311                         //read key length
312                         char buffer6 [sizeof(header.keyLength)];
313                         in.read(buffer6, sizeof(header.keyLength));
314                         header.keyLength = be_int2(*(unsigned short *)(&buffer6));
315                         
316                         //read number of flow reads
317                         char buffer7 [sizeof(header.numFlowsPerRead)];
318                         in.read(buffer7, sizeof(header.numFlowsPerRead));
319                         header.numFlowsPerRead =  be_int2(*(unsigned short *)(&buffer7));
320                                 
321                         //read format code
322                         char buffer8 [1];
323                         in.read(buffer8, 1);
324                         header.flogramFormatCode = (int)(buffer8[0]);
325                         
326                         //read flow chars
327                         char tempBuffer [header.numFlowsPerRead];
328                         in.read(tempBuffer, header.numFlowsPerRead); 
329                         header.flowChars = tempBuffer;
330                         if (header.flowChars.length() > header.numFlowsPerRead) { header.flowChars = header.flowChars.substr(0, header.numFlowsPerRead);  }
331                         
332                         //read key
333                         char tempBuffer2 [header.keyLength];
334                         in.read(tempBuffer2, header.keyLength);
335                         header.keySequence = tempBuffer2;
336                         if (header.keySequence.length() > header.keyLength) { header.keySequence = header.keySequence.substr(0, header.keyLength);  }
337                                 
338                         /* Pad to 8 chars */
339                         int spotInFile = in.tellg();
340                         int spot = (spotInFile + 7)& ~7;  // ~ inverts
341                         in.seekg(spot);
342                         
343                 }else{
344                         m->mothurOut("Error reading sff common header."); m->mothurOutEndLine();
345                 }
346
347                 return 0;
348         }
349         catch(exception& e) {
350                 m->errorOut(e, "SffInfoCommand", "readCommonHeader");
351                 exit(1);
352         }
353 }
354 //**********************************************************************************************************************
355 int SffInfoCommand::readHeader(ifstream& in, Header& header){
356         try {
357         
358                 if (!in.eof()) {
359                         
360                         //read header length
361                         char buffer [sizeof(header.headerLength)];
362                         in.read(buffer, sizeof(header.headerLength));
363                         header.headerLength = be_int2(*(unsigned short *)(&buffer));
364                                                 
365                         //read name length
366                         char buffer2 [sizeof(header.nameLength)];
367                         in.read(buffer2, sizeof(header.nameLength));
368                         header.nameLength = be_int2(*(unsigned short *)(&buffer2));
369
370                         //read num bases
371                         char buffer3 [sizeof(header.numBases)];
372                         in.read(buffer3, sizeof(header.numBases));
373                         header.numBases =  be_int4(*(unsigned int *)(&buffer3));
374                         
375                         //read clip qual left
376                         char buffer4 [sizeof(header.clipQualLeft)];
377                         in.read(buffer4, sizeof(header.clipQualLeft));
378                         header.clipQualLeft =  be_int2(*(unsigned short *)(&buffer4));
379                         
380                         //read clip qual right
381                         char buffer5 [sizeof(header.clipQualRight)];
382                         in.read(buffer5, sizeof(header.clipQualRight));
383                         header.clipQualRight =  be_int2(*(unsigned short *)(&buffer5));
384                         
385                         //read clipAdapterLeft
386                         char buffer6 [sizeof(header.clipAdapterLeft)];
387                         in.read(buffer6, sizeof(header.clipAdapterLeft));
388                         header.clipAdapterLeft = be_int2(*(unsigned short *)(&buffer6));
389
390                         //read clipAdapterRight
391                         char buffer7 [sizeof(header.clipAdapterRight)];
392                         in.read(buffer7, sizeof(header.clipAdapterRight));
393                         header.clipAdapterRight = be_int2(*(unsigned short *)(&buffer7));
394                 
395                         //read name
396                         char tempBuffer [header.nameLength];
397                         in.read(tempBuffer, header.nameLength);
398                         header.name = tempBuffer;
399                         if (header.name.length() > header.nameLength) { header.name = header.name.substr(0, header.nameLength);  }
400                         
401                         /* Pad to 8 chars */
402                         int spotInFile = in.tellg();
403                         int spot = (spotInFile + 7)& ~7;
404                         in.seekg(spot);
405                         
406                 }else{
407                         m->mothurOut("Error reading sff header info."); m->mothurOutEndLine();
408                 }
409
410                 return 0;
411         }
412         catch(exception& e) {
413                 m->errorOut(e, "SffInfoCommand", "readHeader");
414                 exit(1);
415         }
416 }
417 //**********************************************************************************************************************
418 int SffInfoCommand::readSeqData(ifstream& in, seqRead& read, int numFlowReads, int numBases){
419         try {
420         
421                 if (!in.eof()) {
422         
423                         //read flowgram
424                         read.flowgram.resize(numFlowReads);
425                         for (int i = 0; i < numFlowReads; i++) {  
426                                 char buffer [sizeof(unsigned short)];
427                                 in.read(buffer, (sizeof(unsigned short)));
428                                 read.flowgram[i] = be_int2(*(unsigned short *)(&buffer));
429                         }
430         
431                         //read flowIndex
432                         read.flowIndex.resize(numBases);
433                         for (int i = 0; i < numBases; i++) {  
434                                 char temp[1];
435                                 in.read(temp, 1);
436                                 read.flowIndex[i] = be_int1(*(unsigned char *)(&temp));
437                         }
438                 
439                         //read bases
440                         char tempBuffer[numBases];
441                         in.read(tempBuffer, numBases);
442                         read.bases = tempBuffer;
443                         if (read.bases.length() > numBases) { read.bases = read.bases.substr(0, numBases);  }
444
445                         //read flowgram
446                         read.qualScores.resize(numBases);
447                         for (int i = 0; i < numBases; i++) {  
448                                 char temp[1];
449                                 in.read(temp, 1);
450                                 read.qualScores[i] = be_int1(*(unsigned char *)(&temp));
451                         }
452                 
453                         /* Pad to 8 chars */
454                         int spotInFile = in.tellg();
455                         int spot = (spotInFile + 7)& ~7;
456                         in.seekg(spot);
457                         
458                 }else{
459                         m->mothurOut("Error reading."); m->mothurOutEndLine();
460                 }
461
462                 return 0;
463         }
464         catch(exception& e) {
465                 m->errorOut(e, "SffInfoCommand", "readSeqData");
466                 exit(1);
467         }
468 }
469 //**********************************************************************************************************************
470 int SffInfoCommand::printCommonHeader(ofstream& out, CommonHeader& header) {
471         try {
472         
473                 out << "Common Header:\nMagic Number: " << header.magicNumber << endl;
474                 out << "Version: " << header.version << endl;
475                 out << "Index Offset: " << header.indexOffset << endl;
476                 out << "Index Length: " << header.indexLength << endl;
477                 out << "Number of Reads: " << header.numReads << endl;
478                 out << "Header Length: " << header.headerLength << endl;
479                 out << "Key Length: " << header.keyLength << endl;
480                 out << "Number of Flows: " << header.numFlowsPerRead << endl;
481                 out << "Format Code: " << header.flogramFormatCode << endl;
482                 out << "Flow Chars: " << header.flowChars << endl;
483                 out << "Key Sequence: " << header.keySequence << endl << endl;
484                         
485                 return 0;
486         }
487         catch(exception& e) {
488                 m->errorOut(e, "SffInfoCommand", "printCommonHeader");
489                 exit(1);
490         }
491 }
492 //**********************************************************************************************************************
493 int SffInfoCommand::printHeader(ofstream& out, Header& header) {
494         try {
495                 
496                 out << ">" << header.name << endl;
497                 out << "Run Prefix: " << endl;
498                 out << "Region #:  " << endl;
499                 out << "XY Location: " << endl << endl;
500                 
501                 out << "Run Name:  " << endl;
502                 out << "Analysis Name:  " << endl;
503                 out << "Full Path: " << endl << endl;
504                 
505                 out << "Read Header Len: " << header.headerLength << endl;
506                 out << "Name Length: " << header.nameLength << endl;
507                 out << "# of Bases: " << header.numBases << endl;
508                 out << "Clip Qual Left: " << header.clipQualLeft << endl;
509                 out << "Clip Qual Right: " << header.clipQualRight << endl;
510                 out << "Clip Adap Left: " << header.clipAdapterLeft << endl;
511                 out << "Clip Adap Right: " << header.clipAdapterRight << endl << endl;
512                 
513                 return 0;
514         }
515         catch(exception& e) {
516                 m->errorOut(e, "SffInfoCommand", "printHeader");
517                 exit(1);
518         }
519 }
520
521 //**********************************************************************************************************************
522 int SffInfoCommand::printSffTxtSeqData(ofstream& out, seqRead& read) {
523         try {
524                 
525                 out << "FlowGram: ";
526                 for (int i = 0; i < read.flowgram.size(); i++) { out << setprecision(2) << (read.flowgram[i]/(float)100) << '\t';  }
527                 
528                 out << endl <<  "Flow Indexes: ";
529                 int sum = 0;
530                 for (int i = 0; i < read.flowIndex.size(); i++) {  sum +=  read.flowIndex[i];  out << sum << '\t'; }
531                 
532                 out << endl <<  "Bases: " << read.bases << endl << "Quality Scores: ";
533                 for (int i = 0; i < read.qualScores.size(); i++) {   out << read.qualScores[i] << '\t';  }
534                 out << endl << endl;
535                 
536                 return 0;
537         }
538         catch(exception& e) {
539                 m->errorOut(e, "SffInfoCommand", "printSffTxtSeqData");
540                 exit(1);
541         }
542 }
543 //**********************************************************************************************************************
544 int SffInfoCommand::printFastaSeqData(ofstream& out, seqRead& read, Header& header) {
545         try {
546                 
547                 string seq = read.bases;
548                 
549                 
550                 if (trim) {
551                         seq = seq.substr(header.clipQualLeft, (header.clipQualRight-header.clipQualLeft));
552                 }
553                 
554                 out << ">" << header.name << endl;
555                 out << seq << endl;
556                 
557                 return 0;
558         }
559         catch(exception& e) {
560                 m->errorOut(e, "SffInfoCommand", "printFastaSeqData");
561                 exit(1);
562         }
563 }
564
565 //**********************************************************************************************************************
566 int SffInfoCommand::printQualSeqData(ofstream& out, seqRead& read, Header& header) {
567         try {
568                 
569                 if (trim) {
570                         out << ">" << header.name << " length=" << (header.clipQualRight-header.clipQualLeft) << endl;
571                         for (int i = header.clipQualLeft; i < (header.clipQualRight-header.clipQualLeft); i++) {   out << read.qualScores[i] << '\t';  }
572                 }else{
573                         out << ">" << header.name << " length=" << read.qualScores.size() << endl;
574                         for (int i = 0; i < read.qualScores.size(); i++) {   out << read.qualScores[i] << '\t';  }
575                 }
576                 
577                 out << endl;
578                 
579                 return 0;
580         }
581         catch(exception& e) {
582                 m->errorOut(e, "SffInfoCommand", "printQualSeqData");
583                 exit(1);
584         }
585 }
586
587 //**********************************************************************************************************************
588 int SffInfoCommand::printFlowSeqData(ofstream& out, seqRead& read, Header& header) {
589         try {
590                 
591                 out << ">" << header.name << endl;
592                 for (int i = 0; i < read.flowgram.size(); i++) { out << setprecision(2) << (read.flowgram[i]/(float)100) << '\t';  }
593                 out << endl;
594                 
595                 return 0;
596         }
597         catch(exception& e) {
598                 m->errorOut(e, "SffInfoCommand", "printFlowSeqData");
599                 exit(1);
600         }
601 }
602 //**********************************************************************************************************************
603 int SffInfoCommand::readAccnosFile(string filename) {
604         try {
605                 //remove old names
606                 seqNames.clear();
607                 
608                 ifstream in;
609                 openInputFile(filename, in);
610                 string name;
611                 
612                 while(!in.eof()){
613                         in >> name; gobble(in);
614                                                 
615                         seqNames.insert(name);
616                         
617                         if (m->control_pressed) { seqNames.clear(); break; }
618                 }
619                 in.close();             
620                 
621                 return 0;
622         }
623         catch(exception& e) {
624                 m->errorOut(e, "SffInfoCommand", "readAccnosFile");
625                 exit(1);
626         }
627 }
628 //**********************************************************************************************************************/