Skip to content

Commit 6157bf3

Browse files
committed
Version 2.3.0. Mike Hasson's work on material dependent transport. Also
.mat file support is here.
1 parent 2dfd256 commit 6157bf3

File tree

7 files changed

+1170
-31
lines changed

7 files changed

+1170
-31
lines changed

comets_simplified/src/edu/bu/segrelab/comets/Comets.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public class Comets implements CometsConstants,
9494
* by each cell just runs through a diffusion routine.
9595
*/
9696
public static boolean DIFFUSION_TEST_MODE = false;
97-
private String versionString = "2.2.3, 2 August 2016";
97+
private String versionString = "2.3.0, 24 October 2016";
9898

9999
// The setup pane
100100
private CometsSimRunner runner;

comets_simplified/src/edu/bu/segrelab/comets/CometsSimRunner.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ else if (c.getParameters().getNumLayers()>1)
114114
c.fireSimulationStateChangeEvent(new SimulationStateChangeEvent(SimulationStateChangeEvent.State.PAUSE));
115115
}
116116
if (c.getParameters().showCycleTime())
117-
// System.out.println("Cycle complete in " + (System.currentTimeMillis() - start)/1000.0 + "s");
117+
System.out.println("Cycle complete in " + (System.currentTimeMillis() - start)/1000.0 + "s");
118118
totalTime += System.currentTimeMillis() - start;
119119
c.updateOnCycle();
120120
}

comets_simplified/src/edu/bu/segrelab/comets/fba/FBACell.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,6 @@ public synchronized int run(FBAModel[] models)
590590
media = world.getModelMediaAt(x, y, i);
591591
else if (cParams.getNumLayers() > 1)
592592
media = world3D.getModelMediaAt(x, y, z, i);
593-
594593
double[] lb = ((FBAModel)models[i]).getBaseExchLowerBounds();
595594
double[] ub = ((FBAModel)models[i]).getBaseExchUpperBounds();
596595
// String[] exchNames = ((FBAModel)models[i]).getExchangeReactionNames();
@@ -757,7 +756,7 @@ else if (cParams.getNumLayers() > 1)
757756
if(deltaBiomass[i]<0.0)deltaBiomass[i]=0.0;
758757
// deltaBiomass[i] = (double)(((FBAModel)models[i]).getObjectiveFluxSolution()) * cParams.getTimeStep();
759758
// deltaBiomass[i] = (double)(((FBAModel)models[i]).getObjectiveFluxSolution());
760-
//System.out.println("solution: " + ((FBAModel)models[i]).getObjectiveSolution());
759+
// System.out.println("solution: " + ((FBAModel)models[i]).getObjectiveSolution());
761760

762761
if (cParams.showGraphics())
763762
cellColor = calculateColor();

comets_simplified/src/edu/bu/segrelab/comets/fba/FBACometsLoader.java

+255-9
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,15 @@ private enum LoaderState
7070
private boolean useGui;
7171
private Comets c;
7272
private int lineCount;
73-
73+
private boolean substrate = false;
74+
private boolean modelDiffusion = false;
75+
private boolean specific = false;
76+
private boolean friction = false;
77+
private double[][] substrateDiffConsts;
78+
private double[][] modelDiffConsts;
79+
private int[][] substrateLayout;
80+
private double[][] specificMedia;
81+
private double[][] substrateFrictionConsts;
7482
private static final String MODEL_FILE = "model_file",
7583
MODEL_WORLD = "model_world",
7684
GRID_SIZE = "grid_size",
@@ -87,7 +95,12 @@ private enum LoaderState
8795
BARRIER = "barrier",
8896
MEDIA = "media",
8997
PARAMETERS = "parameters",
90-
DIFFUSION_CONST = "diffusion_constants";
98+
DIFFUSION_CONST = "diffusion_constants",
99+
SUBSTRATE_DIFFUSIVITY = "substrate_diffusivity",
100+
SUBSTRATE_FRICTION = "substrate_friction",
101+
MODEL_DIFFUSIVITY = "model_diffusivity",
102+
SUBSTRATE_LAYOUT = "substrate_layout",
103+
SPECIFIC_MEDIA = "specific_media";
91104
/**
92105
* Returns the recently loaded World2D.
93106
*/
@@ -202,7 +215,7 @@ public int loadLayoutFile(String filename, Comets c, boolean useGui) throws IOEx
202215
/*
203216
* makes and stores internally: an FBAWorld, an array of FBAModels, an
204217
* ArrayList of FBACells
205-
*/
218+
*/
206219
try
207220
{
208221
BufferedReader reader = new BufferedReader(new FileReader(filename));
@@ -270,7 +283,6 @@ public int loadLayoutFile(String filename, Comets c, boolean useGui) throws IOEx
270283
if (state == LoaderState.CANCELED)
271284
throw new LayoutFileException("Layout file loading canceled", lineCount);
272285
}
273-
274286
else if (parsed[0].equalsIgnoreCase(MODEL_WORLD))
275287
{
276288
Map<String, Point2D.Double> media = new HashMap<String, Point2D.Double>();
@@ -363,10 +375,10 @@ else if (worldParsed[0].equalsIgnoreCase(GRID_SIZE))
363375
else if(worldParsed.length == 3)
364376
c.getParameters().setNumLayers(Integer.valueOf(1));
365377

366-
if (Integer.valueOf(worldParsed[3])==1)
367-
{
368-
throw new IOException("In a 3D simulation the number of layers along the 3rd coordinate must be larger than 1.");
369-
}
378+
//if (Integer.valueOf(worldParsed[3])==1)
379+
//{
380+
// throw new IOException("In a 3D simulation the number of layers along the 3rd coordinate must be larger than 1.");
381+
//}
370382
}
371383

372384
/****************** BARRIER *************************/
@@ -396,6 +408,47 @@ else if (worldParsed[0].equalsIgnoreCase(DIFFUSION_CONST))
396408
List<String> lines = collectLayoutFileBlock(reader);
397409
state = parseMediaDiffusionConstantsBlock(lines, diffConsts);
398410
}
411+
/****************** DIFFUSION CONSTANTS BY SUBSTRATE ********************/
412+
413+
else if (worldParsed[0].equalsIgnoreCase(SUBSTRATE_DIFFUSIVITY))
414+
{
415+
substrate = true;
416+
List<String> lines = collectLayoutFileBlock(reader);
417+
state = parseSubstrateDiffusionConstantsBlock(lines,numMedia);
418+
}
419+
/****************** FRICTION CONSTANTS BY SUBSTRATE ********************/
420+
421+
else if (worldParsed[0].equalsIgnoreCase(SUBSTRATE_FRICTION))
422+
{
423+
friction = true;
424+
List<String> lines = collectLayoutFileBlock(reader);
425+
state = parseSubstrateFrictionConstantsBlock(lines);
426+
}
427+
/****************** DIFFUSION CONSTANTS BY MODEL ********************/
428+
429+
else if (worldParsed[0].equalsIgnoreCase(MODEL_DIFFUSIVITY))
430+
{
431+
modelDiffusion = true;
432+
List<String> lines = collectLayoutFileBlock(reader);
433+
state = parseModelDiffusionConstantsBlock(lines,numMedia);
434+
}
435+
436+
/****************** SUBSTRATE LAYOUT ********************/
437+
438+
else if (worldParsed[0].equalsIgnoreCase(SUBSTRATE_LAYOUT))
439+
{
440+
List<String> lines = collectLayoutFileBlock(reader);
441+
state = parseSubstrateLayoutBlock(lines,c.getParameters().getNumCols(),c.getParameters().getNumRows());
442+
}
443+
444+
/****************** SPECIFIC MEDIA ********************/
445+
446+
else if (worldParsed[0].equalsIgnoreCase(SPECIFIC_MEDIA))
447+
{
448+
specific = true;
449+
List<String> lines = collectLayoutFileBlock(reader);
450+
state = parseSpecificMediaBlock(lines);
451+
}
399452

400453
/****************** MEDIA ***********************/
401454

@@ -634,7 +687,6 @@ else if (worldParsed[0].equalsIgnoreCase("prevent_media_in"))
634687
}
635688
}
636689
}
637-
638690
/* Set diffusion constants */
639691
double[] diffusionConsts = new double[numMedia];
640692
double defaultDiffConst = pParams.getDefaultDiffusionConstant();
@@ -649,6 +701,22 @@ else if (worldParsed[0].equalsIgnoreCase("prevent_media_in"))
649701
}
650702
}
651703
world.setDiffusionConstants(diffusionConsts);
704+
if(substrate)
705+
{
706+
world.setSubstrateDiffusion(substrateDiffConsts);
707+
world.setSubstrateLayout(substrateLayout);
708+
}
709+
if(modelDiffusion){
710+
world.setModelDiffusivity(modelDiffConsts);
711+
}
712+
if(specific)
713+
{
714+
world.setSpecificMedia(specificMedia);
715+
}
716+
if(friction)
717+
{
718+
world.setSubstrateFriction(substrateFrictionConsts);
719+
}
652720
System.out.println("Done!");
653721
}
654722
else if(c.getParameters().getNumLayers()>1)
@@ -1109,6 +1177,184 @@ private LoaderState parseMediaDiffusionConstantsBlock(List<String> lines, Map<In
11091177

11101178
}
11111179

1180+
private LoaderState parseSubstrateDiffusionConstantsBlock(List<String> lines, int numMedia) throws LayoutFileException,
1181+
NumberFormatException
1182+
{
1183+
/* the 'diffusion_constants' block is taken from the way of doing it in the Model files, so it looks like this:
1184+
*
1185+
* diffusion_constants <default>
1186+
* <medium number> <diff_const>
1187+
* <medium number> <diff_const>
1188+
* //
1189+
*/
1190+
Integer i = 0;
1191+
substrateDiffConsts = new double[lines.size()][numMedia];
1192+
for (String line : lines)
1193+
{
1194+
lineCount++;
1195+
if (line.length() == 0)
1196+
continue;
1197+
1198+
String[] diffConstParsed = line.split("\\s+");
1199+
if (diffConstParsed.length != numMedia)
1200+
throw new LayoutFileException("Each line of the 'diffusion_constants' block should have two tokens.\n The first should be the index of the medium component, followed by its (non-default) diffusion constant.", lineCount);
1201+
1202+
else
1203+
{
1204+
for(int j = 0;j<numMedia;j++)
1205+
{
1206+
substrateDiffConsts[i][j] = Double.parseDouble(diffConstParsed[j]);
1207+
}
1208+
i++;
1209+
}
1210+
}
1211+
return LoaderState.OK;
1212+
1213+
}
1214+
1215+
private LoaderState parseSubstrateFrictionConstantsBlock(List<String> lines) throws LayoutFileException,
1216+
NumberFormatException
1217+
{
1218+
/* the 'diffusion_constants' block is taken from the way of doing it in the Model files, so it looks like this:
1219+
*
1220+
* diffusion_constants <default>
1221+
* <medium number> <diff_const>
1222+
* <medium number> <diff_const>
1223+
* //
1224+
*/
1225+
Integer i = 0;
1226+
substrateFrictionConsts = new double[lines.size()][models.length];
1227+
for (String line : lines)
1228+
{
1229+
lineCount++;
1230+
if (line.length() == 0)
1231+
continue;
1232+
1233+
String[] diffConstParsed = line.split("\\s+");
1234+
if (diffConstParsed.length != models.length)
1235+
throw new LayoutFileException("Each line of the 'diffusion_constants' block should have two tokens.\n The first should be the index of the medium component, followed by its (non-default) diffusion constant.", lineCount);
1236+
1237+
else
1238+
{
1239+
for(int j = 0;j<models.length;j++)
1240+
{
1241+
substrateFrictionConsts[i][j] = Double.parseDouble(diffConstParsed[j]);
1242+
}
1243+
i++;
1244+
}
1245+
}
1246+
return LoaderState.OK;
1247+
1248+
}
1249+
private LoaderState parseModelDiffusionConstantsBlock(List<String> lines, int numMedia) throws LayoutFileException,
1250+
NumberFormatException
1251+
{
1252+
/* the 'diffusion_constants' block is taken from the way of doing it in the Model files, so it looks like this:
1253+
*
1254+
* diffusion_constants <default>
1255+
* <medium number> <diff_const>
1256+
* <medium number> <diff_const>
1257+
* //
1258+
*/
1259+
Integer i = 0;
1260+
modelDiffConsts = new double[lines.size()][numMedia];
1261+
for (String line : lines)
1262+
{
1263+
lineCount++;
1264+
if (line.length() == 0)
1265+
continue;
1266+
1267+
String[] diffConstParsed = line.split("\\s+");
1268+
if (diffConstParsed.length != numMedia)
1269+
throw new LayoutFileException("Each line of the 'diffusion_constants' block should have two tokens.\n The first should be the index of the medium component, followed by its (non-default) diffusion constant.", lineCount);
1270+
1271+
else
1272+
{
1273+
for(int j = 0;j<numMedia;j++)
1274+
{
1275+
modelDiffConsts[i][j] = Double.parseDouble(diffConstParsed[j]);
1276+
}
1277+
i++;
1278+
}
1279+
}
1280+
return LoaderState.OK;
1281+
1282+
}
1283+
1284+
private LoaderState parseSubstrateLayoutBlock(List<String> lines,int cols,int rows) throws LayoutFileException,
1285+
NumberFormatException
1286+
{
1287+
/* the 'diffusion_constants' block is taken from the way of doing it in the Model files, so it looks like this:
1288+
*
1289+
* diffusion_constants <default>
1290+
* <medium number> <diff_const>
1291+
* <medium number> <diff_const>
1292+
* //
1293+
*/
1294+
if (lines.size() != rows)
1295+
throw new LayoutFileException("Each line of the 'diffusion_constants' block should have two tokens.\n The first should be the index of the medium component, followed by its (non-default) diffusion constant.", lineCount);
1296+
else
1297+
{
1298+
Integer i = 0;
1299+
substrateLayout = new int[cols][rows];
1300+
for (String line : lines)
1301+
{
1302+
lineCount++;
1303+
if (line.length() == 0)
1304+
continue;
1305+
1306+
String[] layoutParsed = line.split("\\s+");
1307+
if (layoutParsed.length != cols)
1308+
throw new LayoutFileException("Each line of the 'diffusion_constants' block should have two tokens.\n The first should be the index of the medium component, followed by its (non-default) diffusion constant.", lineCount);
1309+
1310+
else
1311+
{
1312+
for(int j = 0;j<cols;j++)
1313+
{
1314+
substrateLayout[j][i] = Integer.parseInt(layoutParsed[j]);
1315+
}
1316+
i++;
1317+
}
1318+
}
1319+
}
1320+
return LoaderState.OK;
1321+
1322+
}
1323+
1324+
private LoaderState parseSpecificMediaBlock(List<String> lines) throws LayoutFileException,
1325+
NumberFormatException
1326+
{
1327+
/* the 'diffusion_constants' block is taken from the way of doing it in the Model files, so it looks like this:
1328+
*
1329+
* diffusion_constants <default>
1330+
* <medium number> <diff_const>
1331+
* <medium number> <diff_const>
1332+
* //
1333+
*/
1334+
Integer i = 0;
1335+
specificMedia = new double[4][lines.size()];
1336+
for (String line : lines)
1337+
{
1338+
lineCount++;
1339+
if (line.length() == 0)
1340+
continue;
1341+
1342+
String[] sMediaParsed = line.split("\\s+");
1343+
if (sMediaParsed.length != 4)
1344+
throw new LayoutFileException("Each line of the 'specific_media' block should have two tokens.\n The first should be the index of the medium component, followed by its (non-default) diffusion constant.", lineCount);
1345+
1346+
else
1347+
{
1348+
for(int j = 0;j<4;j++)
1349+
{
1350+
specificMedia[j][i] = Double.parseDouble(sMediaParsed[j]);
1351+
}
1352+
i++;
1353+
}
1354+
}
1355+
return LoaderState.OK;
1356+
}
1357+
11121358
private LoaderState parseInitialPopBlock(String[] header, List<String> lines) throws LayoutFileException,
11131359
NumberFormatException
11141360
{

0 commit comments

Comments
 (0)