]> git.donarmstrong.com Git - mothur.git/blob - database.cpp
pat's edits of screen.seqs and summary.seqs
[mothur.git] / database.cpp
1 /*
2  *  database.cpp
3  *  
4  *
5  *  Created by Pat Schloss on 12/16/08.
6  *  Copyright 2008 Patrick D. Schloss. All rights reserved.
7  *
8  */
9
10 using namespace std;
11
12
13 #include "sequence.hpp"
14 #include "database.hpp"
15
16 /**************************************************************************************************/
17
18 Database::Database(string fastaFileName){               //      This assumes that the template database is in fasta format, may 
19                                                                                                 //      need to alter this in the future?
20
21         ifstream fastaFile;
22         openInputFile(fastaFileName, fastaFile);
23
24         cout << endl << "Reading in the " << fastaFileName << " template sequences...\t";       cout.flush();
25
26         //all of this is elsewhere already!
27         numSeqs=count(istreambuf_iterator<char>(fastaFile),istreambuf_iterator<char>(), '>');   //      count the number of
28         fastaFile.seekg(0);                                                                                                                                             //      sequences
29         
30         templateSequences.resize(numSeqs);
31         
32         string seqName, sequence;
33         for(int i=0;i<numSeqs;i++){
34                 fastaFile >> seqName;
35                 seqName = seqName.substr(1);
36                 char letter;
37                 string aligned;
38                 
39                 while(fastaFile && (letter=fastaFile.get()) != '>'){
40                         if(isprint(letter)){
41                                 letter = toupper(letter);
42                                 if(letter == 'U'){letter = 'T';}
43                                 aligned += letter;
44                         }
45                 }
46                 templateSequences[i] = new Sequence(seqName, aligned);
47                 fastaFile.putback(letter);
48         }
49         
50         fastaFile.close();
51         //all of this is elsewhere already!
52         
53         cout << "DONE." << endl;        cout.flush();
54
55 }
56
57 /**************************************************************************************************/
58
59 float Database::getSearchScore()        {       return searchScore;             }       //      we're assuming that the search is already done
60
61 /**************************************************************************************************/