Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

readnamesalgo.cc

Go to the documentation of this file.
00001 #include "readnamesalgo.h"
00002 #include <fstream>
00003 #include "viewparam.h"
00004 #include <cassert>
00005 #include <qstring.h>
00006 #include <qfiledialog.h>
00007 #include <qdir.h>
00008 #include <qfile.h>
00009 #include <qmessagebox.h>
00010 #include "trapperview.h"
00011 
00012 using namespace std;
00013 
00014 void ReadnamesAlgo::start()
00015 {
00016   if ( getMAl()->get_num_seq() == 0 ) {
00017 //     cerr<<"Nothing to be done here! "<<endl;
00018     return;
00019   }
00020   
00021   ViewParam* param = dynamic_cast<ViewParam*>(my_param);
00022   assert(param);
00023   
00024   QString title = param->view()->getDocument()->title();
00025 
00026   QString currdir = QDir::currentDirPath();
00027   QString contig = title.section( '/', -2 );
00028   
00029   QString header = contig + ".selectedreads.txt";
00030   QString default_file_name = currdir + '/' + header;
00031   
00032 
00033   QString filename = QFileDialog::getSaveFileName( default_file_name,
00034                                             0,
00035                                             0,
00036                                            "save seqs file dialog"
00037                                            "Choose a filename to save sequences under" );
00038   
00039 
00040   if ( filename.isEmpty() ) return;
00041 
00042   if ( QFile::exists( filename ) &&
00043        QMessageBox::question(
00044                              0,
00045                              tr("Overwrite File? -- Trapper"),
00046                              tr("A file called %1 already exists."
00047                                 "Do you want to overwrite it?")
00048                              .arg( filename ),
00049                              tr("&Yes"), tr("&No"),
00050                              QString::null, 0, 1 ) ) {
00051     
00052     return;
00053   }
00054   
00055   
00056   
00057   ofstream outFile(filename);
00058   
00059 
00060   for( size_t i = 0; i < getMAl()->get_num_seq(); i++ ) {
00061     outFile<<getMAl()->get_name(i)<<'\n';
00062   }
00063 
00064   outFile.close();
00065   
00066   
00067 }

Generated on Fri Mar 17 17:44:24 2006 for trapper by  doxygen 1.4.4