//if user gave a namesfile then use it
if (namesfile != "") { readNamesFile(); }
- if (countfile != "") { ct.readTable(countfile, true); }
+ if (countfile != "") { ct.readTable(countfile, true, false); }
input = new InputData(listfile, "list");
list = input->getListVector();
if (hasCount) {
CountTable* ct = new CountTable();
- ct->readTable(nameFile, true);
+ ct->readTable(nameFile, true, false);
if (ct->hasGroupInfo()) {
cparser = new SequenceCountParser(fastaFileNames[s], *ct);
if(processors == 1) { numSeqs = driverGroups(outputFileName, accnosFileName, newCountFile, 0, groups.size(), groups);
if (dups) {
- CountTable c; c.readTable(nameFile, true);
+ CountTable c; c.readTable(nameFile, true, false);
if (!m->isBlank(newCountFile)) {
ifstream in2;
m->openInputFile(newCountFile, in2);
numChimeras = deconvoluteResults(uniqueNames, outputFileName, accnosFileName);
}else {
set<string> doNotRemove;
- CountTable c; c.readTable(newCountFile, true);
+ CountTable c; c.readTable(newCountFile, true, true);
vector<string> namesInTable = c.getNamesOfSeqs();
for (int i = 0; i < namesInTable.size(); i++) {
int temp = c.getNumSeqs(namesInTable[i]);
int num = 0;
CountTable newCount;
- if (hasCount && dups) { newCount.readTable(name, true); }
+ if (hasCount && dups) { newCount.readTable(name, true, false); }
//sanity check
if (groups.size() < processors) { processors = groups.size(); }
SequenceCountParser* cparser;
if (pDataArray->hasCount) {
CountTable* ct = new CountTable();
- ct->readTable(pDataArray->namefile, true);
+ ct->readTable(pDataArray->namefile, true, false);
cparser = new SequenceCountParser(pDataArray->fastafile, *ct);
delete ct;
}else {
if (processors == 1) {
numSeqs = driverGroups(outputFileName, accnosFileName, trimFastaFileName, fileToPriority, fileGroup, newCountFile);
if (hasCount && dups) {
- CountTable c; c.readTable(nameFileNames[s], true);
+ CountTable c; c.readTable(nameFileNames[s], true, false);
if (!m->isBlank(newCountFile)) {
ifstream in2;
m->openInputFile(newCountFile, in2);
}else {
if (hasCount) {
set<string> doNotRemove;
- CountTable c; c.readTable(newCountFile, true);
+ CountTable c; c.readTable(newCountFile, true, true);
vector<string> namesInTable = c.getNamesOfSeqs();
for (int i = 0; i < namesInTable.size(); i++) {
int temp = c.getNumSeqs(namesInTable[i]);
if (fileToPriority.size() < processors) { processors = fileToPriority.size(); }
CountTable newCount;
- if (hasCount && dups) { newCount.readTable(countFile, true); }
+ if (hasCount && dups) { newCount.readTable(countFile, true, false); }
int groupsPerProcessor = fileToPriority.size() / processors;
int remainder = fileToPriority.size() % processors;
int error;
if (hasCount) {
CountTable ct;
- ct.readTable(nameFile, true);
+ ct.readTable(nameFile, true, false);
for(map<string, string>::iterator it = seqs.begin(); it != seqs.end(); it++) {
int num = ct.getNumSeqs(it->first);
int error;
if (hasCount) {
CountTable ct;
- ct.readTable(nameFile, true);
+ ct.readTable(nameFile, true, false);
for(map<string, string>::iterator it = seqs.begin(); it != seqs.end(); it++) {
int num = ct.getNumSeqs(it->first);
if (num == 0) { error = 1; }
if(processors == 1) { totalSeqs = driverGroups(outputFileName, newFasta, accnosFileName, alnsFileName, newCountFile, 0, groups.size(), groups);
if (hasCount && dups) {
- CountTable c; c.readTable(nameFile, true);
+ CountTable c; c.readTable(nameFile, true, false);
if (!m->isBlank(newCountFile)) {
ifstream in2;
m->openInputFile(newCountFile, in2);
if (hasCount) {
set<string> doNotRemove;
- CountTable c; c.readTable(newCountFile, true);
+ CountTable c; c.readTable(newCountFile, true, true);
vector<string> namesInTable = c.getNamesOfSeqs();
for (int i = 0; i < namesInTable.size(); i++) {
int temp = c.getNumSeqs(namesInTable[i]);
int num = 0;
CountTable newCount;
- if (hasCount && dups) { newCount.readTable(nameFile, true); }
+ if (hasCount && dups) { newCount.readTable(nameFile, true, false); }
//sanity check
if (groups.size() < processors) { processors = groups.size(); }
SequenceCountParser* cparser;
if (pDataArray->hasCount) {
CountTable* ct = new CountTable();
- ct->readTable(pDataArray->namefile, true);
+ ct->readTable(pDataArray->namefile, true, false);
cparser = new SequenceCountParser(pDataArray->fastafile, *ct);
delete ct;
}else {
iss >> name; m->gobble(iss);
iss >> taxInfo;
if (m->debug) { m->mothurOut("[DEBUG]: name = " + name + " tax = " + taxInfo + "\n"); }
- if (m->inUsersGroups(name, names)) {
+ //commented out to save time with large templates. 10/7/13
+ //if (m->inUsersGroups(name, names)) {
taxonomy[name] = taxInfo;
phyloTree->addSeqToTree(name, taxInfo);
- }else {
- m->mothurOut("[WARNING]: " + name + " is in your taxonomy file and not in your reference file, ignoring.\n");
- }
+ //}else {
+ // m->mothurOut("[WARNING]: " + name + " is in your taxonomy file and not in your reference file, ignoring.\n");
+ //}
}
MPI_File_close(&inMPI);
if (namefile != "") { m->readNames(namefile, nameMap, true); }
if (groupfile != "") { groupMap = new GroupMap(groupfile); groupMap->readMap(); groups = groupMap->getNamesOfGroups(); }
else { groupMap = NULL; }
- if (countfile != "") { ct = new CountTable(); ct->readTable(countfile, true); if (ct->hasGroupInfo()) { groups = ct->getNamesOfGroups(); } }
+ if (countfile != "") { ct = new CountTable(); ct->readTable(countfile, true, false); if (ct->hasGroupInfo()) { groups = ct->getNamesOfGroups(); } }
else { ct = NULL; }
//read taxonomy file and save in map for easy access in building bin trees
PhyloSummary* taxaSum;
if (hasCount) {
ct = new CountTable();
- ct->readTable(countfileNames[s], true);
+ ct->readTable(countfileNames[s], true, false);
taxaSum = new PhyloSummary(taxonomyFileName, ct);
taxaSum->summarize(tempTaxonomyFile);
}else {
read->read(nameMap);
}else if (countfile != "") {
ct = new CountTable();
- ct->readTable(countfile, false);
+ ct->readTable(countfile, false, false);
read->read(ct);
}else { read->read(nameMap); }
delete nameMap;
}else if (countfile != "") {
ct = new CountTable();
- ct->readTable(countfile, false);
+ ct->readTable(countfile, false, false);
cluster->readPhylipFile(phylipfile, ct);
delete ct;
}else {
countfile = validParameter.validFile(parameters, "count", true);
if (countfile == "not open") { abort = true; countfile = ""; }
else if (countfile == "not found") { countfile = ""; }
- else { ct.readTable(countfile, true); m->setCountTableFile(countfile); }
+ else { ct.readTable(countfile, true, false); m->setCountTableFile(countfile); }
if ((countfile != "") && (namefile != "")) { m->mothurOut("When executing a cluster.fragments command you must enter ONLY ONE of the following: count or name."); m->mothurOutEndLine(); abort = true; }
cluster->readPhylipFile(thisDistFile, nameMap);
}else if (countfile != "") {
ct = new CountTable();
- ct->readTable(thisNamefile, false);
+ ct->readTable(thisNamefile, false, false);
cluster->readPhylipFile(thisDistFile, ct);
}
tag = cluster->getTag();
read->read(nameMap);
}else if (countfile != "") {
ct = new CountTable();
- ct->readTable(thisNamefile, false);
+ ct->readTable(thisNamefile, false, false);
read->read(ct);
}else { read->read(nameMap); }
if (m->control_pressed) { return 0; }
if (namefile != "") { readNames(); }
- if (countfile != "") { ct.readTable(countfile, true); }
+ if (countfile != "") { ct.readTable(countfile, true, false); }
if (m->control_pressed) { return 0; }
m->openOutputFile(outputFileName, out);
CountTable ct;
- ct.readTable(countfile, true);
+ ct.readTable(countfile, true, false);
//make sure groups are valid
//takes care of user setting groupNames that are invalid or setting groups=all
}
}
/************************************************************/
-int CountTable::readTable(string file, bool readGroups) {
+int CountTable::readTable(string file, bool readGroups, bool mothurRunning) {
try {
filename = file;
ifstream in;
in >> name; m->gobble(in); in >> thisTotal; m->gobble(in);
if (m->debug) { m->mothurOut("[DEBUG]: " + name + '\t' + toString(thisTotal) + "\n"); }
- if (thisTotal == 0) { error=true; m->mothurOut("[ERROR]: Your count table contains a sequence named " + name + " with a total=0. Please correct."); m->mothurOutEndLine();
+ if ((thisTotal == 0) && !mothurRunning) { error=true; m->mothurOut("[ERROR]: Your count table contains a sequence named " + name + " with a total=0. Please correct."); m->mothurOutEndLine();
}
//if group info, then read it
//reads and creates smart enough to eliminate groups with zero counts
int createTable(set<string>&, map<string, string>&, set<string>&); //seqNames, seqName->group, groupNames
int createTable(string, string, bool); //namefile, groupfile, createGroup
- int readTable(string, bool);
+ int readTable(string, bool, bool);
int printTable(string);
int printHeaders(ofstream&);
}
repNames = tempRepNames;
}else {
- ct.readTable(countfile, true);
+ ct.readTable(countfile, true, false);
numUniqueNamesFile = ct.getNumUniqueSeqs();
nameMap = ct.getNameMap();
}
try {
int index = -1;
for (int i = 0; i < otuLabels.size(); i++) {
- if (otuLabels[i] == label) { index = i; break; }
+ if (m->isLabelEquivalent(otuLabels[i],label)) { index = i; break; }
}
return index;
}
}
CountTable ct;
if (countfile != "") {
- ct.readTable(countfile, true);
+ ct.readTable(countfile, true, false);
if (countfile == outCountFile){
//prepare filenames and open files
map<string, string> mvariables;
m->mothurOut("\n[NOTE]: The count file should contain only unique names, so mothur assumes your fasta, list and taxonomy files also contain only uniques.\n\n");
}
CountTable ct;
- ct.readTable(countfile, true);
+ ct.readTable(countfile, true, false);
if (!ct.hasGroupInfo()) { m->mothurOut("[ERROR]: your count file does not contain group info, aborting.\n"); return 0; }
vector<string> gNamesOfGroups = ct.getNamesOfGroups();
//check for groups that have been eliminated
CountTable ct;
if (ct.testGroups(outputFileName)) {
- ct.readTable(outputFileName, true);
+ ct.readTable(outputFileName, true, false);
ct.printTable(outputFileName);
}
}
otuLabel += sbinNumber;
- if (names.count(otuLabel) != 0) {
+ if (names.count(m->getSimpleLabel(otuLabel)) != 0) {
selectedCount++;
newList.push_back(list->get(i));
}
if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) { delete newLookup[j]; } for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; } return 0; }
//is this otu on the list
- if (names.count(m->currentBinLabels[i]) != 0) {
+ if (names.count(m->getSimpleLabel(m->currentBinLabels[i])) != 0) {
numSelected++; wroteSomething = true;
newLabels.push_back(m->currentBinLabels[i]);
for (int j = 0; j < newLookup.size(); j++) { //add this OTU to the new lookup
int pos = newtax.find(noConfidenceTaxons[j]);
if (pos != string::npos) { //this sequence contains the taxon the user wants
- names.insert(otuLabel);
+ names.insert(m->getSimpleLabel(otuLabel));
out << otuLabel << '\t' << numReps << '\t' << tax << endl;
//since you belong to at least one of the taxons we want you are included so no need to search for other
break;
int pos = newtax.find(noConfidenceTaxons[j]);
if (pos != string::npos) { //this sequence contains the taxon the user wants
- names.insert(otuLabel);
+ names.insert(m->getSimpleLabel(otuLabel));
out << otuLabel << '\t' << numReps << '\t' << tax << endl;
//since you belong to at least one of the taxons we want you are included so no need to search for other
break;
//passed the test so add you
if (good) {
- names.insert(otuLabel);
+ names.insert(m->getSimpleLabel(otuLabel));
out << otuLabel << '\t' << numReps << '\t' << tax << endl;
break;
}
//get labels you want to keep
labels = m->readAccnos(accnosfile);
+ //simplfy labels
+ set<string> newLabels;
+ for (set<string>::iterator it = labels.begin(); it != labels.end(); it++) { newLabels.insert(m->getSimpleLabel(*it)); }
+ labels = newLabels;
if (m->control_pressed) { return 0; }
in >> otu >> size >> tax; m->gobble(in);
- if (labels.count(otu) != 0) {
+ if (labels.count(m->getSimpleLabel(otu)) != 0) {
wroteSomething = true;
selectedCount++;
in >> otu1 >> otu2;
string line = m->getline(in); m->gobble(in);
- if ((labels.count(otu1) != 0) && (labels.count(otu2) != 0)){
+ if ((labels.count(m->getSimpleLabel(otu1)) != 0) && (labels.count(m->getSimpleLabel(otu2)) != 0)){
wroteSomething = true;
selectedCount++;
in >> otu;
string line = m->getline(in); m->gobble(in);
- if (labels.count(otu) != 0) {
+ if (labels.count(m->getSimpleLabel(otu)) != 0) {
wroteSomething = true;
selectedCount++;
if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) { delete newLookup[j]; } for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; } return 0; }
//is this otu on the list
- if (labels.count(m->currentBinLabels[i]) != 0) {
+ if (labels.count(m->getSimpleLabel(m->currentBinLabels[i])) != 0) {
numSelected++; wroteSomething = true;
newLabels.push_back(m->currentBinLabels[i]);
for (int j = 0; j < newLookup.size(); j++) { //add this OTU to the new lookup
}
otuLabel += sbinNumber;
- if (labels.count(otuLabel) != 0) {
+ if (labels.count(m->getSimpleLabel(otuLabel)) != 0) {
selectedCount++;
newList.push_back(list->get(i));
}
else if (countfile == "not open") { abort = true; countfile = ""; }
else {
m->setCountTableFile(countfile);
- ct.readTable(countfile, true);
+ ct.readTable(countfile, true, false);
if (ct.hasGroupInfo()) { hasGroups = true; }
}
CountTable thisCt;
if (countfile != "") {
- thisCt.readTable(countfile, true);
+ thisCt.readTable(countfile, true, false);
if (tempGroup != "noGroup") { out2 << "Representative_Sequence\ttotal\t" << tempGroup << endl; }
}
CountTable thisCt;
if (countfile != "") {
- thisCt.readTable(countfile, true);
+ thisCt.readTable(countfile, true, false);
if (tempGroup != "noGroup") { out2 << "Representative_Sequence\ttotal\t" << tempGroup << endl; }
}
int GetRAbundCommand::processList(ofstream& out){
try {
CountTable ct;
- ct.readTable(countfile, false);
+ ct.readTable(countfile, false, false);
InputData input(inputfile, format);
ListVector* list = input.getListVector();
int GetSAbundCommand::processList(ofstream& out){
try {
CountTable ct;
- ct.readTable(countfile, false);
+ ct.readTable(countfile, false, false);
InputData input(inputfile, format);
ListVector* list = input.getListVector();
//check for groups that have been eliminated
CountTable ct;
if (ct.testGroups(outputFileName)) {
- ct.readTable(outputFileName, true);
+ ct.readTable(outputFileName, true, false);
ct.printTable(outputFileName);
}
}
//sort lookup so shared bins are on top
- if (sorted != "none") { sortSharedVectors(lookup); }
+ vector<string> sortedLabels = m->currentBinLabels;
+ if (sorted != "none") { sortedLabels = sortSharedVectors(lookup); }
vector<vector<string> > scaleRelAbund;
vector<float> maxRelAbund(lookup[0]->size(), 0.0);
string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + ".heatmap.bin.svg";
m->openOutputFile(filenamesvg, outsvg);
+ int binHeight = 20;
+ int labelBump = 100;
+ int binWidth = 300;
//svg image
- outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(lookup.size() * 300) + " " + toString((numBinsToDisplay*5 + 120)) + "\">\n";
+ outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(lookup.size() * binWidth + labelBump) + " " + toString((numBinsToDisplay*binHeight + 120)) + "\">\n";
outsvg << "<g>\n";
//white backround
- outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(lookup.size() * 300) + "\" height=\"" + toString((numBinsToDisplay*5 + 120)) + "\"/>";
+ outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(lookup.size() * binWidth+labelBump) + "\" height=\"" + toString((numBinsToDisplay*binHeight + 120)) + "\"/>";
outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" text-anchor=\"middle\" x=\"" + toString((lookup.size() * 150) - 40) + "\" y=\"25\">Heatmap at distance " + lookup[0]->getLabel() + "</text>\n";
//column labels
- for (int h = 0; h < lookup.size(); h++) {
- outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(((300 * (h+1)) - 150) - ((int)lookup[h]->getGroup().length() / 2)) + "\" y=\"50\">" + lookup[h]->getGroup() + "</text>\n";
+ for (int h = 0; h < lookup.size()+1; h++) {
+ if (h == 0) {
+ string tempLabel = "OTU";
+ outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(labelBump-labelBump/2+1) + "\" y=\"50\">" + tempLabel + "</text>\n";
+ }else {
+ outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(((binWidth * h) - 150) - ((int)lookup[h-1]->getGroup().length() / 2)+labelBump/2) + "\" y=\"50\">" + lookup[h-1]->getGroup() + "</text>\n";
+ }
}
//output legend and color labels
string color;
int x = 0;
- int y = 103 + (numBinsToDisplay*5);
+ int y = 103 + (numBinsToDisplay*binHeight);
printLegend(y, superMaxRelAbund);
y = 70;
for (int i = 0; i < numBinsToDisplay; i++) {
+ outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\">" + sortedLabels[i] + "</text>\n";
+ x += labelBump;
for (int j = 0; j < scaleRelAbund.size(); j++) {
if (m->control_pressed) { outsvg.close(); return "control"; }
- outsvg << "<rect fill=\"#" + scaleRelAbund[j][i] + "\" stroke=\"#" + scaleRelAbund[j][i] + "\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\" width=\"300\" height=\"5\"/>\n";
- x += 300;
+ outsvg << "<rect fill=\"#" + scaleRelAbund[j][i] + "\" stroke=\"#" + scaleRelAbund[j][i] + "\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\" width=\"" + toString(binWidth) + "\" height=\"" + toString(binHeight) + "\"/>\n";
+ x += binWidth;
}
x = 0;
- y += 5;
+ y += binHeight;
}
outsvg << "</g>\n</svg>\n";
}
//**********************************************************************************************************************
-int HeatMap::sortSharedVectors(vector<SharedRAbundVector*>& lookup){
+vector<string> HeatMap::sortSharedVectors(vector<SharedRAbundVector*>& lookup){
try {
vector<SharedRAbundVector*> looktemp;
map<int, int> place; //spot in lookup where you insert shared by, ie, 3 -> 2 if they are shared by 3 inset into location 2.
map<int, int>::iterator it;
+
+ vector<string> sortedLabels = m->currentBinLabels;
/****************** find order of otus **********************/
if (sorted == "shared") {
place = orderTopOtu(lookup);
}else if (sorted == "topgroup") {
place = orderTopGroup(lookup);
- }else { m->mothurOut("Error: invalid sort option."); m->mothurOutEndLine(); return 1; }
+ }else { m->mothurOut("Error: invalid sort option."); m->mothurOutEndLine(); return sortedLabels; }
/******************* create copy of lookup *********************/
int newAbund = looktemp[j]->getAbundance(i); // 1 -> 3
lookup[j]->set(place[i], newAbund, looktemp[j]->getGroup()); //binNumber, abundance, group
}
+ sortedLabels[place[i]] = m->currentBinLabels[i];
}
//delete looktemp -- Sarah look at - this is causing segmentation faults
// delete looktemp[j];
}
- return 0;
+ return sortedLabels;
}
catch(exception& e) {
}
//sort lookup so shared bins are on top
- if (sorted != "none") { sortSharedVectors(lookup); }
+ vector<string> sortedLabels = m->currentBinLabels;
+ if (sorted != "none") { sortedLabels = sortSharedVectors(lookup); }
vector<vector<string> > scaleRelAbund;
vector<float> maxRelAbund(lookup.size(), 0.0);
string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + ".heatmap.bin.svg";
m->openOutputFile(filenamesvg, outsvg);
+
+ int binHeight = 20;
+ int labelBump = 100;
+ int binWidth = 300;
//svg image
- outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(lookup.size() * 300) + " " + toString((numBinsToDisplay*5 + 120)) + "\">\n";
+ outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(lookup.size() * binWidth + labelBump) + " " + toString((numBinsToDisplay*binHeight + 120)) + "\">\n";
outsvg << "<g>\n";
//white backround
- outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(lookup.size() * 300) + "\" height=\"" + toString((numBinsToDisplay*5 + 120)) + "\"/>";
+ outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(lookup.size() * binWidth+labelBump) + "\" height=\"" + toString((numBinsToDisplay*binHeight + 120)) + "\"/>";
outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" text-anchor=\"middle\" x=\"" + toString((lookup.size() * 150) - 40) + "\" y=\"25\">Heatmap at distance " + lookup[0]->getLabel() + "</text>\n";
//column labels
- for (int h = 0; h < lookup.size(); h++) {
- outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(((300 * (h+1)) - 150) - ((int)lookup[h]->getGroup().length() / 2)) + "\" y=\"50\">" + lookup[h]->getGroup() + "</text>\n";
- }
-
+ for (int h = 0; h < lookup.size()+1; h++) {
+ if (h == 0) {
+ string tempLabel = "OTU";
+ outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(labelBump-labelBump/2+1) + "\" y=\"50\">" + tempLabel + "</text>\n";
+ }else {
+ outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(((binWidth * h) - 150) - ((int)lookup[h-1]->getGroup().length() / 2)+labelBump/2) + "\" y=\"50\">" + lookup[h-1]->getGroup() + "</text>\n";
+ }
+ }
+
//output legend and color labels
string color;
int x = 0;
- int y = 103 + (numBinsToDisplay*5);
+ int y = 103 + (numBinsToDisplay*binHeight);
printLegend(y, superMaxRelAbund);
y = 70;
for (int i = 0; i < numBinsToDisplay; i++) {
+ outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\">" + sortedLabels[i] + "</text>\n";
+ x += labelBump;
for (int j = 0; j < scaleRelAbund.size(); j++) {
if (m->control_pressed) { outsvg.close(); return "control"; }
- outsvg << "<rect fill=\"#" + scaleRelAbund[j][i] + "\" stroke=\"#" + scaleRelAbund[j][i] + "\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\" width=\"300\" height=\"5\"/>\n";
- x += 300;
+ outsvg << "<rect fill=\"#" + scaleRelAbund[j][i] + "\" stroke=\"#" + scaleRelAbund[j][i] + "\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\" width=\"" + toString(binWidth) + "\" height=\"" + toString(binHeight) + "\"/>\n";
+ x += binWidth;
}
x = 0;
- y += 5;
+ y += binHeight;
}
outsvg << "</g>\n</svg>\n";
}
}
//**********************************************************************************************************************
-int HeatMap::sortSharedVectors(vector<SharedRAbundFloatVector*>& lookup){
+vector<string> HeatMap::sortSharedVectors(vector<SharedRAbundFloatVector*>& lookup){
try {
vector<SharedRAbundFloatVector*> looktemp;
map<int, int> place; //spot in lookup where you insert shared by, ie, 3 -> 2 if they are shared by 3 inset into location 2.
map<int, int>::iterator it;
+
+ vector<string> sortedLabels = m->currentBinLabels;
/****************** find order of otus **********************/
if (sorted == "shared") {
place = orderTopOtu(lookup);
}else if (sorted == "topgroup") {
place = orderTopGroup(lookup);
- }else { m->mothurOut("Error: invalid sort option."); m->mothurOutEndLine(); return 1; }
+ }else { m->mothurOut("Error: invalid sort option."); m->mothurOutEndLine(); return sortedLabels; }
/******************* create copy of lookup *********************/
for (int j = 0; j < looktemp.size(); j++) { // 3 -> 2
float newAbund = looktemp[j]->getAbundance(i); // 1 -> 3
lookup[j]->set(place[i], newAbund, looktemp[j]->getGroup()); //binNumber, abundance, group
+ sortedLabels[place[i]] = m->currentBinLabels[i];
}
}
// delete looktemp[j];
}
- return 0;
+ return sortedLabels;
}
catch(exception& e) {
string getPic(vector<SharedRAbundFloatVector*>);
private:
- int sortSharedVectors(vector<SharedRAbundVector*>& );
- int sortSharedVectors(vector<SharedRAbundFloatVector*>& );
+ vector<string> sortSharedVectors(vector<SharedRAbundVector*>& );
+ vector<string> sortSharedVectors(vector<SharedRAbundFloatVector*>& );
int sortRabund(RAbundVector*&);
void printLegend(int, float);
}
}else if (countfile != "") {
nameMap = NULL;
- ct.readTable(countfile, true);
+ ct.readTable(countfile, true, false);
names = ct.getNamesOfSeqs();
}
//**********************************************************************************************************************
int HelpCommand::execute(){
try {
- validCommands->printCommands(cout);
+ validCommands->printCommands(cout);
m->mothurOut("For more information about a specific command type 'commandName(help)' i.e. 'read.dist(help)'"); m->mothurOutEndLine();
m->mothurOutEndLine(); m->mothurOut("For further assistance please refer to the Mothur manual on our wiki at http://www.mothur.org/wiki, or contact Pat Schloss at mothur.bugs@gmail.com.\n");
int ListSeqsCommand::readCount(){
try {
CountTable ct;
- ct.readTable(countfile, false);
+ ct.readTable(countfile, false, false);
if (m->control_pressed) { return 0; }
for (int h = 0; h < diff; h++) { binLabel += "0"; }
}
binLabel += sbinNumber;
+ binLabel = m->getSimpleLabel(binLabel);
labelTaxMap[binLabel] = taxs[i];
- }else { labelTaxMap[otuLabels[i]] = taxs[i]; }
+ }else { labelTaxMap[m->getSimpleLabel(otuLabels[i])] = taxs[i]; }
}
if (m->control_pressed) { return metadata; }
- it = labelTaxMap.find(m->currentBinLabels[i]);
+ it = labelTaxMap.find(m->getSimpleLabel(m->currentBinLabels[i]));
if (it == labelTaxMap.end()) { m->mothurOut("[ERROR]: can't find taxonomy information for " + m->currentBinLabels[i] + ".\n"); m->control_pressed = true; }
else {
if (seq2End < overlapEnd) { overlapEnd = seq2End; } //smallest end position is where overlapping ends
int oStart = contig.length();
+ //cout << fSeq.getAligned() << endl; cout << rSeq.getAligned() << endl;
for (int i = overlapStart; i < overlapEnd; i++) {
+ //cout << seq1[i] << ' ' << seq2[i] << ' ' << scores1[ABaseMap[i]] << ' ' << scores2[BBaseMap[i]] << endl;
if (seq1[i] == seq2[i]) { //match, add base and choose highest score
contig += seq1[i];
}else if (((seq1[i] == '.') || (seq1[i] == '-')) && ((seq2[i] != '-') && (seq2[i] != '.'))) { //seq1 is a gap and seq2 is a base, choose seq2, unless quality score for base is below insert. In that case eliminate base
}else { //seq2 ends before seq1 so take from overlap to length from seq1
for (int i = overlapEnd; i < length; i++) { contig += seq1[i]; }
}
-
+ //cout << contig << endl;
+ //exit(1);
if (trimOverlap) { contig = contig.substr(overlapStart-1, oend-oStart); if (contig.length() == 0) { trashCode += "l"; } }
if(trashCode.length() == 0){
nameMap->readMap();
}else if (countfile != "") {
ct = new CountTable();
- ct->readTable(countfile, false);
+ ct->readTable(countfile, false, false);
nameMap= new NameAssignment();
vector<string> tempNames = ct->getNamesOfSeqs();
for (int i = 0; i < tempNames.size(); i++) { nameMap->push_back(tempNames[i]); }
exit(1);
}
}
+/***********************************************************************/
+string MothurOut::getSimpleLabel(string label){
+ try {
+ string simple = "";
+
+ //remove OTU or phylo tag
+ string newLabel1 = "";
+ for (int i = 0; i < label.length(); i++) {
+ if(label[i]>47 && label[i]<58) { //is a digit
+ newLabel1 += label[i];
+ }
+ }
+
+ int num1;
+ mothurConvert(newLabel1, num1);
+
+ simple = toString(num1);
+
+ return simple;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "isLabelEquivalent");
+ exit(1);
+ }
+}
+/***********************************************************************/
+
+bool MothurOut::isLabelEquivalent(string label1, string label2){
+ try {
+ bool same = false;
+
+ //remove OTU or phylo tag
+ string newLabel1 = "";
+ for (int i = 0; i < label1.length(); i++) {
+ if(label1[i]>47 && label1[i]<58) { //is a digit
+ newLabel1 += label1[i];
+ }
+ }
+
+ string newLabel2 = "";
+ for (int i = 0; i < label2.length(); i++) {
+ if(label2[i]>47 && label2[i]<58) { //is a digit
+ newLabel2 += label2[i];
+ }
+ }
+
+ int num1, num2;
+ mothurConvert(newLabel1, num1);
+ mothurConvert(newLabel2, num2);
+
+ if (num1 == num2) { same = true; }
+
+ return same;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "isLabelEquivalent");
+ exit(1);
+ }
+}
//**********************************************************************************************************************
bool MothurOut::isSubset(vector<string> bigset, vector<string> subset) {
try {
bool isTrue(string);
bool isContainingOnlyDigits(string);
bool isNumeric1(string);
+ bool isLabelEquivalent(string, string);
+ string getSimpleLabel(string);
string findEdianness();
else if (countfile == "not open") { abort = true; countfile = ""; }
else {
m->setCountTableFile(countfile);
- ct.readTable(countfile, true);
+ ct.readTable(countfile, true, false);
if (!ct.hasGroupInfo()) {
abort = true;
m->mothurOut("[ERROR]: The parse.list command requires group info to be present in your countfile, quitting."); m->mothurOutEndLine();
//check for groups that have been eliminated
CountTable ct;
if (ct.testGroups(goodCountFile)) {
- ct.readTable(goodCountFile, true);
+ ct.readTable(goodCountFile, true, false);
ct.printTable(goodCountFile);
}
else if (countfile == "not open") { abort = true; countfile = ""; }
else {
m->setCountTableFile(countfile);
- ct.readTable(countfile, true);
+ ct.readTable(countfile, true, false);
if (ct.hasGroupInfo()) { bygroup = true; }
else { bygroup = false; }
}
map<string, int> nameMap;
CountTable ct;
- ct.readTable(countfile, false);
+ ct.readTable(countfile, false, false);
vector<string> namesOfSeqs = ct.getNamesOfSeqs();
numSeqs = ct.getNumUniqueSeqs();
m->mothurOut("\n[NOTE]: The count file should contain only unique names, so mothur assumes your fasta, list and taxonomy files also contain only uniques.\n\n");
}
CountTable ct;
- ct.readTable(countfile, true);
+ ct.readTable(countfile, true, false);
if (!ct.hasGroupInfo()) { m->mothurOut("[ERROR]: your count file does not contain group info, aborting.\n"); return 0; }
vector<string> gNamesOfGroups = ct.getNamesOfGroups();
//check for groups that have been eliminated
CountTable ct;
if (ct.testGroups(outputFileName)) {
- ct.readTable(outputFileName, true);
+ ct.readTable(outputFileName, true, false);
ct.printTable(outputFileName);
}
}
otuLabel += sbinNumber;
- if (names.count(otuLabel) == 0) {
+ if (names.count(m->getSimpleLabel(otuLabel)) == 0) {
newList.push_back(list->get(i));
}else { removedCount++; }
}
if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) { delete newLookup[j]; } for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; } return 0; }
//is this otu on the list
- if (names.count(m->currentBinLabels[i]) == 0) {
+ if (names.count(m->getSimpleLabel(m->currentBinLabels[i])) == 0) {
wroteSomething = true;
newLabels.push_back(m->currentBinLabels[i]);
for (int j = 0; j < newLookup.size(); j++) { //add this OTU to the new lookup
//wroteSomething = true;
//out << name << '\t' << tax << endl;
}else{ //this sequence contains the taxon the user wants to remove
- names.insert(otuLabel);
+ names.insert(m->getSimpleLabel(otuLabel));
remove=true; break;
}
//wroteSomething = true;
//out << name << '\t' << tax << endl;
}else{ //this sequence contains the taxon the user wants to remove
- names.insert(otuLabel);
+ names.insert(m->getSimpleLabel(otuLabel));
remove=true; break;
}
}else { //both have confidences so we want to make sure the users confidences are greater then or equal to the taxons
//passed the test so remove you
if (remove) {
- names.insert(otuLabel);
+ names.insert(m->getSimpleLabel(otuLabel));
remove=true; break;
}else {
//wroteSomething = true;
//get labels you want to keep
labels = m->readAccnos(accnosfile);
+ //simplfy labels
+ set<string> newLabels;
+ for (set<string>::iterator it = labels.begin(); it != labels.end(); it++) { newLabels.insert(m->getSimpleLabel(*it)); }
+ labels = newLabels;
if (m->debug) { m->mothurOut("[DEBUG]: numlabels = " + toString(labels.size()) + "\n"); }
if (m->debug) { m->mothurOut("[DEBUG]: " + otu + toString(size) + tax + "\n"); }
- if (labels.count(otu) == 0) {
+ if (labels.count(m->getSimpleLabel(otu)) == 0) {
wroteSomething = true;
out << otu << '\t' << size << '\t' << tax << endl;
}else { removedCount++; }
in >> otu1 >> otu2;
string line = m->getline(in); m->gobble(in);
- if ((labels.count(otu1) == 0) && (labels.count(otu2) == 0)){
+ if ((labels.count(m->getSimpleLabel(otu1)) == 0) && (labels.count(m->getSimpleLabel(otu2)) == 0)){
wroteSomething = true;
out << otu1 << '\t' << otu2 << '\t' << line << endl;
in >> otu;
string line = m->getline(in); m->gobble(in);
- if (labels.count(otu) == 0) {
+ if (labels.count(m->getSimpleLabel(otu)) == 0) {
wroteSomething = true;
out << otu << '\t' << line << endl;
if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) { delete newLookup[j]; } for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; } return 0; }
//is this otu on the list
- if (labels.count(m->currentBinLabels[i]) == 0) {
+ if (labels.count(m->getSimpleLabel(m->currentBinLabels[i])) == 0) {
wroteSomething = true;
newLabels.push_back(m->currentBinLabels[i]);
for (int j = 0; j < newLookup.size(); j++) { //add this OTU to the new lookup
}
otuLabel += sbinNumber;
- if (labels.count(otuLabel) == 0) {
+ if (labels.count(m->getSimpleLabel(otuLabel)) == 0) {
newList.push_back(list->get(i));
}else { removedCount++; }
}
util.setGroups(Groups, namesGroups);
m->openOutputFile(outputGroupFileName, outGroup);
}else if (countfile != "") {
- ct.readTable(countfile, true);
+ ct.readTable(countfile, true, false);
if (ct.hasGroupInfo()) {
vector<string> namesGroups = ct.getNamesOfGroups();
SharedUtil util;
//check for groups that have been eliminated
CountTable ct;
if (ct.testGroups(outputFileName)) {
- ct.readTable(outputFileName, true);
+ ct.readTable(outputFileName, true, false);
ct.printTable(outputFileName);
}
vector<string> ScreenSeqsCommand::setParameters(){
try {
CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","fasta",false,true,true); parameters.push_back(pfasta);
- CommandParameter pcontigsreport("contigsreport", "InputTypes", "", "", "report", "none", "none","contigsreport",false,true,true); parameters.push_back(pcontigsreport);
+ CommandParameter pcontigsreport("contigsreport", "InputTypes", "", "", "report", "none", "none","contigsreport",false,false,true); parameters.push_back(pcontigsreport);
CommandParameter palignreport("alignreport", "InputTypes", "", "", "report", "none", "none","alignreport",false,false); parameters.push_back(palignreport);
CommandParameter psummary("summary", "InputTypes", "", "", "report", "none", "none","summary",false,false); parameters.push_back(psummary);
CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none","name",false,false,true); parameters.push_back(pname);
if (namefile != "") { nameMap = m->readNames(namefile); }
else if (countfile != "") {
CountTable ct;
- ct.readTable(countfile, true);
+ ct.readTable(countfile, true, false);
nameMap = ct.getNameMap();
}
getSummary(positions);
if (namefile != "") { nameMap = m->readNames(namefile); }
else if (countfile != "") {
CountTable ct;
- ct.readTable(countfile, true);
+ ct.readTable(countfile, true, false);
nameMap = ct.getNameMap();
}
getSummaryReport();
if (namefile != "") { nameMap = m->readNames(namefile); }
else if (countfile != "") {
CountTable ct;
- ct.readTable(countfile, true);
+ ct.readTable(countfile, true, false);
nameMap = ct.getNameMap();
}
getSummary(positions);
//check for groups that have been eliminated
CountTable ct;
if (ct.testGroups(goodCountFile)) {
- ct.readTable(goodCountFile, true);
+ ct.readTable(goodCountFile, true, false);
ct.printTable(goodCountFile);
}
if (namefile != "") { nameMap = m->readNames(namefile); }
else if (countfile != "") {
CountTable ct;
- ct.readTable(countfile, false);
+ ct.readTable(countfile, false, false);
nameMap = ct.getNameMap();
}
if(namesFileName != "") { weights = getWeights(); }
else if (countfile != "") {
CountTable ct;
- ct.readTable(countfile, false);
+ ct.readTable(countfile, false, false);
weights = ct.getNameMap();
}
if (namefile != "") { nameMap = m->readNames(namefile); }
else if (countfile != "") {
CountTable ct;
- ct.readTable(countfile, false);
+ ct.readTable(countfile, false, false);
nameMap = ct.getNameMap();
}
//read count file
CountTable countTable;
- countTable.readTable(countfile, true);
+ countTable.readTable(countfile, true, false);
//initialize maps
namesOfGroups = countTable.getNamesOfGroups();
m->setAllGroups(allGroups);
}else{
countTable = new CountTable();
- countTable->readTable(countfile, true);
+ countTable->readTable(countfile, true, false);
}
if (m->control_pressed) { return 0; }
groupmap->readMap();
}else {
countTable = new CountTable();
- countTable->readTable(m->getCountTableFile(), true);
+ countTable->readTable(m->getCountTableFile(), true, false);
}
int hold;
RAbundVector* rabund = new RAbundVector(list->getRAbundVector());
- Cluster* cluster = new CompleteLinkage(rabund, list, matrix, cutoff, "furthest");
+ float adjust = -1.0;
+ Cluster* cluster = new CompleteLinkage(rabund, list, matrix, cutoff, "furthest", adjust);
string tag = cluster->getTag();
double clusterCutoff = cutoff;
else if (countfile == "not found") { countfile = ""; }
else {
m->setCountTableFile(countfile);
- ct.readTable(countfile, true);
+ ct.readTable(countfile, true, false);
}
if ((namefile != "") && (countfile != "")) {
try {
CountTable ct;
- ct.readTable(countfile, true);
+ ct.readTable(countfile, true, false);
if (!ct.hasGroupInfo()) { m->mothurOut("[ERROR]: your count file does not contain group info, cannot split by group.\n"); m->control_pressed = true; }
if (m->control_pressed) { return 0; }
else if (countfile == "not found") { countfile = ""; }
else {
m->setCountTableFile(countfile);
- ct.readTable(countfile, true);
+ ct.readTable(countfile, true, false);
}
if ((namefile != "") && (countfile != "")) {
if (namefile != "") { nameMap = m->readNames(namefile); }
else if (countfile != "") {
CountTable ct;
- ct.readTable(countfile, false);
+ ct.readTable(countfile, false, false);
nameMap = ct.getNameMap();
}
groupMap->readMap();
}else if (countfile != "") {
ct = new CountTable();
- ct->readTable(countfile, true);
+ ct->readTable(countfile, true, false);
}
PhyloSummary* taxaSum;
readMatrix->read(nameMap);
}else if (countfile != "") {
ct = new CountTable();
- ct->readTable(countfile, true);
+ ct->readTable(countfile, true, false);
readMatrix->read(ct);
}else {
readMatrix->read(nameMap);
try {
m = MothurOut::getInstance();
ct = new CountTable();
- ct->readTable(cf, true);
+ ct->readTable(cf, true, false);
//if no groupinfo in count file we need to add it
if (!ct->hasGroupInfo()) {
if (countfile != "") {
CountTable ct;
- ct.readTable(countfile, true);
+ ct.readTable(countfile, true, false);
nameCount = ct.getNameMap();
outputNames.push_back(trimCountFile);
outputNames.push_back(scrapCountFile);
if (countfile != "") { //create countfile with group info included
CountTable* ct = new CountTable();
- ct->readTable(trimCountFile, true);
+ ct->readTable(trimCountFile, true, false);
map<string, int> justTrimmedNames = ct->getNameMap();
delete ct;