예제 #1
0
def test_load():
    engine = create_engine('sqlite://')
    metadata = waldo.goslim.models.Base.metadata
    metadata.bind = engine
    metadata.create_all()

    sessionmaker_ = sessionmaker(engine)
    nr_entries, nr_aspects = waldo.goslim.load.load(testdir, sessionmaker_)
    inputfile = open(path_to_testfile(waldo.goslim.load._inputfilename))
    nr_lines = len(inputfile.readlines())
    assert nr_entries == (nr_lines-1)
    aspects = set()
    inputfile = open(path_to_testfile(waldo.goslim.load._inputfilename))
    lines = inputfile.readlines()
    for line in lines[1:]:
        tokens = line.strip().split('\t')
        aspects.add(tokens[-2])
    assert len(aspects) == nr_aspects
    session = sessionmaker_()
    name = waldo.goslim.goslim.map_to_goslim('GO:0014709', 'mgi', session)
    assert name == 'developmental processes'
    nonexistent = waldo.goslim.goslim.map_to_goslim('GO:99999', 'mgi', session)
    assert nonexistent is None
예제 #2
0
from sqlalchemy.orm import sessionmaker
import re
import gzip

import waldo.backend
import waldo.uniprot.load
import waldo.uniprot.models
import waldo.uniprot.retrieve
import waldo.go.load
import waldo.go.go

from waldo.translations.models import Translation
from .backend import testdir as _testdir
from waldo.tests.backend import path_to_testfile

_testfile = path_to_testfile('uniprot_sprot.xml.gz')
_mapping_testfile = path_to_testfile('idmapping_selected.tab.gz')

def load_uniprot_test():
    from waldo.tests.test_go import load_go
    engine = create_engine('sqlite://')
    metadata = waldo.uniprot.models.Base.metadata
    metadata.bind = engine
    metadata.create_all()

    conn = engine.connect()
    if waldo.backend.use_fts:
        conn.execute("drop table uniprot_entry")
        conn.execute("CREATE VIRTUAL TABLE uniprot_entry USING fts4 (" +
                "name VARCHAR(32) NOT NULL, " +
                "rname VARCHAR(128) NOT NULL, " +
예제 #3
0
def test_read():
    seqs = list(fasta.read(path_to_testfile('test.fasta')))
    assert len(seqs) == 2
    assert seqs[1].header.find('gene:ENSMUSG00000064345')
    assert seqs[1].header[-1] != '\n'
    assert seqs[1].header[0] != '>'