<jupyter_start><jupyter_text>Step 1: get sequencesneed a dataframe `snp_df` with a `chr`, `start`, `end` columns, for the regions that you are picking<jupyter_code>import urllib.request
import xmltodict

def get_sequence(row,chr_col='chr', start_col='start', stop_col='end'):
    url = 'http://genome.ucsc.edu/cgi-bin/das/hg19/dna?segment={}:{},{}'.format(row[chr_col],row[start_col],row[stop_col])#chr4:39355986,39356120'
    contents = urllib.request.urlopen(url).read()
    sequence = ''.join(xmltodict.parse(contents)['DASDNA']['SEQUENCE']['DNA']['#text'].upper().split('\n'))
    return(sequence)
%%time
# probably will take ~20 min (12 min 35s for 15instances , 17 min for 20instances)

snp_df['sequence'] = snp_df.apply(lambda x: get_sequence(x, chr_col='chr', start_col='start_pad', stop_col='stop_pad'),axis=1)
snp_df['seq_type'] = 'ref'<jupyter_output>(4586, 18)
CPU times: user 4.72 s, sys: 1.51 s, total: 6.23 s
Wall time: 15min 45s
{'fraction_non_alphanumeric': 0.18008474576271186, 'fraction_numerical': 0.05508474576271186, 'mean_word_length': 6.745901639344262, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '550618', 'license': 'MIT', 'n_tokens_mistral': 400, 'n_tokens_neox': 360, 'n_words': 74, 'path': 'notebooks/make_mpra_tutorial.ipynb', 'repo_name': 'mguo123/pan_omics', 'size': '944'}