Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Blaze9
    Junior Member
    • Feb 2013
    • 8

    #1

    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.
  • lindenb
    Senior Member
    • Apr 2010
    • 143

    #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

    • SEQadmin2
      The Factors Reshaping Genome Assembly
      by SEQadmin2



      When the Human Genome Project declared the human genome finished in 2003, portions of the sequence were still missing, including many of its most repetitive and structurally complex regions.1 Still, for the next two decades, researchers analyzed their sequencing data against the single linear reference that came out of this effort. Released in 2013 as GRCh38, that reference has powered countless discoveries, but it has gaps and cannot capture the genetic diversity of the world’s...
      11-24-2026, 07:04 AM
    • SEQadmin2
      16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
      by SEQadmin2





      NGS has revolutionized clinical microbiology by offering new ways to identify and surveil pathogens without prior knowledge of the target. One popular approach is 16S rRNA and ITS amplicon sequencing, which targets specific microbial markers. But studies are increasingly incorporating shotgun metagenomics, a technique that sequences all DNA from a sample without targeting specific microbial markers. This approach allows more detailed taxonomic classification,...
      10-30-2026, 06:46 AM

    ad_right_rmr

    Collapse

    News

    Collapse

    Topics Statistics Last Post
    Started by SEQadmin2, 11-23-2026, 11:11 AM
    0 responses
    39 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, 11-17-2026, 06:27 AM
    0 responses
    47 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, 11-12-2026, 07:59 AM
    0 responses
    68 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, 11-05-2026, 09:25 AM
    0 responses
    68 views
    0 reactions
    Last Post SEQadmin2  
    Working...