Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Convert blastx XML to Fasta w/ NTs, not Proteins?

    Hey,

    I have a blastx xml output. I want to convert this blastx back into a fasta file for downstream analysis. However, the xml contains only protein sequences since it's a blastx output. I have the original fasta I sent into blast. Is there a way I can "merge" these two files together? I want to take the annotation from the xml and append it to the original fasta's sequences.

    Is this possible via command line? Right now I'm doing this by importing my fasta and XML into blast2go and exporting the fasta w/ the new header information, but blast2go gets really slow with very large datasets.

  • #2
    an idea (not tested) you could create a awk script from the xml using XSLT

    Code:
    <?xml version='1.0'  encoding="UTF-8" ?>
    <xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  version='1.0'>
    
    <xsl:output method="text" />
    
    
    <xsl:template match="/">
    <xsl:apply-templates select="BlastOutput/BlastOutput_iterations/Iteration"/>
    </xsl:template>
    
    
    <xsl:template match="Iteration">
    <xsl:text>$1 == "&gt;</xsl:text><xsl:value-of select="Iteration_query-def/text()"/> <xsl:text>"	{ </xsl:text>
    <xsl:for-each select="Iteration_hits/Hit/Hit_hsps/Hsp">printf("%s [%s-%s]\n%s\n",$1,<xsl:value-of select="Hsp_query-from/text()"/>,<xsl:value-of select="Hsp_query-to/text()"/>,substr($2,<xsl:value-of select="Hsp_query-from/text()"/>,<xsl:value-of select="Hsp_query-to/text()"/>));</xsl:for-each>
    <xsl:text> next;}
    </xsl:text>
    </xsl:template>
    </xsl:stylesheet>

    Code:
    xsltproc stylesheet.xsl input.blastx.xml  > my.awk
    then, linearise the input fasta and use this awk script to extract the substring


    Code:
    awk '/>/ {printf("\n%s\t",$0);next;} {printf("%s",$0);} END {printf("\n");}' query.fasta  |\
      awk -F '\t' -f my.awk
    if the input fasta is too large, you could index the query.fasta with makeblastdb and call blastdbcmd with 'range' instead of awk

    Comment

    Latest Articles

    Collapse

    • seqadmin
      Strategies for Sequencing Challenging Samples
      by seqadmin


      Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
      03-22-2024, 06:39 AM
    • seqadmin
      Techniques and Challenges in Conservation Genomics
      by seqadmin



      The field of conservation genomics centers on applying genomics technologies in support of conservation efforts and the preservation of biodiversity. This article features interviews with two researchers who showcase their innovative work and highlight the current state and future of conservation genomics.

      Avian Conservation
      Matthew DeSaix, a recent doctoral graduate from Kristen Ruegg’s lab at The University of Colorado, shared that most of his research...
      03-08-2024, 10:41 AM

    ad_right_rmr

    Collapse

    News

    Collapse

    Topics Statistics Last Post
    Started by seqadmin, Yesterday, 06:37 PM
    0 responses
    10 views
    0 likes
    Last Post seqadmin  
    Started by seqadmin, Yesterday, 06:07 PM
    0 responses
    9 views
    0 likes
    Last Post seqadmin  
    Started by seqadmin, 03-22-2024, 10:03 AM
    0 responses
    50 views
    0 likes
    Last Post seqadmin  
    Started by seqadmin, 03-21-2024, 07:32 AM
    0 responses
    67 views
    0 likes
    Last Post seqadmin  
    Working...
    X