Beispiel #1
0
    def _make_gene_pair(org, gene_id1, gene_id2):
        """create a pair of genes that belong to the same organism."""
        lo_genes = []
        for k in gene_id1, gene_id2:
            o_gene = Gene(k)
            o_gene.fill_parents(org, None)

            lo_genes.append(o_gene)

            o_family = GeneFamily(k, k)
            o_family.addGene(o_gene)

        return tuple(lo_genes)
Beispiel #2
0
    def _make_gene_pair(org, gene_id1, gene_id2):
        """create 2 genes from org.
            each gene belong to its own family."""
        lo_genes = []
        for k in gene_id1, gene_id2:
            o_gene = Gene(k)
            o_gene.fill_parents(org, None)

            lo_genes.append(o_gene)

            o_family = GeneFamily(k, k)
            o_family.addGene(o_gene)

        return tuple(lo_genes)
Beispiel #3
0
def test_cstr():
    o_src = Gene('source')
    o_tgt = Gene('target')

    # set organism and contig to None.
    o_src.fill_parents(None, None)
    o_tgt.fill_parents(None, None)

    # define the None GeneFamily, and add the 2 genes to it.
    o_family = GeneFamily(None, None)
    o_family.addGene(o_src)
    o_family.addGene(o_tgt)

    o_edge = Edge(o_src, o_tgt)
    assert isinstance(o_edge, Edge)

    assert o_edge.source == o_src.family
    assert o_edge.target == o_tgt.family
    assert dict(o_edge.organisms) == {None: [(o_src, o_tgt)]}
def filled_families():
    """
    return a list of families and genes.
    there will be between 3 and 10 genes/families.
    Each family has only one gene.
    """
    lo_genes = []
    lo_fam   = []

    n_families = randint(3, 10)
    for fam in range(n_families):
        o_gene = Gene(fam)
        o_gene.fill_parents(None, None)

        o_family = GeneFamily(fam,fam)
        o_family.addGene(o_gene)

        lo_genes.append(o_gene)
        lo_fam.append(o_family)

    return lo_fam, lo_genes
def test_cstr():
    ID = 33
    name = "33"
    o_family = GeneFamily(ID, name)
    assert isinstance(o_family, GeneFamily)

    for attr in "ID", "name", "genes", \
                "removed", "sequence", "partition":
        assert hasattr(o_family, attr)
    assert o_family.ID == ID
    assert o_family.name == name
    assert o_family.genes == set()
    assert o_family.removed == False
    assert o_family.sequence == ""
    assert o_family.partition == ""
Beispiel #6
0
def test_cstr_error():
    o_src = Gene('source')
    o_tgt = Gene('target')
    # genes should have a family
    with pytest.raises(Exception):
        o_edge = Edge(o_src, o_tgt)

    o_family = GeneFamily(None, None)
    o_family.addGene(o_src)
    # both genes sould have a family
    with pytest.raises(Exception):
        o_edge = Edge(o_src, o_tgt)

    # gene should belong to the same organism
    o_family.addGene(o_tgt)
    o_src.fill_parents("", None)
    o_tgt.fill_parents(None, None)
    with pytest.raises(Exception):
        o_edge = Edge(o_src, o_tgt)
def o_family():
    return GeneFamily(33, "trente-trois")