11 name =
"New Component";
32 bool US_Model::SimulationComponent::operator==
35 if ( analyteGUID != sc.analyteGUID )
return false;
36 if ( name != sc.name )
return false;
37 if ( molar_concentration != sc.molar_concentration )
return false;
38 if ( signal_concentration != sc.signal_concentration )
return false;
39 if ( vbar20 != sc.vbar20 )
return false;
40 if ( mw != sc.mw )
return false;
41 if ( s != sc.s )
return false;
42 if ( D != sc.D )
return false;
43 if ( f != sc.f )
return false;
44 if ( f_f0 != sc.f_f0 )
return false;
45 if ( extinction != sc.extinction )
return false;
46 if ( sigma != sc.sigma )
return false;
47 if ( delta != sc.delta )
return false;
48 if ( oligomer != sc.oligomer )
return false;
49 if ( shape != sc.shape )
return false;
50 if ( axial_ratio != sc.axial_ratio )
return false;
51 if ( analyte_type != sc.analyte_type )
return false;
53 if ( c0.radius != sc.c0.radius )
return false;
54 if ( c0.concentration != sc.c0.concentration )
return false;
69 if ( k_d != a.
k_d )
return false;
70 if ( k_off != a.
k_off )
return false;
71 if ( rcomps != a.
rcomps )
return false;
72 if ( stoichs != a.
stoichs )
return false;
139 for (
int ii = 0; ii <
components.size(); ii++ )
152 double radius_sphere;
177 vol_fac = 0.75 / M_PI;
178 onethird = 1.0 / 3.0;
186 f_f0 = component.
f_f0;
194 double ssgn = ( s < 0.0 ) ? -1.0 : 1.0;
200 double numer = 0.02 * s * f_f0 * vbar *
VISC_20W;
202 f0 = 0.09 * VISC_20W * M_PI * sqrt( numer / buoyancyb );
205 mw = s *
R * t / ( D * buoyancyb );
213 mw = s *
R * t / ( D * buoyancyb );
216 radius_sphere = pow( volume * vol_fac, onethird );
217 f0 = radius_sphere * rsph_fac;
218 fv = mw * buoyancyb / ( s20w *
AVOGADRO );
222 double ffdif = qAbs( ff0sv - f_f0 );
223 f_f0 = ( ffdif < 1.e-5 ) ? ff0sv : f_f0;
228 else if ( mw != 0.0 )
230 D = s *
R * t / ( buoyancyb * mw );
232 fv = mw * buoyancyb / ( s20w *
AVOGADRO );
235 radius_sphere = pow( volume * vol_fac, onethird );
236 f0 = radius_sphere * rsph_fac;
243 mw = s *
R * t / ( D * buoyancyb );
246 radius_sphere = pow( volume * vol_fac, onethird );
247 f0 = radius_sphere * rsph_fac;
255 else if ( component.
mw != 0.0 )
258 radius_sphere = pow( volume * vol_fac, onethird );
259 f0 = radius_sphere * rsph_fac;
263 s = D * buoyancyb * mw / (
R * t );
264 fv = mw * buoyancyb / ( s *
AVOGADRO );
268 else if ( f_f0 != 0.0 )
271 s = mw * buoyancyb / (
AVOGADRO * fv );
272 D = s *
R * t / ( buoyancyb * mw );
278 s = mw * buoyancyb / (
AVOGADRO * fv );
279 D = s *
R * t / ( buoyancyb * mw );
286 else if ( component.
D != 0.0 )
292 radius_sphere = f0 / ( 0.06 * M_PI *
VISC_20W );
293 double volume = ( 4.0 / 3.0 ) * M_PI * pow( radius_sphere, 3.0 );
295 s = mw * buoyancyb / (
AVOGADRO * fv );
304 else if ( fv > 0.0 && f_f0 >= 1.0 )
308 radius_sphere = f0 / ( 0.06 * M_PI *
VISC_20W );
309 double volume = ( 4.0 / 3.0 ) * M_PI * pow( radius_sphere, 3.0 );
311 s = mw * buoyancyb / (
AVOGADRO * fv );
317 double df = qAbs( f - fv ) / fv;
331 component.
f_f0 = f_f0;
341 path = is_perm ?
"" :
"";
347 if ( ! dir.exists( path ) )
349 if ( ! dir.mkpath( path ) )
368 const typemap tmap[] =
370 {
MANUAL, QObject::tr(
"Manual" ) },
371 {
TWODSA, QObject::tr(
"2DSA" ) },
373 {
GA, QObject::tr(
"GA" ) },
374 {
GA_MW, QObject::tr(
"GA-MW" ) },
375 {
COFS, QObject::tr(
"COFS" ) },
376 {
FE, QObject::tr(
"FE" ) },
377 {
PCSA, QObject::tr(
"PCSA" ) },
379 {
DMGA, QObject::tr(
"DMGA" ) },
383 const int ntmap =
sizeof( tmap ) /
sizeof( tmap[ 0 ] );
385 QString tdesc = tmap[ 0 ].typedesc;
387 for (
int jj = 0; jj < ntmap; jj++ )
390 if (
analysis == tmap[ jj ].typeval )
392 tdesc = tmap[ jj ].typedesc;
395 tdesc = tdesc +
"-RA";
398 tdesc = tdesc +
"-TR";
401 tdesc = tdesc +
"-FM";
404 tdesc = ( jj > 0 ) ? tdesc +
"-GL" :
"Global";
407 tdesc = ( jj > 0 ) ? tdesc +
"-SG" :
"SuperGlobal";
414 tdesc = tdesc +
"-SL";
415 else if ( subtype == 2 )
416 tdesc = tdesc +
"-IS";
417 else if ( subtype == 4 )
418 tdesc = tdesc +
"-DS";
419 else if ( subtype == 8 )
420 tdesc = tdesc +
"-HL";
422 tdesc = tdesc +
"-IS";
431 tdesc = tdesc +
"-IS";
436 tdesc = tdesc +
"-MC";
451 for (
int ii = 1; ii <
components.size(); ii++ )
453 valmin = qMin( valmin,
components[ ii ].f_f0 );
454 valmax = qMax( valmax,
components[ ii ].f_f0 );
457 return ( ( valmax - valmin ) < 1.0e-3 );
466 for (
int ii = 1; ii <
components.size(); ii++ )
468 valmin = qMin( valmin,
components[ ii ].vbar20 );
469 valmax = qMax( valmax,
components[ ii ].vbar20 );
472 return ( ( valmax - valmin ) < 1.0e-4 );
478 bool is_react =
false;
483 int rcx = as->
rcomps.indexOf( compx );
485 if ( rcx >= 0 && as->
stoichs[ rcx ] >= 0 )
498 bool is_prod =
false;
503 int rcx = as->
rcomps.indexOf( compx );
505 if ( rcx >= 0 && as->
stoichs[ rcx ] < 0 )
518 if ( db_access )
return load_db ( guid, db );
531 message = QObject::tr (
"Could not create model directory" );
536 QStringList filter(
"M*.xml" );
537 QStringList names = f.entryList( filter, QDir::Files, QDir::Name );
541 for (
int i = 0; i < names.size(); i++ )
543 filename = path +
"/" + names[ i ];
544 QFile file( filename );
546 if ( ! file.open( QIODevice::ReadOnly | QIODevice::Text) )
continue;
548 QXmlStreamReader xml( &file );
550 while ( ! xml.atEnd() )
554 if ( xml.isStartElement() )
556 if ( xml.name() ==
"model" )
558 QXmlStreamAttributes a = xml.attributes();
560 if ( a.value(
"modelGUID" ).toString() == guid )
569 if ( found )
return load( filename );
572 message = QObject::tr (
"Could not find analyte guid" );
579 QFile file( filename );
581 if ( ! file.open( QIODevice::ReadOnly | QIODevice::Text) )
584 QXmlStreamReader xml( &file );
591 file.open( QIODevice::ReadOnly | QIODevice::Text );
593 QTextStream tsi( &file );
605 QXmlStreamReader xml( mcont );
619 QXmlStreamAttributes a;
620 bool read_next =
true;
623 while ( ! xml.atEnd() )
625 if ( read_next ) xml.readNext();
628 if ( xml.isStartElement() )
630 if ( xml.name() ==
"model" )
640 a = xml.attributes();
642 QString mcst = a.value(
"monteCarlo" ).toString();
643 monteCarlo = ( ! mcst.isEmpty() && mcst !=
"0" );
644 QString iter = a.value(
"iterations" ).toString();
646 ( iter.isEmpty() ?
false : ( iter.toInt() > 1 ) );
647 wavelength = a.value(
"wavelength" ).toString().toDouble();
648 QString vari = a.value(
"variance" ).toString();
649 variance = vari.isEmpty() ? 0.0 : vari.toDouble();
650 QString meni = a.value(
"meniscus" ).toString();
651 meniscus = meni.isEmpty() ? 0.0 : meni.toDouble();
652 QString alph = a.value(
"alphaRP" ).toString();
653 alphaRP = alph.isEmpty() ? 0.0 : alph.toDouble();
655 modelGUID = a.value(
"modelGUID" ).toString();
656 editGUID = a.value(
"editGUID" ).toString();
659 coSedStr = a.value(
"coSedSolute" ).toString();
660 coSedSolute = ( coSedStr.isEmpty() ) ? -1 : coSedStr.toInt();
661 QString subgs = a.value(
"subGrids" ).toString();
664 QString anal1 = a.value(
"type" ).toString();
665 QString anal2 = a.value(
"analysisType" ).toString();
671 (
GlobalType) a.value(
"globalType" ).toString().toInt();
673 (
OpticsType) a.value(
"opticsType" ).toString().toInt();
676 else if ( xml.name() ==
"analyte" )
679 a = xml.attributes();
681 sc.
analyteGUID = a.value(
"analyteGUID" ).toString();
683 sc.
name = a.value(
"name" ).toString();
684 QString avbar = a.value(
"vbar20" ).toString();
686 sc.
mw = a.value(
"mw" ).toString().toDouble();
687 sc.
s = a.value(
"s" ).toString().toDouble();
688 sc.
D = a.value(
"D" ).toString().toDouble();
689 sc.
f = a.value(
"f" ).toString().toDouble();
690 sc.
f_f0 = a.value(
"f_f0" ).toString().toDouble();
691 sc.
extinction = a.value(
"extinction" ).toString().toDouble();
692 QString aaxia = a.value(
"axial" ).toString();
693 sc.
axial_ratio = aaxia.isEmpty() ? 10.0 : aaxia.toDouble();
694 sc.
sigma = a.value(
"sigma" ).toString().toDouble();
695 sc.
delta = a.value(
"delta" ).toString().toDouble();
699 sc.
oligomer = a.value(
"oligomer" ).toString().toInt();
703 sc.
oligomer = a.value(
"stoich" ).toString().toInt();
708 (
ShapeType)a.value(
"shape" ).toString().toInt();
718 else if ( xml.name() ==
"association" )
739 QString mline, mdesc, mcont;
744 QString line1 = tsi.readLine() +
"\n";
745 QString line2 = tsi.readLine() +
"\n";
746 QString line3 = tsi.readLine() +
"\n";
749 while ( ! tsi.atEnd() )
751 mline = tsi.readLine();
752 if ( mline.contains(
"</ModelData>" ) )
755 if ( mline.contains(
"<model " ) )
757 mcont = line1 + line2 + line3 + mline +
"\n";
761 int idx = qMax( mline.indexOf(
"description=" ), 0 );
762 mdesc = QString( mline ).mid( idx, 99 ).section(
"\"", 1, 1 );
766 else if ( mline.contains(
"</model>" ) )
768 mcont = mcont + mline +
"\n</ModelData>\n";
775 mcont = mcont + mline +
"\n";
779 QVector< SimulationComponent > mmcomps;
780 QVector< Association > mmassos;
785 for (
int ii = 0; ii <
nmcixs; ii++ )
788 QXmlStreamReader xml( mcont );
802 double sclnrm = 1.0 / (double)nmcixs;
803 bool cnst_vb = ( ncnstv >= ncnstk );
807 for (
int ii = 0; ii < mmcomps.size(); ii++ )
809 double sval = mmcomps[ ii ].s * 1.0e+13;
810 double kval = cnst_vb ? mmcomps[ ii ].f_f0 : mmcomps[ ii ].vbar20;
811 QString skval = QString().sprintf(
"%10.4f %8.5f", sval, kval );
813 if ( ! skvals.contains( skval ) )
817 int nskl = sklist.size();
818 int nskv = skvals.size();
822 for (
int ii = 0; ii < nskv; ii ++ )
824 QString skval = skvals[ ii ];
827 for (
int jj = 0; jj < nskl; jj++ )
829 if ( skval == sklist[ jj ] )
831 scomp = mmcomps[ jj ];
836 scomp.
name = QString().sprintf(
"SC%04d", ii + 1 );
841 if ( mmassos.size() > 0 )
844 QString mdsc1 = QString( mdesc ).section(
".", 0, -3 );
845 QString mdsc2 = QString( mdesc ).section(
".", -2, -2 )
846 .section(
"_", 0, -2 );
847 QString mdsc3 = QString( mdesc ).section(
".", -1, -1 );
848 QString miter = QString().sprintf(
"_mcN%03i", nmcixs );
849 description = mdsc1 +
"." + mdsc2 + miter +
"." + mdsc3;
862 for (
int ii = 0; ii <
nmcixs; ii++ )
864 QString mlines =
mcixmls[ ii ];
867 int flx = ( ii == 0 ) ? 0 : 3;
868 int llx = ( ( ii + 1 ) < nmcixs ) ? -3 : -2;
869 QString mcont = mlines.section(
"\n", flx, llx ) +
"\n";
878 while ( ! xml.atEnd() )
882 if ( xml.isStartElement() )
884 if ( xml.name() ==
"mfem_scan" )
886 QXmlStreamAttributes a = xml.attributes();
888 sc.
c0.
radius << a.value(
"radius" ).toString().toDouble();
900 QXmlStreamAttributes a = xml.attributes();
901 QString skassoc = a.value(
"k_assoc" ).toString();
902 QString skeq = a.value(
"k_eq" ).toString();
903 QString skdisso = a.value(
"K_d" ).toString();
904 QString skoff = a.value(
"k_off" ).toString();
906 if ( ! skdisso.isEmpty() )
907 as.
k_d = skdisso.toDouble();
910 double k_assoc = 0.0;
911 if ( ! skassoc.isEmpty() )
912 k_assoc = skassoc.toDouble();
913 else if ( ! skeq.isEmpty() )
914 k_assoc = skeq.toDouble();
915 as.
k_d = ( k_assoc != 0.0 ) ? ( 1.0 / k_assoc ) : 0.0;
918 if ( ! skoff.isEmpty() )
919 as.
k_off = skoff.toDouble();
921 while ( ! xml.atEnd() )
925 if ( xml.isStartElement() )
927 if ( xml.name() ==
"component" )
929 a = xml.attributes();
931 as.
rcomps << a.value(
"index" ).toString().toInt();
932 as.
stoichs << a.value(
"stoich" ).toString().toInt();
945 q <<
"get_modelID" << guid;
951 QString
id = db->
value( 0 ).toString();
952 return load(
id, db );
960 q <<
"get_model_info" << id;
966 QByteArray contents = db->
value( 2 ).toString().toAscii();
969 QXmlStreamReader xml( contents );
975 QTextStream tsi( contents );
986 if ( db_access )
return write( db );
987 else return write( filename );
994 QByteArray temporary;
999 QXmlStreamWriter xml( &temporary );
1005 QTextStream tso( &temporary );
1010 qDebug() <<
"model writedb contsize tempsize" << contents.size() << temporary.size();
1022 QString meni = QString::number(
meniscus );
1023 QString vari = QString::number(
variance );
1028 q <<
"new_model" << modelGUID <<
description << contents
1031 message = QObject::tr(
"created" );
1036 QString
id = db->
value( 0 ).toString();
1038 q <<
"update_model" <<
id <<
description << contents
1040 message = QObject::tr(
"updated" );
1044 qDebug() <<
"model writedb message" <<
message <<
"wstat" << wstat;
1048 QString filename =
get_filename( path, modelGUID, newFile );
1057 QFile file( filename );
1059 if ( ! file.open( QIODevice::WriteOnly | QIODevice::Text) )
1064 QXmlStreamWriter xml( &file );
1070 QTextStream tso( &file );
1085 xml.setAutoFormatting(
true );
1087 xml.writeStartDocument();
1088 xml.writeDTD (
"<!DOCTYPE US_Model>" );
1089 xml.writeStartElement(
"ModelData" );
1090 xml.writeAttribute (
"version",
"1.0" );
1092 xml.writeStartElement(
"model" );
1093 xml.writeAttribute (
"description",
description );
1094 xml.writeAttribute (
"modelGUID",
modelGUID );
1095 xml.writeAttribute (
"editGUID",
editGUID );
1096 xml.writeAttribute (
"wavelength", QString::number(
wavelength ) );
1098 xml.writeAttribute(
"variance", QString::number(
variance ) );
1100 xml.writeAttribute(
"meniscus", QString::number(
meniscus ) );
1102 xml.writeAttribute(
"alphaRP", QString::number(
alphaRP ) );
1103 xml.writeAttribute (
"coSedSolute", QString::number(
coSedSolute ) );
1105 xml.writeAttribute(
"subGrids", QString::number(
subGrids ) );
1106 xml.writeAttribute (
"opticsType", QString::number(
optics ) );
1107 xml.writeAttribute (
"analysisType",QString::number(
analysis ) );
1108 xml.writeAttribute (
"globalType", QString::number(
global ) );
1111 xml.writeAttribute (
"requestGUID",
requestGUID );
1114 xml.writeAttribute (
"monteCarlo",
"1" );
1121 xml.writeAttribute (
"dataDescrip",
dataDescrip );
1126 bool notmany = ( ncomps < 400 );
1128 for (
int i = 0; i < ncomps; i++ )
1131 xml.writeStartElement(
"analyte" );
1134 xml.writeAttribute(
"analyteGUID", sc->
analyteGUID );
1135 xml.writeAttribute(
"name", sc->
name );
1136 xml.writeAttribute(
"mw", QString::number( sc->
mw ) );
1137 xml.writeAttribute(
"s", QString::number( sc->
s ) );
1138 xml.writeAttribute(
"D", QString::number( sc->
D ) );
1139 xml.writeAttribute(
"f", QString::number( sc->
f ) );
1140 xml.writeAttribute(
"f_f0", QString::number( sc->
f_f0 ) );
1141 QString strVbar = QString::number( sc->
vbar20 );
1142 QString strExtinc = QString::number( sc->
extinction );
1143 QString strAxial = QString::number( sc->
axial_ratio );
1144 QString strSigma = QString::number( sc->
sigma );
1145 QString strDelta = QString::number( sc->
delta );
1146 QString strOligo = QString::number( sc->
oligomer );
1147 QString strShape = QString::number( sc->
shape );
1153 xml.writeAttribute(
"vbar20", strVbar );
1154 xml.writeAttribute(
"extinction", strExtinc );
1155 xml.writeAttribute(
"axial", strAxial );
1156 xml.writeAttribute(
"sigma", strSigma );
1157 xml.writeAttribute(
"delta", strDelta );
1158 xml.writeAttribute(
"oligomer", strOligo );
1159 xml.writeAttribute(
"shape", strShape );
1160 xml.writeAttribute(
"type", strType );
1161 xml.writeAttribute(
"molar", strMolar );
1166 xml.writeAttribute(
"vbar20", strVbar );
1168 xml.writeAttribute(
"extinction", strExtinc );
1170 xml.writeAttribute(
"axial", strAxial );
1171 if ( sc->
sigma != 0.0 )
1172 xml.writeAttribute(
"sigma", strSigma );
1173 if ( sc->
delta != 0.0 )
1174 xml.writeAttribute(
"delta", strDelta );
1176 xml.writeAttribute(
"oligomer", strOligo );
1178 xml.writeAttribute(
"shape", strShape );
1180 xml.writeAttribute(
"type", strType );
1182 xml.writeAttribute(
"molar", strMolar );
1184 xml.writeAttribute(
"signal", strSignal );
1186 for (
int j = 0; j < sc->
c0.
radius.size(); j++ )
1188 xml.writeStartElement(
"mfem_scan" );
1191 xml.writeAttribute(
"radius",
1192 QString::number( scan->
radius [ j ] ) );
1193 xml.writeAttribute(
"conc",
1195 xml.writeEndElement();
1198 xml.writeEndElement();
1205 xml.writeStartElement(
"association" );
1206 xml.writeAttribute(
"K_d", QString::number( as->
k_d ) );
1207 xml.writeAttribute(
"k_off", QString::number( as->
k_off ) );
1209 for (
int j = 0; j < as->
rcomps.size(); j++ )
1211 xml.writeStartElement(
"component" );
1213 QString index = QString::number( as->
rcomps [ j ] );
1214 QString stoich = QString::number( as->
stoichs[ j ] );
1216 xml.writeAttribute(
"index", index );
1217 xml.writeAttribute(
"stoich", stoich );
1218 xml.writeEndElement();
1221 xml.writeEndElement();
1224 xml.writeEndElement();
1225 xml.writeEndElement();
1226 xml.writeEndDocument();
1234 QStringList filter(
"M???????.xml" );
1235 QStringList f_names = f.entryList( filter, QDir::Files, QDir::Name );
1239 for (
int i = 0; i < f_names.size(); i++ )
1241 QFile m_file( path +
"/" + f_names[ i ] );
1243 if ( ! m_file.open( QIODevice::ReadOnly | QIODevice::Text) )
continue;
1245 QXmlStreamReader xml( &m_file );
1247 while ( ! xml.atEnd() )
1251 if ( xml.isStartElement() )
1253 if ( xml.name() ==
"model" )
1255 QXmlStreamAttributes a = xml.attributes();
1257 if ( a.value(
"modelGUID" ).toString() == guid )
1259 fnamo = path +
"/" + f_names[ i ];
1272 int number = ( f_names.size() > 0 ) ?
1273 f_names.last().mid( 1, 7 ).toInt() : 0;
1275 for (
int ii = 0; ii < number; ii++ )
1277 QString fnamck =
"M" + QString().sprintf(
"%07i", ii + 1 ) +
".xml";
1279 if ( ! f_names.contains( fnamck ) )
1287 fnamo = path +
"/M" + QString().sprintf(
"%07i", number + 1 ) +
".xml";
1296 const QChar dquo(
'"' );
1297 QString empty_str(
"" );
1298 QString cmfname = empty_str;
1299 int mc_iters = mcfiles.size();
1303 if ( mc_iters < 1 )
return cmfname;
1305 cmfname = mcfiles[ 0 ];
1306 bool name_desc = cmfname.contains(
".mc" ) || cmfname.contains(
"_mc" );
1310 if ( mc_iters == 1 )
1312 if ( cmfname.contains(
".mcN" ) || cmfname.contains(
"_mcN" ) )
1316 QFile filei( cmfname );
1317 if ( ! filei.open( QIODevice::ReadOnly | QIODevice::Text) )
1319 qDebug() <<
"**MC iteration file open error**";
1323 QTextStream tsi( &filei );
1324 QString mcont = tsi.readAll();
1326 int jj = qMax( 0, mcont.indexOf(
"description=" ) );
1327 QString mdesc = QString( mcont ).mid( jj, 99 ).section( dquo, 1, 1 );
1328 if ( mdesc.contains(
"_mcN" ) )
1334 for (
int ii = 0; ii < mcfiles.size(); ii++ )
1338 if ( mcfiles[ ii ].contains(
".mcN" ) ||
1339 mcfiles[ ii ].contains(
"_mcN" ) )
1343 cmfname = mcfiles[ ii ];
1348 QFile filei( mcfiles[ ii ] );
1349 if ( ! filei.open( QIODevice::ReadOnly | QIODevice::Text) )
1351 QTextStream tsi( &filei );
1352 QString mcont = tsi.readAll();
1354 int jj = qMax( 0, mcont.indexOf(
"description=" ) );
1355 QString mdesc = QString( mcont ).mid( jj, 99 ).section( dquo, 1, 1 );
1356 if ( mdesc.contains(
"_mcN" ) )
1360 cmfname = mcfiles[ ii ];
1366 if ( mc_comps > 1 || mc_iters < 1 )
1368 qDebug() <<
"**" << mc_comps <<
"MC composites, and" << mc_iters
1369 <<
"MC iterations **";
1373 QString mditer1 = QString().sprintf(
".mcN%03i", mc_iters );
1374 QString mditer2 = QString( mditer1 ).replace(
".mcN",
"_mcN" );
1375 QString mditer = mditer1;
1378 if ( mc_comps == 0 )
1380 cmfname = mcfiles[ 0 ];
1381 QFile filei( mcfiles[ 0 ] );
1382 if ( ! filei.open( QIODevice::ReadOnly | QIODevice::Text) )
1384 qDebug() <<
"**MC iteration file open error**";
1387 QTextStream tsi( &filei );
1388 QString mcont = tsi.readAll();
1390 int jj = qMax( 0, mcont.indexOf(
"modelGUID=" ) );
1391 QString mcguid = QString( mcont ).mid( jj, 99 ).section( dquo, 1, 1 );
1402 bool newFile =
true;
1403 QString path = QString( cmfname ).section(
"/", 0, -2 );
1412 int moix1 = cmfname.indexOf(
".mc" );
1413 int moix2 = cmfname.indexOf(
"_mc" );
1414 int moix = ( moix1 > 0 ) ? moix1 : qMax( 0, moix2 );
1415 QString moiter = QString( cmfname ).mid( moix, 7 );
1416 mditer = ( moix1 > 0 ) ? mditer1 : mditer2;
1417 cmfname = cmfname.replace( moiter, mditer )
1418 .replace(
".mdl.tmp",
".model.xml" );
1423 QFile fileo( cmfname );
1424 if ( ! fileo.open( QIODevice::WriteOnly | QIODevice::Text ) )
1426 qDebug() <<
"**MC composite file open error**";
1431 QTextStream tso( &fileo );
1432 jj = qMax( 0, mcont.indexOf(
"modelGUID=" ) );
1433 QString miguid = QString( mcont ).mid( jj, 99 ).section( dquo, 1, 1 );
1434 if ( miguid != mcguid )
1435 mcont.replace( miguid, mcguid );
1437 int llx = ( mc_iters > 1 ) ? -3 : -2;
1438 tso << mcont.section(
"\n", flx, llx ) <<
"\n";
1442 for (
int ii = 1; ii < mc_iters; ii++ )
1444 QFile filei( mcfiles[ ii ] );
1445 if ( ! filei.open( QIODevice::ReadOnly | QIODevice::Text) )
1447 QTextStream tsi( &filei );
1448 mcont = tsi.readAll();
1450 jj = qMax( 0, mcont.indexOf(
"modelGUID=" ) );
1451 QString miguid = QString( mcont ).mid( jj, 99 ).section( dquo, 1, 1 );
1452 if ( miguid != mcguid )
1453 mcont.replace( miguid, mcguid );
1454 llx = ( ( ii + 1 ) < mc_iters ) ? -3 : -2;
1455 tso << mcont.section(
"\n", flx, llx ) <<
"\n";
1463 QFile filei( cmfname );
1464 if ( ! filei.open( QIODevice::ReadOnly | QIODevice::Text) )
1466 qDebug() <<
"**MC composite file open error**";
1470 QTextStream tsi( &filei );
1471 QString mcont = tsi.readAll();
1473 mcont = mcont.section(
"\n", 0, -3 ) +
"\n";
1474 int jj = qMax( 0, mcont.indexOf(
"modelGUID=" ) );
1475 QString mcguid = QString( mcont ).mid( jj, 99 ).section( dquo, 1, 1 );
1479 int moix1 = cmfname.indexOf(
".mc" );
1480 int moix2 = cmfname.indexOf(
"_mc" );
1481 int moix = ( moix1 > 0 ) ? moix1 : qMax( 0, moix2 );
1482 QString moiter = QString( cmfname ).mid( moix, 7 );
1483 int mc_ittot = QString( moiter ).mid( 4 ).toInt() + mc_iters;
1484 mditer = ( ( moix1 > 0 ) ?
"." :
"_" )
1485 + QString().sprintf(
"mcN%03i", mc_ittot );
1488 if ( moiter != mditer )
1490 cmfname = cmfname.replace( moiter, mditer )
1491 .replace(
".mdl.tmp",
".model.xml" );
1492 filei.rename( cmfname );
1506 QFile fileo( cmfname );
1507 if ( ! fileo.open( QIODevice::WriteOnly | QIODevice::Text ) )
1509 qDebug() <<
"**MC composite file open error**";
1514 QTextStream tso( &fileo );
1517 tso << mcont.section(
"\n", flx, llx ) <<
"\n";
1521 for (
int ii = 0; ii < mc_iters; ii++ )
1523 QFile filei( mcfiles[ ii ] );
1524 if ( ! filei.open( QIODevice::ReadOnly | QIODevice::Text) )
1526 QTextStream tsi( &filei );
1527 mcont = tsi.readAll();
1529 jj = qMax( 0, mcont.indexOf(
"modelGUID=" ) );
1530 QString miguid = QString( mcont ).mid( jj, 99 ).section( dquo, 1, 1 );
1531 if ( miguid != mcguid )
1532 mcont.replace( miguid, mcguid );
1533 llx = ( ( ii + 1 ) < mc_iters ) ? -3 : -2;
1534 tso << mcont.section(
"\n", flx, llx ) <<
"\n";
1542 if ( mc_comps == 0 )
1544 for (
int ii = 0; ii < mcfiles.size(); ii++ )
1546 if ( mcfiles[ 0 ] != cmfname )
1547 QFile( mcfiles[ ii ] ).remove();
1551 else if ( name_desc )
1553 for (
int ii = 0; ii < mcfiles.size(); ii++ )
1555 if ( ! mcfiles[ ii ].contains(
"mcN" ) )
1556 QFile( mcfiles[ ii ] ).remove();
1562 for (
int ii = 0; ii < mcfiles.size(); ii++ )
1564 if ( mcfiles[ ii ] == cmfname )
1566 QFile filei( mcfiles[ ii ] );
1567 if ( ! filei.open( QIODevice::ReadOnly | QIODevice::Text) )
1569 qDebug() <<
"**MC iteration file open error**";
1573 QTextStream tsi( &filei );
1574 QString mcont = tsi.readAll();
1576 int jj = qMax( 0, mcont.indexOf(
"description=" ) );
1577 QString mdesc = QString(mcont).mid( jj, 99 ).section( dquo, 1, 1 );
1578 if ( ! mdesc.contains(
"_mcN" ) )
1579 QFile( mcfiles[ ii ] ).remove();
1598 qDebug() <<
"model dump";
1601 qDebug() <<
"variance" <<
variance;
1602 qDebug() <<
"meniscus" <<
meniscus;
1603 qDebug() <<
"alphaRP" <<
alphaRP;
1604 qDebug() <<
"edit guid" <<
editGUID;
1609 qDebug() <<
"subGrids" <<
subGrids;
1610 qDebug() <<
"AnalysisType" << (int)
analysis;
1611 qDebug() <<
"GlobalType" << (int)
global;
1612 qDebug() <<
"OpticsType" << (int)
optics;
1615 for (
int i = 0; i <
components.size(); i++ )
1618 qDebug() <<
" component" << ( i + 1 );
1619 qDebug() <<
" name" << sc->
name;
1620 qDebug() <<
" vbar20" << sc->
vbar20;
1621 qDebug() <<
" mw" << sc->
mw;
1622 qDebug() <<
" s" << sc->
s;
1623 qDebug() <<
" D" << sc->
D;
1624 qDebug() <<
" f" << sc->
f;
1625 qDebug() <<
" f/f0" << sc->
f_f0;
1628 qDebug() <<
" sigma" << sc->
sigma;
1629 qDebug() <<
" delta" << sc->
delta;
1632 qDebug() <<
" oligomer" << sc->
oligomer;
1633 qDebug() <<
" shape" << (int)sc->
shape;
1636 for (
int j = 0; j < sc->
c0.
radius.size(); j++ )
1638 qDebug() <<
" c0 r c"