Xtract 5.50, part of today's EDirect release, has better methods for handling recursive objects, with two specific improvements:
1) Nested exploration (e.g., "*/Gene-commentary") masks deeper objects from being seen by the -element selection command. It is no longer necessary to use -first instead of -element to exclude information from lower levels.
2) Recursive exploration (e.g., "**/Gene-commentary") flattens the recursive structure, visiting every indicated object regardless of depth. The same -element masking applies here.
In addition, the -match and -avoid commands, along with the "object:value" selection construct, have been deprecated, so that colon can be used to indicate namespace prefixes.
Conditional execution now uses -if and -unless commands, and has compound statements for string comparison (e.g., -contains) or numeric comparison (e.g., -lt).
Retrieving genomic accessions from Bombus terrestris can be done with:
esearch -db gene -query XP_003399880.1 |
efetch -format xml |
xtract -pattern Entrezgene -block "**/Gene-commentary" \
-if Gene-commentary_type@value -equals genomic \
-tab "\n" -element Gene-commentary_accession |
sort | uniq
This returns two accessions:
AELG01001811
NC_015773
Note that the efetch.fcgi "id" argument should have rejected a non-integer (accession) value sent to the gene database. This oversight has been reported to the program's maintainers. EDirect's efetch front-end now issues an error message if an accession is passed to -id and the -db argument is not a sequence database.
Please update to the latest version of EDirect by rerunning the download instructions in:
https://www.ncbi.nlm.nih.gov/books/NBK179288/
(deleted - misplaced comment)