+//***************************************************************************************************************
+//this is a vertical soft filter
+string Chimera::createFilter(vector<Sequence*> seqs, float t) {
+ try {
+ filterString = "";
+ int threshold = int (t * seqs.size());
+//cout << "threshhold = " << threshold << endl;
+
+ vector<int> gaps; gaps.resize(seqs[0]->getAligned().length(), 0);
+ vector<int> a; a.resize(seqs[0]->getAligned().length(), 0);
+ vector<int> t; t.resize(seqs[0]->getAligned().length(), 0);
+ vector<int> g; g.resize(seqs[0]->getAligned().length(), 0);
+ vector<int> c; c.resize(seqs[0]->getAligned().length(), 0);
+
+ filterString = (string(seqs[0]->getAligned().length(), '1'));
+
+ //for each sequence
+ for (int i = 0; i < seqs.size(); i++) {
+
+ if (m->control_pressed) { return filterString; }
+
+ string seqAligned = seqs[i]->getAligned();
+
+ for (int j = 0; j < seqAligned.length(); j++) {
+ //if this spot is a gap
+ if ((seqAligned[j] == '-') || (seqAligned[j] == '.')) { gaps[j]++; }
+ else if (toupper(seqAligned[j]) == 'A') { a[j]++; }
+ else if (toupper(seqAligned[j]) == 'T') { t[j]++; }
+ else if (toupper(seqAligned[j]) == 'G') { g[j]++; }
+ else if (toupper(seqAligned[j]) == 'C') { c[j]++; }
+ }
+ }
+
+ //zero out spot where all sequences have blanks
+ int numColRemoved = 0;
+ for(int i = 0;i < seqs[0]->getAligned().length(); i++){
+
+ if (m->control_pressed) { return filterString; }
+
+ if(gaps[i] == seqs.size()) { filterString[i] = '0'; numColRemoved++; }
+
+ else if (((a[i] < threshold) && (t[i] < threshold) && (g[i] < threshold) && (c[i] < threshold))) { filterString[i] = '0'; numColRemoved++; }
+ //cout << "a = " << a[i] << " t = " << t[i] << " g = " << g[i] << " c = " << c[i] << endl;
+ }
+
+ if (threshold != 0.0) { m->mothurOut("Filter removed " + toString(numColRemoved) + " columns."); m->mothurOutEndLine(); }
+
+ return filterString;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "Chimera", "createFilter");
+ exit(1);
+ }
+}
+//***************************************************************************************************************
+map<int, int> Chimera::runFilter(Sequence* seq) {
+ try {
+ map<int, int> maskMap;
+ string seqAligned = seq->getAligned();
+ string newAligned = "";
+ int count = 0;
+
+ for (int j = 0; j < seqAligned.length(); j++) {
+ //if this spot is a gap
+ if (filterString[j] == '1') {
+ newAligned += seqAligned[j];
+ maskMap[count] = j;
+ count++;
+ }
+ }
+
+ seq->setAligned(newAligned);
+
+ return maskMap;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "Chimera", "runFilter");
+ exit(1);
+ }
+}