//read through file
while (getline(in, line)) {
- if (isalnum(line.at(0))){ //if it's a sequence line
- sequence += line;
- }
- else{
+ if (line != "") {
+ if (isalnum(line.at(0))) { //if it's a sequence line
+ sequence += line;
+ }
+ else{
//input sequence info into map
- it = data.find(sequence);
- if (it == data.end()) { //it's unique.
- data[sequence].groupname = name; //group name will be the name of the first duplicate sequence found.
- data[sequence].groupnumber = 1;
- data[sequence].names = name;
- }else { // its a duplicate.
- data[sequence].names += "," + name;
- data[sequence].groupnumber++;
+ it = data.find(sequence);
+ if (it == data.end()) { //it's unique.
+ data[sequence].groupname = name; //group name will be the name of the first duplicate sequence found.
+ data[sequence].groupnumber = 1;
+ data[sequence].names = name;
+ }else { // its a duplicate.
+ data[sequence].names += "," + name;
+ data[sequence].groupnumber++;
+ }
+ name = (line.substr(1, (line.npos))); //The line you just read is a new name so rip off '>'
+ sequence = "";
}
- name = (line.substr(1, (line.npos))); //The line you just read is a new name so rip off '>'
- sequence = "";
}
}
}
}
/*******************************************************************************/
+void FastaMap::printCondensedFasta(ostream& out){ //prints data
+ try {
+ // two column file created with groupname and them list of identical sequence names
+ for (it = data.begin(); it != data.end(); it++) {
+ out << ">" << it->second.groupname << endl;
+ out << it->first << endl;
+ }
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the FastaMap class Function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the FastaMap class function print. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+/*******************************************************************************/
+