]> git.donarmstrong.com Git - mothur.git/blobdiff - filterseqscommand.cpp
added boneh, efron, and solow calculators
[mothur.git] / filterseqscommand.cpp
index f92253d4b39d8cd444d60018843b70a27187e676..f4cc6d82fbe5d97779d4d80dbba9ee9a483940ab 100644 (file)
@@ -3,13 +3,11 @@
  *  Mothur
  *
  *  Created by Thomas Ryabin on 5/4/09.
- *  Copyright 2009 __MyCompanyName__. All rights reserved.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
  *
  */
 
 #include "filterseqscommand.h"
-#include <iostream>
-#include <fstream>
 
 /**************************************************************************************/
 void FilterSeqsCommand::doTrump() {
@@ -99,8 +97,24 @@ void FilterSeqsCommand::doFilter() {
 int FilterSeqsCommand::execute() {     
        try {
                globaldata = GlobalData::getInstance();
-               db = globaldata->gSequenceDB;
+               filename = globaldata->inputFileName;
                
+               if(globaldata->getFastaFile() != "") {
+                       readSeqs =  new ReadFasta(filename); }
+               else if(globaldata->getNexusFile() != "") {
+                       readSeqs = new ReadNexus(filename); }
+               else if(globaldata->getClustalFile() != "") {
+                       readSeqs = new ReadClustal(filename); }
+               else if(globaldata->getPhylipFile() != "") {
+                       readSeqs = new ReadPhylip(filename); }
+                       
+               readSeqs->read();
+               db = readSeqs->getDB();
+               
+               //for(int i = 0; i < db->size(); i++) {
+//                     cout << db->get(i).getLength() << "\n" << db->get(i).getName() << ": " << db->get(i).getAligned() << "\n\n";
+//             }
+
                for(int i = 0; i < db->get(0).getLength(); i++) 
                        columnsToRemove.push_back(false);
                
@@ -109,7 +123,6 @@ int FilterSeqsCommand::execute() {
                        doTrump();
                else if(globaldata->getSoft().compare("") != 0)
                        doSoft();
-                       
                else if(globaldata->getFilter().compare("") != 0) 
                        doFilter();
                
@@ -121,6 +134,8 @@ int FilterSeqsCommand::execute() {
 //                     else
 //                             cout << "false\n";
 //             }
+
+
                //Creating the new SequenceDB 
                SequenceDB newDB;
                for(int i = 0; i < db->size(); i++) {
@@ -136,11 +151,16 @@ int FilterSeqsCommand::execute() {
                        newDB.add(newSeq);
                }
                
+               string newFileName = getRootName(filename) + "filter.fa";
                ofstream outfile;
-               outfile.open("filtertest.txt");
+               outfile.open(newFileName.c_str());
                newDB.print(outfile);
                outfile.close();
                        
+               globaldata->clear();
+               //delete db;
+               //delete newDB;
+               
                return 0;
        }
        catch(exception& e) {
@@ -151,5 +171,4 @@ int FilterSeqsCommand::execute() {
                cout << "An unknown error has occurred in the FilterSeqsCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
                exit(1);
        }
-}
-/**************************************************************************************/
+}
\ No newline at end of file