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


Python Selection.site_residue_groups[group_id-1][0]方法代码示例

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


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

示例1: site_upload

# 需要导入模块: from common.selection import Selection [as 别名]
# 或者: from common.selection.Selection import site_residue_groups[group_id-1][0] [as 别名]
def site_upload(request):
    
    # get simple selection from session
    simple_selection = request.session.get('selection', False)
    
    # create full selection and import simple selection (if it exists)
    selection = Selection()
    if simple_selection:
        selection.importer(simple_selection)

    selection_type = 'segments'
    selection_subtype = 'site_residue'

    if request.FILES == {}:
        return render(request, 'common/selection_lists_sitesearch.html', '')

    #Overwriting the existing selection
    selection.clear(selection_type)

    print(type(request.FILES['xml_file'].file))

    wb=load_workbook(filename=request.FILES['xml_file'].file)
    ws=wb.active


    for row in ws.rows:
        if len(row) < 5:
            continue
        group_id = int(row[0].value)
        min_match = int(row[1].value)
        try:
            position = ResidueGenericNumberEquivalent.objects.get(label=row[2].value, scheme__slug=row[3].value)
        except e:
            print(e)
            continue
        feature = row[4].value

        # update the selected group
        selection.active_site_residue_group = group_id
        print(selection.site_residue_groups)
        if not selection.site_residue_groups:
            selection.site_residue_groups = [[]]
        selection.site_residue_groups[selection.active_site_residue_group - 1].append(1)
        if len(selection.site_residue_groups) < group_id:
            for x in group_id - len(selection.site_residue_groups):
                selection.site_residue_groups.append([])
        selection.site_residue_groups[group_id - 1][0] = min_match
        selection_object = SelectionItem(selection_subtype, position)
        selection_object.properties['feature'] = feature
        selection_object.properties['site_residue_group'] = selection.active_site_residue_group
        selection_object.properties['amino_acids'] = ','.join(definitions.AMINO_ACID_GROUPS[feature])
        selection.add(selection_type, selection_subtype, selection_object)

    # export simple selection that can be serialized
    simple_selection = selection.exporter()

    # add simple selection to session
    request.session['selection'] = simple_selection
    
    return render(request, 'common/selection_lists_sitesearch.html', selection.dict(selection_type))
开发者ID:MeeMaster,项目名称:protwis,代码行数:62,代码来源:views.py

示例2: SetGroupMinMatch

# 需要导入模块: from common.selection import Selection [as 别名]
# 或者: from common.selection.Selection import site_residue_groups[group_id-1][0] [as 别名]
def SetGroupMinMatch(request):
    """Receives a selection request, sets a minimum match for a group, and returns the updated selection"""
    selection_type = request.GET['selection_type']
    group_id = int(request.GET['group_id'])
    min_match = int(request.GET['min_match'])
    
    # get simple selection from session
    simple_selection = request.session.get('selection', False)
    
    # create full selection and import simple selection (if it exists)
    selection = Selection()
    if simple_selection:
        selection.importer(simple_selection)

    # update the group
    selection.site_residue_groups[group_id - 1][0] = min_match

    # export simple selection that can be serialized
    simple_selection = selection.exporter()

    # add simple selection to session
    request.session['selection'] = simple_selection

    # context
    context = selection.dict(selection_type)
    
    # amino acid groups
    amino_acid_groups = {
        'amino_acid_groups': definitions.AMINO_ACID_GROUPS,
        'amino_acid_group_names': definitions.AMINO_ACID_GROUP_NAMES }
    context.update(amino_acid_groups)

    # template to load
    template = 'common/selection_lists_sitesearch.html'

    return render(request, template, context)
开发者ID:AnnaTsolakou,项目名称:protwis,代码行数:38,代码来源:views.py

示例3: site_upload

# 需要导入模块: from common.selection import Selection [as 别名]
# 或者: from common.selection.Selection import site_residue_groups[group_id-1][0] [as 别名]
def site_upload(request):
    
    # get simple selection from session
    simple_selection = request.session.get('selection', False)
    
    # create full selection and import simple selection (if it exists)
    selection = Selection()
    if simple_selection:
        selection.importer(simple_selection)

    selection_type = 'segments'
    selection_subtype = 'site_residue'

    if request.FILES == {}:
        return render(request, 'common/selection_lists_sitesearch.html', '')

    #Overwriting the existing selection
    selection.clear(selection_type)

    workbook = xlrd.open_workbook(file_contents=request.FILES['xml_file'].read())
    worksheets = workbook.sheet_names()
    for worksheet_name in worksheets:
        worksheet = workbook.sheet_by_name(worksheet_name)
        for row in worksheet.get_rows():

    #for row in ws.rows:
            if len(row) < 5:
                continue
            group_id = int(row[0].value)
            min_match = int(row[1].value)
            try:
                position = ResidueGenericNumberEquivalent.objects.get(label=row[2].value, scheme__slug=row[3].value)
            except e:
                print(e)
                continue
            feature = row[4].value

            # update the selected group
            if not selection.active_site_residue_group:
                selection.active_site_residue_group = group_id
            if not selection.site_residue_groups:
                selection.site_residue_groups = [[]]
            if len(selection.site_residue_groups) < group_id:
                for x in group_id - len(selection.site_residue_groups):
                    selection.site_residue_groups[x].append([])
#            selection.site_residue_groups[group_id - 1].append(1)
            properties = {}
            properties['feature'] = feature
            properties['site_residue_group'] = selection.active_site_residue_group
            properties['amino_acids'] = ','.join(definitions.AMINO_ACID_GROUPS[feature]) if feature != 'custom' else row[5].value
            selection_object = SelectionItem(selection_subtype, position, properties)
            selection.add(selection_type, selection_subtype, selection_object)
            selection.site_residue_groups[group_id - 1][0] = min_match
    # export simple selection that can be serialized
    simple_selection = selection.exporter()
    # add simple selection to session
    request.session['selection'] = simple_selection

    context = selection.dict(selection_type)
    # amino acid groups
    amino_acid_groups = {
        'amino_acid_groups': definitions.AMINO_ACID_GROUPS,
        'amino_acid_group_names': definitions.AMINO_ACID_GROUP_NAMES }
    context.update(amino_acid_groups)

    return render(request, 'common/selection_lists_sitesearch.html', context)
开发者ID:pszgaspar,项目名称:protwis,代码行数:68,代码来源:views.py


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