Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions examples/fetch_status_chart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from pipebio.pipebio_client import PipebioClient

client = PipebioClient(url='https://app.pipebio.com')

# Set document id to get the status chart for.
# NOTE: This document must be annotated or you will not get a good result back.
document_id = 'ent_TozXnaXkMVhEjFm9'

result = client.session.get(f'sequences/charts/StatusPieChart?documentId={document_id}')

data = result.json()

# Below are some examples of how to interact with the data returned from the StatusPieChart endpoint.
correct_count = data['status']['CORRECT']
assert correct_count == 131

incorrect_count = data['status']['INCORRECT']
assert incorrect_count == 6

assert data['total'] == correct_count + incorrect_count
2 changes: 1 addition & 1 deletion examples/run_extract_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Run an extract job and put the results in the new_folder we just created.
job_id = client.jobs.create(
shareable_id=shareable_id,
name='Extract job from API',
name='Extract job from SDK',
job_type=JobType.ExtractJob,
# Either hard code input entity ids or get these from the output_entity_ids from a previous job.
input_entity_ids=[document_id],
Expand Down
46 changes: 46 additions & 0 deletions examples/run_report_job_to_summarize_documents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import os
from pipebio.pipebio_client import PipebioClient
from pipebio.models.job_type import JobType

client = PipebioClient(url='https://app.pipebio.com')
shareable_id = os.environ['TARGET_SHAREABLE_ID']
folder_id = os.environ['TARGET_FOLDER_ID']

document_id = 'ent_PbyAluxijmJfNXph'

# Summarise 1 or more documents using a summary job.
job_id = client.jobs.create(
shareable_id=shareable_id,
name='Summary job from SDK',
job_type=JobType.SummaryJob,
# Include 1 or more document ids here to summarize in one go.
input_entity_ids=[document_id],
params={
"targetFolderId": folder_id
},
poll_jobs=True
)

# Fetch the job.
job = client.jobs.get(job_id)

# Get the id of the report that was created.
output_id = next(e['id'] for e in job['outputEntities'])

# Fetch the summary report we just created.
response = client.session.get(f'entities/{output_id}/attachments/Report')
result = response.json()
annotation_summary = next(item for item in result['data']['items'] if item['title'].startswith('Analysis results for'))

# Print the results.
# e.g:
# Id: SRR11974622
# Total reads: 1059733
# Correct annotated: 320376
# Correct annotated percent: 30.2317659259455
for row in annotation_summary['data']['rows']:
for col in annotation_summary['data']['columns']:
header = col['headerName']
field = col['field']
value = row[field]
print(f'{header}: {value}')