comparison imagej2_skeletonize3d.py @ 1:269923244cc8 draft

planemo upload commit 18df9e67efd4adafcde4eb9b62cd815e4afe9733-dirty
author iuc
date Wed, 26 Aug 2015 14:38:34 -0400
parents 8b787f641b9c
children
comparison
equal deleted inserted replaced
0:8b787f641b9c 1:269923244cc8
7 import imagej2_base_utils 7 import imagej2_base_utils
8 8
9 parser = argparse.ArgumentParser() 9 parser = argparse.ArgumentParser()
10 parser.add_argument( '--input', dest='input', help='Path to the input file' ) 10 parser.add_argument( '--input', dest='input', help='Path to the input file' )
11 parser.add_argument( '--input_datatype', dest='input_datatype', help='Datatype of the input image' ) 11 parser.add_argument( '--input_datatype', dest='input_datatype', help='Datatype of the input image' )
12 parser.add_argument( '--black_background', dest='black_background', help='Black background' )
12 parser.add_argument( '--jython_script', dest='jython_script', help='Path to the Jython script' ) 13 parser.add_argument( '--jython_script', dest='jython_script', help='Path to the Jython script' )
13 parser.add_argument( '--max_heap_size_type', dest='max_heap_size_type', help='Type (default or megabytes) of max_heap_size value' )
14 parser.add_argument( '--max_heap_size', dest='max_heap_size', help='Maximum size of the memory allocation pool used by the JVM.' )
15 parser.add_argument( '--output', dest='output', help='Path to the output file' ) 14 parser.add_argument( '--output', dest='output', help='Path to the output file' )
16 parser.add_argument( '--output_datatype', dest='output_datatype', help='Datatype of the output image' ) 15 parser.add_argument( '--output_datatype', dest='output_datatype', help='Datatype of the output image' )
17 args = parser.parse_args() 16 args = parser.parse_args()
18 17
19 tmp_dir = imagej2_base_utils.get_temp_dir() 18 tmp_dir = imagej2_base_utils.get_temp_dir()
20 # ImageJ expects valid image file extensions, so the Galaxy .dat extension does not 19 # ImageJ expects valid image file extensions, so the Galaxy .dat extension does not
21 # work for some features. The following creates a symlink with an appropriate file 20 # work for some features. The following creates a symlink with an appropriate file
22 # extension that points to the Galaxy dataset. This symlink is used by ImageJ. 21 # extension that points to the Galaxy dataset. This symlink is used by ImageJ.
23 tmp_input_path = imagej2_base_utils.get_input_image_path( tmp_dir, args.input, args.input_datatype ) 22 tmp_input_path = imagej2_base_utils.get_input_image_path( tmp_dir, args.input, args.input_datatype )
24 tmp_output_path = imagej2_base_utils.get_temporary_image_path( tmp_dir, args.output_datatype ) 23 tmp_output_path = imagej2_base_utils.get_temporary_image_path( tmp_dir, args.output_datatype )
25 # Set the size of the memory allocation pool used by the JVM.
26 memory_size = imagej2_base_utils.get_max_heap_size_value( args.max_heap_size_type, args.max_heap_size )
27 # Define command response buffers. 24 # Define command response buffers.
28 tmp_out = tempfile.NamedTemporaryFile().name 25 tmp_out = tempfile.NamedTemporaryFile().name
29 tmp_stdout = open( tmp_out, 'wb' ) 26 tmp_stdout = open( tmp_out, 'wb' )
30 tmp_err = tempfile.NamedTemporaryFile().name 27 tmp_err = tempfile.NamedTemporaryFile().name
31 tmp_stderr = open( tmp_err, 'wb' ) 28 tmp_stderr = open( tmp_err, 'wb' )
32 # Java writes a lot of stuff to stderr, so we'll specify a file for handling actual errors. 29 # Java writes a lot of stuff to stderr, so we'll specify a file for handling actual errors.
33 error_log = tempfile.NamedTemporaryFile( delete=False ).name 30 error_log = tempfile.NamedTemporaryFile( delete=False ).name
34 # Build the command line. 31 # Build the command line.
35 cmd = imagej2_base_utils.get_base_command_imagej2( memory_size, jython_script=args.jython_script ) 32 cmd = imagej2_base_utils.get_base_command_imagej2( None, jython_script=args.jython_script )
36 if cmd is None: 33 if cmd is None:
37 imagej2_base_utils.stop_err( "ImageJ not found!" ) 34 imagej2_base_utils.stop_err( "ImageJ not found!" )
38 cmd += ' %s' % error_log 35 cmd += ' %s' % error_log
39 cmd += ' %s' % tmp_input_path 36 cmd += ' %s' % tmp_input_path
37 cmd += ' %s' % args.black_background
40 cmd += ' %s' % tmp_output_path 38 cmd += ' %s' % tmp_output_path
41 cmd += ' %s' % args.output_datatype 39 cmd += ' %s' % args.output_datatype
42 # Run the command. 40 # Run the command.
43 proc = subprocess.Popen( args=cmd, stderr=tmp_stderr, stdout=tmp_stdout, shell=True ) 41 proc = subprocess.Popen( args=cmd, stderr=tmp_stderr, stdout=tmp_stdout, shell=True )
44 rc = proc.wait() 42 rc = proc.wait()