#include <readnamesalgo.h>
Inheritance diagram for ReadnamesAlgo:
Public Member Functions | |
ReadnamesAlgo (TrapperDoc *pDoc_, std::set< db_recno_t > &recnoList, AlgoParam *param) | |
void | start () |
Definition at line 6 of file readnamesalgo.h.
|
Definition at line 9 of file readnamesalgo.h. 00009 : 00010 RWAlgo(pDoc_, recnoList, param) {}
|
|
Implements RWAlgo. Definition at line 14 of file readnamesalgo.cc. References MAl_Readonly::get_name(), MAl_Readonly::get_num_seq(), TrapperView::getDocument(), RWAlgo::getMAl(), Algo::my_param, TrapperDoc::title(), and ViewParam::view(). 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 }
|