string input;
while(!inFASTA.eof()){
- getline(inFASTA, input);
+ input = getline(inFASTA);
if (input.length() != 0) {
if(input[0] == '>'){ int pos = inFASTA.tellg(); positions.push_back(pos - input.length() - 1); }
}
#include "chimeraseqscommand.h"
#include "eachgapdist.h"
+#include "ignoregaps.h"
+#include "onegapdist.h"
//***************************************************************************************************************
delete distCalculator;
- //find average pref score across windows
- //if (increment != 0) {
-
- //for (int i = 0; i < pref.size(); i++) {
- //pref[i].score[0] = pref[i].score[0] / iters;
- //}
- //}
+ //rank preference score to eachother
+ float dme = 0.0;
+ float expectedPercent = 1 / (float) (pref.size());
+
+ for (int i = 0; i < pref.size(); i++) { dme += pref[i].score[0]; }
+
+ for (int i = 0; i < pref.size(); i++) {
+
+ //gives the actual percentage of the dme this seq adds
+ pref[i].score[0] = pref[i].score[0] / dme;
+
+ //how much higher or lower is this than expected
+ pref[i].score[0] = pref[i].score[0] / expectedPercent;
+
+ }
+
//sort Preferences highest to lowest
sort(pref.begin(), pref.end(), comparePref);
itL = currentLeft.find(j);
itR = currentRight.find(j);
-cout << " i = " << i << " j = " << j << " distLeft = " << itL->second << endl;
-cout << " i = " << i << " j = " << j << " distright = " << itR->second << endl;
+//cout << " i = " << i << " j = " << j << " distLeft = " << itL->second << endl;
+//cout << " i = " << i << " j = " << j << " distright = " << itR->second << endl;
//if you can find this entry update the preferences
if ((itL != currentLeft.end()) && (itR != currentRight.end())) {
if (!correction) {
pref[i].score[1] += abs((itL->second - itR->second));
pref[j].score[1] += abs((itL->second - itR->second));
-cout << "left " << i << " " << j << " = " << itL->second << " right " << i << " " << j << " = " << itR->second << endl;
-cout << "abs = " << abs((itL->second - itR->second)) << endl;
-cout << i << " score = " << pref[i].score[1] << endl;
-cout << j << " score = " << pref[j].score[1] << endl;
+//cout << "left " << i << " " << j << " = " << itL->second << " right " << i << " " << j << " = " << itR->second << endl;
+//cout << "abs = " << abs((itL->second - itR->second)) << endl;
+//cout << i << " score = " << pref[i].score[1] << endl;
+//cout << j << " score = " << pref[j].score[1] << endl;
}else {
pref[i].score[1] += abs((sqrt(itL->second) - sqrt(itR->second)));
pref[j].score[1] += abs((sqrt(itL->second) - sqrt(itR->second)));
-cout << "left " << i << " " << j << " = " << itL->second << " right " << i << " " << j << " = " << itR->second << endl;
-cout << "abs = " << abs((sqrt(itL->second) - sqrt(itR->second))) << endl;
-cout << i << " score = " << pref[i].score[1] << endl;
-cout << j << " score = " << pref[j].score[1] << endl;
+//cout << "left " << i << " " << j << " = " << itL->second << " right " << i << " " << j << " = " << itR->second << endl;
+//cout << "abs = " << abs((sqrt(itL->second) - sqrt(itR->second))) << endl;
+//cout << i << " score = " << pref[i].score[1] << endl;
+//cout << j << " score = " << pref[j].score[1] << endl;
}
-cout << "pref[" << i << "].closestLeft[1] = " << pref[i].closestLeft[1] << " parent = " << pref[i].leftParent[1] << endl;
+//cout << "pref[" << i << "].closestLeft[1] = " << pref[i].closestLeft[1] << " parent = " << pref[i].leftParent[1] << endl;
//are you the closest left sequence
if (itL->second < pref[i].closestLeft[1]) {
pref[i].closestLeft[1] = itL->second;
pref[i].leftParent[1] = seqs[j].getName();
-cout << "updating closest left to " << pref[i].leftParent[1] << endl;
+//cout << "updating closest left to " << pref[i].leftParent[1] << endl;
}
-cout << "pref[" << j << "].closestLeft[1] = " << pref[j].closestLeft[1] << " parent = " << pref[j].leftParent[1] << endl;
+//cout << "pref[" << j << "].closestLeft[1] = " << pref[j].closestLeft[1] << " parent = " << pref[j].leftParent[1] << endl;
if (itL->second < pref[j].closestLeft[1]) {
pref[j].closestLeft[1] = itL->second;
pref[j].leftParent[1] = seqs[i].getName();
-cout << "updating closest left to " << pref[j].leftParent[1] << endl;
+//cout << "updating closest left to " << pref[j].leftParent[1] << endl;
}
//are you the closest right sequence
//calculate the dme
+
int count0 = 0;
for (int i = 0; i < pref.size(); i++) { dme += pref[i].score[1]; if (pref[i].score[1] == 0.0) { count0++; } }
float expectedPercent = 1 / (float) (pref.size() - count0);
-cout << endl << "dme = " << dme << endl;
+//cout << endl << "dme = " << dme << endl;
//recalculate prefernences based on dme
for (int i = 0; i < pref.size(); i++) {
-cout << "unadjusted pref " << i << " = " << pref[i].score[1] << endl;
+//cout << "unadjusted pref " << i << " = " << pref[i].score[1] << endl;
// gives the actual percentage of the dme this seq adds
pref[i].score[1] = pref[i].score[1] / dme;
//how much higher or lower is this than expected
pref[i].score[1] = pref[i].score[1] / expectedPercent;
+ //pref[i].score[1] = dme / (dme - 2 * pref[i].score[1]);
+
//so a non chimeric sequence would be around 1, and a chimeric would be signifigantly higher.
-cout << "adjusted pref " << i << " = " << pref[i].score[1] << endl;
+//cout << "adjusted pref " << i << " = " << pref[i].score[1] << endl;
}
//is this score bigger then the last score
pref[i].midpoint = mid;
}
- //total of preference scores across windows
- //pref[i].score[0] += pref[i].score[1];
}
}
mostSimSequenceVector.resize(numCandSeqs);
for(int i=0;i<numCandSeqs;i++){
- inputData >> candidateSeqName >> closestMatch.seqName >> closestMatch.indexNumber >> closestMatch.simScore;
-// getline(inputData, junk);
+ inputData >> candidateSeqName >> closestMatch.seqName >> closestMatch.indexNumber >> closestMatch.simScore;
mostSimSequenceVector[i] = closestMatch;
}
mothurOut(toString(numCandSeqs)); mothurOutEndLine();
openedBatch = openInputFile(batchFileName, inputBatchFile);
globaldata->argv = path;
-
-
- // char buffer = ' ';
- // ifstream header("introtext.txt");
- // while(!header.eof()){
- // cout << buffer;
- // buffer = header.get();
- // }
}
catch(exception& e) {
errorOut(e, "BatchEngine", "BatchEngine");
while(quitCommandCalled == 0){
if (inputBatchFile.eof()) { input = "quit()"; }
- else { getline(inputBatchFile, input); }
+ else { input = getline(inputBatchFile); }
openInputFile(inName, inFile);
string inputBuffer;
- getline(inFile, inputBuffer);
+ inputBuffer = getline(inFile);
outFile << inputBuffer << '\t' << label << "\tlci\thci" << endl;
}
try {
if(counter != 0){
string inputBuffer;
- getline(inFile, inputBuffer);
+ inputBuffer = getline(inFile);
outFile << inputBuffer << setprecision(4) << '\t' << data[0] << '\t' << data[1] << '\t' << data[2] << endl;
}
openInputFile(inName, inFile);
string inputBuffer;
- getline(inFile, inputBuffer);
+ inputBuffer = getline(inFile);
outFile << inputBuffer << '\t';
for(int i = 0; i < tags.size(); i++) {
if(counter != 0){
string inputBuffer;
- getline(inFile, inputBuffer);
+ inputBuffer = getline(inFile);
outFile << inputBuffer << '\t' << setprecision(6) << data[0] << setprecision(iters.length());
for (int i = 1; i< data.size(); i++) {
openInputFile(inName, inFile);
string inputBuffer;
- getline(inFile, inputBuffer);
+ inputBuffer = getline(inFile);
outFile << inputBuffer << '\t' << label << "\tlci\thci" << endl;
}
try {
if(counter != 0){
string inputBuffer;
- getline(inFile, inputBuffer);
+ inputBuffer = getline(inFile);
outFile << inputBuffer << setprecision(4) << '\t' << data[0] << '\t' << data[1] << '\t' << data[2] << endl;
}
openInputFile(inName, inFile);
string inputBuffer;
- getline(inFile, inputBuffer);
+ inputBuffer = getline(inFile);
outFile << inputBuffer << '\t' << label << endl;
}
try {
if(counter != 0){
string inputBuffer;
- getline(inFile, inputBuffer);
+ inputBuffer = getline(inFile);
outFile << inputBuffer << setprecision(4) << '\t' << data[0] << endl;
}
openInputFile(inName, inFile);
string inputBuffer;
- getline(inFile, inputBuffer);
+ inputBuffer = getline(inFile);
outFile << inputBuffer << '\t' << label << endl;
}
if(counter != 0){
string inputBuffer;
- getline(inFile, inputBuffer);
+ inputBuffer = getline(inFile);
outFile << inputBuffer << setprecision(2) << '\t' << dataOutput << endl;
}
}
}
+/***********************************************************************/
+
+inline string getline(ifstream& fileHandle) {
+ try {
+
+ string line = "";
+
+ while (!fileHandle.eof()) {
+ //get next character
+ char c = fileHandle.get();
+
+ //are you at the end of the line
+ if (c == 10 || c == 13){ break; }
+ else { line += c; }
+ }
+
+ return line;
+
+ }
+ catch(exception& e) {
+ cout << "Error in mothur function getline" << endl;
+ exit(1);
+ }
+}
/**************************************************************************************************/
if(option == "help") { help(); abort = true; }
else {
- //valid paramters for this command
- string Array[] = {"command"};
- vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
-
- OptionParser parser(option);
- map<string,string> parameters = parser.getParameters();
-
- ValidParameters validParameter;
-
- //check to make sure all parameters are valid for command
- for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) {
- if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
- }
-
- //check for required parameters
- command = validParameter.validFile(parameters, "command", false);
- if (command == "not found") { mothurOut("command is a required parameter."); mothurOutEndLine(); abort = true; }
+ if (option = "") { mothurOut("You must enter a command to run."); mothurOutEndLine(); abort = true; }
+ else { command = option; }
}
}
void SystemCommand::help(){
try {
mothurOut("The system command allows you to execute a system command from within mothur.\n");
- mothurOut("The system command parameter is command and it is required.\n");
- mothurOut("The system command should be in the following format: system(command=yourCommand).\n");
- mothurOut("Example system(command=clear).\n");
- mothurOut("Note: No spaces between parameter labels (i.e. command), '=' and parameters (i.e.yourCommand).\n\n");
+ mothurOut("The system has no parameters.\n");
+ mothurOut("The system command should be in the following format: system(yourCommand).\n");
+ mothurOut("Example system(clear).\n");
}
catch(exception& e) {
errorOut(e, "SystemCommand", "help");