예제 #1
0
from graphkb import GraphKBConnection
from graphkb.constants import BASE_RETURN_PROPERTIES, GENERIC_RETURN_PROPERTIES
from graphkb.match import match_positional_variant
from graphkb.util import convert_to_rid_list
from graphkb.vocab import get_term_tree

GKB_API_URL = 'https://pori-demo.bcgsc.ca/graphkb-api/api'
GKB_USER = '******'
GKB_PASSWORD = '******'

graphkb_conn = GraphKBConnection(GKB_API_URL, use_global_cache=False)
graphkb_conn.login(GKB_USER, GKB_PASSWORD)

variant_name = 'KRAS:p.G12D'
variant_matches = match_positional_variant(graphkb_conn, variant_name)

for match in variant_matches:
    print(variant_name, 'will match', match['displayName'])

# return properties should be customized to the users needs
return_props = (BASE_RETURN_PROPERTIES +
                ['sourceId', 'source.name', 'source.displayName'] +
                [f'conditions.{p}' for p in GENERIC_RETURN_PROPERTIES] +
                [f'subject.{p}' for p in GENERIC_RETURN_PROPERTIES] +
                [f'evidence.{p}' for p in GENERIC_RETURN_PROPERTIES] +
                [f'relevance.{p}' for p in GENERIC_RETURN_PROPERTIES] +
                [f'evidenceLevel.{p}' for p in GENERIC_RETURN_PROPERTIES])

statements = graphkb_conn.query({
    'target': 'Statement',
    'filters': {
예제 #2
0
def genes() -> List[Dict]:
    graphkb_conn = GraphKBConnection()
    graphkb_conn.login(os.environ['IPR_USER'], os.environ['IPR_PASS'])

    return get_gene_information(graphkb_conn,
                                ['kras', 'cdkn2a', 'blargh-monkeys', 'ewsr1'])
예제 #3
0
def conn():
    conn = GraphKBConnection()
    conn.login(os.environ['GRAPHKB_USER'], os.environ['GRAPHKB_PASS'])
    return conn
예제 #4
0
def test_login_ok():
    conn = GraphKBConnection()
    conn.login(os.environ['GRAPHKB_USER'], os.environ['GRAPHKB_PASS'])
    assert conn.token is not None
예제 #5
0
parser.add_argument('--graphkb_user',
                    default='colab_demo',
                    help='The username for logging in to GraphKB')
parser.add_argument('--graphkb_pass',
                    default='colab_demo',
                    help='The password for logging in to GraphKB')
parser.add_argument(
    '--include_unmatched',
    default=False,
    action='store_true',
    help='Include lines for variants that did not match any statements',
)
args = parser.parse_args()

graphkb_conn = GraphKBConnection(args.graphkb_url, use_global_cache=True)
graphkb_conn.login(args.graphkb_user, args.graphkb_pass)

# read the input files
inputs = []
for filename in args.inputs:
    print(f'reading: {filename}')
    temp_df = pd.read_csv(filename, sep='\t')
    temp_df['filename'] = os.path.basename(filename)
    inputs.append(temp_df)
input_df = pd.concat(inputs)


# generate the variant list df
def get_variant(row):
    if not pd.isnull(row['ANN[*].HGVS_P']):
        return row['ANN[*].GENE'] + ':' + row['ANN[*].HGVS_P']