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

TrapperParser Class Reference

#include <trapperparser.h>

Collaboration diagram for TrapperParser:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TrapperParser (DbEnv *dbenv, QString projectDir)
bool startElement (const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &attributes)
bool endElement (const QString &namespaceURI, const QString &localName, const QString &qName)

Private Member Functions

QStringList contigNamesInProjectDir ()

Private Attributes

DbEnv * env
QString projDir
TrapperDoccurrent_doc
db_recno_t current_read_recno
bool format_ok

Detailed Description

Definition at line 11 of file trapperparser.h.


Constructor & Destructor Documentation

TrapperParser::TrapperParser DbEnv *  dbenv,
QString  projectDir
[inline]
 

Definition at line 15 of file trapperparser.h.

00015                                                   : 
00016     env(dbenv), projDir(projectDir), current_doc(0), format_ok(false) {}


Member Function Documentation

QStringList TrapperParser::contigNamesInProjectDir  )  [private]
 

Definition at line 89 of file trapperparser.cpp.

References projDir.

Referenced by startElement().

00090 {
00091     QString contigName;
00092     QDir d( projDir );
00093     Q_ASSERT( d.exists() );
00094     d.setFilter( QDir::Dirs | QDir::NoSymLinks );
00095     d.setSorting( QDir::Name );
00096     QStringList slist = d.entryList();
00097     return slist;
00098 }

bool TrapperParser::endElement const QString &  namespaceURI,
const QString &  localName,
const QString &  qName
 

Definition at line 76 of file trapperparser.cpp.

References current_doc.

00078 {
00079   if ( qName == "contig" ) {
00080     //Delete old doc, if any
00081     delete current_doc;
00082 //     cerr<<"end contig"<<endl;
00083   }
00084   return true;
00085 }

bool TrapperParser::startElement const QString &  namespaceURI,
const QString &  localName,
const QString &  qName,
const QXmlAttributes &  attributes
 

Definition at line 9 of file trapperparser.cpp.

References contigNamesInProjectDir(), Database::Creator< T >::create(), current_doc, current_read_recno, Database::Creator< T >::data(), env, format_ok, TrapperView::message(), TrapperDoc::openDocument(), projDir, GeneralData::readAttributes(), FeatureData::setReadRecno(), and TrapperView::TrapperDoc.

00013 {
00014   //Three cases:
00015   if ( qName == "TRAPPER" ) {
00016     format_ok = true;
00017     return true;
00018   }
00019   else if ( qName == "contig" && format_ok ) {
00020 //     cerr<<"new contig"<<endl;
00021     /* Basically, all the functionality of TrapperApp::slotImport()
00022        has moved here. The other two cases below now contains the
00023        old functionality of TrapperDoc::import(). */
00024 
00025 
00026     //Use attributes to get name
00027     QString contigName = attributes.value("name");
00028 
00029 
00030     //Some bookkeeping to check if contig is already present
00031     QStringList contigNamesAlreadyPresent = contigNamesInProjectDir();
00032     if ( contigNamesAlreadyPresent.contains( contigName ) ) {
00033       QString message;
00034       message = QString("The contig name \"%1\" was specified in the import file, but that contig is already present in the project dir. Skipping this one").arg(contigName);
00035       QMessageBox::warning(0,"",message);
00036       return false;
00037     }
00038     //Create directory for contig
00039     QString fName = projDir + "/" + contigName;
00040                 
00041 
00042     //Create directories and databases for this contig
00043 
00044     current_doc = new TrapperDoc(env);
00045     current_doc->openDocument(fName);
00046 
00047     return true;
00048   }
00049   else if ( format_ok ) {
00050 //     cerr<<"parsing "<<qName<<endl;
00051     //Get data name from attributes and put into QString generalDataName
00052 
00053     //Create object factory for this data type
00054     
00055     Database::Creator<GeneralData> creator( current_doc, qName.ascii() );
00056 
00057     creator.data()->readAttributes( attributes );
00058     
00059     if ( qName != "ReadData" ) {//All other cases are FeatureData and need the corresponding read recno
00060       
00061       FeatureData* fdata = dynamic_cast<FeatureData*>(creator.data());
00062       assert( fdata );
00063       fdata->setReadRecno( current_read_recno );
00064       
00065     }
00066     db_recno_t new_recno = creator.create( false );//Should give dna, quality etc same recno as read (as previously)
00067     if ( qName == "ReadData" ) {
00068 
00069       current_read_recno = new_recno;
00070     }
00071     return true;
00072   }
00073   return false;
00074 }


Member Data Documentation

TrapperDoc* TrapperParser::current_doc [private]
 

Definition at line 34 of file trapperparser.h.

Referenced by endElement(), and startElement().

db_recno_t TrapperParser::current_read_recno [private]
 

Definition at line 35 of file trapperparser.h.

Referenced by startElement().

DbEnv* TrapperParser::env [private]
 

Definition at line 31 of file trapperparser.h.

Referenced by startElement().

bool TrapperParser::format_ok [private]
 

Definition at line 36 of file trapperparser.h.

Referenced by startElement().

QString TrapperParser::projDir [private]
 

Definition at line 32 of file trapperparser.h.

Referenced by contigNamesInProjectDir(), and startElement().


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