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

ReadListAlgo Class Reference

#include <readlistalgo.h>

Inheritance diagram for ReadListAlgo:

Inheritance graph
[legend]
Collaboration diagram for ReadListAlgo:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ReadListAlgo (TrapperDoc *pDoc_, std::set< db_recno_t > &recnoList, AlgoParam *param)
void start ()

Detailed Description

Definition at line 7 of file readlistalgo.h.


Constructor & Destructor Documentation

ReadListAlgo::ReadListAlgo TrapperDoc pDoc_,
std::set< db_recno_t > &  recnoList,
AlgoParam param
[inline]
 

Definition at line 10 of file readlistalgo.h.

00010                                                                                       : 
00011     RAlgo(pDoc_, recnoList, param) {}


Member Function Documentation

void ReadListAlgo::start  )  [virtual]
 

Implements RAlgo.

Definition at line 9 of file readlistalgo.cc.

References MAl_Readonly::get_num_seq(), RAlgo::getMAl(), and MAl_Readonly::select_read().

00010 {
00011   
00012   //Get readlist filename
00013   
00014   if ( getMAl()->get_num_seq() == 0 ) {
00015     cerr<<"Nothing to be done here! "<<endl;
00016     return;
00017   }
00018   
00019   
00020   
00021   QString currdir = QDir::currentDirPath();
00022   
00023   QString filename = QFileDialog::getOpenFileName(
00024                                            currdir,
00025                                            0,
00026                                            0,
00027                                            "open listfile file dialog",
00028                                            "Choose a read list file to open" );
00029 
00030   if ( filename.isEmpty() ) return;
00031 
00032   //Parse list
00033 
00034   QFile f( filename );
00035   
00036   if ( !f.open(IO_ReadOnly) ) {
00037     cerr<<"ReadListAlgo::start(): Could not open file "<<filename<<", exiting!"<<endl;
00038     return;
00039   }
00040   
00041   QTextStream t( &f );        // use a text stream
00042   QString s;
00043 
00044   set<QString> readlist;
00045 
00046   while ( !t.atEnd() ) {
00047     s = t.readLine();       // line of text excluding '\n'
00048     s = s.simplifyWhiteSpace();
00049 
00050     readlist.insert(s);
00051   }
00052 
00053   //NB, names in list can be truncated and thus match several reads
00054   //Quick'n'dirty: add names of selected reads to a easily searchable structure
00055   
00056   map<QString, size_t> selected_readnames;
00057   
00058   for( size_t i = 0; i < getMAl()->get_num_seq(); i++ ) {
00059     selected_readnames.insert(make_pair(getMAl()->get_name(i), i));
00060     getMAl()->select_read(i, false);    
00061   }
00062   
00063   //Select reads from list
00064   for( set<QString>::iterator it = readlist.begin(); it != readlist.end(); ++it ) {
00065     for( map<QString, size_t>::iterator it2 = selected_readnames.lower_bound(*it);
00066          it2 != selected_readnames.upper_bound(*it + '~'); ++it2 ) {
00067       getMAl()->select_read((*it2).second, true);
00068     }
00069   }
00070 
00071 }


The documentation for this class was generated from the following files:
Generated on Fri Mar 17 17:45:00 2006 for trapper by  doxygen 1.4.4