Permalink
Browse files

SearchIO hmmer2: Correctly handle the 'no match' case

Signed-off-by: Kai Blin <kai.blin@biotech.uni-tuebingen.de>
  • Loading branch information...
1 parent 38ad25e commit 8ae53818264e1c6aa62e646b6f62cf1f0eb425b5 Kai Blin committed with peterjc Dec 6, 2012
@@ -109,8 +109,9 @@ def parse_qresult(self):
description = self.parse_key_value()[1]
hit_placeholders = self.parse_hits()
- self.parse_hsps(hit_placeholders)
- self.parse_hsp_alignments()
+ if len(hit_placeholders) > 0:
+ self.parse_hsps(hit_placeholders)
+ self.parse_hsp_alignments()
while self.read_next() and self.line != '//':
pass
@@ -126,6 +127,8 @@ def parse_hits(self):
while self.read_next():
if self.line.startswith('Parsed'):
break
+ if self.line.find('no hits') > -1:
+ break
if self.line.startswith('Sequence') or \
self.line.startswith('Model') or \
View
@@ -36,5 +36,6 @@ domtab_30_hmmsearch_001.out single query, multiple matches, hmm as query
text_21_hmmpfam_001.out single query, two matches, bioperl's hmmpfam.out file
text_22_hmmpfam_001.out single query, one match, bioperl's L77119.hmmer file
text_23_hmmpfam_001.out single query, multiple matches, bioperl's hmmpfam_cs.out file
+text_23_hmmpfam_002.out single query, no match
text_20_hmmsearch_001.out single query, multiple matches, bioperl's hmmsearch.out file
text_22_hmmsearch_001.out single query, multiple matches, bioperl's cysprot1b.hmmsearch file
@@ -0,0 +1,44 @@
+hmmpfam - search one or more sequences against HMM database
+HMMER 2.3.2 (Oct 2003)
+Copyright (C) 1992-2003 HHMI/Washington University School of Medicine
+Freely distributed under the GNU General Public License (GPL)
+- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+HMM file: unsuccessful.hmm
+Sequence file: sequences.fa
+- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+Query sequence: SEQ0001
+Accession: [none]
+Description: [none]
+
+Scores for sequence family classification (score includes all domains):
+Model Description Score E-value N
+-------- ----------- ----- ------- ---
+ [no hits above thresholds]
+
+Parsed for domains:
+Model Domain seq-f seq-t hmm-f hmm-t score E-value
+-------- ------- ----- ----- ----- ----- ----- -------
+ [no hits above thresholds]
+
+Alignments of top-scoring domains:
+ [no hits above thresholds]
+//
+
+Query sequence: SEQ0002
+Accession: [none]
+Description: [none]
+
+Scores for sequence family classification (score includes all domains):
+Model Description Score E-value N
+-------- ----------- ----- ------- ---
+ [no hits above thresholds]
+
+Parsed for domains:
+Model Domain seq-f seq-t hmm-f hmm-t score E-value
+-------- ------- ----- ----- ----- ----- ----- -------
+ [no hits above thresholds]
+
+Alignments of top-scoring domains:
+ [no hits above thresholds]
+//
@@ -139,6 +139,18 @@ def test_hmmpfam_23(self):
self.assertAlmostEqual(857.3, hsp.bitscore)
self.assertAlmostEqual(9e-255, hsp.evalue)
+ def test_hmmpfam_23_no_match(self):
+ results = parse(path.join("Hmmer", "text_23_hmmpfam_002.out"), "hmmer2-text")
+ res = results.next()
+
+ self.assertEqual('SEQ0001', res.id)
+ self.assertEqual(0, len(res.hits))
+
+ res = results.next()
+
+ self.assertEqual('SEQ0002', res.id)
+ self.assertEqual(0, len(res.hits))
+
if __name__ == "__main__":
runner = unittest.TextTestRunner(verbosity=2)

0 comments on commit 8ae5381

Please sign in to comment.