if not os.path.exists(scratch_dir): os.makedirs(scratch_dir) full_source = os.path.join(old_phylesystem_study, source_study, source_study + '.json') dest_dir = os.path.split(dest_full)[0] assert(os.path.exists(full_source)) if os.path.exists(dest_full): debug('Skipping {} because output exists'.format(f)) continue # read input and do the phylografter_workaround to valid 0.0.0 syntax # store in scratch. valid_bf = os.path.join(scratch_dir, 'v0.0.0-' + source_study + '.json') debug('Raw phylografter from "{}" to valid 0.0.0 NexSON at "{}" ...'.format(full_source, valid_bf)) with codecs.open(full_source, mode='rU', encoding='utf-8') as inp: obj = json.load(inp) try: workaround_phylografter_export_diffs(obj, valid_bf) except: _LOG.exception('Exception in workaround_phylografter_export_diffs for study ' + f) failed.append(f) continue # Convert to 1.2.1 unchecked_hbf = os.path.join(scratch_dir, 'v1.2.1-' + source_study + '.json') debug('Converting cleaned 0.0.0 NexSON from "{}" to unchecked 1.2.1 NexSON at "{}" ...'.format(valid_bf, unchecked_hbf)) invoc = [sys.executable, conversion_script, '-s', '-e', '1.2.1', '-o', unchecked_hbf,
source_study + '.json') dest_dir = os.path.split(dest_full)[0] assert (os.path.exists(full_source)) if os.path.exists(dest_full): debug('Skipping {} because output exists'.format(f)) continue # read input and do the phylografter_workaround to valid 0.0.0 syntax # store in scratch. valid_bf = os.path.join(scratch_dir, 'v0.0.0-' + source_study + '.json') debug('Raw phylografter from "{}" to valid 0.0.0 NexSON at "{}" ...'. format(full_source, valid_bf)) with codecs.open(full_source, mode='rU', encoding='utf-8') as inp: obj = json.load(inp) try: workaround_phylografter_export_diffs(obj, valid_bf) except: _LOG.exception( 'Exception in workaround_phylografter_export_diffs for study ' + f) failed.append(f) continue # Convert to 1.2.1 unchecked_hbf = os.path.join(scratch_dir, 'v1.2.1-' + source_study + '.json') debug( 'Converting cleaned 0.0.0 NexSON from "{}" to unchecked 1.2.1 NexSON at "{}" ...' .format(valid_bf, unchecked_hbf)) invoc = [ sys.executable, conversion_script, '-s', '-e', '1.2.1', '-o',
#!/usr/bin/env python import sys, json, codecs from peyotl.phylografter.nexson_workaround import workaround_phylografter_export_diffs inpfn = sys.argv[1] outfn = sys.argv[2] inp = codecs.open(inpfn, mode='rU', encoding='utf-8') obj = json.load(inp) workaround_phylografter_export_diffs(obj, outfn)
#!/usr/bin/env python import sys, json, codecs from peyotl.phylografter.nexson_workaround import workaround_phylografter_export_diffs inpfn = sys.argv[1] outfn = sys.argv[2] with codecs.open(inpfn, mode='rU', encoding='utf-8') as inp: obj = json.load(inp) workaround_phylografter_export_diffs(obj, outfn)