]> git.donarmstrong.com Git - mothur.git/blobdiff - sffinfocommand.cpp
added tempdefault to set.dir and fixed bug with padding type in sffinfo.
[mothur.git] / sffinfocommand.cpp
index 885aadc9c05eb34ba16d0dca6e48322dc452e5af..01338ca34be42556131b15a0ead73c0ef9952858 100644 (file)
@@ -54,11 +54,21 @@ SffInfoCommand::SffInfoCommand(string option)  {
                                        }
        
                                        ifstream in;
-                                       int ableToOpen = openInputFile(filenames[i], in);
+                                       int ableToOpen = openInputFile(filenames[i], in, "noerror");
+                               
+                                       //if you can't open it, try default location
+                                       if (ableToOpen == 1) {
+                                               if (m->getDefaultPath() != "") { //default path is set
+                                                       string tryPath = m->getDefaultPath() + getSimpleName(filenames[i]);
+                                                       m->mothurOut("Unable to open " + filenames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = openInputFile(tryPath, in, "noerror");
+                                                       filenames[i] = tryPath;
+                                               }
+                                       }
                                        in.close();
                                        
                                        if (ableToOpen == 1) { 
-                                               m->mothurOut(filenames[i] + " will be disregarded."); m->mothurOutEndLine(); 
+                                               m->mothurOut("Unable to open " + filenames[i] + ". It will be disregarded."); m->mothurOutEndLine();
                                                //erase from file list
                                                filenames.erase(filenames.begin()+i);
                                                i--;
@@ -84,11 +94,21 @@ SffInfoCommand::SffInfoCommand(string option)  {
                                        }
        
                                        ifstream in;
-                                       int ableToOpen = openInputFile(accnosFileNames[i], in);
+                                       int ableToOpen = openInputFile(accnosFileNames[i], in, "noerror");
+                               
+                                       //if you can't open it, try default location
+                                       if (ableToOpen == 1) {
+                                               if (m->getDefaultPath() != "") { //default path is set
+                                                       string tryPath = m->getDefaultPath() + getSimpleName(accnosFileNames[i]);
+                                                       m->mothurOut("Unable to open " + accnosFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
+                                                       ableToOpen = openInputFile(tryPath, in, "noerror");
+                                                       accnosFileNames[i] = tryPath;
+                                               }
+                                       }
                                        in.close();
                                        
                                        if (ableToOpen == 1) { 
-                                               m->mothurOut(accnosFileNames[i] + " will be disregarded."); m->mothurOutEndLine(); 
+                                               m->mothurOut("Unable to open " + accnosFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine();
                                                //erase from file list
                                                accnosFileNames.erase(accnosFileNames.begin()+i);
                                                i--;
@@ -128,9 +148,16 @@ SffInfoCommand::SffInfoCommand(string option)  {
 
 void SffInfoCommand::help(){
        try {
-               m->mothurOut("The sffinfo command reads a sff file and outputs a .sff.txt file.\n");
-               
-               m->mothurOut("Example sffinfo(sff=...).\n");
+               m->mothurOut("The sffinfo command reads a sff file and extracts the sequence data.\n");
+               m->mothurOut("The sffinfo command parameters are sff, fasta, qfile, accnos, flow, sfftxt, and trim. sff is required. \n");
+               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");
+               m->mothurOut("The fasta parameter allows you to indicate if you would like a fasta formatted file generated.  Default=True. \n");
+               m->mothurOut("The qfile parameter allows you to indicate if you would like a quality file generated.  Default=True. \n");
+               m->mothurOut("The flow parameter allows you to indicate if you would like a flowgram file generated.  Default=False. \n");
+               m->mothurOut("The sfftxt parameter allows you to indicate if you would like a sff.txt file generated.  Default=False. \n");
+               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");
+               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");
+               m->mothurOut("Example sffinfo(sff=mySffFile.sff, trim=F).\n");
                m->mothurOut("Note: No spaces between parameter labels (i.e. sff), '=' and parameters (i.e.yourSffFileName).\n\n");
        }
        catch(exception& e) {
@@ -336,8 +363,8 @@ int SffInfoCommand::readCommonHeader(ifstream& in, CommonHeader& header){
                        if (header.keySequence.length() > header.keyLength) { header.keySequence = header.keySequence.substr(0, header.keyLength);  }
                                
                        /* Pad to 8 chars */
-                       int spotInFile = in.tellg();
-                       int spot = (spotInFile + 7)& ~7;  // ~ inverts
+                       unsigned long int spotInFile = in.tellg();
+                       unsigned long int spot = (spotInFile + 7)& ~7;  // ~ inverts
                        in.seekg(spot);
                        
                }else{
@@ -399,8 +426,8 @@ int SffInfoCommand::readHeader(ifstream& in, Header& header){
                        if (header.name.length() > header.nameLength) { header.name = header.name.substr(0, header.nameLength);  }
                        
                        /* Pad to 8 chars */
-                       int spotInFile = in.tellg();
-                       int spot = (spotInFile + 7)& ~7;
+                       unsigned long int spotInFile = in.tellg();
+                       unsigned long int spot = (spotInFile + 7)& ~7;
                        in.seekg(spot);
                        
                }else{
@@ -451,8 +478,8 @@ int SffInfoCommand::readSeqData(ifstream& in, seqRead& read, int numFlowReads, i
                        }
                
                        /* Pad to 8 chars */
-                       int spotInFile = in.tellg();
-                       int spot = (spotInFile + 7)& ~7;
+                       unsigned long int spotInFile = in.tellg();
+                       unsigned long int spot = (spotInFile + 7)& ~7;
                        in.seekg(spot);
                        
                }else{