Exemplo n.º 1
0
 def test_blastdb():
     'It creates a blast database.'
     db_name = 'arabidopsis_genes'
     seq_fpath = os.path.join(TEST_DATA_DIR, db_name)
     db_dir = TemporaryDir(prefix='blast_dbs_')
     try:
         db_path1 = get_or_create_blastdb(seq_fpath, directory=db_dir.name,
                                 dbtype='nucl')
         db_path = os.path.join(db_dir.name, db_name)
         assert 'CATAGGGTCACCAATGGC' in open(db_path1).read(100)
         assert db_path1 == db_path
         assert os.path.exists(db_path)
         index_fpath = os.path.join(db_dir.name, db_name + '.nsq')
         assert os.path.exists(index_fpath)
     finally:
         db_dir.close()
Exemplo n.º 2
0
 def test_blast_search(self):
     'It does a blast search'
     db_name = 'arabidopsis_genes'
     seq_fpath = os.path.join(TEST_DATA_DIR, db_name)
     db_dir = TemporaryDir(prefix='blast_dbs_')
     try:
         db_fpath = get_or_create_blastdb(seq_fpath, directory=db_dir.name,
                                           dbtype='nucl')
         query_fhand = NamedTemporaryFile()
         query_fhand.write(open(seq_fpath).read(200))
         query_fhand.flush()
         out_fhand = NamedTemporaryFile()
         do_blast(seq_fpath, db_fpath, program='blastn',
                  out_fpath=out_fhand.name)
         assert '</BlastOutput>' in open(out_fhand.name).read()
     finally:
         db_dir.close()
Exemplo n.º 3
0
 def test_blastdb():
     'It creates a blast database.'
     db_name = 'arabidopsis_genes'
     seq_fpath = os.path.join(TEST_DATA_DIR, db_name)
     db_dir = TemporaryDir(prefix='blast_dbs_')
     try:
         db_path1 = get_or_create_blastdb(seq_fpath,
                                          directory=db_dir.name,
                                          dbtype='nucl')
         db_path = os.path.join(db_dir.name, db_name)
         assert 'CATAGGGTCACCAATGGC' in open(db_path1).read(100)
         assert db_path1 == db_path
         assert os.path.exists(db_path)
         index_fpath = os.path.join(db_dir.name, db_name + '.nsq')
         assert os.path.exists(index_fpath)
     finally:
         db_dir.close()
Exemplo n.º 4
0
 def test_blast_search(self):
     'It does a blast search'
     db_name = 'arabidopsis_genes'
     seq_fpath = os.path.join(TEST_DATA_DIR, db_name)
     db_dir = TemporaryDir(prefix='blast_dbs_')
     try:
         db_fpath = get_or_create_blastdb(seq_fpath,
                                          directory=db_dir.name,
                                          dbtype='nucl')
         query_fhand = NamedTemporaryFile()
         query_fhand.write(open(seq_fpath).read(200))
         query_fhand.flush()
         out_fhand = NamedTemporaryFile()
         do_blast(seq_fpath,
                  db_fpath,
                  program='blastn',
                  out_fpath=out_fhand.name)
         assert '</BlastOutput>' in open(out_fhand.name).read()
     finally:
         db_dir.close()
Exemplo n.º 5
0
    def test_get_or_create_blastdb():
        blastdb = os.path.join(TEST_DATA_DIR, 'arabidopsis_genes')

        directory = TemporaryDir()
        assert not _blastdb_exists(blastdb, NUCL)
        get_or_create_blastdb(blastdb, NUCL, directory.name)
        new_blast_path = os.path.join(directory.name,
                                      os.path.basename(blastdb))
        assert _blastdb_exists(new_blast_path, NUCL)
        get_or_create_blastdb(blastdb, NUCL, directory.name)
        assert _blastdb_exists(new_blast_path, NUCL)
        directory.close()

        # already exists
        blastdb = os.path.join(TEST_DATA_DIR, 'blastdbs', 'arabidopsis_genes')
        assert _blastdb_exists(blastdb, NUCL)
        get_or_create_blastdb(blastdb, NUCL)
        assert _blastdb_exists(blastdb, NUCL)
Exemplo n.º 6
0
    def test_get_or_create_blastdb():
        blastdb = os.path.join(TEST_DATA_DIR, 'arabidopsis_genes')

        directory = TemporaryDir()
        assert not _blastdb_exists(blastdb, NUCL)
        get_or_create_blastdb(blastdb, NUCL, directory.name)
        new_blast_path = os.path.join(directory.name,
                                      os.path.basename(blastdb))
        assert _blastdb_exists(new_blast_path, NUCL)
        get_or_create_blastdb(blastdb, NUCL, directory.name)
        assert _blastdb_exists(new_blast_path, NUCL)
        directory.close()

        # already exists
        blastdb = os.path.join(TEST_DATA_DIR, 'blastdbs', 'arabidopsis_genes')
        assert _blastdb_exists(blastdb, NUCL)
        get_or_create_blastdb(blastdb, NUCL)
        assert _blastdb_exists(blastdb, NUCL)