Hello,
I am trying to build a custom haystac database. I have a list of species. Is there any program which I can use so that I can use this list of species names as an input and get the list of refseq accession numbers of the genome assemblies of the respective species? I tried to use the "datasets summary" command after following [API for NCBI Accession ID (GenBank or RefSeq ) generation from a list of species names?]. But it did not work.
Can you please help?
Thank you :)
3 answers
Using EntrezDirect:
$ esearch -db assembly -query "Gorilla gorilla" | efetch -format docsum | xtract -pattern DocumentSummary -element RefSeq
GCF_029281585.2
GCF_029281585.1
GCF_008122165.1
GCF_000151905.2
GCF_000151905.1
$ esearch -db assembly -query "Gallus gallus" | efetch -format docsum | xtract -pattern DocumentSummary -element RefSeq
GCF_016700215.2
GCF_016699485.2
GCF_016700215.1
GCF_000002315.6
GCF_000002315.5
GCF_000002315.4
GCF_000002315.3
GCF_000002315.2
GCF_000002315.1
Using the rentrezpackage.
First, define a function to extract the refseq category :
refseq_cat <- function(ids) {
sapply(ids, function(i) {
foo = entrez_summary(db = "assembly", id = i)
foo$refseq_category
}, USE.NAMES = F)
}
The code should work when the assembly is labeled as 'representative genome'.
# Load library
library(rentrez)
# Get the assembly entries for a given species
my_assembly = entrez_search(db = "assembly", term = "Gorilla gorilla[ORGN]")
# Get the index for the 'representative genome' from those entries
rep_genome_idx = which(refseq_cat(my_assembly$ids) == "representative genome")
# Get the id. of the 'representative genome' (if any)
foo = entrez_summary(db = "assembly", id= my_assembly$ids[rep_genome_idx])
foo$assemblyaccession
[1] "GCF_029281585.2"
Idem for 'Cicer arietinum'
my_assembly = entrez_search(db = "assembly", term = "Cicer arietinum[ORGN]")
rep_genome_idx = which(refseq_cat(my_assembly$ids) == "representative genome")
foo = entrez_summary(db = "assembly", id= my_assembly$ids[rep_genome_idx])
foo$assemblyaccession
[1] "GCF_000331145.1"
Idem for 'Felis catus'
my_assembly = entrez_search(db = "assembly", term = "Felis catus[ORGN]")
rep_genome_idx = which(refseq_cat(my_assembly$ids) == "representative genome")
foo = entrez_summary(db = "assembly", id= my_assembly$ids[rep_genome_idx])
foo$assemblyaccession
[1] "GCF_018350175.1"
Hi,
You can do that using datasets, but you should use the flag --reference. That should return the current reference genome for the taxa requested. Like this:
datasets summary genome taxon "gorilla gorilla" --reference --as-json-lines | dataformat tsv genome --fields organism-name,accession
Organism Name Assembly Accession
Gorilla gorilla gorilla GCF_029281585.2
You can loop through your list of taxa (one per line, plain text) like this:
cat taxa.list | while read TAXON; do
datasets summary genome taxon "$TAXON" --reference --as-json-lines | \
dataformat tsv genome --fields organism-name,accession --elide-header;
done
Gorilla gorilla gorilla GCF_029281585.2
Homo sapiens GCF_000001405.40
Mustela putorius furo GCF_011764305.1
Gallus gallus GCF_016699485.2
Let me know if you have any other questions or if this solution doesn't work for you.
Log in to answer this question.
NCBI
datasetsalso works but returns JSONGenoMax thank you so much for your reply. The problem is I want only one reference assembly for each species and not the all versions, and I dont know how to specify that in the command using esearch. If there is any such option, then I will just create a loop for that and get all the accession numbers.