]> git.donarmstrong.com Git - mothur.git/blobdiff - database.cpp
added remove.seqs command
[mothur.git] / database.cpp
index b661d41402fc715b8073266d11c23224ad65a781..5fc9b676f128dd0a1d6999918b4fcb42357c407e 100644 (file)
@@ -7,52 +7,61 @@
  *
  */
 
-using namespace std;
-
 #include "mothur.h"
 #include "sequence.hpp"
 #include "database.hpp"
 
 /**************************************************************************************************/
 
-Database::Database(string fastaFileName){
+Database::Database(string fastaFileName){              //      This assumes that the template database is in fasta format, may 
+                                                                                               //      need to alter this in the future?
+
+       ifstream fastaFile;
+       openInputFile(fastaFileName, fastaFile);
        
-       ifstream fastaFile(fastaFileName.c_str());
-       if(!fastaFile) {
-               cerr << "Error: Could not open " << fastaFileName << endl;
-               exit(1);
-       }
-       cout << endl << "Reading in the " << fastaFileName << " template sequences...\t";       cout.flush();
+       mothurOutEndLine();
+       mothurOut("Reading in the " + fastaFileName + " template sequences...\t");      cout.flush();
 
-       numSeqs=count(istreambuf_iterator<char>(fastaFile),istreambuf_iterator<char>(), '>');
-       fastaFile.seekg(0);
+       //all of this is elsewhere already!
+       numSeqs=count(istreambuf_iterator<char>(fastaFile),istreambuf_iterator<char>(), '>');   //      count the number of
+       fastaFile.seekg(0);                                                                                                                                             //      sequences
        
        templateSequences.resize(numSeqs);
        
        string seqName, sequence;
        for(int i=0;i<numSeqs;i++){
-               templateSequences[i] = new Sequence();
-               
                fastaFile >> seqName;
-               templateSequences[i]->setName(seqName);
-               
+               seqName = seqName.substr(1);
                char letter;
                string aligned;
                
                while(fastaFile && (letter=fastaFile.get()) != '>'){
                        if(isprint(letter)){
                                letter = toupper(letter);
+                               if(letter == 'U'){letter = 'T';}
                                aligned += letter;
                        }
                }
-               templateSequences[i]->setAligned(aligned);
-               templateSequences[i]->setUnaligned(aligned);
+               templateSequences[i] = Sequence(seqName, aligned);
                fastaFile.putback(letter);
        }
        
        fastaFile.close();
-       cout << "DONE." << endl;        cout.flush();
+       //all of this is elsewhere already!
+       
+       mothurOut("DONE.");
+       mothurOutEndLine();     cout.flush();
 
 }
+/**************************************************************************************************/
+
+Database::~Database(){                                                                                                         
+
+               templateSequences.clear();
+}
+
+/**************************************************************************************************/
+
+float Database::getSearchScore()       {       return searchScore;             }       //      we're assuming that the search is already done
 
 /**************************************************************************************************/