diff --git a/src/main/java/org/neuroml/JNeuroML.java b/src/main/java/org/neuroml/JNeuroML.java index 3595419..2cc3dff 100644 --- a/src/main/java/org/neuroml/JNeuroML.java +++ b/src/main/java/org/neuroml/JNeuroML.java @@ -105,6 +105,7 @@ public class JNeuroML public static final String CELLML_EXPORT_FLAG = "-cellml"; public static final String NEURON_EXPORT_FLAG = "-neuron"; + public static final String NEURON_COMPILE_FLAG = "-compile"; public static final String PYNN_EXPORT_FLAG = "-pynn"; public static final String RUN_PYNN_NEURON_FLAG = "-run-neuron"; @@ -151,9 +152,10 @@ public class JNeuroML + " Load LEMSFile.xml using jLEMS, and convert it to SED-ML format\n\n" + " " + JNML_SCRIPT + " LEMSFile.xml " + NEURON_EXPORT_FLAG + " [" + NO_GUI_FLAG + "] [" + RUN_FLAG+ "] ["+OUTPUT_DIR_FLAG+" dir]\n" - + " Load LEMSFile.xml using jLEMS, and convert it to NEURON format \n" - + " " + NO_GUI_FLAG+ " Do not generate graphical elements in NEURON, just run, save data and quit\n" - + " " + RUN_FLAG + " Compile NMODL files and run the main NEURON hoc file (Linux only currently)\n" + + " Load LEMSFile.xml using jLEMS, and convert it to NEURON format, OR load ModelFile.nml and generate hoc and mod files for cells, channels, synapses \n" + + " " + NO_GUI_FLAG+ " Do not generate graphical elements in NEURON, just run, save data and quit (if input file is LEMS file)\n" + + " " + RUN_FLAG + " Compile NMODL files and run the main NEURON hoc file (Linux only currently; only with LEMS file)\n" + + " " + NEURON_COMPILE_FLAG + " Compile NMODL files, but don't run (Linux only currently)\n" + " " + OUTPUT_DIR_FLAG + " Generate NEURON files in another directory, dir\n\n" + " " + JNML_SCRIPT + " NMLFile.nml " + SVG_FLAG + "\n" @@ -234,6 +236,17 @@ private static Lems loadLemsFile(File lemsFile, boolean includeConnectionsFromHD return Utils.readLemsNeuroMLFile(lemsFile,includeConnectionsFromHDF5).getLems(); } + private static Lems loadNmlFileAsLems(File nmlFile) throws LEMSException, NeuroMLException, IOException + { + if(!nmlFile.exists()) + { + System.err.println("File does not exist: " + nmlFile.getAbsolutePath()); + showUsage(); + System.exit(1); + } + return Utils.readNeuroMLFile(nmlFile).getLems(); + } + private static String generateFormatFilename(File lemsFile, Format format, String extra) { String filename = lemsFile.getName(); @@ -425,19 +438,34 @@ else if(args[0].equals(VALIDATE_V1_FLAG)) else if(args[1].equals(NEURON_EXPORT_FLAG)) { - File lemsFile = (new File(args[0])).getCanonicalFile(); - Lems lems = loadLemsFile(lemsFile); + File lemsNmlFile = (new File(args[0])).getCanonicalFile(); + Lems lems = null; + + if (lemsNmlFile.getName().endsWith("nml")) + { + lems = loadNmlFileAsLems(lemsNmlFile); + } + else + { + lems = loadLemsFile(lemsNmlFile); + } boolean nogui = false; boolean run = false; - File outputDir = lemsFile.getParentFile(); - + boolean compile = false; + File outputDir = lemsNmlFile.getParentFile(); + int i = 2; while (i