X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=filterseqscommand.cpp;h=f4cc6d82fbe5d97779d4d80dbba9ee9a483940ab;hb=37a2c0b7dc68bfa53c8f38a713259929c4c46a9f;hp=f92253d4b39d8cd444d60018843b70a27187e676;hpb=a5a908953ab2ebb9386a895e5ddddf0135ad1f99;p=mothur.git diff --git a/filterseqscommand.cpp b/filterseqscommand.cpp index f92253d..f4cc6d8 100644 --- a/filterseqscommand.cpp +++ b/filterseqscommand.cpp @@ -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 -#include /**************************************************************************************/ 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