File: __init__.py

package info (click to toggle)
python-bioblend 1.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,096 kB
  • sloc: python: 7,596; sh: 219; makefile: 158
file content (129 lines) | stat: -rw-r--r-- 3,605 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
"""
Contains possible interactions with the Galaxy Histories
"""
from typing import (
    Any,
    Dict,
    Optional,
    TYPE_CHECKING,
)

from typing_extensions import Literal

from bioblend.galaxy.client import Client

if TYPE_CHECKING:
    from bioblend.galaxy import GalaxyInstance


class GenomeClient(Client):
    module = "genomes"

    def __init__(self, galaxy_instance: "GalaxyInstance") -> None:
        super().__init__(galaxy_instance)

    def get_genomes(self) -> list:
        """
        Returns a list of installed genomes

        :rtype: list
        :return: List of installed genomes
        """
        genomes = self._get()
        return genomes

    def show_genome(
        self,
        id: str,
        num: Optional[str] = None,
        chrom: Optional[str] = None,
        low: Optional[str] = None,
        high: Optional[str] = None,
    ) -> Dict[str, Any]:
        """
        Returns information about build <id>

        :type id: str
        :param id: Genome build ID to use

        :type num: str
        :param num: num

        :type chrom: str
        :param chrom: chrom

        :type low: str
        :param low: low

        :type high: str
        :param high: high

        :rtype: dict
        :return: Information about the genome build
        """
        params: Dict[str, str] = {}
        if num:
            params["num"] = num
        if chrom:
            params["chrom"] = chrom
        if low:
            params["low"] = low
        if high:
            params["high"] = high
        return self._get(id=id, params=params)

    def install_genome(
        self,
        func: Literal["download", "index"] = "download",
        source: Optional[str] = None,
        dbkey: Optional[str] = None,
        ncbi_name: Optional[str] = None,
        ensembl_dbkey: Optional[str] = None,
        url_dbkey: Optional[str] = None,
        indexers: Optional[list] = None,
    ) -> Dict[str, Any]:
        """
        Download and/or index a genome.

        :type func: str
        :param func: Allowed values: 'download', Download and index; 'index', Index only

        :type source: str
        :param source: Data source for this build. Can be: UCSC, Ensembl, NCBI, URL

        :type dbkey: str
        :param dbkey: DB key of the build to download, ignored unless 'UCSC' is specified as the source

        :type ncbi_name: str
        :param ncbi_name: NCBI's genome identifier, ignored unless NCBI is specified as the source

        :type ensembl_dbkey: str
        :param ensembl_dbkey: Ensembl's genome identifier, ignored unless Ensembl is specified as the source

        :type url_dbkey: str
        :param url_dbkey: DB key to use for this build, ignored unless URL is specified as the source

        :type indexers: list
        :param indexers: POST array of indexers to run after downloading (indexers[] = first, indexers[] = second, ...)

        :rtype: dict
        :return: dict( status: 'ok', job: <job ID> )
                 If error:
                 dict( status: 'error', error: <error message> )
        """
        payload: Dict[str, Any] = {}
        if source:
            payload["source"] = source
        if func:
            payload["func"] = func
        if dbkey:
            payload["dbkey"] = dbkey
        if ncbi_name:
            payload["ncbi_name"] = ncbi_name
        if ensembl_dbkey:
            payload["ensembl_dbkey"] = ensembl_dbkey
        if url_dbkey:
            payload["url_dbkey"] = url_dbkey
        if indexers:
            payload["indexers"] = indexers
        return self._post(payload)