Mercurial > repos > rv43 > tomo
comparison tomo_combine.py @ 71:1cf15b61cd83 draft
planemo upload for repository https://github.com/rolfverberg/galaxytools commit 366e516aef0735af2998c6ff3af037181c8d5213
| author | rv43 | 
|---|---|
| date | Mon, 20 Mar 2023 13:56:57 +0000 | 
| parents | fba792d5f83b | 
| children | 
   comparison
  equal
  deleted
  inserted
  replaced
| 70:97c4e2cbbad9 | 71:1cf15b61cd83 | 
|---|---|
| 21 help='''Full or relative path to the input file (in Nexus format).''') | 21 help='''Full or relative path to the input file (in Nexus format).''') | 
| 22 parser.add_argument('-o', '--output_file', | 22 parser.add_argument('-o', '--output_file', | 
| 23 required=False, | 23 required=False, | 
| 24 type=pathlib.Path, | 24 type=pathlib.Path, | 
| 25 help='''Full or relative path to the output file (in yaml format).''') | 25 help='''Full or relative path to the output file (in yaml format).''') | 
| 26 parser.add_argument('--galaxy_flag', | |
| 27 action='store_true', | |
| 28 help='''Use this flag to run the scripts as a galaxy tool.''') | |
| 26 parser.add_argument('-l', '--log', | 29 parser.add_argument('-l', '--log', | 
| 27 # type=argparse.FileType('w'), | 30 # type=argparse.FileType('w'), | 
| 28 default=sys.stdout, | 31 default=sys.stdout, | 
| 29 help='Logging stream or filename') | 32 help='Logging stream or filename') | 
| 30 parser.add_argument('--log_level', | 33 parser.add_argument('--log_level', | 
| 31 choices=logging._nameToLevel.keys(), | 34 choices=logging._nameToLevel.keys(), | 
| 32 default='INFO', | 35 default='INFO', | 
| 33 help='''Specify a preferred logging level.''') | 36 help='''Specify a preferred logging level.''') | 
| 37 parser.add_argument('--x_bounds', | |
| 38 required=False, | |
| 39 nargs=2, | |
| 40 type=int, | |
| 41 help='''Boundaries of reconstructed images in x-direction.''') | |
| 42 parser.add_argument('--y_bounds', | |
| 43 required=False, | |
| 44 nargs=2, | |
| 45 type=int, | |
| 46 help='''Boundaries of reconstructed images in y-direction.''') | |
| 34 args = parser.parse_args() | 47 args = parser.parse_args() | 
| 35 | 48 | 
| 36 # Set log configuration | 49 # Set log configuration | 
| 37 # When logging to file, the stdout log level defaults to WARNING | 50 # When logging to file, the stdout log level defaults to WARNING | 
| 38 logging_format = '%(asctime)s : %(levelname)s - %(module)s : %(funcName)s - %(message)s' | 51 logging_format = '%(asctime)s : %(levelname)s - %(module)s : %(funcName)s - %(message)s' | 
| 61 logging.info(f'input_file = {args.input_file}') | 74 logging.info(f'input_file = {args.input_file}') | 
| 62 logging.info(f'output_file = {args.output_file}') | 75 logging.info(f'output_file = {args.output_file}') | 
| 63 logging.debug(f'log = {args.log}') | 76 logging.debug(f'log = {args.log}') | 
| 64 logging.debug(f'is log stdout? {args.log is sys.stdout}') | 77 logging.debug(f'is log stdout? {args.log is sys.stdout}') | 
| 65 logging.debug(f'log_level = {args.log_level}') | 78 logging.debug(f'log_level = {args.log_level}') | 
| 79 logging.info(f'x_bounds = {args.x_bounds}') | |
| 80 logging.info(f'y_bounds = {args.y_bounds}') | |
| 66 | 81 | 
| 67 # Instantiate Tomo object | 82 # Instantiate Tomo object | 
| 68 tomo = Tomo() | 83 tomo = Tomo(galaxy_flag=args.galaxy_flag) | 
| 69 | 84 | 
| 70 # Read input file | 85 # Read input file | 
| 71 data = tomo.read(args.input_file) | 86 data = tomo.read(args.input_file) | 
| 72 | 87 | 
| 73 # Combine the reconstructed tomography stacks | 88 # Combine the reconstructed tomography stacks | 
| 74 data = tomo.combine_data(data) | 89 data = tomo.combine_data(data, x_bounds=args.x_bounds, y_bounds=args.y_bounds) | 
| 75 | 90 | 
| 76 # Write output file | 91 # Write output file | 
| 77 data = tomo.write(data, args.output_file) | 92 if data is not None: | 
| 93 data = tomo.write(data, args.output_file) | |
| 78 | 94 | 
| 79 # Displaying memory usage | 95 # Displaying memory usage | 
| 80 # logging.info(f'Memory usage: {tracemalloc.get_traced_memory()}') | 96 # logging.info(f'Memory usage: {tracemalloc.get_traced_memory()}') | 
| 81 | 97 | 
| 82 # stopping memory monitoring | 98 # stopping memory monitoring | 
