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


Python CharonSession.sample_create方法代码示例

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


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

示例1: create_charon_entries_from_project

# 需要导入模块: from ngi_pipeline.database.classes import CharonSession [as 别名]
# 或者: from ngi_pipeline.database.classes.CharonSession import sample_create [as 别名]
def create_charon_entries_from_project(project, best_practice_analysis="whole_genome_reseq",
                                       sequencing_facility="NGI-S",
                                       force_overwrite=False, delete_existing=False,
                                       retry_on_fail=True):
    """Given a project object, creates the relevant entries in Charon.
    This code is remarkably shoddy as I created it in a hurry and then later
    it became a part of the pipeline. Use at your own risk! Ha ha.

    :param NGIProject project: The NGIProject object
    :param str best_practice_analysis: The workflow to assign for this project (default "variant_calling")
    :param str sequencing_facility: The facility that did the sequencing
    :param bool force_overwrite: If this is set to true, overwrite existing entries in Charon (default false)
    :param bool delete_existing: Don't just update existing entries, delete them and create new ones (default false)
    """
    charon_session = CharonSession()
    update_failed=False
    try:
        status = "OPEN"
        LOG.info('Creating project "{}" with status "{}", best practice analysis "{}", '
                 'and sequencing_facility {}'.format(project, status,
                                                     best_practice_analysis,
                                                     sequencing_facility))
        charon_session.project_create(projectid=project.project_id,
                                      name=project.name,
                                      status=status,
                                      best_practice_analysis=best_practice_analysis,
                                      sequencing_facility=sequencing_facility)
        LOG.info('Project "{}" created in Charon.'.format(project))
    except CharonError as e:
        if e.status_code == 400:
            if force_overwrite:
                LOG.warn('Overwriting data for project "{}"'.format(project))
                charon_session.project_update(projectid=project.project_id,
                                              name=project.name,
                                              status=status,
                                              best_practice_analysis=best_practice_analysis,
                                              sequencing_facility=sequencing_facility)
                LOG.info('Project "{}" updated in Charon.'.format(project))
            else:
                LOG.info('Project "{}" already exists; moving to samples...'.format(project))
        else:
            raise
    for sample in project:
        if delete_existing:
            LOG.warn('Deleting existing sample "{}"'.format(sample))
            try:
                charon_session.sample_delete(projectid=project.project_id,
                                             sampleid=sample.name)
            except CharonError as e:
                update_failed=True
                LOG.error('Could not delete sample "{}": {}'.format(sample, e))
        try:
            analysis_status = "TO_ANALYZE"
            LOG.info('Creating sample "{}" with analysis_status "{}"'.format(sample, analysis_status))
            charon_session.sample_create(projectid=project.project_id,
                                         sampleid=sample.name,
                                         analysis_status=analysis_status)
            LOG.info('Project/sample "{}/{}" created in Charon.'.format(project, sample))
        except CharonError as e:
            if e.status_code == 400:
                if force_overwrite:
                    LOG.warn('Overwriting data for project "{}" / '
                             'sample "{}"'.format(project, sample))
                    charon_session.sample_update(projectid=project.project_id,
                                                 sampleid=sample.name,
                                                 analysis_status=analysis_status)
                    LOG.info('Project/sample "{}/{}" updated in Charon.'.format(project, sample))
                else:
                    LOG.info('Project "{}" / sample "{}" already exists; moving '
                             'to libpreps'.format(project, sample))
            else:
                update_failed=True
                LOG.error(e)
                continue
        for libprep in sample:
            if delete_existing:
                LOG.warn('Deleting existing libprep "{}"'.format(libprep))
                try:
                    charon_session.libprep_delete(projectid=project.project_id,
                                                  sampleid=sample.name,
                                                  libprepid=libprep.name)
                except CharonError as e:
                    LOG.warn('Could not delete libprep "{}": {}'.format(libprep, e))
            try:
                qc = "PASSED"
                LOG.info('Creating libprep "{}" with qc status "{}"'.format(libprep, qc))
                charon_session.libprep_create(projectid=project.project_id,
                                              sampleid=sample.name,
                                              libprepid=libprep.name,
                                              qc=qc)
                LOG.info(('Project/sample/libprep "{}/{}/{}" created in '
                          'Charon').format(project, sample, libprep))
            except CharonError as e:
                if e.status_code == 400:
                    if force_overwrite:
                        LOG.warn('Overwriting data for project "{}" / '
                                 'sample "{}" / libprep "{}"'.format(project, sample,
                                                                     libprep))
                        charon_session.libprep_update(projectid=project.project_id,
                                                      sampleid=sample.name,
#.........这里部分代码省略.........
开发者ID:Galithil,项目名称:ngi_pipeline,代码行数:103,代码来源:filesystem.py

示例2: create_charon_entries_from_project

# 需要导入模块: from ngi_pipeline.database.classes import CharonSession [as 别名]
# 或者: from ngi_pipeline.database.classes.CharonSession import sample_create [as 别名]
def create_charon_entries_from_project(project, workflow="NGI", force_overwrite=False):
    """Given a project object, creates the relevant entries
    in Charon.

    :param NGIProject project: The NGIProject object
    :param str workflow: The workflow to assign for this project (default NGI)
    :param bool force_overwrite: If this is set to true, overwrite existing entries in Charon (default false)
    """
    charon_session = CharonSession()
    try:
        status="SEQUENCED"
        LOG.info('Creating project "{}" with status "{}" and workflow "{}"'.format(project, status, workflow))
        charon_session.project_create(projectid=project.project_id,
                                      name=project.name,
                                      status=status,
                                      pipeline=workflow)
    except CharonError:
        if force_overwrite:
            LOG.warn('Overwriting data for project "{}"'.format(project))
            charon_session.project_update(projectid=project.project_id,
                                          name=project.name,
                                          status=status,
                                          pipeline=workflow)
        else:
            LOG.info('Project "{}" already exists; moving to samples...'.format(project))

    for sample in project:
        try:
            LOG.info('Creating sample "{}"'.format(sample))
            charon_session.sample_create(projectid=project.project_id,
                                         sampleid=sample.name,
                                         status="NEW")
        except CharonError:
            if force_overwrite:
                LOG.warn('Overwriting data for project "{}" / '
                         'sample "{}"'.format(project, sample))
                charon_session.sample_update(projectid=project.project_id,
                                             sampleid=sample.name,
                                             status="NEW")
            else:
                LOG.info('Project "{}" / sample "{}" already exists; moving '
                         'to libpreps'.format(project, sample))

        for libprep in sample:
            try:
                LOG.info('Creating libprep "{}"'.format(libprep))
                charon_session.libprep_create(projectid=project.project_id,
                                              sampleid=sample.name,
                                              libprepid=libprep.name,
                                              status="NEW")
            except CharonError:
                if force_overwrite:
                    LOG.warn('Overwriting data for project "{}" / '
                             'sample "{}" / libprep "{}"'.format(project, sample,
                                                                 libprep))
                    charon_session.libprep_update(projectid=project.project_id,
                                                  sampleid=sample.name,
                                                  libprepid=libprep.name,
                                                  status="NEW")
                else:
                    LOG.info('Project "{}" / sample "{}" / libprep "{}" already '
                             'exists; moving to libpreps'.format(project, sample, libprep))

            for seqrun in libprep:
                try:
                    LOG.info('Creating seqrun "{}"'.format(seqrun))
                    charon_session.seqrun_create(projectid=project.project_id,
                                                 sampleid=sample.name,
                                                 libprepid=libprep.name,
                                                 seqrunid=seqrun.name,
                                                 total_reads=0,
                                                 mean_autosomal_coverage=0,
                                                 sequencing_status="DONE",
                                                 alignment_status="NEW")
                except CharonError as e:
                    if force_overwrite:
                        LOG.warn('Overwriting data for project "{}" / '
                                 'sample "{}" / libprep "{}" / '
                                 'seqrun "{}"'.format(project, sample,
                                                      libprep, seqrun))
                        charon_session.seqrun_update(projectid=project.project_id,
                                                     sampleid=sample.name,
                                                     libprepid=libprep.name,
                                                     seqrunid=seqrun.name,
                                                     status="NEW")
                    else:
                        LOG.info('Project "{}" / sample "{}" / libprep "{}" / '
                                 'seqrun "{}" already exists; next...'.format(project, sample,
                                                                              libprep, seqrun))
开发者ID:johandahlberg,项目名称:ngi_pipeline,代码行数:91,代码来源:filesystem.py


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