Mercurial > repos > rv43 > chess_tomo
comparison workflow/run_tomo.py @ 11:9c48ef48c604 draft
planemo upload for repository https://github.com/rolfverberg/galaxytools commit f8c4bdb31c20c468045ad5e6eb255a293244bc6c
| author | rv43 |
|---|---|
| date | Tue, 21 Mar 2023 13:31:00 +0000 |
| parents | 1dbb29320ce8 |
| children | da3116b620b3 |
comparison
equal
deleted
inserted
replaced
| 10:0f553c8d7b98 | 11:9c48ef48c604 |
|---|---|
| 163 f'processors and reduced to {cpu_count()}') | 163 f'processors and reduced to {cpu_count()}') |
| 164 self.num_core= cpu_count() | 164 self.num_core= cpu_count() |
| 165 | 165 |
| 166 def read(self, filename): | 166 def read(self, filename): |
| 167 logger.info(f'looking for {filename}') | 167 logger.info(f'looking for {filename}') |
| 168 extension = os_path.splitext(filename)[1] | 168 if self.galaxy_flag: |
| 169 if extension == '.yml' or extension == '.yaml' or self.galaxy_flag and extension == '.dat': | 169 try: |
| 170 with open(filename, 'r') as f: | 170 with open(filename, 'r') as f: |
| 171 config = safe_load(f) | 171 config = safe_load(f) |
| 172 # if len(config) > 1: | 172 return(config) |
| 173 # raise ValueError(f'Multiple root entries in {filename} not yet implemented') | 173 except: |
| 174 # if len(list(config.values())[0]) > 1: | 174 try: |
| 175 # raise ValueError(f'Multiple sample maps in {filename} not yet implemented') | 175 with NXFile(filename, mode='r') as nxfile: |
| 176 return(config) | 176 nxroot = nxfile.readfile() |
| 177 elif extension == '.nxs': | 177 return(nxroot) |
| 178 with NXFile(filename, mode='r') as nxfile: | 178 except: |
| 179 nxroot = nxfile.readfile() | 179 raise ValueError(f'Unable to open ({filename})') |
| 180 return(nxroot) | 180 else: |
| 181 else: | 181 extension = os_path.splitext(filename)[1] |
| 182 raise ValueError(f'Invalid filename extension ({extension})') | 182 if extension == '.yml' or extension == '.yaml': |
| 183 with open(filename, 'r') as f: | |
| 184 config = safe_load(f) | |
| 185 # if len(config) > 1: | |
| 186 # raise ValueError(f'Multiple root entries in {filename} not yet implemented') | |
| 187 # if len(list(config.values())[0]) > 1: | |
| 188 # raise ValueError(f'Multiple sample maps in {filename} not yet implemented') | |
| 189 return(config) | |
| 190 elif extension == '.nxs': | |
| 191 with NXFile(filename, mode='r') as nxfile: | |
| 192 nxroot = nxfile.readfile() | |
| 193 return(nxroot) | |
| 194 else: | |
| 195 raise ValueError(f'Invalid filename extension ({extension})') | |
| 183 | 196 |
| 184 def write(self, data, filename): | 197 def write(self, data, filename): |
| 185 extension = os_path.splitext(filename)[1] | 198 extension = os_path.splitext(filename)[1] |
| 186 if extension == '.yml' or extension == '.yaml': | 199 if extension == '.yml' or extension == '.yaml': |
| 187 with open(filename, 'w') as f: | 200 with open(filename, 'w') as f: |
