def test_genome_halving_only_rearrangements_post_wgd(): param = simulator.SimParameters(wgd_type="GH", num_genes=40, num_chr=2, events=[0, 10]) sim = simulator.Simulation(folder=None, sim_parameters=param) genomes = sim.run_simulation() assert 2 * len(genomes[0].chromosomes) == len(genomes[2].chromosomes) assert len(genomes[0].gene_count().keys()) == len(genomes[2].gene_count().keys()) assert str(genomes[0].chromosomes[0]) == str(genomes[1].chromosomes[0]) and \ str(genomes[0].chromosomes[1]) == str(genomes[1].chromosomes[1])
def test_genome_halving_only_deletions_pre_wgd(): param = simulator.SimParameters(wgd_type="GH", num_genes=40, num_chr=2, del_p=[1, 0], indel_length=[3, 0], events=[10, 0]) sim = simulator.Simulation(folder=None, sim_parameters=param) genomes = sim.run_simulation() assert 2 * len(genomes[0].chromosomes) >= len(genomes[1].chromosomes) assert len(genomes[0].gene_count().keys()) > len(genomes[1].gene_count().keys()) assert len(genomes[1].gene_count().keys()) == len(genomes[2].gene_count().keys())
def test_pipeline_double_distance_with_only_inter_chromosomal_segmental_duplication(): param = simulator.SimParameters(wgd_type="DD", num_genes=40, num_chr=2, duplication_p=[0, 1], duplication_length=[0, 3], events=[0, 10], inter_p=1) sim = simulator.Simulation(folder=None, sim_parameters=param) genomes = sim.run_simulation() assert 2 * len(genomes[0].chromosomes) == len(genomes[1].chromosomes) assert len(genomes[0].gene_count().keys()) == len(genomes[1].gene_count().keys()) assert sum(genomes[0].gene_count().values()) < sum(genomes[1].gene_count().values())
def test_pipeline_double_distance_only_deletions(): param = simulator.SimParameters(wgd_type="DD", num_genes=40, num_chr=2, del_p=[0, 1], indel_length=[0, 3], events=[0, 10]) sim = simulator.Simulation(folder=None, sim_parameters=param) genomes = sim.run_simulation() assert 2 * len(genomes[0].chromosomes) >= len(genomes[1].chromosomes) assert len(genomes[0].gene_count().keys()) >= len(genomes[1].gene_count().keys()) assert 2 * sum(genomes[0].gene_count().values()) > sum(genomes[1].gene_count().values())
def test_genome_halving_only_segmental_duplications_post_wgd(): param = simulator.SimParameters(wgd_type="GH", num_genes=40, num_chr=2, duplication_p=[0, 1], duplication_length=[0, 3], events=[0, 10]) sim = simulator.Simulation(folder=None, sim_parameters=param) genomes = sim.run_simulation() assert 2 * len(genomes[0].chromosomes) == len(genomes[2].chromosomes) assert len(genomes[0].gene_count().keys()) == len(genomes[1].gene_count().keys()) assert len(genomes[1].gene_count().keys()) == len(genomes[2].gene_count().keys()) assert sum(genomes[0].gene_count().values()) == sum(genomes[1].gene_count().values()) assert 2 * sum(genomes[1].gene_count().values()) < sum(genomes[2].gene_count().values())
from src import simulator import pyximport pyximport.install() from utils import model, dcj test_sim = simulator.Simulation(folder=None) # TODO: FIGURE OUT WHETHER OR NOT COPY NUMBER IS CORRECT, MAY HAVE TO MODIFY SOME TESTS FOR THIS IN THE NEAR FUTURE # UTILITY FUNCTIONS def gen_genome(genes, chromosomes): genome = model.Genome.identity(genes, chromosomes) for chromosome in genome.chromosomes: chromosome.copy_number = [1] * len(chromosome.gene_order) return genome def get_chr(genome, number): return genome.chromosomes[number].gene_order def get_copy_number(genome, number): return genome.chromosomes[number].copy_number ################################# # BASIC FUNCTIONALITY TESTS ##### #################################