Skip to content

Instantly share code, notes, and snippets.

@sverhoeven
Created February 23, 2016 14:10
Show Gist options
  • Save sverhoeven/288e398a97b5a3f81ec9 to your computer and use it in GitHub Desktop.
Save sverhoeven/288e398a97b5a3f81ec9 to your computer and use it in GitHub Desktop.
Knime node to fetch molblock and protein name for query and hit fragment.
import pandas as pd
from kripodb.canned import fragments_by_id
# Requires as input table with columns
# hit_frag_id, query_frag_id and score
# Returns id and molblock of query and hit
# and protein name of hit.
# Location of fragment database
fragments_db_filename = '/data/kripo/tiny/fragments.sqlite'
# Columns to output
required_cols = ['query_frag_id', 'query_mol', 'hit_frag_id', 'hit_mol', 'score', 'hit_prot_name']
query_table = fragments_by_id(input_table['query_frag_id'],
fragments_db_filename,
'query_')
inter_table = pd.merge(input_table,
query_table,
on='query_frag_id')
hits_table = fragments_by_id(input_table['hit_frag_id'],
fragments_db_filename,
'hit_')
output_table = pd.merge(inter_table,
hits_table,
on='hit_frag_id')[required_cols]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment