예제 #1
0
    def _get_available_organisms(self):
        available_organism = sorted([(tax_id, taxonomy.name(tax_id))
                                     for tax_id in taxonomy.common_taxids()],
                                    key=lambda x: x[1])

        self.organisms = [tax_id[0] for tax_id in available_organism]

        self.organism_select_combobox.addItems(
            [tax_id[1] for tax_id in available_organism])
예제 #2
0
def register_serverfiles(genesets):
    """ Registers using the common hierarchy and organism. """
    org = genesets.common_org()
    hierarchy = genesets.common_hierarchy()
    fn = filename(hierarchy, org)

    file_path = os.path.join(DOMAIN_PATH, fn)

    if org is not None:
        taxname = taxonomy.name(org)
        title = "Gene sets: " + ", ".join(hierarchy) + (
            (" (" + taxname + ")") if org is not None else "")

        tags = list(hierarchy) + ["gene sets"] + (
            [taxname] if org is not None else []) + taxonomy.shortname(org)
        genesets.to_gmt_file_format(file_path)
        create_info_file(file_path, title=title, tags=tags)
예제 #3
0
def kegg_gene_sets(tax_id: str) -> None:
    """ Returns gene sets from KEGG pathways.
    """
    caching.clear_cache()
    kegg_org = kegg.KEGGOrganism(taxonomy.name(tax_id))
    ncbi_id_mapper = kegg_org.kegg_to_ncbi_mapper()
    genesets = []

    for id in kegg_org.pathways():
        pway = kegg.KEGGPathway(id)
        hier = ('KEGG', 'Pathways')

        if pway.pathway_attributes():
            kegg_names = kegg_org.get_genes_by_pathway(id)
            mapped_genes = set()
            for gene in kegg_names:
                try:
                    mapped_genes.add(ncbi_id_mapper[gene.upper()])
                except KeyError:
                    # some kegg names can not be matched to ncbi ids
                    # they are included in geneset anyway
                    # remove prefix, that specifies kegg organism
                    # mapped_genes.append(gene.split(':')[-1])
                    pass

            gs = GeneSet(gs_id=id,
                         name=pway.title,
                         genes=mapped_genes,
                         hierarchy=hier,
                         organism=tax_id,
                         link=pway.link)
            genesets.append(gs)

    for gs_group in GeneSets(genesets).split_by_hierarchy():
        hierarchy = gs_group.common_hierarchy()
        gs_group.to_gmt_file_format(
            f'{data_path}/gene_sets/{filename(hierarchy, tax_id)}')
def listAvailable():
    taxids = taxonomy.common_taxids()
    essential = [(taxonomy.name(taxid), 'gene_association.{}'.format(taxid)) for taxid in taxids
                 if (DOMAIN, 'gene_association.{}'.format(taxid)) in serverfiles.ServerFiles().listfiles(DOMAIN)]
    return dict(essential)
예제 #5
0
 def setUp(self):
     self.common_ids = taxonomy.common_taxids()
     self.organisms = [(taxonomy.name(tax_id), tax_id)
                       for tax_id in self.common_ids]
     self.taxon = taxonomy.Taxonomy()