How to use the refgenconf.CFG_ENV_VARS function in refgenconf

To help you get started, we’ve selected a few refgenconf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github databio / refgenie / refgenie / add_assets_igenome.py View on Github external
def build_argparser():
    """
    Build a parser for this tool

    :return argparse.ArgumentParser: constructed parser
    """
    parser = argparse.ArgumentParser(description='Integrates every asset from the downloaded iGenomes'
                                                 ' tarball/directory with Refgenie asset management system')
    parser.add_argument('-p', '--path', dest="path", type=str,
                        help='path to the desired genome tarball or directory to integrate', required=True)
    parser.add_argument('-g', '--genome', dest="genome", type=str,  help='name to be assigned to the selected genome',
                        required=True)
    parser.add_argument('-c', '--config', dest="config", type=str,
                        help="path to local genome configuration file. Optional if '{}' environment variable is set.".
                        format(", ".join(refgenconf.CFG_ENV_VARS)), required=False)
    return parser
github databio / refgenie / refgenie / add_assets_igenome.py View on Github external
def main():
    """ main workflow """
    parser = build_argparser()
    args, remaining_args = parser.parse_known_args()
    cfg = select_config(args.config, refgenconf.CFG_ENV_VARS, check_exist=True, strict_env=True)
    if not cfg:
        raise MissingGenomeConfigError(args.config)
    rgc = refgenconf.RefGenConf(filepath=cfg, writable=True)
    pths = [args.path, mkabs(args.path, rgc.genome_folder)]
    if not untar_or_copy(pths[0], os.path.join(rgc.genome_folder, args.genome)) \
            and not untar_or_copy(pths[1], os.path.join(rgc.genome_folder, args.genome)):
        rgc.unlock()
        raise OSError("Path '{}' does not exist. Tried: {}".format(args.path, " and ".join(pths)))
    path_components = [rgc.genome_folder] + [args.genome] + ["*"] * 3 + ["Sequence"]
    assets_paths = glob(os.path.join(*path_components))
    assert len(assets_paths) > 0, OSError("Your iGenomes directory is corrupted, more than one directory matched by {}."
                                          "\nMatched dirs: {}".format(os.path.join(*path_components),
                                                                      ", ".join(assets_paths)))
    assets_path = assets_paths[0]
    asset_names = [d for d in os.listdir(assets_path) if os.path.isdir(assets_path)]
    processed = []
github databio / refgenie / refgenie / exceptions.py View on Github external
def __init__(self, conf_file=None):
        """
        Create the error message, using optionally an attempt filepath.

        :param str conf_file: path attempted to be used as genome config file
        """
        msg = "You must provide a config file either as an argument or via an environment variable: {}"\
            .format(", ".join(CFG_ENV_VARS))
        if conf_file:
            msg = "Not a file {} -- {}.".format(conf_file, msg)
        super(MissingGenomeConfigError, self).__init__(msg)
github databio / refgenie / refgenie / refgenie.py View on Github external
epilog=additional_description)

    subparsers = parser.add_subparsers(dest="command")

    def add_subparser(cmd, description):
        return subparsers.add_parser(
            cmd, description=description, help=description)

    sps = {}
    for cmd, desc in SUBPARSER_MESSAGES.items():
        sps[cmd] = add_subparser(cmd, desc)
        # It's required for init
        sps[cmd].add_argument(
            '-c', '--genome-config', required=(cmd == INIT_CMD), dest="genome_config",
            help="Path to local genome configuration file. Optional if {} environment variable is set."
                .format(", ".join(refgenconf.CFG_ENV_VARS)))

    sps[INIT_CMD].add_argument('-s', '--genome-server', nargs='+', default=DEFAULT_SERVER,
                               help="URL(s) to use for the {} attribute in config file. Default: {}."
                               .format(CFG_SERVERS_KEY, DEFAULT_SERVER))
    sps[INIT_CMD].add_argument('-f', '--genome-folder',
                               help="Absolute path to parent folder refgenie-managed assets.")
    sps[INIT_CMD].add_argument('-a', '--genome-archive-folder',
                               help="Absolute path to parent archive folder refgenie-managed assets; used by refgenieserver.")
    sps[INIT_CMD].add_argument('-b', '--genome-archive-config',
                               help="Absolute path to desired archive config file; used by refgenieserver.")
    sps[INIT_CMD].add_argument('-u', '--remote-url-base',
                               help="URL to use as an alternative, remote archive location; used by refgenieserver.")
    sps[INIT_CMD].add_argument('-j', '--settings-json',
                               help="Absolute path to a JSON file with the key "
                                    "value pairs to inialize the configuration "
                                    "file with. Overwritten by itemized specifications.")

refgenconf

A standardized configuration object for reference genome assemblies

BSD-2-Clause
Latest version published 3 years ago

Package Health Score

49 / 100
Full package analysis

Similar packages