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
      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, detection...
      Yesterday, 06:46 AM
    • SEQadmin2
      Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
      by SEQadmin2



      Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

      Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
      ...
      10-14-2026, 09:55 AM

    ad_right_rmr

    Collapse

    News

    Collapse

    Topics Statistics Last Post
    Started by SEQadmin2, 10-28-2026, 09:57 AM
    0 responses
    29 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, 10-28-2026, 09:51 AM
    0 responses
    20 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, 10-22-2026, 11:13 AM
    0 responses
    71 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, 10-22-2026, 10:48 AM
    0 responses
    48 views
    0 reactions
    Last Post SEQadmin2  
    Working...