Skip to content

Commit ee2f1a3

Browse files
author
Markus Johansson
committed
Added method for creating reference genomes
1 parent ef7cb25 commit ee2f1a3

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

src/bonsai_libs/api_client/bonsai/client.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
from .models import (
1515
CreateGroupInput,
16+
CreateReferenceGenomeInput,
1617
CreateSampleResponse,
1718
CreateUserInput,
1819
GenomicResourceInput,
@@ -391,4 +392,25 @@ def get_igv_config(self, sample_id: str, *, analysis_id: str | None = None, vari
391392
except UnauthorizedError as exc:
392393
LOG.error("Failed authenticating user", exc_info=exc)
393394
raise
395+
return resp.data
396+
397+
# ----------------------------
398+
# References
399+
# ----------------------------
400+
401+
def create_reference_genome(self, reference_genome: CreateReferenceGenomeInput,*, headers: OpHeaders = None) -> dict[str, Any]:
402+
"""Get a IGV configuration for a sample.
403+
404+
Optional center the view on a variant by providing a analysis_id and variant_id
405+
"""
406+
try:
407+
resp = self.request_json(
408+
"POST",
409+
f"reference-genomes",
410+
json=reference_genome.model_dump(mode="json"),
411+
headers=headers,
412+
)
413+
except UnauthorizedError as exc:
414+
LOG.error("Failed authenticating user", exc_info=exc)
415+
raise
394416
return resp.data

src/bonsai_libs/api_client/bonsai/models.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,32 @@ class GenomicResourceInput(Model):
241241
reference_genome_id: str
242242
pipeline_run_id: str
243243
resource_data: list[AnnotationTrack] = Field(default_factory=list, min_length=1)
244+
245+
246+
class GenomicResourceBase(Model):
247+
"""BED file track."""
248+
249+
# Classification
250+
format: str = Field(..., description="File format, e.g. bed, gff, gtf")
251+
type: str = Field(..., description="alignment | variant | annotation")
252+
253+
# Metadata
254+
name: str = Field(..., description="Track name shown in IGV")
255+
256+
path: str = Field(..., description="Path to main resource file")
257+
index_path: str | None = Field(
258+
None, description="Optional path to index file."
259+
)
260+
261+
262+
class CreateReferenceGenomeInput(Model):
263+
"""Input to create-reference-genome"""
264+
265+
name: str = Field(..., description="Human-readable name")
266+
accession: str = Field(..., description="RefSeq accession")
267+
organism: str = Field(..., description="Scientific name")
268+
269+
fasta_resource: str = Field(..., description="Path or URL to FASTA file")
270+
fasta_index_resource: str = Field(..., description="Path or URL to FASTA index.")
271+
272+
reference_tracks: list[ResourceInput] = Field(default_factory=list, description="Optional list of reference tracks")

0 commit comments

Comments
 (0)