]> git.donarmstrong.com Git - mothur.git/blobdiff - database.cpp
line and label no longer persist between commands. Added phylip formated output...
[mothur.git] / database.cpp
index b661d41402fc715b8073266d11c23224ad65a781..f8491469a3fec224f299125fdd960a38343f921b 100644 (file)
@@ -7,52 +7,53 @@
  *
  */
 
-using namespace std;
-
 #include "mothur.h"
 #include "sequence.hpp"
 #include "database.hpp"
 
 /**************************************************************************************************/
 
-Database::Database(string fastaFileName){
-       
-       ifstream fastaFile(fastaFileName.c_str());
-       if(!fastaFile) {
-               cerr << "Error: Could not open " << fastaFileName << endl;
-               exit(1);
-       }
+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);
+
        cout << endl << "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] = new Sequence(seqName, aligned);
                fastaFile.putback(letter);
        }
        
        fastaFile.close();
+       //all of this is elsewhere already!
+       
        cout << "DONE." << endl;        cout.flush();
 
 }
 
 /**************************************************************************************************/
+
+float Database::getSearchScore()       {       return searchScore;             }       //      we're assuming that the search is already done
+
+/**************************************************************************************************/