from Bio import Entrez
#import pandas as pd


#for loop when have all gene ids
#store in file

def get_entrez_gene_dict(gene_id):
    gene_id = str(gene_id)
    Entrez.email = 'emma.gail15@imperial.ac.uk'
    handle = Entrez.esummary(db='gene',id=gene_id,retmode='text')
    record = Entrez.read(handle)
    handle.close()
    entrez_dict = dict(record['DocumentSummarySet'])
    gene_dict = dict(entrez_dict['DocumentSummary'][0])
    return gene_dict


Entrez.email = 'emma.gail15@imperial.ac.uk'
#handle = Entrez.esearch(db='snp',term='rs80356994')
#handle = Entrez.esummary(db='snp',id='80356994',rettype='gb', retmode='text')
#handle = Entrez.esearch(db='nucleotide',retmax=10,term='BRCA1[gene] AND human[orgn]')
handle = Entrez.esummary(db='gene',id='672',retmode='text')
#record = handle.read()
record = Entrez.read(handle)
handle.close()

#print record

entrez_dict = dict(record['DocumentSummarySet'])
gene_dict = dict(entrez_dict['DocumentSummary'][0])
print gene_dict.keys()
print gene_dict['CurrentID']
#print gene_dict['Description']
#print gene_dict['Summary']

#with open('gene_dict.py','w') as text_file:
#    text_file.write('gene_dict = '+str(gene_dict))
