void FastaMap::readFastaFile(string inFileName) {
try {
ifstream in;
- openInputFile(inFileName, in);
+ m->openInputFile(inFileName, in);
string name, sequence, line;
sequence = "";
string temp;
-
+ map<string, string>::iterator itName;
+
+
while(!in.eof()){
if (m->control_pressed) { break; }
if(currSeq.getIsAligned()) { sequence = currSeq.getAligned(); }
else { sequence = currSeq.getUnaligned(); }
- seqmap[name] = sequence;
+ itName = seqmap.find(name);
+ if (itName == seqmap.end()) { seqmap[name] = sequence; }
+ else { m->mothurOut("You already have a sequence named " + name + ", sequence names must be unique, please correct."); m->mothurOutEndLine(); }
+
map<string,group>::iterator 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++;
}
}
- gobble(in);
+ m->gobble(in);
}
in.close();
}
void FastaMap::readFastaFile(string inFastaFile, string oldNameFileName){ //prints data
ifstream oldNameFile;
- openInputFile(oldNameFileName, oldNameFile);
+ m->openInputFile(oldNameFileName, oldNameFile);
map<string,string> oldNameMap;
+ map<string, string>::iterator itName;
string name, list;
while(!oldNameFile.eof()){
if (m->control_pressed) { break; }
- oldNameFile >> name >> list;
+ oldNameFile >> name; m->gobble(oldNameFile);
+ oldNameFile >> list;
oldNameMap[name] = list;
- gobble(oldNameFile);
+ m->gobble(oldNameFile);
}
oldNameFile.close();
ifstream inFASTA;
- openInputFile(inFastaFile, inFASTA);
+ m->openInputFile(inFastaFile, inFASTA);
string sequence;
while(!inFASTA.eof()){
if (m->control_pressed) { break; }
if(currSeq.getIsAligned()) { sequence = currSeq.getAligned(); }
else { sequence = currSeq.getUnaligned(); }
+ itName = seqmap.find(name);
+ if (itName == seqmap.end()) { seqmap[name] = sequence; }
+ else { m->mothurOut("You already have a sequence named " + name + ", sequence names must be unique, please correct."); m->mothurOutEndLine(); }
+
seqmap[name] = sequence;
map<string,group>::iterator it = data.find(sequence);
if (it == data.end()) { //it's unique.
// data[sequence].groupnumber++;
}
}
- gobble(inFASTA);
+ m->gobble(inFASTA);
}
void FastaMap::printNamesFile(string outFileName){ //prints data
try {
ofstream outFile;
- openOutputFile(outFileName, outFile);
+ m->openOutputFile(outFileName, outFile);
// two column file created with groupname and them list of identical sequence names
for (map<string,group>::iterator it = data.begin(); it != data.end(); it++) {
void FastaMap::printCondensedFasta(string outFileName){ //prints data
try {
ofstream out;
- openOutputFile(outFileName, out);
+ m->openOutputFile(outFileName, out);
//creates a fasta file
for (map<string,group>::iterator it = data.begin(); it != data.end(); it++) {
if (m->control_pressed) { break; }