This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Retrieve exon ranges from E-utils

Hi,

I'm trying to retrieve exon ranges for a gene from GenBank format efetch -id NG_007086.2 -format gb -mode xml -db nucleotide | xtract -pattern GBFeature -match GBFeature_key: exon -first GBFeature_location but it's giving me error message saying ERROR: Unexpected 'exon' argument after 'GBFeature_key', I tried to play around with GBFeature_key: exon, but couldn't get it right.

I followed their tutorial demo: https://ftp.ncbi.nlm.nih.gov/pub/education/public_webinars/2016/06Jun29_Exons/Gene_Exon_Demos.txt

Any help would be greatly appreciated

Thanks!

etuils ncbi exon genbank

2 answers

using xslt


<xsl:stylesheet version="1.0" xmlns:xsl="&lt;a href=" http:="" www.w3.org="" 1999="" XSL="" Transform"="" rel="nofollow">http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:apply-templates select="//GBFeature[GBFeature_key='exon']/GBFeature_intervals/GBInterval"/>
</xsl:template>
<xsl:template match="GBInterval">
<xsl:value-of select="GBInterval_from/text()"/><xsl:text> </xsl:text><xsl:value-of select="GBInterval_to/text()"/><xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>

usage:

 wget -q  -O - "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nucleotide&id=NG_007086.2&retmode=xml&rettype=gb" | xsltproc biostars.xsl - 

5002 5115
8439 8511
10887 11061
12995 13154
14397 14491
14836 14940
15131 15267
15518 16105

I used -if ... -equals .. and it worked,

efetch -id NG_007086.2 -format gb -mode xml -db nucleotide | xtract -pattern GBFeature -if GBFeature_key -equals exon -first GBFeature_location

Since this answer works you can accept this as well. It is different from what @Pierre provided and actually answers your own question with same software package.

Log in to answer this question.