Python API

The HiGlass python API provides a functionality for starting a lightweight server, creating viewconfs and displaying a HiGlass component within Jupyter.

Connecting

resgen.connect(username: str | None = None, password: str | None = None, host: str = 'https://resgen.io', bucket: str = 'resgen') ResgenConnection[source]

Open a connection to resgen.

ResgenConnection

class resgen.ResgenConnection(username, password, host='https://resgen.io', bucket='resgen')[source]

Connection to the resgen server.

authenticated_request(func, *args, **kwargs)[source]

Send post request

download_progress(tileset_uuid)[source]

Get the download progress for a tileset.

Raise an exception if there’s no recorded tileset progress for this uuid.

find_datasets(search_string='', project=None, limit=1000, datafile=None, **kwargs)[source]

Search for datasets.

find_or_create_project(project_name: str, group: str | None = None, private: bool = True)[source]

Find or create a project.

For now this function can only create a project for the logged in user. If a project with the same name exists, do nothing.

Parameters:
  • project_name – The name of the project to create.

  • private – Whether to make this a private project.

find_project(project_name: str, gruser: str | None = None)[source]

Find a project.

get_chrominfo(chrominfo_ds)[source]

Retrieve chromosome information from a chromsizes dataset.

get_dataset(uuid)[source]

Retrieve a dataset.

get_genes(annotations_ds, gene_name)[source]

Retreive gene information by searching by gene name.

get_token() str[source]

Get a JWT token for interacting with the service.

list_projects(gruser: str | None = None)[source]

List the projects of the connected user or the specified group.

Parameters:

gruser – The name of the user or group to list projects for. Defaults to the connected user if not specified.

update_dataset(uuid: str, metadata: Dict[str, Any]) ResgenDataset[source]

Update the properties of a dataset.

upload_to_resgen_aws(filepath: str, prefix: str | None = None, index_filepath=None) str[source]

Upload file to a resgen aws bucket.

Parameters:
  • filepath – The local filepath

  • prefix – A prefix to upload to on the S3 bucket

Returns:

The path within the bucket where the object is uploaded

ResgenProject

class resgen.ResgenProject(uuid: str, conn: ResgenConnection, name: str | None = None)[source]

Encapsulates a project on the resgen service.

add_download_dataset(filepath: str, index_filepath: str | None = None)[source]

Add a dataset by downloading it from a remote source

Parameters:
  • filepath – The filename of the dataset to add. Can also be a url.

  • index_filepath – The filename of the index for this dataset

Returns:

The uuid of the newly created dataset.

add_folder_dataset(folder_name: str, parent: str)[source]

Add a folder dataset.

Add a remote dataset

Parameters:
  • filepath – The filename of the dataset to add. Can also be a url.

  • index_filepath – The filename of the index for this dataset

Returns:

The uuid of the newly created dataset.

add_upload_dataset(filepath: str, index_filepath: str | None = None, name: str | None = None, parent: str | None = None, private: bool = True)[source]

Add a dataset by uploading it to resgen

Parameters:
  • filepath – The filename of the dataset to add. Can also be a url.

  • index_filepath – The filename of the index for this dataset

  • name – The name to add to this dataset

  • parent – The directory to put this dataset under

  • private – Whether to add this as a private dataset

Returns:

The uuid of the newly created dataset.

add_viewconf(viewconf, name)[source]

Save a viewconf to this project.

delete_dataset(uuid: str)[source]

Delete a dataset.

delete_viewconf(uuid)[source]

Delete a viewconf.

list_datasets(limit: int = 1000)[source]

List the datasets available in this project.

Returns up to a limit

sync_dataset(filepath: str, sync_remote: bool = False, filetype=None, datatype=None, assembly=None, index_filepath=None, force_update: bool = False, sync_full_path: bool = False, **metadata)[source]

Check if this file already exists in this dataset.

Do nothing if it does and create it if it doesn’t. If a new dataset is created.

In both instances, ensure that the metadata is updated. The available metadata tags that can be updated are: name and tags

If more than one dataset with this name exists, raise a ValueError.

Args:

sync_genome(base_url, genome_info, dry=False)[source]

Sync a genome within a track hub.

sync_track_hub(base_url, dry=False)[source]

Sync a UCSC track hub.

sync_viewconf(viewconf, name)[source]

Create a viewconf if it doesn’t exist and update it if it does.

ChromosomeInfo

class resgen.ChromosomeInfo[source]
to_abs(chrom: str, pos: int) int[source]

Calculate absolute coordinates.

to_abs_range(chrom: str, start: int, end: int, padding: float = 0, padding_abs: float = 0) Tuple[int, int][source]

Return a range along a chromosome with optional padding.