Exemple #1
0
def self():
    # Set up
    self = Empty()
    self.genomes = test_utils.load_test_genomes()
    self.broken_genome = test_utils.load_broken_genome()
    self.wd_loc = test_utils.load_test_wd_loc()
    self.test_dir = test_utils.load_random_test_dir()
    self.s_wd_loc = test_utils.load_solutions_wd()

    if os.path.isdir(self.test_dir):
        shutil.rmtree(self.test_dir)

    if os.path.isdir(self.wd_loc):
        shutil.rmtree(self.wd_loc, ignore_errors=True)
    if not os.path.isdir(self.test_dir):
        os.mkdir(self.test_dir)

    importlib.reload(logging)

    yield self

    # Teardown
    logging.shutdown()
    if os.path.isdir(self.wd_loc):
        shutil.rmtree(self.wd_loc)
    if os.path.isdir(self.test_dir):
        shutil.rmtree(self.test_dir)
Exemple #2
0
def self():
    # Set up
    self = Empty()
    self.s_wd_loc = test_utils.load_solutions_wd()
    self.working_wd_loc = test_utils.load_test_wd_loc()
    self.genomes = test_utils.load_test_genomes()

    logging.shutdown()
    if os.path.isdir(self.working_wd_loc):
        shutil.rmtree(self.working_wd_loc, ignore_errors=True)

    os.mkdir(self.working_wd_loc)
    shutil.copytree(os.path.join(self.s_wd_loc, 'data'), \
                    os.path.join(self.working_wd_loc, 'data'))
    shutil.rmtree(os.path.join(self.working_wd_loc, 'data',
                               'Clustering_files'))

    importlib.reload(logging)

    yield self

    # Teardown
    logging.shutdown()
    if os.path.isdir(self.working_wd_loc):
        shutil.rmtree(self.working_wd_loc, ignore_errors=True)
Exemple #3
0
def self(caplog):

    # Set up
    self = Empty()
    self._caplog = caplog
    self.genomes = test_utils.load_test_genomes()
    self.wd_loc = test_utils.load_test_wd_loc()
    self.s_wd_loc = test_utils.load_solutions_wd()
    self.testdir = test_utils.load_random_test_dir()
    self.stinker_genome = os.path.join(test_utils.load_test_backend(), 'other/Enterococcus_faecalis_TX0104.fa')

    self.prodigal_loc = os.path.join(test_utils.load_solutions_wd(), 'data/prodigal/')

    # Teardown
    importlib.reload(logging)
    if os.path.isdir(self.wd_loc):
        shutil.rmtree(self.wd_loc)

    yield self
Exemple #4
0
def self():
    # Set up
    self = Empty()
    self.genomes = test_utils.load_test_genomes()
    self.wd_loc = test_utils.load_test_wd_loc()
    self.s_wd_loc = test_utils.load_solutions_wd()
    self.testdir = test_utils.load_random_test_dir()

    importlib.reload(logging)
    if os.path.isdir(self.wd_loc):
        shutil.rmtree(self.wd_loc)

    yield self

    # Teardown
    logging.shutdown()
    if os.path.isdir(self.wd_loc):
        shutil.rmtree(self.wd_loc)
Exemple #5
0
def self():
    # Set up
    self = Empty()
    self.genomes = test_utils.load_test_genomes()
    self.wd_loc = test_utils.load_test_wd_loc()
    self.s_wd_loc = test_utils.load_solutions_wd()
    self.zipped_genome = test_utils.load_zipped_genome()

    importlib.reload(logging)
    if os.path.isdir(self.wd_loc):
        shutil.rmtree(self.wd_loc)
    os.mkdir(self.wd_loc)

    yield self

    importlib.reload(logging)
    if os.path.isdir(self.wd_loc):
        shutil.rmtree(self.wd_loc)
    os.mkdir(self.wd_loc)
Exemple #6
0
def test_goANI2(self):
    '''
    Test goANI in the case where the genomes share no genes
    '''
    import time

    bdb = drep.d_cluster.utils.load_genomes(self.genomes)
    data_folder = self.test_dir

    # Copy over prodigal
    self.s_wd_loc = test_utils.load_solutions_wd()
    p_folder = os.path.join(data_folder, 'data/prodigal/')
    shutil.copytree(os.path.join(self.s_wd_loc, 'data/prodigal'), \
        p_folder)

    # Remove all but one gene in one of the prodigal files
    p_folder = os.path.join(data_folder, 'data/prodigal/')
    for f in glob.glob(p_folder + '*'):
        if 'Escherichia_coli_Sakai.fna.fna' in f:
            new_file = open(f + '.2', 'w')
            old_file = open(f, 'r')
            j = 0
            for line in old_file.readlines():
                if ((line[0] == '>') & (j != 0)):
                    break
                j += 1
                new_file.write(line.strip() + '/')
            new_file.close()
            old_file.close()
            os.remove(f)
            shutil.copy(f + '.2', f)

    # Try goANI
    p_folder = os.path.join(data_folder, 'data/prodigal/')
    Ndb = drep.d_cluster.compare_utils.compare_genomes(bdb, 'goANI', data_folder, \
                                                       prod_folder = p_folder)
    db = Ndb[(Ndb['reference'] == 'Enterococcus_faecalis_T2.fna')\
        & (Ndb['querry'] == 'Enterococcus_casseliflavus_EC20.fasta')]

    assert (db['ani'].tolist()[0] > 0.7) & (db['ani'].tolist()[0] < 0.8)
Exemple #7
0
def test_goANI(self):
    '''
    Test goANI
    '''
    import time

    bdb = drep.d_cluster.utils.load_genomes(self.genomes)
    data_folder = self.test_dir

    # Copy over prodigal
    self.s_wd_loc = test_utils.load_solutions_wd()
    p_folder = os.path.join(data_folder, 'data/prodigal/')
    shutil.copytree(os.path.join(self.s_wd_loc, 'data/prodigal'), \
        p_folder)

    # Try goANI
    p_folder = os.path.join(data_folder, 'data/prodigal/')
    Ndb = drep.d_cluster.compare_utils.compare_genomes(bdb, 'goANI', data_folder, \
                                                       prod_folder = p_folder)
    db = Ndb[(Ndb['reference'] == 'Enterococcus_faecalis_T2.fna')\
        & (Ndb['querry'] == 'Enterococcus_casseliflavus_EC20.fasta')]

    assert (db['ani'].tolist()[0] > 0.7) & (db['ani'].tolist()[0] < 0.8)
Exemple #8
0
def self():
    # Set up
    self = Empty()
    self.genomes = test_utils.load_test_genomes()
    self.zipped_genomes = test_utils.load_zipped_genomes()
    self.large_genome_set = test_utils.load_large_genome_set()
    self.wd_loc = test_utils.load_test_wd_loc()
    self.wd_loc2 = test_utils.load_test_wd_loc_2()
    self.s_wd_loc = test_utils.load_solutions_wd()

    importlib.reload(logging)
    if os.path.isdir(self.wd_loc):
        shutil.rmtree(self.wd_loc)
    if os.path.isdir(self.wd_loc2):
        shutil.rmtree(self.wd_loc2)

    yield self

    # Teardown
    logging.shutdown()
    if os.path.isdir(self.wd_loc):
        shutil.rmtree(self.wd_loc)
    if os.path.isdir(self.wd_loc2):
        shutil.rmtree(self.wd_loc2)