I have read the instruction here:
XSLT stylesheet to filter blast xml output
And here:
How to filter a blast xml output ?
and I came up with this script:
#!/bin/sh
#
# filterblastxml.sh : Script to filter blast XML output by evalue
# Usage: filterblastxml.sh <blastxmlfile> <gt|lt> <evalue> <output_file_name>
# For example: "filterblastxml.sh test.blastn.xml lt 1e-5 filtered_test.blastn.xml"
# Above command filter the test.blastn.xml file to exclude all hits which has evalue
# less than 1e-5 and output the content to filtered_test.blastn.xml file.
tmpdir=/tmp
xslt_file=$tmpdir/$(date +%s)_blastfilter.xslt.xsl
cat << XSLTOUT > ${xslt_file}
<xsl:stylesheet xmlns:xsl="<a href=" <a="" href="http://www.w3.org/1999/XSL/Transform" rel="nofollow">http://www.w3.org/1999/XSL/Transform" "="" rel="nofollow">http://www.w3.org/1999/XSL/Transform'
version='1.0'
>
<xsl:output method="xml" encoding="UTF-8" indent="yes" doctype-public="-//NCBI//NCBI BlastOutput/EN" doctype-system="NCBI_BlastOutput.dtd"/>
<xsl:template match="*|text()">
<xsl:copy>
<xsl:apply-templates select="*|text()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Iteration_hits/Hit/Hit_hsps">
<xsl:apply-templates select="Hsp[number(Hsp_evalue)&${2};${3}]"/>
</xsl:template>
</xsl:stylesheet>
XSLTOUT
xsltproc --novalid ${xslt_file} $1 >$4
It seems to work fine, but when all hits have been removed from a query, the output becomes incompatible with blast xml standard. The xml tags "Hit_hsps" and "Hsp" got deleted. How do I avoid this?
Sample blast xml data:
<?xml version="1.0"?>
<!DOCTYPE BlastOutput PUBLIC "-//NCBI//NCBI BlastOutput/EN" "NCBI_BlastOutput.dtd">
<BlastOutput>
<BlastOutput_program>blastn</BlastOutput_program>
<BlastOutput_version>BLASTN 2.2.25+</BlastOutput_version>
<BlastOutput_reference>Zheng Zhang, Scott Schwartz, Lukas Wagner, and Webb Miller (2000), "A greedy algorithm for aligning DNA sequences", J Comput Biol 2000; 7(1-2):203-14.</BlastOutput_reference>
<BlastOutput_db>nt</BlastOutput_db>
<BlastOutput_query-ID>Query_1</BlastOutput_query-ID>
<BlastOutput_query-def>G3QAAIR07ISVPP length=527 xy=3492_1275 region=7 run=R_2011_06_03_10_33_44_</BlastOutput_query-def>
<BlastOutput_query-len>528</BlastOutput_query-len>
<BlastOutput_param>
<Parameters>
<Parameters_expect>10</Parameters_expect>
<Parameters_sc-match>1</Parameters_sc-match>
<Parameters_sc-mismatch>-2</Parameters_sc-mismatch>
<Parameters_gap-open>0</Parameters_gap-open>
<Parameters_gap-extend>0</Parameters_gap-extend>
<Parameters_filter>L;m;</Parameters_filter>
</Parameters>
</BlastOutput_param>
<BlastOutput_iterations>
<Iteration>
<Iteration_iter-num>1</Iteration_iter-num>
<Iteration_query-ID>Query_1</Iteration_query-ID>
<Iteration_query-def>G3QAAIR07ISVPP length=527 xy=3492_1275 region=7 run=R_2011_06_03_10_33_44_</Iteration_query-def>
<Iteration_query-len>528</Iteration_query-len>
<Iteration_hits>
<Hit>
<Hit_num>1</Hit_num>
<Hit_id>gi|110430570|gb|DQ675076.1|</Hit_id>
<Hit_def>Uncultured bacterium clone QHO-B31 16S ribosomal RNA gene, partial sequence</Hit_def>
<Hit_accession>DQ675076</Hit_accession>
<Hit_len>1490</Hit_len>
<Hit_hsps>
<Hsp>
<Hsp_num>1</Hsp_num>
<Hsp_bit-score>881.972178398883</Hsp_bit-score>
<Hsp_score>477</Hsp_score>
<Hsp_evalue>3</Hsp_evalue>
<Hsp_query-from>15</Hsp_query-from>
<Hsp_query-to>525</Hsp_query-to>
<Hsp_hit-from>510</Hsp_hit-from>
<Hsp_hit-to>1</Hsp_hit-to>
<Hsp_query-frame>1</Hsp_query-frame>
<Hsp_hit-frame>-1</Hsp_hit-frame>
<Hsp_identity>504</Hsp_identity>
<Hsp_positive>504</Hsp_positive>
<Hsp_gaps>9</Hsp_gaps>
<Hsp_align-len>515</Hsp_align-len>
</Hsp>
</Hit_hsps>
</Hit>
<Hit>
<Hit_num>2</Hit_num>
<Hit_id>gi|34305683|gb|AY363244.1|</Hit_id>
<Hit_def>Hydrocarboniphaga effusa strain AP102 16S ribosomal RNA gene, partial sequence</Hit_def>
<Hit_accession>AY363244</Hit_accession>
<Hit_len>1520</Hit_len>
<Hit_hsps>
<Hsp>
<Hsp_num>1</Hsp_num>
<Hsp_bit-score>878.278879094208</Hsp_bit-score>
<Hsp_score>475</Hsp_score>
<Hsp_evalue>1</Hsp_evalue>
<Hsp_query-from>15</Hsp_query-from>
<Hsp_query-to>525</Hsp_query-to>
<Hsp_hit-from>511</Hsp_hit-from>
<Hsp_hit-to>2</Hsp_hit-to>
<Hsp_query-frame>1</Hsp_query-frame>
<Hsp_hit-frame>-1</Hsp_hit-frame>
<Hsp_identity>503</Hsp_identity>
<Hsp_positive>503</Hsp_positive>
<Hsp_gaps>9</Hsp_gaps>
<Hsp_align-len>515</Hsp_align-len>
</Hsp>
</Hit_hsps>
</Hit>
<Hit>
<Hit_num>3</Hit_num>
<Hit_id>gi|110430571|gb|DQ675077.1|</Hit_id>
<Hit_def>Uncultured bacterium clone QHO-B35 16S ribosomal RNA gene, partial sequence</Hit_def>
<Hit_accession>DQ675077</Hit_accession>
<Hit_len>1490</Hit_len>
<Hit_hsps>
<Hsp>
<Hsp_num>1</Hsp_num>
<Hsp_bit-score>876.43222944187</Hsp_bit-score>
<Hsp_score>474</Hsp_score>
<Hsp_evalue>2</Hsp_evalue>
<Hsp_query-from>15</Hsp_query-from>
<Hsp_query-to>525</Hsp_query-to>
<Hsp_hit-from>510</Hsp_hit-from>
<Hsp_hit-to>1</Hsp_hit-to>
<Hsp_query-frame>1</Hsp_query-frame>
<Hsp_hit-frame>-1</Hsp_hit-frame>
<Hsp_identity>503</Hsp_identity>
<Hsp_positive>503</Hsp_positive>
<Hsp_gaps>9</Hsp_gaps>
<Hsp_align-len>515</Hsp_align-len>
</Hsp>
</Hit_hsps>
</Hit>
<Hit>
<Hit_num>4</Hit_num>
<Hit_id>gi|110430574|gb|DQ675080.1|</Hit_id>
<Hit_def>Uncultured bacterium clone QHO-B36 16S ribosomal RNA gene, partial sequence</Hit_def>
<Hit_accession>DQ675080</Hit_accession>
<Hit_len>1497</Hit_len>
<Hit_hsps>
<Hsp>
<Hsp_num>1</Hsp_num>
<Hsp_bit-score>872.738930137194</Hsp_bit-score>
<Hsp_score>472</Hsp_score>
<Hsp_evalue>0</Hsp_evalue>
<Hsp_query-from>15</Hsp_query-from>
<Hsp_query-to>525</Hsp_query-to>
<Hsp_hit-from>511</Hsp_hit-from>
<Hsp_hit-to>1</Hsp_hit-to>
<Hsp_query-frame>1</Hsp_query-frame>
<Hsp_hit-frame>-1</Hsp_hit-frame>
<Hsp_identity>503</Hsp_identity>
<Hsp_positive>503</Hsp_positive>
<Hsp_gaps>10</Hsp_gaps>
<Hsp_align-len>516</Hsp_align-len>
</Hsp>
</Hit_hsps>
</Hit>
<Hit>
<Hit_num>5</Hit_num>
<Hit_id>gi|110430531|gb|DQ675037.1|</Hit_id>
<Hit_def>Uncultured bacterium clone QHO-B33 16S ribosomal RNA gene, partial sequence</Hit_def>
<Hit_accession>DQ675037</Hit_accession>
<Hit_len>1490</Hit_len>
<Hit_hsps>
<Hsp>
<Hsp_num>1</Hsp_num>
<Hsp_bit-score>872.738930137194</Hsp_bit-score>
<Hsp_score>472</Hsp_score>
<Hsp_evalue>5</Hsp_evalue>
<Hsp_query-from>15</Hsp_query-from>
<Hsp_query-to>525</Hsp_query-to>
<Hsp_hit-from>511</Hsp_hit-from>
<Hsp_hit-to>1</Hsp_hit-to>
<Hsp_query-frame>1</Hsp_query-frame>
<Hsp_hit-frame>-1</Hsp_hit-frame>
<Hsp_identity>503</Hsp_identity>
<Hsp_positive>503</Hsp_positive>
<Hsp_gaps>10</Hsp_gaps>
<Hsp_align-len>516</Hsp_align-len>
</Hsp>
</Hit_hsps>
</Hit>
</Iteration_hits>
<Iteration_stat>
<Statistics>
<Statistics_db-num>14234969</Statistics_db-num>
<Statistics_db-len>36678711190</Statistics_db-len>
<Statistics_hsp-len>32</Statistics_hsp-len>
<Statistics_eff-space>17966703322272</Statistics_eff-space>
<Statistics_kappa>0.46</Statistics_kappa>
<Statistics_lambda>1.28</Statistics_lambda>
<Statistics_entropy>0.85</Statistics_entropy>
</Statistics>
</Iteration_stat>
</Iteration>
<Iteration>
<Iteration_iter-num>2</Iteration_iter-num>
<Iteration_query-ID>Query_2</Iteration_query-ID>
<Iteration_query-def>G3QAAIR07ITTWS length=486 xy=3503_0538 region=7 run=R_2011_06_03_10_33_44_</Iteration_query-def>
<Iteration_query-len>527</Iteration_query-len>
<Iteration_hits>
<Hit>
<Hit_num>1</Hit_num>
<Hit_id>gi|110430570|gb|DQ675076.1|</Hit_id>
<Hit_def>Uncultured bacterium clone QHO-B31 16S ribosomal RNA gene, partial sequence</Hit_def>
<Hit_accession>DQ675076</Hit_accession>
<Hit_len>1490</Hit_len>
<Hit_hsps>
<Hsp>
<Hsp_num>1</Hsp_num>
<Hsp_bit-score>931.831719012006</Hsp_bit-score>
<Hsp_score>504</Hsp_score>
<Hsp_evalue>1</Hsp_evalue>
<Hsp_query-from>15</Hsp_query-from>
<Hsp_query-to>524</Hsp_query-to>
<Hsp_hit-from>510</Hsp_hit-from>
<Hsp_hit-to>1</Hsp_hit-to>
<Hsp_query-frame>1</Hsp_query-frame>
<Hsp_hit-frame>-1</Hsp_hit-frame>
<Hsp_identity>508</Hsp_identity>
<Hsp_positive>508</Hsp_positive>
<Hsp_gaps>0</Hsp_gaps>
<Hsp_align-len>510</Hsp_align-len>
</Hsp>
</Hit_hsps>
</Hit>
<Hit>
<Hit_num>2</Hit_num>
<Hit_id>gi|34305683|gb|AY363244.1|</Hit_id>
<Hit_def>Hydrocarboniphaga effusa strain AP102 16S ribosomal RNA gene, partial sequence</Hit_def>
<Hit_accession>AY363244</Hit_accession>
<Hit_len>1520</Hit_len>
<Hit_hsps>
<Hsp>
<Hsp_num>1</Hsp_num>
<Hsp_bit-score>928.13841970733</Hsp_bit-score>
<Hsp_score>502</Hsp_score>
<Hsp_evalue>0</Hsp_evalue>
<Hsp_query-from>15</Hsp_query-from>
<Hsp_query-to>524</Hsp_query-to>
<Hsp_hit-from>511</Hsp_hit-from>
<Hsp_hit-to>2</Hsp_hit-to>
<Hsp_query-frame>1</Hsp_query-frame>
<Hsp_hit-frame>-1</Hsp_hit-frame>
<Hsp_identity>507</Hsp_identity>
<Hsp_positive>507</Hsp_positive>
<Hsp_gaps>0</Hsp_gaps>
<Hsp_align-len>510</Hsp_align-len>
</Hsp>
</Hit_hsps>
</Hit>
<Hit>
<Hit_num>3</Hit_num>
<Hit_id>gi|110430571|gb|DQ675077.1|</Hit_id>
<Hit_def>Uncultured bacterium clone QHO-B35 16S ribosomal RNA gene, partial sequence</Hit_def>
<Hit_accession>DQ675077</Hit_accession>
<Hit_len>1490</Hit_len>
<Hit_hsps>
<Hsp>
<Hsp_num>1</Hsp_num>
<Hsp_bit-score>926.291770054992</Hsp_bit-score>
<Hsp_score>501</Hsp_score>
<Hsp_evalue>0</Hsp_evalue>
<Hsp_query-from>15</Hsp_query-from>
<Hsp_query-to>524</Hsp_query-to>
<Hsp_hit-from>510</Hsp_hit-from>
<Hsp_hit-to>1</Hsp_hit-to>
<Hsp_query-frame>1</Hsp_query-frame>
<Hsp_hit-frame>-1</Hsp_hit-frame>
<Hsp_identity>507</Hsp_identity>
<Hsp_positive>507</Hsp_positive>
<Hsp_gaps>0</Hsp_gaps>
<Hsp_align-len>510</Hsp_align-len>
</Hsp>
</Hit_hsps>
</Hit>
<Hit>
<Hit_num>4</Hit_num>
<Hit_id>gi|110430574|gb|DQ675080.1|</Hit_id>
<Hit_def>Uncultured bacterium clone QHO-B36 16S ribosomal RNA gene, partial sequence</Hit_def>
<Hit_accession>DQ675080</Hit_accession>
<Hit_len>1497</Hit_len>
<Hit_hsps>
<Hsp>
<Hsp_num>1</Hsp_num>
<Hsp_bit-score>920.751821097979</Hsp_bit-score>
<Hsp_score>498</Hsp_score>
<Hsp_evalue>4</Hsp_evalue>
<Hsp_query-from>15</Hsp_query-from>
<Hsp_query-to>524</Hsp_query-to>
<Hsp_hit-from>511</Hsp_hit-from>
<Hsp_hit-to>1</Hsp_hit-to>
<Hsp_query-frame>1</Hsp_query-frame>
<Hsp_hit-frame>-1</Hsp_hit-frame>
<Hsp_identity>507</Hsp_identity>
<Hsp_positive>507</Hsp_positive>
<Hsp_gaps>1</Hsp_gaps>
<Hsp_align-len>511</Hsp_align-len>
</Hsp>
</Hit_hsps>
</Hit>
</Iteration_hits>
<Iteration_stat>
<Statistics>
<Statistics_db-num>14234969</Statistics_db-num>
<Statistics_db-len>36678711190</Statistics_db-len>
<Statistics_hsp-len>32</Statistics_hsp-len>
<Statistics_eff-space>17930480130090</Statistics_eff-space>
<Statistics_kappa>0.46</Statistics_kappa>
<Statistics_lambda>1.28</Statistics_lambda>
<Statistics_entropy>0.85</Statistics_entropy>
</Statistics>
</Iteration_stat>
</Iteration>
<Iteration>
<Iteration_iter-num>3</Iteration_iter-num>
<Iteration_query-ID>Query_3</Iteration_query-ID>
<Iteration_query-def>G3QAAIR07ITRSJ length=526 xy=3502_1889 region=7 run=R_2011_06_03_10_33_44_</Iteration_query-def>
<Iteration_query-len>527</Iteration_query-len>
<Iteration_hits>
<Hit>
<Hit_num>1</Hit_num>
<Hit_id>gi|110430570|gb|DQ675076.1|</Hit_id>
<Hit_def>Uncultured bacterium clone QHO-B31 16S ribosomal RNA gene, partial sequence</Hit_def>
<Hit_accession>DQ675076</Hit_accession>
<Hit_len>1490</Hit_len>
<Hit_hsps>
<Hsp>
<Hsp_num>1</Hsp_num>
<Hsp_bit-score>931.831719012006</Hsp_bit-score>
<Hsp_score>504</Hsp_score>
<Hsp_evalue>0</Hsp_evalue>
<Hsp_query-from>15</Hsp_query-from>
<Hsp_query-to>524</Hsp_query-to>
<Hsp_hit-from>510</Hsp_hit-from>
<Hsp_hit-to>1</Hsp_hit-to>
<Hsp_query-frame>1</Hsp_query-frame>
<Hsp_hit-frame>-1</Hsp_hit-frame>
<Hsp_identity>508</Hsp_identity>
<Hsp_positive>508</Hsp_positive>
<Hsp_gaps>0</Hsp_gaps>
<Hsp_align-len>510</Hsp_align-len>
</Hsp>
</Hit_hsps>
</Hit>
<Hit>
<Hit_num>2</Hit_num>
<Hit_id>gi|34305683|gb|AY363244.1|</Hit_id>
<Hit_def>Hydrocarboniphaga effusa strain AP102 16S ribosomal RNA gene, partial sequence</Hit_def>
<Hit_accession>AY363244</Hit_accession>
<Hit_len>1520</Hit_len>
<Hit_hsps>
<Hsp>
<Hsp_num>1</Hsp_num>
<Hsp_bit-score>928.13841970733</Hsp_bit-score>
<Hsp_score>502</Hsp_score>
<Hsp_evalue>0</Hsp_evalue>
<Hsp_query-from>15</Hsp_query-from>
<Hsp_query-to>524</Hsp_query-to>
<Hsp_hit-from>511</Hsp_hit-from>
<Hsp_hit-to>2</Hsp_hit-to>
<Hsp_query-frame>1</Hsp_query-frame>
<Hsp_hit-frame>-1</Hsp_hit-frame>
<Hsp_identity>507</Hsp_identity>
<Hsp_positive>507</Hsp_positive>
<Hsp_gaps>0</Hsp_gaps>
<Hsp_align-len>510</Hsp_align-len>
</Hsp>
</Hit_hsps>
</Hit>
</Iteration_hits>
<Iteration_stat>
<Statistics>
<Statistics_db-num>14234969</Statistics_db-num>
<Statistics_db-len>36678711190</Statistics_db-len>
<Statistics_hsp-len>32</Statistics_hsp-len>
<Statistics_eff-space>17930480130090</Statistics_eff-space>
<Statistics_kappa>0.46</Statistics_kappa>
<Statistics_lambda>1.28</Statistics_lambda>
<Statistics_entropy>0.85</Statistics_entropy>
</Statistics>
</Iteration_stat>
</Iteration>
<Iteration>
<Iteration_iter-num>4</Iteration_iter-num>
<Iteration_query-ID>Query_4</Iteration_query-ID>
<Iteration_query-def>G3QAAIR07IS4TC length=527 xy=3495_0782 region=7 run=R_2011_06_03_10_33_44_</Iteration_query-def>
<Iteration_query-len>526</Iteration_query-len>
<Iteration_hits>
<Hit>
<Hit_num>1</Hit_num>
<Hit_id>gi|110430570|gb|DQ675076.1|</Hit_id>
<Hit_def>Uncultured bacterium clone QHO-B31 16S ribosomal RNA gene, partial sequence</Hit_def>
<Hit_accession>DQ675076</Hit_accession>
<Hit_len>1490</Hit_len>
<Hit_hsps>
<Hsp>
<Hsp_num>1</Hsp_num>
<Hsp_bit-score>924.445120402654</Hsp_bit-score>
<Hsp_score>500</Hsp_score>
<Hsp_evalue>0</Hsp_evalue>
<Hsp_query-from>15</Hsp_query-from>
<Hsp_query-to>523</Hsp_query-to>
<Hsp_hit-from>510</Hsp_hit-from>
<Hsp_hit-to>1</Hsp_hit-to>
<Hsp_query-frame>1</Hsp_query-frame>
<Hsp_hit-frame>-1</Hsp_hit-frame>
<Hsp_identity>507</Hsp_identity>
<Hsp_positive>507</Hsp_positive>
<Hsp_gaps>1</Hsp_gaps>
<Hsp_align-len>510</Hsp_align-len>
</Hsp>
</Hit_hsps>
</Hit>
<Hit>
<Hit_num>2</Hit_num>
<Hit_id>gi|34305683|gb|AY363244.1|</Hit_id>
<Hit_def>Hydrocarboniphaga effusa strain AP102 16S ribosomal RNA gene, partial sequence</Hit_def>
<Hit_accession>AY363244</Hit_accession>
<Hit_len>1520</Hit_len>
<Hit_hsps>
<Hsp>
<Hsp_num>1</Hsp_num>
<Hsp_bit-score>920.751821097979</Hsp_bit-score>
<Hsp_score>498</Hsp_score>
<Hsp_evalue>0</Hsp_evalue>
<Hsp_query-from>15</Hsp_query-from>
<Hsp_query-to>523</Hsp_query-to>
<Hsp_hit-from>511</Hsp_hit-from>
<Hsp_hit-to>2</Hsp_hit-to>
<Hsp_query-frame>1</Hsp_query-frame>
<Hsp_hit-frame>-1</Hsp_hit-frame>
<Hsp_identity>506</Hsp_identity>
<Hsp_positive>506</Hsp_positive>
<Hsp_gaps>1</Hsp_gaps>
<Hsp_align-len>510</Hsp_align-len>
</Hsp>
</Hit_hsps>
</Hit>
<Hit>
<Hit_num>3</Hit_num>
<Hit_id>gi|110430571|gb|DQ675077.1|</Hit_id>
<Hit_def>Uncultured bacterium clone QHO-B35 16S ribosomal RNA gene, partial sequence</Hit_def>
<Hit_accession>DQ675077</Hit_accession>
<Hit_len>1490</Hit_len>
<Hit_hsps>
<Hsp>
<Hsp_num>1</Hsp_num>
<Hsp_bit-score>918.905171445641</Hsp_bit-score>
<Hsp_score>497</Hsp_score>
<Hsp_evalue>0</Hsp_evalue>
<Hsp_query-from>15</Hsp_query-from>
<Hsp_query-to>523</Hsp_query-to>
<Hsp_hit-from>510</Hsp_hit-from>
<Hsp_hit-to>1</Hsp_hit-to>
<Hsp_query-frame>1</Hsp_query-frame>
<Hsp_hit-frame>-1</Hsp_hit-frame>
<Hsp_identity>506</Hsp_identity>
<Hsp_positive>506</Hsp_positive>
<Hsp_gaps>1</Hsp_gaps>
<Hsp_align-len>510</Hsp_align-len>
</Hsp>
</Hit_hsps>
</Hit>
<Hit>
<Hit_num>4</Hit_num>
<Hit_id>gi|110430574|gb|DQ675080.1|</Hit_id>
<Hit_def>Uncultured bacterium clone QHO-B36 16S ribosomal RNA gene, partial sequence</Hit_def>
<Hit_accession>DQ675080</Hit_accession>
<Hit_len>1497</Hit_len>
<Hit_hsps>
<Hsp>
<Hsp_num>1</Hsp_num>
<Hsp_bit-score>915.211872140965</Hsp_bit-score>
<Hsp_score>495</Hsp_score>
<Hsp_evalue>1e-10</Hsp_evalue>
<Hsp_query-from>15</Hsp_query-from>
<Hsp_query-to>523</Hsp_query-to>
<Hsp_hit-from>511</Hsp_hit-from>
<Hsp_hit-to>1</Hsp_hit-to>
<Hsp_query-frame>1</Hsp_query-frame>
<Hsp_hit-frame>-1</Hsp_hit-frame>
<Hsp_identity>506</Hsp_identity>
<Hsp_positive>506</Hsp_positive>
<Hsp_gaps>2</Hsp_gaps>
<Hsp_align-len>511</Hsp_align-len>
</Hsp>
</Hit_hsps>
</Hit>
</Iteration_hits>
<Iteration_stat>
<Statistics>
<Statistics_db-num>14234969</Statistics_db-num>
<Statistics_db-len>36678711190</Statistics_db-len>
<Statistics_hsp-len>32</Statistics_hsp-len>
<Statistics_eff-space>17894256937908</Statistics_eff-space>
<Statistics_kappa>0.46</Statistics_kappa>
<Statistics_lambda>1.28</Statistics_lambda>
<Statistics_entropy>0.85</Statistics_entropy>
</Statistics>
</Iteration_stat>
</Iteration>
</BlastOutput_iterations>
</BlastOutput>
Use existing solutions for this. Probably not bash.
You don't need a bash script here. You can pass some arguments to the stylesheet using xsltproc and xsl:param . See the manual page.
Not clear what you want to do. If you want to avoid removing all hits then...don't remove all hits?
@maasha, could you be more specific of which solutions? I've been searching long before I was persuaded to put up this question myself. BioPerl does not support parse BLAST result and output XML file. I couldn't make XML::Simple and XML::Twig work. What I am trying to do is not pure bash, it actually just automation of instruction at http://biostar.stackexchange.com/questions/2869 @neilfws, sorry I did not put the description more visible. I want to write a "Script to filter blast XML output by evalue", which removes hits that are below or above an input evalue and output filtered XML file.
@Pierre, That is what I am trying to do. It is just one step further after xsltproc command: To make it more flexible with runtime parameters instead of diving into the XSL file and edit it every time users want to run similar jobs.