Пример #1
0
    def add_genelist(self, list_id, gene_ids, case_obj=None):
        """Create a new gene list and optionally link to cases."""
        new_genelist = GeneList(list_id=list_id)
        new_genelist.gene_ids = gene_ids
        if case_obj:
            new_genelist.cases.append(case_obj)

        self.session.add(new_genelist)
        self.save()
        return new_genelist
Пример #2
0
    def add_genelist(self, list_id, gene_ids, case_obj=None):
        """Create a new gene list and optionally link to cases."""
        new_genelist = GeneList(list_id=list_id)
        new_genelist.gene_ids = gene_ids
        if case_obj:
            new_genelist.cases.append(case_obj)

        self.session.add(new_genelist)
        self.save()
        return new_genelist
Пример #3
0
    def case_genelist(self, case_obj):
        """Get or create a new case specific gene list record."""
        list_id = "{}-HPO".format(case_obj.case_id)
        gene_list = self.gene_list(list_id)

        if gene_list is None:
            gene_list = GeneList(list_id=list_id)
            case_obj.gene_lists.append(gene_list)
            self.session.add(gene_list)

        return gene_list
Пример #4
0
def test_delete_gene():
    gene_list = GeneList(list_id='my cool list')
    assert gene_list.list_id == 'my cool list'
    assert gene_list.gene_ids == []

    gene_ids = ['ADK', 'SKD', 'EGFR']
    gene_list.gene_ids = gene_ids
    assert gene_list._gene_ids == ','.join(gene_ids)

    # remove one gene
    gene_list.delete_gene('ADK')
    assert gene_list.gene_ids == gene_ids[1:]

    # remove multiple genes
    gene_list.delete_gene('SKD', 'EGFR')
    assert gene_list.gene_ids == []