gravatar for sepidehafshar303

2 hours ago by

Hi
I have a file of gene names and I want to find their Ensembl-id using python, but I have error, how can fix it?

nDis = 100000
with open('geo.csv', 'rt', encoding='utf-8') as csvfile:
mg = mygene.MyGeneInfo()
csvreader = csv.reader(csvfile, delimiter=',')
raw_file = []
n = 0
counter = 0
for row in csvreader:
counter = counter + 1
if counter is not 1 and counter < nDis:
#print('Preprocessing gene data: ' + str(counter))
d = {}
d['geneName'] = row[9]
raw_file.append(d)
#print(d)
for gene in raw_file:
result = mg.query(gene, scopes="symbol", fields=["ensembl"], species="human", verbose=False)
hgnc_name = gene
for hit in result["hits"]:
if "ensembl" in hit and "gene" in hit["ensembl"]:
sys.stdout.write("%st%sn" % (hgnc_name, hit["ensembl"]["gene"]))

HTTPError: 400 Client Error: Bad Request for url: mygene.info/v3/query/



Source link