27 qDebug() <<
"Error: solution file not found - guid "
32 QFile file( filename );
33 if ( !file.open( QIODevice::ReadOnly | QIODevice::Text) )
35 qDebug() <<
"Error: can't open file for reading"
40 QXmlStreamReader xml( &file );
44 while ( ! xml.atEnd() )
48 if ( xml.isStartElement() )
50 if ( xml.name() ==
"solution" )
52 QXmlStreamAttributes a = xml.attributes();
53 solutionID = a.value(
"id" ).toString().toInt();
55 commonVbar20 = a.value(
"commonVbar20" ).toString().toDouble();
56 storageTemp = a.value(
"storageTemp" ).toString().toDouble();
67 qDebug() <<
"Error: xml error: \n"
104 while ( ! xml.atEnd() )
108 if ( xml.isEndElement() && xml.name() ==
"solution" )
return;
110 if ( xml.isStartElement() )
112 if ( xml.name() ==
"description" )
118 else if ( xml.name() ==
"notes" )
121 notes = xml.text().toString();
124 else if ( xml.name() ==
"buffer" )
126 QXmlStreamAttributes a = xml.attributes();
132 else if ( xml.name() ==
"analyte" )
136 QXmlStreamAttributes a = xml.attributes();
140 ai.
amount = a.value(
"amount" ).toString().toDouble();
141 ai.
analyte.
mw = a.value(
"mw" ).toString().toDouble();
142 ai.
analyte.
vbar20 = a.value(
"vbar20" ).toString().toDouble();
143 QString typetext = a.value(
"type" ).toString();
158 QStringList q(
"get_solution" );
159 q << QString::number( solutionID );
174 q <<
"get_solutionBuffer"
175 << QString::number( solutionID );
189 q <<
"get_solutionAnalyte"
190 << QString::number( solutionID );
193 QList< QString > GUIDs;
194 QList< double > amounts;
197 GUIDs << db->
value( 1 ).toString();
198 amounts << db->
value( 3 ).toDouble();
202 for (
int i = 0; i < GUIDs.size(); i++ )
206 int status = newInfo.
analyte.
load(
true, GUIDs[ i ], db );
210 newInfo.
amount = amounts[ i ];
224 QRegExp rx(
"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" );
238 QFile file( filename );
239 if ( !file.open( QIODevice::WriteOnly | QIODevice::Text) )
241 qDebug() <<
"Error: can't open file for writing"
252 qDebug() <<
"Error: Solution cannot be written to disk,"
253 <<
" due to invalid values:";
262 QXmlStreamWriter xml;
263 xml.setDevice( &file );
264 xml.setAutoFormatting(
true );
266 xml.writeStartDocument();
267 xml.writeDTD(
"<!DOCTYPE US_Solution>");
268 xml.writeStartElement(
"SolutionData");
269 xml.writeAttribute(
"version",
"1.0");
272 xml.writeStartElement(
"solution" );
273 xml.writeAttribute (
"id", QString::number(
solutionID ) );
275 xml.writeAttribute (
"commonVbar20", QString::number(
commonVbar20 ) );
276 xml.writeAttribute (
"storageTemp", QString::number(
storageTemp ) );
278 xml.writeTextElement (
"notes",
notes );
280 xml.writeStartElement(
"buffer" );
284 xml.writeEndElement ();
291 xml.writeStartElement(
"analyte" );
295 xml.writeAttribute (
"amount", QString::number( ai.
amount ) );
296 xml.writeAttribute (
"mw", QString::number( ai.
analyte.
mw ) );
297 xml.writeAttribute (
"vbar20", QString::number( ai.
analyte.
vbar20 ) );
299 xml.writeEndElement ();
302 xml.writeEndElement ();
303 xml.writeEndDocument ();
355 QRegExp rx(
"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" );
362 q <<
"get_solutionID_from_GUID"
373 q <<
"update_solution"
394 << QString::number( expID )
395 << QString::number( channelID )
404 qDebug() <<
"MySQL error: " << db->
lastError();
416 q <<
"new_solutionBuffer"
424 qDebug() <<
"MySQL error associating buffer with solution in database:"
432 q <<
"delete_solutionAnalytes"
437 qDebug() <<
"MySQL error: " << db->
lastError();
445 q <<
"new_solutionAnalyte"
449 << QString::number( newInfo.
amount );
454 qDebug() <<
"MySQL error associating analyte "
475 if ( ! dir.exists( path ) )
499 if ( ! dir.exists( path ) )
501 if ( ! dir.mkpath( path ) )
503 qDebug() <<
"Error: Could not create default directory for buffers\n"
517 if ( diskStatus ==
false )
518 qDebug() <<
"Buffer write to disk error";
528 if ( ! dir.exists( path ) )
530 if ( ! dir.mkpath( path ) )
532 qDebug() <<
"Error: Could not create default directory for analytes\n"
548 <<
" write to disk error " << status;
570 QFile file( filename );
588 q <<
"get_solutionID_from_GUID"
600 q <<
"delete_solution"
609 qDebug() <<
"MySQL error: " << db->
lastError();
624 qDebug() <<
"Error: could not create the solutions directory";
629 QStringList filter(
"S*.xml" );
630 QStringList names = dir.entryList( filter, QDir::Files, QDir::Name );
633 for (
int i = 0; i < names.size(); i++ )
635 filename = path +
"/" + names[ i ];
636 QFile file( filename );
638 if ( ! file.open( QIODevice::ReadOnly | QIODevice::Text) )
continue;
640 QXmlStreamReader xml( &file );
642 while ( ! xml.atEnd() )
646 if ( xml.isStartElement() )
648 if ( xml.name() ==
"solution" )
650 QXmlStreamAttributes a = xml.attributes();
652 if ( a.value(
"guid" ).toString() == guid ) found =
true;
664 filename = QString(
"" );
677 if ( ! dir.exists( path ) )
679 if ( ! dir.mkpath( path ) )
681 qDebug() <<
"Error: Could not create default directory for solutions\n"
692 const QString& path,
bool& newFile )
695 QStringList filter(
"S???????.xml" );
696 QStringList f_names = f.entryList( filter, QDir::Files, QDir::Name );
700 for (
int i = 0; i < f_names.size(); i++ )
702 QFile b_file( path +
"/" + f_names[ i ] );
704 if ( ! b_file.open( QIODevice::ReadOnly | QIODevice::Text) )
continue;
706 QXmlStreamReader xml( &b_file );
708 while ( ! xml.atEnd() )
712 if ( xml.isStartElement() )
714 if ( xml.name() ==
"solution" )
716 QXmlStreamAttributes a = xml.attributes();
721 filename = path +
"/" + f_names[ i ];
730 if ( ! newFile )
return filename;
734 int number = ( f_names.size() > 0 ) ? f_names.last().mid( 1, 7 ).toInt() : 0;
736 return path +
"/S" + QString().sprintf(
"%07i", number + 1 ) +
".xml";
746 if (! ( analyte == rhs.
analyte ) )
return false;
747 if ( amount != rhs.
amount )
return false;
786 notes = QString(
"" );
793 qDebug() <<
"solutionID = " <<
solutionID <<
'\n'
803 <<
"notes = " <<
notes <<
'\n'
806 qDebug() <<
"Analytes...";
807 qDebug() <<
"Analytes size = " << QString::number(
analyteInfo.size() );
818 <<
"type = " << typetext <<
'\n'
820 <<
"amount = " << ai.
amount <<
'\n';
828 if ( antype ==
"Protein" )
830 else if ( antype ==
"DNA" )
832 else if ( antype ==
"RNA" )
834 else if ( antype ==
"Other" )
842 QString antype =
"Protein";
862 QStringList expdirs = QDir( resdir )
863 .entryList( QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name );
864 resdir = resdir +
"/";
866 for (
int ii = 0; ii < expdirs.size(); ii++ )
868 QString subdir = resdir + expdirs.at( ii );
870 expfilt << expdirs.at( ii ) +
".*.xml";
871 QStringList expfiles = QDir( subdir )
872 .entryList( QDir::Files, QDir::Name );
873 subdir = subdir +
"/";
875 for (
int jj = 0; jj < expfiles.size(); jj++ )
877 QString fname = subdir + expfiles.at( jj );
878 QFile xfile( fname );
879 if ( ! xfile.open( QIODevice::ReadOnly ) )
882 QXmlStreamReader xml( &xfile );
884 while ( ! xml.atEnd() )
888 if ( xml.isStartElement() && xml.name() ==
"solution" )
890 QXmlStreamAttributes atts = xml.attributes();
891 QString guid = atts.value(
"guid" ).toString();
893 if ( guid == solutionGUID )