我对Python还算陌生,一直在尝试通过实践方法来学习Python。现在我要通过TCGA、GEO等基因组数据库提取乳腺癌的基因组数据来写一篇关于癌症转移的综述文章。我在编写代码时遇到了麻烦和问题。如果有任何编码员可以帮助我摆脱困境。这对我来说意味着整个世界。谢谢!
我还没有尝试过任何东西。
我已经创建了一个代码,可以让你做到这一点。
Python:
导入请求 进口重新
file_id =“你的文件id”
data_endpt =“https://api.gdc.cancer.gov/data/{}”.format(file_id)
response = requests.get(data_endpt, headers = {"Content-Type": "application/json"})
response_head_cd = response.headers["内容处置"]
file_name = re.findall("filename=(.+)", response_head_cd)[0]
使用 open(file_name, "wb") 作为输出文件: 输出文件.write(响应.内容)
response_head_cd = response.headers["内容描述"]
response = requests.get(data_endpt, headers = {"Content-Type": "application/json"})