]> git.donarmstrong.com Git - mothur.git/blobdiff - sffinfocommand.cpp
added sequence name to error string in fastq.info. Changed np_shannon to npshannon.
[mothur.git] / sffinfocommand.cpp
index 8c50247c6845867ff9f99f62760d81300d433779..4965cfd75e06c9f8ba8157056922514581e3e10e 100644 (file)
@@ -82,6 +82,7 @@ SffInfoCommand::SffInfoCommand(string option)  {
                
                //allow user to run help
                if(option == "help") { help(); abort = true; calledHelp = true; }
+               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
                
                else {
                        //valid paramters for this command
@@ -169,7 +170,7 @@ SffInfoCommand::SffInfoCommand(string option)  {
                                                        //erase from file list
                                                        filenames.erase(filenames.begin()+i);
                                                        i--;
-                                               }
+                                               }else { m->setSFFFile(filenames[i]); }
                                        }
                                }
                                
@@ -282,7 +283,7 @@ SffInfoCommand::SffInfoCommand(string option)  {
                        }
                        
                        if ((sfftxtFilename == "") && (filenames.size() == 0)) {  
-                               //if there is a current fasta file, use it
+                               //if there is a current sff file, use it
                                string filename = m->getSFFFile(); 
                                if (filename != "") { filenames.push_back(filename); m->mothurOut("Using " + filename + " as input file for the sff parameter."); m->mothurOutEndLine(); }
                                else {  m->mothurOut("[ERROR]: you must provide a valid sff or sfftxt file."); m->mothurOutEndLine(); abort=true;  }
@@ -302,7 +303,7 @@ int SffInfoCommand::execute(){
                
                for (int s = 0; s < filenames.size(); s++) {
                        
-                       if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str());         } return 0; }
+                       if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]);        } return 0; }
                        
                        int start = time(NULL);
                        
@@ -318,7 +319,7 @@ int SffInfoCommand::execute(){
                
                if (sfftxtFilename != "") {  parseSffTxt(); }
                
-               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       remove(outputNames[i].c_str());         } return 0; }
+               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]);        } return 0; }
                
                //set fasta file as new current fastafile
                string current = "";
@@ -465,7 +466,7 @@ int SffInfoCommand::readCommonHeader(ifstream& in, CommonHeader& header){
                        //read offset
                        char buffer2 [8];
                        in.read(buffer2, 8);
-                       header.indexOffset =  be_int8(*(unsigned long int *)(&buffer2));
+                       header.indexOffset =  be_int8(*(unsigned long long *)(&buffer2));
                        
                        //read index length
                        char buffer3 [4];
@@ -512,8 +513,8 @@ int SffInfoCommand::readCommonHeader(ifstream& in, CommonHeader& header){
                        delete[] tempBuffer2;
                                
                        /* Pad to 8 chars */
-                       unsigned long int spotInFile = in.tellg();
-                       unsigned long int spot = (spotInFile + 7)& ~7;  // ~ inverts
+                       unsigned long long spotInFile = in.tellg();
+                       unsigned long long spot = (spotInFile + 7)& ~7;  // ~ inverts
                        in.seekg(spot);
                        
                }else{
@@ -580,8 +581,8 @@ int SffInfoCommand::readHeader(ifstream& in, Header& header){
                        decodeName(header.timestamp, header.region, header.xy, header.name);
                        
                        /* Pad to 8 chars */
-                       unsigned long int spotInFile = in.tellg();
-                       unsigned long int spot = (spotInFile + 7)& ~7;
+                       unsigned long long spotInFile = in.tellg();
+                       unsigned long long spot = (spotInFile + 7)& ~7;
                        in.seekg(spot);
                        
                }else{
@@ -633,8 +634,8 @@ int SffInfoCommand::readSeqData(ifstream& in, seqRead& read, int numFlowReads, i
                        }
        
                        /* Pad to 8 chars */
-                       unsigned long int spotInFile = in.tellg();
-                       unsigned long int spot = (spotInFile + 7)& ~7;
+                       unsigned long long spotInFile = in.tellg();
+                       unsigned long long spot = (spotInFile + 7)& ~7;
                        in.seekg(spot);
                        
                }else{
@@ -900,13 +901,20 @@ int SffInfoCommand::parseSffTxt() {
                //output file names
                ofstream outFasta, outQual, outFlow;
                string outFastaFileName, outQualFileName;
-               string outFlowFileName = outputDir + m->getRootName(m->getSimpleName(sfftxtFilename)) + "flow";
+               string fileRoot = m->getRootName(m->getSimpleName(sfftxtFilename));
+               if (fileRoot.length() > 0) {
+                       //rip off last .
+                       fileRoot = fileRoot.substr(0, fileRoot.length()-1);
+                       fileRoot = m->getRootName(fileRoot);
+               }
+               
+               string outFlowFileName = outputDir + fileRoot + "flow";
                if (trim) {
-                       outFastaFileName = outputDir + m->getRootName(m->getSimpleName(sfftxtFilename)) + "fasta";
-                       outQualFileName = outputDir + m->getRootName(m->getSimpleName(sfftxtFilename)) + "qual";
+                       outFastaFileName = outputDir + fileRoot + "fasta";
+                       outQualFileName = outputDir + fileRoot + "qual";
                }else{
-                       outFastaFileName = outputDir + m->getRootName(m->getSimpleName(sfftxtFilename)) + "raw.fasta";
-                       outQualFileName = outputDir + m->getRootName(m->getSimpleName(sfftxtFilename)) + "raw.qual";
+                       outFastaFileName = outputDir + fileRoot + "raw.fasta";
+                       outQualFileName = outputDir + fileRoot + "raw.qual";
                }
                
                if (fasta)      { m->openOutputFile(outFastaFileName, outFasta);        outputNames.push_back(outFastaFileName); outputTypes["fasta"].push_back(outFastaFileName); }