示例#1
0
文件: views.py 项目: cmbi/whynot
def entries_file():
    # TODO: speed up this method
    collection = request.args.get('collection')
    databank_name = request.args.get('databank')
    comment_text = request.args.get('comment')

    # listing determines what is shown per entry(pdb ids, databank names, comments, file names, etc.)
    listing = request.args.get('listing')

    _log.info("request for entries file %s %s %s %s" %(collection, databank_name, comment_text, listing))

    if not listing:
        return ''

    listing = listing.lower()

    entries = []
    name="0"
    if databank_name and collection:

        entries = get_entries_from_collection(databank_name, collection)
        name = "%s%s" %(databank_name, collection)

    elif databank_name and comment_text:

        entries = get_entries_with_comment(databank_name, comment_text)
        name = "%s%s" %(databank_name, remove_tags(comment_text))

    elif comment_text:

        entries = get_all_entries_with_comment(comment_text)
        name = remove_tags(comment_text)

    text = ''
    if listing == 'comments':

        d = {}
        for entry in entries:
            if 'comment' in entry:
                c = entry ['comment']
                if c not in d:
                    d [c] = ''
                d [c] += '%s,%s\n' %(entry['databank_name'], entry['pdbid'])

        for comment in d:
            text += comment + ":\n" + d [comment]
    else:
        for entry in entries:

            if listing == 'pdbids':
                text += entry ['pdbid'] + '\n'
            elif listing == 'entries':
                text += '%s,%s\n' %(entry['databank_name'], entry ['pdbid'])
            elif listing == 'files' and 'filepath' in entry:
                text += '%s,%s,%s\n' %(entry['databank_name'], entry ['pdbid'], entry ['filepath'])

    response = Response(text, mimetype='text/plain')
    response.headers["Content-Disposition"] = "attachment; filename=%s" %('%s_%s' %(name, listing))

    return response
示例#2
0
文件: routes.py 项目: jonblack/whynot
def entries_file():
    # TODO: speed up this method
    collection = request.args.get('collection')
    databank_name = request.args.get('databank')
    comment_text = request.args.get('comment')

    # listing determines what is shown per entry(pdb ids, databank names,
    # comments, file names, etc.)
    listing = request.args.get('listing')

    _log.info("request for entries file %s %s %s %s" % (
        collection, databank_name, comment_text, listing))

    if not listing:
        return ''

    listing = listing.lower()

    entries = []
    name = "0"
    if databank_name and collection:
        entries = get_entries_from_collection(databank_name, collection)
        name = "%s%s" % (databank_name, collection)
    elif databank_name and comment_text:
        entries = get_entries_with_comment(databank_name, comment_text)
        name = "%s%s" % (databank_name, remove_tags(comment_text))
    elif comment_text:
        entries = get_all_entries_with_comment(comment_text)
        name = remove_tags(comment_text)

    text = ''
    if listing == 'comments':
        d = {}
        for entry in entries:
            if 'comment' in entry:
                c = entry['comment']
                if c not in d:
                    d[c] = ''
                d[c] += '%s,%s\n' % (entry['databank_name'], entry['pdb_id'])
        for comment in d:
            text += comment + ":\n" + d[comment]
    else:
        for entry in entries:

            if listing == 'pdb_ids':
                text += entry['pdb_id'] + '\n'
            elif listing == 'entries':
                text += '%s,%s\n' % (entry['databank_name'], entry['pdb_id'])
            elif listing == 'files' and 'filepath' in entry:
                text += '%s,%s,%s\n' % (entry['databank_name'],
                                        entry['pdb_id'],
                                        entry['filepath'])

    response = Response(text, mimetype='text/plain')
    header_val = "attachment; filename=%s_%s" % (name, listing)
    response.headers["Content-Disposition"] = header_val

    return response
示例#3
0
def entries():
    collection = request.args.get('collection')
    databank_name = request.args.get('databank')
    comment_text = request.args.get('comment')

    _log.info("request for entries %s %s %s" %
              (collection, databank_name, comment_text))

    title = 'No entries selected'
    entries = []
    files = []
    comments = {}

    if databank_name and collection:
        start_time = time()
        entries = get_entries_from_collection(databank_name, collection)
        end_time = time()
        title = "%s %s" % (databank_name, collection)
    elif databank_name and comment_text:
        start_time = time()
        entries = get_entries_with_comment(databank_name, comment_text)
        end_time = time()
        title = comment_text
    elif comment_text:
        start_time = time()
        entries = get_all_entries_with_comment(comment_text)
        end_time = time()
        title = comment_text

    databank = storage.find_one('databanks', {'name': databank_name})
    for entry in entries:
        if databank and 'filepath' in entry:
            f = {
                'name': os.path.basename(entry['filepath']),
                'url': get_file_link(databank, entry['pdbid'])
            }
            files.append(f)
        elif 'comment' in entry:
            if entry['comment'] not in comments:
                comments[entry['comment']] = []
            comments[entry['comment']].append(
                '%s,%s' % (entry['databank_name'], entry['pdbid']))

    comment_tree = comments_to_tree(comments)

    return render_template('entries/EntriesPage.html',
                           db_tree=db_tree,
                           nav_disabled='entries',
                           collection=collection,
                           databank_name=databank_name,
                           comment=comment_text,
                           title=title,
                           entries=entries,
                           files=files,
                           comment_tree=comment_tree)
示例#4
0
文件: rs.py 项目: cmbi/whynot2
def entries(databank_name, collection):
    """
    Request all entries in a given databank and collection.

    :param databank_name: Name of the whynot databank.
    :param collection: Name of the collection within the databank. Either PRESENT, VALID, OBSOLETE, MISSING, ANNOTATED or UNANNOTATED.
    :return: a text string with all pdb ids of entries that match the selection.
    """

    # TODO: SPEED THIS UP
    text = ""
    for entry in get_entries_from_collection(databank_name, collection):
        text += entry['pdbid'] + '\n'

    return Response(text, mimetype='text/plain')
示例#5
0
文件: rs.py 项目: cmbi/whynot
def entries (databank_name, collection):
    """
    Request all entries in a given databank and collection.

    :param databank_name: Name of the whynot databank.
    :param collection: Name of the collection within the databank. Either PRESENT, VALID, OBSOLETE, MISSING, ANNOTATED or UNANNOTATED.
    :return: a text string with all pdb ids of entries that match the selection.
    """

    # TODO: SPEED THIS UP
    text = ""
    for entry in get_entries_from_collection (databank_name, collection):
        text += entry ['pdbid'] + '\n'

    return Response (text, mimetype='text/plain')
示例#6
0
文件: views.py 项目: cmbi/whynot
def entries():
    collection = request.args.get('collection')
    databank_name = request.args.get('databank')
    comment_text = request.args.get('comment')

    _log.info("request for entries %s %s %s" %(collection, databank_name, comment_text))

    title = 'No entries selected'
    entries = []
    files = []
    comments = {}

    if databank_name and collection:
        start_time = time()
        entries = get_entries_from_collection(databank_name, collection)
        end_time = time()
        title = "%s %s" %(databank_name, collection)
    elif databank_name and comment_text:
        start_time = time()
        entries = get_entries_with_comment(databank_name, comment_text)
        end_time = time()
        title = comment_text
    elif comment_text:
        start_time = time()
        entries = get_all_entries_with_comment(comment_text)
        end_time = time()
        title = comment_text

    databank = storage.find_one('databanks', {'name': databank_name})
    for entry in entries:
        if databank and 'filepath' in entry:
            f = {'name': os.path.basename(entry ['filepath']),
                 'url': get_file_link(databank, entry ['pdbid'])}
            files.append(f)
        elif 'comment' in entry:
            if entry ['comment'] not in comments:
                comments [entry ['comment']] = []
            comments [entry ['comment']].append('%s,%s' %(entry ['databank_name'], entry ['pdbid']))

    comment_tree = comments_to_tree(comments)

    return render_template('entries/EntriesPage.html', db_tree=db_tree, nav_disabled='entries',
                            collection=collection, databank_name=databank_name, comment=comment_text,
                            title=title, entries=entries, files=files, comment_tree=comment_tree)
示例#7
0
文件: views.py 项目: cmbi/whynot
def resources(tolist):
    _log.info("request for resources " + tolist)

    if '_' not in tolist: # syntax error
        return '', 400

    # TODO: speed up this method
    last = tolist.rfind('_')
    databank_name = tolist [:last]
    collection = tolist [last + 1:]

    text = ''
    for entry in get_entries_from_collection(databank_name, collection):
        text += entry ['pdbid'] + '\n'

    response = Response(text, mimetype='text/plain')
    response.headers["Content-Disposition"] = "attachment; filename=%s" % tolist

    return response
示例#8
0
文件: routes.py 项目: jonblack/whynot
def resources(tolist):
    _log.info("request for resources " + tolist)

    if '_' not in tolist:
        return '', 400

    # TODO: speed up this method
    last = tolist.rfind('_')
    databank_name = tolist[:last]
    collection = tolist[last + 1:]

    text = ''
    for entry in get_entries_from_collection(databank_name, collection):
        text += entry['pdb_id'] + '\n'

    response = Response(text, mimetype='text/plain')
    header_val = "attachment; filename=%s" % tolist
    response.headers["Content-Disposition"] = header_val
    return response