有没有一种方法从NCBI数据库链接中获取序列(使用香草JS)?
https://www.ncbi.nlm.nih.gov/protein/KTC77672.1?report=fasta&log$=seqview&format=text我用其他数据库(uniprot)做了这个工作。但NCBI可能有一些不同。
async function getData(url) {
const data = await fetch(url);
return data.text();
}
const test = getData('https://www.uniprot.org/uniprot/E5G0U9.fasta').then((r) => console.warn(r));test.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
<title>test</title>
</head>
<body>
test
</body>
<script src="test.js"></script>发布于 2019-07-18 04:41:01
问题中的链接不会以纯文本的形式返回FASTA格式。它使用pre标记返回HTML,使其看起来像纯文本。
您应该使用NCBI E-实用程序API -特别是efetch方法。
示例蛋白质的URI如下所示:
https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=protein&id=KTC77672.1&rettype=fasta
所以在Javascript函数中试试这个。似乎工作在我的Chrome控制台(见图片)。

https://stackoverflow.com/questions/57079622
复制相似问题