mcellteam / cellblender

Create, Simulate, Visualize, and Analyze Realistic 3D Cell Models
http://mcell.org/tutorials/index.html
GNU General Public License v2.0
62 stars 10 forks source link

Conflicts in MDL String Reaction Output #96

Open cnlbob opened 8 years ago

cnlbob commented 8 years ago

The current implementation of the MDL String feature can create file naming conflicts.

Assume that "vm" is a molecule that's being counted in the world. Also assume that you'd like to count "vm" inside some other object as well.

The first counting of "vm" in the world will generate an output file named "vm.World.dat". Right now, the MDL counting of "vm" will produce the same file name and MCell won't run:

   Fatal error: COUNT statements in the same reaction data output 
          block should have unique output file names 
          ("./react_data/seed_00001/vm.World.dat" appears more than once)

The problem can be seen in the code from "export_mcell_mdl.py" here:

elif rxn_output.rxn_or_mol == 'MDLString':
  outputStr = rxn_output.mdl_string
  output_file = rxn_output.molecule_name
  if outputStr not in ['', None]:
    outputStr = '{%s} =>  "./react_data/seed_" & seed & \"/%s.World.dat\"\n' % (outputStr, output_file)
    out_file.write(outputStr)
  else:
    print('Found invalid reaction output {0}'.format(rxn_output.name))

The output file name for the MDL String is using the "World" name, and this conflicts with counting that same molecule in the World. It's also not really accurate since it's not known where that molecule is being counted (unless we actually parse the MDL string itself). We might replace "World" with "MDL" or "CustomMDL" or something other than "World" as a quick patch. But then, multiple MDL String output definitions using the same molecule would also collide. Another approach would be to specify the full MDL line (file name and everything), but even then there's a problem when running with multiple seeds.

This may require some more careful thinking about how to ensure that proper file names are generated from the MDL output statement.