Skip to content

Instantly share code, notes, and snippets.

View callahantiff's full-sized avatar
🦈
beep bop booping

Tiffany J. Callahan callahantiff

🦈
beep bop booping
View GitHub Profile
@callahantiff
callahantiff / keyword_search_github_repositories.py
Last active January 1, 2024 11:17
GitHub API Repository Search (Python 3.6.2)
#!/usr/bin/env python3.6.2
# -*- coding: utf-8 -*-
# run script from command line via python3 keyword_search_github_repositories.py
import click
import datetime
import time
from github import Github
@callahantiff
callahantiff / ncbo_rest_api.py
Last active May 16, 2023 16:07
Mapping Identifiers via the NCBO BioPortal API
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# import needed libraries
import glob
import json
import os
import pickle
import random
import requests
@callahantiff
callahantiff / gene_edge_lists.py
Last active March 18, 2020 02:33
Pacific Northwest National Laboratory Collaboration
############
## PURPOSE: Generate gene-centric edge lists for collaboration with PNNL
## Master Repo: https://github.com/callahantiff/PheKnowLator/wiki/v2.0.0
## Edge Data: https://github.com/callahantiff/PheKnowLator/wiki/v2-Data-Sources
###########
# import needed libraries
import pandas
import pickle
import json
@callahantiff
callahantiff / congenital_hypothyroidism.sql
Last active November 27, 2019 00:32
Med2Mech Patient Cohorts
-- Query 1: Search for specific patients using specific vocabulary codes
SELECT DISTINCT
CONCAT('"', CAST(c1.concept_id AS STRING), '"') AS OMOP_ID,
c1.concept_name AS OMOP_LABEL,
CONCAT('"', CAST(c.concept_code AS STRING), '"') AS CLINICAL_CODE,
CONCAT('"', CAST(c1.concept_code AS STRING), '"') AS SNOMED_CODE,
c.vocabulary_id AS VOCABULARY
FROM CHCO_DeID_Oct2018.concept c
JOIN CHCO_DeID_Oct2018.concept_relationship r ON r.concept_id_1 = c.concept_id
SELECT * FROM
(SELECT patient_id, disease_group_label, disease_group_num, disease_group_abbreviation, condition_concept_id AS concept_id, visit_occurrence_id, visit_start_interval
FROM CHCO_DeID_Oct2018.Med2Mech_RareDisease_Conditions
WHERE visit_start_interval>0 AND visit_end_interval>0)
UNION ALL
(SELECT patient_id, disease_group_label, disease_group_num, disease_group_abbreviation, drug_concept_id AS concept_id, visit_occurrence_id, visit_start_interval
FROM CHCO_DeID_Oct2018.Med2Mech_RareDisease_Medications
WHERE visit_start_interval>0 AND visit_end_interval>0)
@callahantiff
callahantiff / generate_code_codes.sql
Last active August 10, 2019 21:18
PheKnowVec helper queries
-- get unique counts of source and standard codes for each phenotype
-- CHCO
SELECT standard_code_set, COUNT(DISTINCT source_code) AS source_code_count, COUNT(DISTINCT standard_code) AS standard_code_count
FROM CHCO_DeID_Oct2018.ADHD_COHORT_VARS
WHERE standard_code_set is NOT NULL
GROUP BY standard_code_set
SELECT standard_code_set, COUNT(DISTINCT source_code) AS source_code_count, COUNT(DISTINCT standard_code) AS standard_code_count
FROM CHCO_DeID_Oct2018.APPENDICITIS_COHORT_VARS
WITH rx_case_inclusion_criteria_1 AS (
SELECT de.person_id, cohort.standard_code_set AS code_set
FROM
{database}.drug_exposure de,
{database}.STEROIDINDUCEDOSTEONECROSIS_COHORT_VARS cohort
WHERE de.route_concept_id IN (4132161, 4171047, 4302612)
AND de.drug_concept_id = CAST(cohort.standard_concept_id AS int64)
AND cohort.phenotype_definition_number = 1
AND cohort.standard_code_set = {code_set_group}
GROUP BY
WITH dx_case_inclusion_criteria_1 AS (
SELECT co.person_id, cohort.standard_code_set AS code_set
FROM
{database}.condition_occurrence co,
{database}.HYPOTHYROIDISM_COHORT_VARS cohort
WHERE
co.condition_concept_id = CAST(cohort.standard_concept_id AS int64)
AND cohort.phenotype_definition_number = 0
AND cohort.standard_code_set = {code_set_group}
GROUP BY co.person_id, cohort.standard_code_set
WITH all_case_inclusion_criteria_1 AS (
SELECT person_id, {code_set_group} AS code_set FROM
(SELECT co.person_id
FROM
{database}.condition_occurrence co,
{database}.PEANUTALLERGY_COHORT_VARS cohort
WHERE
co.condition_concept_id = CAST(cohort.standard_concept_id AS int64)
AND cohort.phenotype_definition_number = 1
AND cohort.standard_code_set = {code_set_group}
@callahantiff
callahantiff / xpath_soup.py
Created July 11, 2019 15:31 — forked from ergoithz/xpath_soup.py
Generate unique XPATH for BeautifulSoup element
#!/usr/bin/python
# -*- coding: utf-8 -*-
def xpath_soup(element):
"""
Generate xpath from BeautifulSoup4 element
:param element: BeautifulSoup4 element.
:type element: bs4.element.Tag or bs4.element.NavigableString
:return: xpath as string