Пример #1
0
def efetch(req, id):
    logger.info("Asked to fetch Id: %s", id)
    session = entrez.EntrezSession(library_root())
    abspath = session.fetch_id(id)
    path = getrelpath(abspath)
    try:
        parsing.initial(abspath)
    except:
        messages.error(req,
                       "There was a problem loading file '%s', "
                       "please try again or try a different record."
                       % path)
        return re_search(req)

    path = getrelpath(abspath)
    remaining_args = dict(req.REQUEST.items())
    action = remaining_args.pop('action', 'run')

    if action in ['run', 'config']:
        return HttpResponseRedirect(
            reverse(action, args=[path]) + dict_to_querystring(remaining_args))
    else:
        logger.error("Unknown action %r", action)
        messages.error(req, "Unknown action.")
        return re_search(req)
def efetch(id):
    logger.info("Asked to fetch Id: %s", id)
    searchsession = entrez.EntrezSession(app.config['UPLOADS'])
    abspath = searchsession.fetch_id(id)
    path = getrelpath(abspath)
    try:
        parsing.initial(abspath)
    except:
        flash("There was a problem loading file '%s', "
              "please try again or try a different record."
              % path)
        return re_search()

    args = dict(request.args.items())

    return redirect(url_for('run_frame', path=path, **args))
def test_translate(gbkfile):
    config = parsing.initial(gbkfile)
    config['startBase'] = 161
    config['endBase'] = 355
    result = parsing.translate(config, rc=False)
    assert result['seq'] == 'CTGCCTTTTGGTGTCGTTTATTTCGGCTTTTGCCATAGAAGCCAAAGCCCCCAGAAGTTCGCCTTTGTCCCATGTTGGATTGCCGGTCTTACTATCGACCAGACCGGCCAGAATAAGCAGGCCAGCAGACTGGATGAGGTTATGCGTTCTTTCCTTGTCCTTGGCGTCTCTTTCTCTCTTGGCGATTTTCGATGA'
    assert result['trans'] == 'LPFGVVYFGFCHRSQSPQKFAFVPCWIAGLTIDQTGQNKQASRLDEVMRSFLVLGVSFSLGDFR*'
def test_trans_myco(gbkfile):
    config = parsing.initial(gbkfile)
    config['startBase'] = 116
    config['endBase'] = 562
    config['mycoplasma'] = True
    result = parsing.translate(config, rc=True)
    assert result['trans'] == 'MASFRIETHIANLRQLEKPSTEQRILILLYDKTDRTPKEERDLKALIRSEKAQEAVKEAKAKASEAKARSSKIAKRERDAKDKERTHNLIQSAGLLILAGLVDSKTGNPTWDKGELLGALASMAKAEINDTKRQEWKEKGDALLAGEKW'
def test_trans_complement(gbkfile):
    config = parsing.initial(gbkfile)
    config['startBase'] = 116
    config['endBase'] = 562
    result = parsing.translate(config, rc=True)
    assert result['seq'] == 'ATGGCCTCTTTTCGGATTGAAACGCATATCGCTAACCTTCGACAGCTTGAGAAGCCATCGACAGAACAGCGCATCCTGATCTTGCTCTATGACAAGACTGACAGAACGCCAAAAGAGGAAAGAGACCTCAAGGCACTCATCCGGTCGGAAAAAGCGCAGGAAGCCGTAAAAGAGGCTAAAGCCAAAGCATCCGAAGCAAAGGCCAGATCATCGAAAATCGCCAAGAGAGAAAGAGACGCCAAGGACAAGGAAAGAACGCATAACCTCATCCAGTCTGCTGGCCTGCTTATTCTGGCCGGTCTGGTCGATAGTAAGACCGGCAATCCAACATGGGACAAAGGCGAACTTCTGGGGGCTTTGGCTTCTATGGCAAAAGCCGAAATAAACGACACCAAAAGGCAGGAGTGGAAAGAAAAAGGTGATGCGTTATTAGCCGGAGAAAAATGA'
    assert result['trans'] == 'MASFRIETHIANLRQLEKPSTEQRILILLYDKTDRTPKEERDLKALIRSEKAQEAVKEAKAKASEAKARSSKIAKRERDAKDKERTHNLIQSAGLLILAGLVDSKTGNPTWDKGELLGALASMAKAEINDTKRQEWKEKGDALLAGEK*'
def build_config(path):
    "Tries to build the config dictionary for the given path"
    try:
        config = parsing.initial(getabspath(path))
    except:
        logger.exception(
            "Error parsing gbk: %r", getabspath(path, raise_on_missing=False))
        raise

    parsing.detect_format(config)
    for k in VALID_KEYS:
        v = request.args.get(k)
        if v:
            nv = parsing.number(v)
            config[k] = v if nv is None else nv
    parsing.endBase(config)
    parsing.mycoplasma(config)

    # fixup nucleotides list
    if 'nucleotides' in request.args:
        config['nucleotides'] = request.args.getlist('nucleotides')

    for key in MAGIC_PARAMS:
        if key in request.args:
            config[key] = request.args[key]

    return config
def run_cmdline(gbkfile, executorName):
    config = parsing.initial(gbkfile)
    with getexecutor(executorName) as executor:
        config = process('allplots', config, executor=executor)
        jid = config.get('allplots_result')
        if not Path(jid).exists():
            logging.info("Work scheduled, waiting")
            output = executor.result(jid, timeout=None)
            logging.info("Finished processing %r", gbkfile)
        else:
            output = jid
        logging.info("See output at %r", output)
def test_initial(gbkfile):
    result = parsing.initial(gbkfile)
    assert 'outputdir' in result
    assert result['filename'] == gbkfile
    assert 'basename' in result
def rawconfig(rawfile, tmpdir):
    return parsing.initial(rawfile, outputdir=str(tmpdir))
def fnaconfig(fnafile, tmpdir):
    return parsing.initial(fnafile, outputdir=str(tmpdir))
def gbkconfig(gbkfile, tmpdir):
    return parsing.initial(gbkfile, outputdir=str(tmpdir))