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

ChromatParser Class Reference

#include <chromatparser.h>

List of all members.

Public Member Functions

 ChromatParser ()
 ~ChromatParser ()
bool startElement (const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
bool endElement (const QString &namespaceURI, const QString &localName, const QString &qName)
void set_result_array (std::vector< TrapperVector< Q_UINT32 > > *array)

Private Attributes

bool inDATA
int curr_tag_num
std::vector< TrapperVector<
Q_UINT32 > > * 
chromats
QString FWO_


Detailed Description

Definition at line 9 of file chromatparser.h.


Constructor & Destructor Documentation

ChromatParser::ChromatParser  ) 
 

Definition at line 11 of file chromatparser.cc.

00011                              : inDATA(false), curr_tag_num(-1)
00012 {
00013   
00014 }

ChromatParser::~ChromatParser  ) 
 

Definition at line 16 of file chromatparser.cc.

00017 {
00018 
00019 }


Member Function Documentation

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

Definition at line 117 of file chromatparser.cc.

References inDATA.

00119 {
00120   if ( qName == "DATA") {
00121     inDATA = false;
00122   }
00123   
00124   return true;
00125 }

void ChromatParser::set_result_array std::vector< TrapperVector< Q_UINT32 > > *  array  ) 
 

Referenced by TrapperDoc::importChromat().

bool ChromatParser::startElement const QString &  namespaceURI,
const QString &  localName,
const QString &  qName,
const QXmlAttributes &  atts
 

Definition at line 21 of file chromatparser.cc.

References chromats, curr_tag_num, FWO_, and inDATA.

00023 {
00024   
00025   if ( qName == "DATA") {
00026     inDATA = true;
00027     curr_tag_num = atts.value("tag_number").toInt();
00028   }
00029   else if ( qName == "FWO_") {
00030     FWO_ = atts.value("string");
00031     //Swap vectors if necessary
00032     //We want C = 0, A = 1, G = 2, T = 3
00033     map<char, size_t> fwo_map;
00034     vector<char> fwo_vec(4);
00035 
00036     fwo_map['C'] = FWO_.find('C');
00037     fwo_vec[ fwo_map['C'] ] = 'C';
00038     fwo_map['A'] = FWO_.find('A');
00039     fwo_vec[ fwo_map['A'] ] = 'A';
00040     fwo_map['G'] = FWO_.find('G');
00041     fwo_vec[ fwo_map['G'] ] = 'G';
00042     fwo_map['T'] = FWO_.find('T');
00043     fwo_vec[ fwo_map['T'] ] = 'T';
00044     
00045     
00046     if ( fwo_map['C'] != 0 ) {
00047       (*chromats)[ 0 ].stlVector().swap( (*chromats)[ fwo_map['C'] ].stlVector() );
00048 
00049       fwo_map[ fwo_vec[ 0 ] ] = fwo_map['C'];
00050       fwo_vec[ fwo_map['C'] ] = fwo_vec[ 0 ];
00051 
00052       fwo_map['C'] = 0;
00053       fwo_vec[ 0 ] = 'C';
00054       
00055     }
00056     if ( fwo_map['A'] != 1 ) {
00057       (*chromats)[ 1 ].stlVector().swap( (*chromats)[ fwo_map['A'] ].stlVector() );
00058 
00059       fwo_map[ fwo_vec[ 1 ] ] = fwo_map['A'];
00060       fwo_vec[ fwo_map['A'] ] = fwo_vec[ 1 ];
00061 
00062       fwo_map['A'] = 1;
00063       fwo_vec[ 1 ] = 'A';
00064       
00065     }
00066     if ( fwo_map['G'] != 2 ) {
00067       (*chromats)[ 2 ].stlVector().swap( (*chromats)[ fwo_map['G'] ].stlVector() );
00068 
00069       fwo_map[ fwo_vec[ 2 ] ] = fwo_map['G'];
00070       fwo_vec[ fwo_map['G'] ] = fwo_vec[ 2 ];
00071 
00072       fwo_map['G'] = 2;
00073       fwo_vec[ 2 ] = 'G';
00074       
00075     }
00076     if ( fwo_map['T'] != 3 ) {
00077       (*chromats)[ 3 ].stlVector().swap( (*chromats)[ fwo_map['T'] ].stlVector() );
00078 
00079       fwo_map[ fwo_vec[ 3 ] ] = fwo_map['T'];
00080       fwo_vec[ fwo_map['T'] ] = fwo_vec[ 3 ];
00081 
00082       fwo_map['T'] = 3;
00083       fwo_vec[ 3 ] = 'T';
00084       
00085     }
00086     assert( fwo_map['C'] == 0 );
00087     assert( fwo_map['A'] == 1 );
00088     assert( fwo_map['G'] == 2 );
00089     assert( fwo_map['T'] == 3 );
00090     
00091     assert( fwo_vec[0] == 'C' );
00092     assert( fwo_vec[1] == 'A' );
00093     assert( fwo_vec[2] == 'G' );
00094     assert( fwo_vec[3] == 'T' );
00095     
00096   }
00097   else if ( inDATA &&               //We're parsing DATA
00098             qName == "integer16" && //We're parsing data array
00099             curr_tag_num > 8 &&     //9=C, 10=A, 11=G, 12=T
00100             curr_tag_num < 13) {
00101 
00102     QString array = atts.value("value");
00103     QTextStream ts(&array, IO_ReadOnly);
00104     
00105     while ( !ts.atEnd()) {
00106       int val;
00107       ts>>val;
00108       (*chromats)[ curr_tag_num - 9 ].stlVector().push_back(val);
00109     }
00110     
00111 
00112   }
00113   
00114   return true;
00115 }


Member Data Documentation

std::vector<TrapperVector<Q_UINT32> >* ChromatParser::chromats [private]
 

Definition at line 25 of file chromatparser.h.

Referenced by startElement().

int ChromatParser::curr_tag_num [private]
 

Definition at line 24 of file chromatparser.h.

Referenced by startElement().

QString ChromatParser::FWO_ [private]
 

Definition at line 26 of file chromatparser.h.

Referenced by startElement().

bool ChromatParser::inDATA [private]
 

Definition at line 23 of file chromatparser.h.

Referenced by endElement(), and startElement().


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