Merck / BioPhi

BioPhi is an open-source antibody design platform. It features methods for automated antibody humanization (Sapiens), humanness evaluation (OASis) and an interface for computer-assisted antibody sequence design.
https://biophi.dichlab.org/
MIT License
131 stars 44 forks source link

Get humanness from Python script #51

Closed tony-res closed 6 months ago

tony-res commented 11 months ago

I wasn't sure how to get the OASis and Germline scores from within a Python script. It works with this code, but I'm wondering if there is a simpler/more preferred way?

from biophi.common.utils.io import parse_antibody_files
from biophi.humanization.methods.humanness import OASisParams
from biophi.humanization.web.tasks import humanness_task, HumannessTaskResult

(
    antibody_inputs,
    invalid_names,
    duplicate_names,
    unrecognized_files,
) = parse_antibody_files(files=["./input.fasta"], verbose=False)

min_percent_subjects = 50
oasis_params = OASisParams(
    oasis_db_path="/general/biophi/OASis_9mers_v1.db",
    min_fraction_subjects=min_percent_subjects / 100,
)

file_index = 0
out = humanness_task(
    input=antibody_inputs[file_index],
    oasis_params=oasis_params,
    scheme="kabat",
    cdr_definition="kabat",
)

df = HumannessTaskResult.to_overview_dataframe([out])

where input.fasta is:

>Test1 H
QVQLQQSGAELARPGASVKMSCKASGYTFTRYTMHWVKQRPGQGLEWIGYINPSRGYTNYNQKFKDKATLTTDKSSSTAYMQLSSLTSEDSAVYYCARYYDDHYCLDYWGQGTTLTVSS