def _main(): parser = ArgumentParser() parser.add_argument("-v", dest="verbose", action="store_true") parser.add_argument("--debug", dest="debug", action="store_true") parser.add_argument("--dir", dest='directory', type=str, default='') parser.add_argument("--cpu", dest='cores', type=int, default=1) parser.add_argument(dest="targets", nargs="*") args = parser.parse_args() APPSPATH = os.path.expanduser("~/.etetoolkit/ext_apps-latest/") ETEHOMEDIR = os.path.expanduser("~/.etetoolkit/") if pexist(pjoin('/etc/etetoolkit/', 'ext_apps-latest')): # if a copy of apps is part of the ete distro, use if by default APPSPATH = pjoin('/etc/etetoolkit/', 'ext_apps-latest') ETEHOMEDIR = '/etc/etetoolkit/' else: # if not, try a user local copy APPSPATH = pjoin(ETEHOMEDIR, 'ext_apps-latest') TARGET_DIR = args.directory while not pexist(TARGET_DIR): TARGET_DIR = input('target directory? [%s]:' % ETEHOMEDIR).strip() if TARGET_DIR == '': TARGET_DIR = ETEHOMEDIR break if TARGET_DIR == ETEHOMEDIR: try: os.mkdir(ETEHOMEDIR) except OSError: pass version_file = "latest.tar.gz" print(colorify('Downloading latest version of tools...', "green"), file=sys.stderr) sys.stderr.flush() urlretrieve( "https://github.com/jhcepas/ext_apps/archive/%s" % version_file, pjoin(TARGET_DIR, version_file)) print(colorify('Decompressing...', "green"), file=sys.stderr) tfile = tarfile.open(pjoin(TARGET_DIR, version_file), 'r:gz') tfile.extractall(TARGET_DIR) print(colorify('Compiling tools...', "green"), file=sys.stderr) sys.path.insert(0, pjoin(TARGET_DIR, 'ext_apps-latest')) import compile_all s = compile_all.compile_all(targets=args.targets, verbose=args.verbose, cores=args.cores) return s
def get_latest_nprdp(basedir): avail_dbs = [] for fname in glob(os.path.join(basedir, "*.db")): m = re.search("npr\.([\d\.]+)\.db", fname) if m: avail_dbs.append([float(m.groups()[0]), fname]) if avail_dbs: avail_dbs.sort() print(avail_dbs) if avail_dbs: last_db = avail_dbs[-1][1] print("Using latest db file available:", os.path.basename(last_db)) return last_db else: #tries compressed data compressed_path = pjoin(basedir, "nprdata.tar.gz") if pexist(compressed_path): import tarfile tar = tarfile.open(compressed_path) for member in tar: print(member.name) m = re.search("npr\.([\d\.]+)\.db", member.name) if m: print(member) avail_dbs.append([float(m.groups()[0]), member]) return None
def _main(): parser = ArgumentParser() parser.add_argument("-v", dest="verbose", action="store_true") parser.add_argument("--debug", dest="debug", action="store_true") parser.add_argument("--dir", dest='directory', type=str, default='') parser.add_argument("--cpu", dest='cores', type=int, default=1) parser.add_argument(dest="targets", nargs="*") args = parser.parse_args() APPSPATH = os.path.expanduser("~/.etetoolkit/ext_apps-latest/") ETEHOMEDIR = os.path.expanduser("~/.etetoolkit/") if pexist(pjoin('/etc/etetoolkit/', 'ext_apps-latest')): # if a copy of apps is part of the ete distro, use if by default APPSPATH = pjoin('/etc/etetoolkit/', 'ext_apps-latest') ETEHOMEDIR = '/etc/etetoolkit/' else: # if not, try a user local copy APPSPATH = pjoin(ETEHOMEDIR, 'ext_apps-latest') TARGET_DIR = args.directory while not pexist(TARGET_DIR): TARGET_DIR = input('target directory? [%s]:' %ETEHOMEDIR).strip() if TARGET_DIR == '': TARGET_DIR = ETEHOMEDIR break if TARGET_DIR == ETEHOMEDIR: try: os.mkdir(ETEHOMEDIR) except OSError: pass version_file = "latest.tar.gz" print (colorify('Downloading latest version of tools...', "green"), file=sys.stderr) sys.stderr.flush() urlretrieve("https://github.com/jhcepas/ext_apps/archive/%s" %version_file, pjoin(TARGET_DIR, version_file)) print(colorify('Decompressing...', "green"), file=sys.stderr) tfile = tarfile.open(pjoin(TARGET_DIR, version_file), 'r:gz') tfile.extractall(TARGET_DIR) print(colorify('Compiling tools...', "green"), file=sys.stderr) sys.path.insert(0, pjoin(TARGET_DIR, 'ext_apps-latest')) import compile_all s = compile_all.compile_all(targets=args.targets, verbose=args.verbose, cores=args.cores) return s
def clear_tempdir(): base_dir = GLOBALS.get("basedir", None) out_dir = GLOBALS["output_dir"] scratch_dir = GLOBALS.get("scratch_dir", GLOBALS.get("dbdir", base_dir)) if base_dir and base_dir != out_dir: try: log.log(20, "Copying new db files to output directory %s..." %out_dir) if not pexist(out_dir): os.makedirs(out_dir) if os.system("cp -a %s/* %s/" %(scratch_dir, out_dir)): log.error("Could not copy data from scratch directory!") log.log(20, "Deleting temp directory %s..." %scratch_dir) except Exception as e: print(e) log.error("Could not copy data from scratch directory!") pass # By all means, try to remove temp data try: shutil.rmtree(scratch_dir) except OSError: pass
else: median = nums[midPos] return median _max = max _min = min else: _std = numpy.std _max = numpy.max _min = numpy.min _mean = numpy.mean _median = numpy.median log = logging.getLogger("main") DEBUG = lambda: log.level <= 10 hascontent = lambda f: pexist(f) and os.path.getsize(f) > 0 GLOBALS = { "running_jobs": set(), # Keeps a list of jobs consuming cpu "cached_status": {}, # Saves job and task statuses by id to be # used them within the same get_status cycle } class _DataTypes(object): def __init__(self): self.msf = 100 self.alg_fasta = 200 self.alg_phylip = 201 self.alg_nt_fasta = 202 self.alg_nt_phylip = 203 self.clean_alg_fasta = 225