Skip to content

Instantly share code, notes, and snippets.

@andy23512
Created March 11, 2020 08:36
Show Gist options
  • Save andy23512/8bad2438598dc36852c12d4a28171750 to your computer and use it in GitHub Desktop.
Save andy23512/8bad2438598dc36852c12d4a28171750 to your computer and use it in GitHub Desktop.
import pandas as pd
df = pd.read_excel('data.xlsx')
print("""
Mode 1: Search with locus
Mode 2: Search with chr and pos
""")
mode = input('Input query mode: ')
if mode == '1':
query_locus = input('Input locus: ')
print(df.loc[df['locus'] == query_locus])
elif mode == '2':
query_chr = input('Input chr: ')
query_pos = int(input('Input pos: '))
print(df.loc[(df['chr'] == query_chr) & (df['start_POS'] <= query_pos) & (df['stop_POS'] >= query_pos)])
else:
raise ValueError('Unexpected mode')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment