Exemple #1
0
def test_lookup_multiple_or():
    i = Index()
    i.insert(id='1', age=65, path='test1.txt', type='txt')
    i.insert(id='2', age=63, path='test2.txt', type='txt')
    i.insert(id='3', age=70, path='test3.jpg', type='jpg')
    i.insert(id='4', age=45, path='test4.pdf', type='pdf')
    selected = i.lookup(type='txt', path='test3.jpg', or_query=True)
    assert selected.datasets != i.datasets
    assert len(selected.datasets) == 3
Exemple #2
0
def test_remove_file():
    i = Index()
    i.insert(id='1', age=65, path='test.txt', type='txt')
    i.insert(id='1', path='test1.txt', type='txt')
    assert len(i.datasets) == 1
    dataset = i.datasets.get('1')
    assert len(dataset) == 2
    i.remove(path='test.txt')
    assert len(i.datasets) == 1
    assert len(i.datasets.get('1')) == 1
Exemple #3
0
def test_lookup_simple_dataset():
    i = Index()
    i.insert(id='1', age=65, path='test.txt', type='txt')
    selected = i.lookup(id='1')
    assert selected.datasets == i.datasets
    dataset = selected.datasets.get('1')
    assert dataset is not None
    assert dataset.id == '1'
    assert dataset.age == 65
    assert len(dataset) == 1
Exemple #4
0
def test_replicates_w_metadata():
    """Test merged datasets with metadata"""
    i = Index('test/data/index.txt')
    i.set_format('test/data/format.json')
    i.open()
    i.insert(id='aWL3.1,aWL3.2',
             path='test/data/format.json',
             type='json',
             view='json')
    i.lookup(id='aWL3.1,aWL3.2')
    i.remove(path='test/data/format.json', clear=True)
Exemple #5
0
def test_export_no_format_no_map():
    """Test export"""
    i = Index()
    #assert i is not None
    i.insert(id="myId",
             path="test/data/index.txt",
             type="text",
             view="TxtFile")
    exp = i.export(map=None, export_type='tab', tags=['id'])
    assert len(exp) == 1
    assert exp[0] == 'myId'
Exemple #6
0
def test_insert_update_exc():
    """Test insertion into the index adding non-existing keys"""
    i = Index()
    i.insert(id='1', age=65, path='test.txt', type='txt')
    with pytest.raises(AttributeError):
        i.insert(id='1',
                 age=70,
                 path='test.txt',
                 type='text',
                 length=20,
                 update=True)
Exemple #7
0
def test_lookup_path():
    i = Index()
    i.insert(id='1', age=65, path='test1.txt', type='txt')
    i.insert(id='2', age=63, path='test2.txt', type='txt')
    i.insert(id='3', age=70, path='test3.jpg', type='jpg')
    selected = i.lookup(path='test3.jpg')
    assert selected.datasets != i.datasets
    dataset = selected.datasets.get('3')
    assert dataset is not None
    assert dataset.id == '3'
    assert dataset.age == 70
    assert len(dataset) == 1
Exemple #8
0
def test_add_file_external():
    index = '''.\tage=-; cell=Neutrophils; dataType=RNA-Seq; dateSubmittedFirst=2012-10-17T09:49:23+0200; donorId=C000XW; ethnicity=NA; lab=MPIMG; labExpId=ERR180946; labProtocolId=C000XWB1; libProtocol=I_bc_pelib_858; localization="Primary Cell"; quality=phred; readStrand=MATE2_SENSE; readType=2x76D; rnaExtract=total; seqPlatform=ILLUMINA; seqRun=1; sex=Male; sraSampleAccession=ERS150362; sraStudyAccession=ERP001664; tissue="Cord blood";'''
    i = Index()
    i.set_format('test/data/tsv_format.json')
    i.insert(**Index.parse_line(index, **i.format))
    i.insert(
        id="ERR180946",
        path=
        "/users/rg/epalumbo/projects/BluePrint/reads/20130805/data/ERR180946_1.fastq.gz",
        view="FastqRd1",
        type="fastq")
    assert i.export(
        map=None
    )[0] == '''/users/rg/epalumbo/projects/BluePrint/reads/20130805/data/ERR180946_1.fastq.gz\tage=-; cell=Neutrophils; dataType=RNA-Seq; dateSubmittedFirst=2012-10-17T09:49:23+0200; donorId=C000XW; ethnicity=NA; lab=MPIMG; labExpId=ERR180946; labProtocolId=C000XWB1; libProtocol=I_bc_pelib_858; localization="Primary Cell"; quality=phred; readStrand=MATE2_SENSE; readType=2x76D; rnaExtract=total; seqPlatform=ILLUMINA; seqRun=1; sex=Male; sraSampleAccession=ERS150362; sraStudyAccession=ERP001664; tissue="Cord blood"; type=fastq; view=FastqRd1;'''
Exemple #9
0
def test_insert_update():
    """Test insertion into the index"""
    i = Index()
    i.insert(id='1', age=65, path='test.txt', type='txt')
    i.insert(id='1', age=70, path='test.txt', type='text', update=True)
    assert len(i.datasets) == 1
    dataset = i.datasets.get('1')
    assert dataset is not None
    assert len(dataset) == 1
    assert hasattr(dataset, 'id')
    assert hasattr(dataset, 'age')
    assert dataset.id == '1'
    assert dataset.age == 70
    assert len(dataset['test.txt']) == 1
    assert hasattr(dataset['test.txt'], 'type')
    assert dataset['test.txt'].type == 'text'
Exemple #10
0
def test_remove_fileinfo():
    i = Index()
    i.insert(id='1', age=65, path='test.txt', type='txt')
    i.insert(id='1', path='test1.txt', type='txt')
    i.insert(id='1', path='test1.jpg', type='jpeg')
    assert len(i.datasets) == 1
    dataset = i.datasets.get('1')
    assert len(dataset) == 3
    i.remove(type='jpeg')
    print i.datasets.get('1')._files
    assert len(i.datasets) == 1
    assert len(i.datasets.get('1')) == 2
Exemple #11
0
def test_remove_dataset():
    i = Index()
    i.insert(id='1', age=65, path='test.txt', type='txt')
    i.remove(id='1')
    assert len(i.datasets) == 0
Exemple #12
0
def test_lookup_multiple_or():
    i = Index()
    i.insert(id='1', age=65, path='test1.txt', type='txt')
    i.insert(id='1', age=65, path='test1.gff', type='gff')
    selected = i.lookup(type='txt')
    assert len(selected.datasets.values()[0]) == 1