当前位置: 首页>>代码示例>>Python>>正文


Python VcfPlugin.cases方法代码示例

本文整理汇总了Python中puzzle.plugins.VcfPlugin.cases方法的典型用法代码示例。如果您正苦于以下问题:Python VcfPlugin.cases方法的具体用法?Python VcfPlugin.cases怎么用?Python VcfPlugin.cases使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在puzzle.plugins.VcfPlugin的用法示例。


在下文中一共展示了VcfPlugin.cases方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load

# 需要导入模块: from puzzle.plugins import VcfPlugin [as 别名]
# 或者: from puzzle.plugins.VcfPlugin import cases [as 别名]
def load(ctx, variant_source, family_file, family_type):
    """
    Load a case into the database.

    This can be done with a config file or from command line.
    If no database was found run puzzle init first.
    """
    db_path = ctx.obj['db_path']
    if not os.path.exists(db_path):
        logger.warn("database not initialized, run 'puzzle init'")
        ctx.abort()

    logger.debug('Set puzzle backend to {0}'.format(ctx.obj['mode']))
    mode = ctx.obj['mode']
    logger.debug('Set puzzle mode to {0}'.format(ctx.obj['variant_type']))
    variant_type = ctx.obj['variant_type']

    if mode == 'vcf':
        logger.info("Initialzing VCF plugin")
        if not family_file:
            logger.error("Please provide a ped like file")
            ctx.abort()
        try:
            plugin = VcfPlugin(
                root_path=variant_source,
                case_lines=family_file,
                case_type=family_type,
                vtype=variant_type
            )
        except SyntaxError as e:
            logger.error(e.message)
            ctx.abort()

    elif mode == 'gemini':
        logger.debug("Initialzing GEMINI plugin")
        try:
            plugin = GeminiPlugin(db=variant_source, vtype=variant_type)
        except NameError:
            logger.error("Need to have gemini installed to use gemini plugin")
            ctx.abort()
        except DatabaseError as e:
            logger.error("{0} is not a valid gemini db".format(variant_source))
            logger.info("variant-source has to point to a gemini database")
            ctx.abort()

    logger.debug("Plugin setup was succesfull")
    # from gemini can create multiple cases
    store = SqlStore(db_path)

    for case_obj in plugin.cases():
        # extract case information
        logger.debug("adding case: {}".format(case_obj['case_id']))
        store.add_case(case_obj, vtype=variant_type, mode=mode)
开发者ID:brainstorm,项目名称:puzzle,代码行数:55,代码来源:cli.py

示例2: load

# 需要导入模块: from puzzle.plugins import VcfPlugin [as 别名]
# 或者: from puzzle.plugins.VcfPlugin import cases [as 别名]
def load(ctx, variant_source, family_file, family_type, root, mode,
        variant_type):
    """
    Load a variant source into the database.

    If no database was found run puzzle init first.
    
    1. VCF: If a vcf file is used it can be loaded with a ped file
    2. GEMINI: Ped information will be retreived from the gemini db
    """
    if root is None:
        #This is the default puzzle folder
        root = os.path.expanduser("~/.puzzle")

    if os.path.isfile(root):
        logger.error("'root' can't be a file")
        ctx.abort()

    logger.info("Root directory is: {}".format(root))

    db_path = os.path.join(root, 'puzzle_db.sqlite3')
    logger.info("db path is: {}".format(db_path))

    if not os.path.exists(db_path):
        logger.warn("database not initialized, run 'puzzle init'")
        ctx.abort()

    logger.debug('Set puzzle backend to {0}'.format(mode))

    logger.debug('Set variant type to {0}'.format(variant_type))

    if mode == 'vcf':
        logger.info("Initialzing VCF plugin")

        try:
            plugin = VcfPlugin(
                root_path=variant_source,
                case_lines=family_file,
                case_type=family_type,
                vtype=variant_type
            )
        except SyntaxError as e:
            logger.error(e.message)
            ctx.abort()

    elif mode == 'gemini':
        logger.debug("Initialzing GEMINI plugin")
        try:
            plugin = GeminiPlugin(db=variant_source, vtype=variant_type)
        except NameError:
            logger.error("Need to have gemini installed to use gemini plugin")
            ctx.abort()
        except DatabaseError as e:
            logger.error("{} is not a valid gemini db".format(variant_source))
            logger.info("variant-source has to point to a gemini database")
            ctx.abort()

    logger.debug("Plugin setup was succesfull")
    # from gemini can create multiple cases
    store = SqlStore(db_path)

    for case_obj in plugin.cases():
        if store.case(case_id=case_obj.case_id).case_id == case_obj.case_id:
            logger.warn("{} already exists in the database"
                        .format(case_obj.case_id))
            continue

        # extract case information
        logger.debug("adding case: {}".format(case_obj.case_id))
        store.add_case(case_obj, vtype=variant_type, mode=mode)
开发者ID:J35P312,项目名称:PuzzleWin,代码行数:72,代码来源:load.py

示例3: test_cases

# 需要导入模块: from puzzle.plugins import VcfPlugin [as 别名]
# 或者: from puzzle.plugins.VcfPlugin import cases [as 别名]
def test_cases(case_obj):
    adapter=VcfPlugin()
    adapter.add_case(case_obj)
    case_id = "636808"
    case_obj = adapter.cases()[0]
    assert case_obj.name == "636808"
开发者ID:J35P312,项目名称:puzzle,代码行数:8,代码来源:test_vcf_case_mixin.py


注:本文中的puzzle.plugins.VcfPlugin.cases方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。