11 sequence::sequence(
string& fileName){
12 file=
new std::ifstream;
13 file->open(fileName.c_str());
14 if (!file->is_open()){
15 cerr <<
"Couldn't find file: " << fileName <<endl;
23 bool sequence::next(){
28 if (file==NULL || file->eof()){
33 while(file->peek() !=
'>'){
40 getline(*file,temp,
'\n');
42 getline(*file,
header,
'\n');
50 while(getline(*file,temp,
'\n')){
52 for(
int j=0;j<temp.size();j++){
53 temp[j]=toupper(temp[j]);
75 char nl_peek=file->peek();
79 else if (nl_peek==EOF){
90 cerr <<
"Mask not the same size as sequence\n";
97 bool sequence::importMask(){
100 if (file==NULL || file->eof()){
106 while(file->peek() !=
'>'){
112 getline(*file,temp,
'\n');
114 getline(*file,temp,
'\n');
121 while(getline(*file,temp,
'\n')){
123 char * str=
new char[temp.size()+1];
125 memcpy(str, temp.c_str(), temp.size());
128 pch = strtok (str,
" ,.");
131 mask.push_back(atoi(pch));
132 pch = strtok (NULL,
" ,.");
135 char nl_peek=file->peek();
139 else if (nl_peek==EOF){
153 for (
int i=0;i<
length;i++){
185 const std::ifstream* file(seqFile[iter]);
189 std::string undigitized;
191 while(getline(*file,temp,
'\n')){
204 std::set<std::string> alphabet;
205 pair<std::set<int>::iterator,
bool> ret;
207 for(
size_t i=0;i<undigitized.size();i++){
208 ret = alphabet.insert(undigitized[i]);
210 indexAlpha[iter].push_back(undigitized[i]);
214 for(
size_t i=0;i<indexAlpha[iter].size();i++){
215 string &temp= indexAlpha[iter][i];
216 alphaIndex[iter][temp]=i;
219 file.seekg(0,std::ios::beg);
226 for(
size_t i=0;i<lst.
size();i++){
227 string& temp = lst[i];
229 alphaIndex[iter][temp]=i;