#pip3 install googletrans==4.0.0rc1
from googletrans import Translator
import pandas as pd
translator = Translator()
translator.detect('hello')
tranlated = translator.translate('hello.', dest='zh-CN')
##translator.translate('veritas lux mea', src='la',dest='en')
src=r'AGO2 amplification is observed at low frequencies in a few tumor types, including breast cancer, sarcoma, and nerve sheath tumors (PMID: 28481359). Assuming the amplification of AGO2 is associated with elevated protein levels, limited data suggest that AGO2 amplification may be an oncogenic event. In one study, overexpression of AGO2 in human breast cancer cell lines mediated transformation (PMID: 18787018) and in another study of clinical specimens from patients with gastric cancer, AGO2 levels were elevated compared to normal tissue and correlated with HER2-negative disease and gender (PMID: 23775134). Knockdown of AGO2 protein in cancer cells resulted in reduced PI3K signaling and led to decreased cell proliferation and migration, arrested cell cycle and induced apoptosis (PMID: 28903378).'
tranlated = translator.translate(src, dest='zh-CN').text
print(tranlated)
df1=pd.read_excel(r'C:\Users\Administrator\Desktop\search\CNV数据库(1).xlsx',sheet_name='oncokb')
df2=pd.read_excel(r'C:\Users\Administrator\Desktop\search\CNV数据库(1).xlsx',sheet_name='ckb')
for i in range(len(df1)):
if pd.isnull(df1.loc[i,'Interpretation']) == False:
# list_all = main(df1.loc[i, 'Interpretation'])['translateResult'][0]
# text_last=''
# for j in list_all:
# text_add=j['tgt']
# text_last += text_add
df1.loc[i,'chinese']=translator.translate(df1.loc[i,'Interpretation'], dest='zh-CN').text
else:
pass
new_wb=pd.ExcelWriter(r'C:\Users\Administrator\Desktop\search\CNV数据库_update1.xlsx')
df1.to_excel(new_wb,sheet_name='oncokb',index=None)
df2.to_excel(new_wb,sheet_name='ckb',index=None)
new_wb.close()
python配合googletrans翻译表格中的内容
最新推荐文章于 2024-04-11 11:10:26 发布