def _data_liftover(lift_over_genomes): """Download chain files for running liftOver. Does not install liftOver binaries automatically. """ lo_dir = os.path.join(env.data_files, "liftOver") if not env.safe_exists(lo_dir): env.safe_run("mkdir %s" % lo_dir) lo_base_url = "ftp://hgdownload.cse.ucsc.edu/goldenPath/%s/liftOver/%s" lo_base_file = "%sTo%s.over.chain.gz" for g1 in lift_over_genomes: for g2 in [g for g in lift_over_genomes if g != g1]: g2u = g2[0].upper() + g2[1:] cur_file = lo_base_file % (g1, g2u) non_zip = os.path.splitext(cur_file)[0] worked = False with cd(lo_dir): if not env.safe_exists(non_zip): result = shared._remote_fetch(env, "%s" % (lo_base_url % (g1, cur_file)), allow_fail=True) # Lift over back and forths don't always exist # Only move forward if we found the file if result: worked = True env.safe_run("gunzip %s" % result) if worked: ref_parts = [g1, g2, os.path.join(lo_dir, non_zip)] galaxy.update_loc_file("liftOver.loc", ref_parts)