mgnipy.mgnipy module#
- class mgnipy.mgnipy.MGnipy(config=None, **config_kwargs)[source]#
Bases:
objectMain class for interacting with the MGnify API. Provides methods to access different resources (e.g., studies, samples, analyses) and their details, as well as utility methods for listing resources and describing endpoints.
- Parameters:
config (MGnipyConfig or dict , optional) – Configuration for MGnipy, either as an MGnipyConfig instance or a dictionary of configuration parameters (default is None).
**config_kwargs – Additional keyword arguments to pass to the MGnipyConfig constructor if config is not provided. For example, cache_dir can be specified as a keyword argument. e.g. MGnipy(cache_dir=”/path/to/cache”)
Examples
>>> MG = MGnipy(cache_dir="/path/to/cache") >>> print(MG.cache_dir) /path/to/cache
- clear_subcaches()[source]#
Clear the cache for a specific resource or all resources.
- Parameters:
resource (str , optional) – The name of the resource to clear the cache for. If None, clears the cache for all resources (default is None).
- Return type:
None
- describe_resource(resource, as_dict=False)[source]#
Provides a description of the endpoint from the openapi documentation i.e., https://www.ebi.ac.uk/metagenomics/api/v2/openapi.json
- Parameters:
- Returns:
A dictionary mapping parameter names to their descriptions if as_dict is True, otherwise None.
- Return type:
dict of str to str or None
- describe_resources(resource=None, as_dict=False)[source]#
Provides a description of the endpoint from the openapi documentation i.e., https://www.ebi.ac.uk/metagenomics/api/v2/openapi.json
- Parameters:
- Returns:
A dictionary mapping parameter names to their descriptions if as_dict is True, otherwise None.
- Return type:
dict of str to str or None