<jupyter_start><jupyter_text>GECCO PhenoPacketsThis notebook runs the same work as FASPScript10. In addition to showing how the three FASP steps can be run from a notebook, it uses the Seven Bridges WES Client in place of direct use of the Seven Bridges CGC API.<jupyter_code>#  IMPORTS

from fasp.runner import FASPRunner

# The implementations we're using
from fasp.search import DataConnectClient
from fasp.loc import DRSMetaResolver
from fasp.workflow import sbcgcWESClient
pp_dbgap_join = """SELECT sp.dbGaP_Subject_ID, 'sbcgc:'||sb_drs_id 
FROM dbgap_demo.scr_gecco_susceptibility.subject_phenotypes_multi sp 
join dbgap_demo.scr_gecco_susceptibility.sample_multi sm on sm.dbgap_subject_id = sp.dbgap_subject_id 
join dbgap_demo.scr_gecco_susceptibility.sb_drs_index di on di.sample_id = sm.sample_id 
join sample_phenopackets.ga4gh_tables.gecco_phenopackets pp on pp.id = sm.biosample_accession 
where  json_extract_scalar(pp.phenopacket, '$.subject.sex') = 'MALE' and file_type = 'cram' limit 3 """

# Step 1 - Discovery
# query for relevant DRS objects
searchClient = DataConnectClient('https://ga4gh-search-adapter-presto-public.prod.dnastack.com/')
# Step 2 - DRS - a metaresolver will deal with which drs server is required
drsClient = DRSMetaResolver()
# Step 3 - set up a class that run a compute for us
faspRunner = FASPRunner()
settings = faspRunner.settings
wesClient = sbcgcWESClient(settings['SevenBridgesProject'])
faspRunner.configure(searchClient, drsClient, wesClient)

faspRunner.runQuery(pp_dbgap_join, 'Phenopacket Gecco')<jupyter_output>Running query
SELECT sp.dbGaP_Subject_ID, 'sbcgc:'||sb_drs_id 
FROM dbgap_demo.scr_gecco_susceptibility.subject_phenotypes_multi sp 
join dbgap_demo.scr_gecco_susceptibility.sample_multi sm on sm.dbgap_subject_id = sp.dbgap_subject_id 
join dbgap_demo.scr_gecco_susceptibility.sb_drs_index di on di.sample_id = sm.sample_id 
join sample_phenopackets.ga4gh_tables.gecco_phenopackets pp on pp.id = sm.biosample_accession 
where  json_extract_scalar(pp.phenopacket, '$.subject.sex') = 'MALE' and file_type = 'cram' limit 3 
_Retrieving the query_
____Page1_______________
____Page2_______________
____Page3_______________
____Page4_______________
____Page5_______________
____Page6_______________
____Page7_______________
____Page8_______________
subject=2474312, drsID=sbcgc:5baa8cece4b0db63859e6590
https://cgc-ga4gh-api.sbgenomics.com/ga4gh/wes/v1
workflow submitted, run:16093ce2-e157-4148-9a2f-e2d051c9482a
____________________________________________________________
subject=2473610, drsID=sbcgc:5[...]
{'fraction_non_alphanumeric': 0.07084468664850137, 'fraction_numerical': 0.028026469443363178, 'mean_word_length': 7.056426332288401, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '173154', 'license': 'Apache-2.0', 'n_tokens_mistral': 957, 'n_tokens_neox': 885, 'n_words': 199, 'path': 'notebooks/FASPNotebook10-PhenoPackets.ipynb', 'repo_name': 'ga4gh/fasp-scripts', 'size': '2569'}