//if user gave a namesfile then use it
if (namesfile != "") { readNamesFile(); }
- if (countfile != "") { ct.readTable(countfile); }
+ if (countfile != "") { ct.readTable(countfile, true); }
input = new InputData(listfile, "list");
list = input->getListVector();
if (hasCount) {
CountTable* ct = new CountTable();
- ct->readTable(nameFile);
+ ct->readTable(nameFile, true);
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);
+ CountTable c; c.readTable(nameFile, true);
if (!m->isBlank(newCountFile)) {
ifstream in2;
m->openInputFile(newCountFile, in2);
numChimeras = deconvoluteResults(uniqueNames, outputFileName, accnosFileName);
}else {
set<string> doNotRemove;
- CountTable c; c.readTable(newCountFile);
+ CountTable c; c.readTable(newCountFile, 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); }
+ if (hasCount && dups) { newCount.readTable(name, true); }
//sanity check
if (groups.size() < processors) { processors = groups.size(); }
SequenceCountParser* cparser;
if (pDataArray->hasCount) {
CountTable* ct = new CountTable();
- ct->readTable(pDataArray->namefile);
+ ct->readTable(pDataArray->namefile, true);
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]);
+ CountTable c; c.readTable(nameFileNames[s], true);
if (!m->isBlank(newCountFile)) {
ifstream in2;
m->openInputFile(newCountFile, in2);
}else {
if (hasCount) {
set<string> doNotRemove;
- CountTable c; c.readTable(newCountFile);
+ CountTable c; c.readTable(newCountFile, 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); }
+ if (hasCount && dups) { newCount.readTable(countFile, true); }
int groupsPerProcessor = fileToPriority.size() / processors;
int remainder = fileToPriority.size() % processors;
int error;
if (hasCount) {
CountTable ct;
- ct.readTable(nameFile);
+ ct.readTable(nameFile, true);
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);
+ ct.readTable(nameFile, true);
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);
+ CountTable c; c.readTable(nameFile, true);
if (!m->isBlank(newCountFile)) {
ifstream in2;
m->openInputFile(newCountFile, in2);
if (hasCount) {
set<string> doNotRemove;
- CountTable c; c.readTable(newCountFile);
+ CountTable c; c.readTable(newCountFile, 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); }
+ if (hasCount && dups) { newCount.readTable(nameFile, true); }
//sanity check
if (groups.size() < processors) { processors = groups.size(); }
SequenceCountParser* cparser;
if (pDataArray->hasCount) {
CountTable* ct = new CountTable();
- ct->readTable(pDataArray->namefile);
+ ct->readTable(pDataArray->namefile, true);
cparser = new SequenceCountParser(pDataArray->fastafile, *ct);
delete ct;
}else {
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); if (ct->hasGroupInfo()) { groups = ct->getNamesOfGroups(); } }
+ if (countfile != "") { ct = new CountTable(); ct->readTable(countfile, true); 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]);
+ ct->readTable(countfileNames[s], true);
taxaSum = new PhyloSummary(taxonomyFileName, ct);
taxaSum->summarize(tempTaxonomyFile);
}else {
read->read(nameMap);
}else if (countfile != "") {
ct = new CountTable();
- ct->readTable(countfile);
+ ct->readTable(countfile, false);
read->read(ct);
}else { read->read(nameMap); }
delete nameMap;
}else if (countfile != "") {
ct = new CountTable();
- ct->readTable(countfile);
+ ct->readTable(countfile, 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); m->setCountTableFile(countfile); }
+ else { ct.readTable(countfile, 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);
+ ct->readTable(thisNamefile, false);
cluster->readPhylipFile(thisDistFile, ct);
}
tag = cluster->getTag();
read->read(nameMap);
}else if (countfile != "") {
ct = new CountTable();
- ct->readTable(thisNamefile);
+ ct->readTable(thisNamefile, false);
read->read(ct);
}else { read->read(nameMap); }
if (m->control_pressed) { return 0; }
if (namefile != "") { readNames(); }
- if (countfile != "") { ct.readTable(countfile); }
+ if (countfile != "") { ct.readTable(countfile, true); }
if (m->control_pressed) { return 0; }
m->openOutputFile(outputFileName, out);
CountTable ct;
- ct.readTable(countfile);
+ ct.readTable(countfile, true);
//make sure groups are valid
//takes care of user setting groupNames that are invalid or setting groups=all
try {
CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none","count",false,true,true); parameters.push_back(pname);
CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none","",false,false,true); parameters.push_back(pgroup);
+ CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
CommandParameter plarge("large", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(plarge);
CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
helpString += "The groups parameter allows you to indicate which groups you want to include in the counts, by default all groups in your groupfile are used.\n";
helpString += "The large parameter indicates the name and group files are too large to fit in RAM.\n";
helpString += "When you use the groups parameter and a sequence does not represent any sequences from the groups you specify it is not included in the .count.summary file.\n";
+ helpString += "The processors parameter allows you to specify the number of processors to use. The default is 1.\n";
helpString += "The count.seqs command should be in the following format: count.seqs(name=yourNameFile).\n";
helpString += "Example count.seqs(name=amazon.names) or make.table(name=amazon.names).\n";
helpString += "Note: No spaces between parameter labels (i.e. name), '=' and parameters (i.e.yourNameFile).\n";
string namefile, groupfile, outputDir, groups;
bool abort, large;
vector<string> Groups, outputNames;
+ int processors;
int processSmall(string);
int processLarge(string);
}
}
/************************************************************/
-int CountTable::readTable(string file) {
+int CountTable::readTable(string file, bool readGroups) {
try {
filename = file;
ifstream in;
indexNameMap.clear();
counts.clear();
map<int, string> originalGroupIndexes;
- if (columnHeaders.size() > 2) { hasGroups = true; numGroups = columnHeaders.size() - 2; }
+ if ((columnHeaders.size() > 2) && readGroups) { hasGroups = true; numGroups = columnHeaders.size() - 2; }
for (int i = 2; i < columnHeaders.size(); i++) { groups.push_back(columnHeaders[i]); originalGroupIndexes[i-2] = columnHeaders[i]; totalGroups.push_back(0); }
//sort groups to keep consistent with how we store the groups in groupmap
sort(groups.begin(), groups.end());
//if group info, then read it
vector<int> groupCounts; groupCounts.resize(numGroups, 0);
- for (int i = 0; i < numGroups; i++) { int thisIndex = indexGroupMap[originalGroupIndexes[i]]; in >> groupCounts[thisIndex]; m->gobble(in); totalGroups[thisIndex] += groupCounts[thisIndex]; }
+ if (columnHeaders.size() > 2) { //file contains groups
+ if (readGroups) { //user wants to save them
+ for (int i = 0; i < numGroups; i++) { int thisIndex = indexGroupMap[originalGroupIndexes[i]]; in >> groupCounts[thisIndex]; m->gobble(in); totalGroups[thisIndex] += groupCounts[thisIndex]; }
+ }else { //read and discard
+ m->getline(in); m->gobble(in);
+ }
+ }
map<string, int>::iterator it = indexNameMap.find(name);
if (it == indexNameMap.end()) {
//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);
+ int readTable(string, bool);
int printTable(string);
int printHeaders(ofstream&);
}
CountTable ct;
if (countfile != "") {
- ct.readTable(countfile);
+ ct.readTable(countfile, 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);
+ ct.readTable(countfile, true);
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);
+ ct.readTable(outputFileName, true);
ct.printTable(outputFileName);
}
else if (countfile == "not open") { abort = true; countfile = ""; }
else {
m->setCountTableFile(countfile);
- ct.readTable(countfile);
+ ct.readTable(countfile, true);
if (ct.hasGroupInfo()) { hasGroups = true; }
}
CountTable thisCt;
if (countfile != "") {
- thisCt.readTable(countfile);
+ thisCt.readTable(countfile, true);
if (tempGroup != "noGroup") { out2 << "Representative_Sequence\ttotal\t" << tempGroup << endl; }
}
CountTable thisCt;
if (countfile != "") {
- thisCt.readTable(countfile);
+ thisCt.readTable(countfile, true);
if (tempGroup != "noGroup") { out2 << "Representative_Sequence\ttotal\t" << tempGroup << endl; }
}
int GetRAbundCommand::processList(ofstream& out){
try {
CountTable ct;
- ct.readTable(countfile);
+ ct.readTable(countfile, false);
InputData input(inputfile, format);
ListVector* list = input.getListVector();
int GetSAbundCommand::processList(ofstream& out){
try {
CountTable ct;
- ct.readTable(countfile);
+ ct.readTable(countfile, 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);
+ ct.readTable(outputFileName, true);
ct.printTable(outputFileName);
}
}
}else if (countfile != "") {
nameMap = NULL;
- ct.readTable(countfile);
+ ct.readTable(countfile, true);
names = ct.getNamesOfSeqs();
}
int ListSeqsCommand::readCount(){
try {
CountTable ct;
- ct.readTable(countfile);
+ ct.readTable(countfile, false);
if (m->control_pressed) { return 0; }
if(countfile != "") {
//map<string, int> nameMapCounts = m->readNames(namefile);
ct = new CountTable();
- ct->readTable(countfile);
+ ct->readTable(countfile, false);
rabund = new RAbundVector();
createRabund(ct, list, rabund);
}else {
else if (countfile == "not open") { abort = true; countfile = ""; }
else {
m->setCountTableFile(countfile);
- ct.readTable(countfile);
+ ct.readTable(countfile, true);
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);
+ ct.readTable(goodCountFile, true);
ct.printTable(goodCountFile);
}
else if (countfile == "not open") { abort = true; countfile = ""; }
else {
m->setCountTableFile(countfile);
- ct.readTable(countfile);
+ ct.readTable(countfile, true);
if (ct.hasGroupInfo()) { bygroup = true; }
else { bygroup = false; }
}
map<string, int> nameMap;
CountTable ct;
- ct.readTable(countfile);
+ ct.readTable(countfile, 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);
+ ct.readTable(countfile, true);
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);
+ ct.readTable(outputFileName, true);
ct.printTable(outputFileName);
}
util.setGroups(Groups, namesGroups);
m->openOutputFile(outputGroupFileName, outGroup);
}else if (countfile != "") {
- ct.readTable(countfile);
+ ct.readTable(countfile, true);
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);
+ ct.readTable(outputFileName, true);
ct.printTable(outputFileName);
}
if (namefile != "") { nameMap = m->readNames(namefile); }
else if (countfile != "") {
CountTable ct;
- ct.readTable(countfile);
+ ct.readTable(countfile, true);
nameMap = ct.getNameMap();
}
getSummary(positions);
if (namefile != "") { nameMap = m->readNames(namefile); }
else if (countfile != "") {
CountTable ct;
- ct.readTable(countfile);
+ ct.readTable(countfile, true);
nameMap = ct.getNameMap();
}
getSummaryReport();
if (namefile != "") { nameMap = m->readNames(namefile); }
else if (countfile != "") {
CountTable ct;
- ct.readTable(countfile);
+ ct.readTable(countfile, true);
nameMap = ct.getNameMap();
}
getSummary(positions);
//check for groups that have been eliminated
CountTable ct;
if (ct.testGroups(goodCountFile)) {
- ct.readTable(goodCountFile);
+ ct.readTable(goodCountFile, true);
ct.printTable(goodCountFile);
}
if (namefile != "") { nameMap = m->readNames(namefile); }
else if (countfile != "") {
CountTable ct;
- ct.readTable(countfile);
+ ct.readTable(countfile, false);
nameMap = ct.getNameMap();
}
if(namesFileName != "") { weights = getWeights(); }
else if (countfile != "") {
CountTable ct;
- ct.readTable(countfile);
+ ct.readTable(countfile, false);
weights = ct.getNameMap();
}
if (namefile != "") { nameMap = m->readNames(namefile); }
else if (countfile != "") {
CountTable ct;
- ct.readTable(countfile);
+ ct.readTable(countfile, false);
nameMap = ct.getNameMap();
}
//read count file
CountTable countTable;
- countTable.readTable(countfile);
+ countTable.readTable(countfile, true);
//initialize maps
namesOfGroups = countTable.getNamesOfGroups();
m->setAllGroups(allGroups);
}else{
countTable = new CountTable();
- countTable->readTable(countfile);
+ countTable->readTable(countfile, true);
}
if (m->control_pressed) { return 0; }
groupmap->readMap();
}else {
countTable = new CountTable();
- countTable->readTable(m->getCountTableFile());
+ countTable->readTable(m->getCountTableFile(), true);
}
int hold;
else if (countfile == "not found") { countfile = ""; }
else {
m->setCountTableFile(countfile);
- ct.readTable(countfile);
+ ct.readTable(countfile, true);
}
if ((namefile != "") && (countfile != "")) {
try {
CountTable ct;
- ct.readTable(countfile);
+ ct.readTable(countfile, true);
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);
+ ct.readTable(countfile, true);
}
if ((namefile != "") && (countfile != "")) {
if (namefile != "") { nameMap = m->readNames(namefile); }
else if (countfile != "") {
CountTable ct;
- ct.readTable(countfile);
+ ct.readTable(countfile, false);
nameMap = ct.getNameMap();
}
groupMap->readMap();
}else if (countfile != "") {
ct = new CountTable();
- ct->readTable(countfile);
+ ct->readTable(countfile, true);
}
PhyloSummary* taxaSum;
readMatrix->read(nameMap);
}else if (countfile != "") {
ct = new CountTable();
- ct->readTable(countfile);
+ ct->readTable(countfile, true);
readMatrix->read(ct);
}else {
readMatrix->read(nameMap);
try {
m = MothurOut::getInstance();
ct = new CountTable();
- ct->readTable(cf);
+ ct->readTable(cf, true);
//if no groupinfo in count file we need to add it
if (!ct->hasGroupInfo()) {
if (countfile != "") {
CountTable ct;
- ct.readTable(countfile);
+ ct.readTable(countfile, true);
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);
+ ct->readTable(trimCountFile, true);
map<string, int> justTrimmedNames = ct->getNameMap();
delete ct;