def test_hmmsearch_22(self):
        """Test parsing hmmsearch 2.2 file (text_22_hmmsearch_001.out)"""
        res = read(path.join("Hmmer", "text_22_hmmsearch_001.out"), self.fmt)

        # first query
        self.assertEqual('Peptidase_C1', res.id)
        self.assertEqual('Papain family cysteine protease', res.description)
        self.assertEqual('hmmsearch', res.program)
        self.assertEqual('2.2g', res.version)
        self.assertEqual('cysprot1b.fa', res.target)
        self.assertEqual(4, len(res))

        # first hit
        hit = res[0]
        self.assertEqual('CATL_RAT', hit.id)
        self.assertEqual('<unknown description>', hit.description)
        self.assertAlmostEqual(449.4, hit.bitscore)
        self.assertAlmostEqual(2e-135, hit.evalue)
        self.assertEqual(1, hit.domain_obs_num)
        self.assertEqual(1, len(hit))

        # first hit, first hsp
        hsp = hit[0]
        self.assertEqual('Peptidase_C1', hsp.query_id)
        self.assertEqual('Papain family cysteine protease', hsp.query_description)
        self.assertEqual('CATL_RAT', hit.id)
        self.assertEqual('<unknown description>', hit.description)
        self.assertEqual(1, hsp.domain_index)
        self.assertAlmostEqual(449.4, hsp.bitscore)
        self.assertAlmostEqual(2e-135, hsp.evalue)
        self.assertEqual(0, hsp.query_start)
        self.assertEqual(337, hsp.query_end)
        self.assertEqual('[]', hsp.query_endtype)
        self.assertEqual('lPesfDWReWkggaVtpVKdQGiqCGSCWAFSavgalEgr', str(hsp.query.seq)[:40])
        self.assertEqual('IVKNSWGtdWGEnGYfriaRgknksgkneCGIaseasypi', str(hsp.query.seq)[-40:])
        self.assertEqual(337, len(hsp.query.seq))
        self.assertEqual('+P+++DWRe kg  VtpVK+QG qCGSCWAFSa g lEg+',
                str(hsp.aln_annotation['similarity'])[:40])
        self.assertEqual('+VKNSWG++WG++GY++ia+++n    n+CG+a+ asypi',
                str(hsp.aln_annotation['similarity'])[-40:])
        self.assertEqual(113, hsp.hit_start)
        self.assertEqual(332, hsp.hit_end)
        self.assertEqual('..', hsp.hit_endtype)
        self.assertEqual('IPKTVDWRE-KG-CVTPVKNQG-QCGSCWAFSASGCLEGQ', str(hsp.hit.seq)[:40])
        self.assertEqual('LVKNSWGKEWGMDGYIKIAKDRN----NHCGLATAASYPI', str(hsp.hit.seq)[-40:])
        self.assertEqual(337, len(hsp.hit.seq))

        # last hit
        hit = res[-1]
        self.assertEqual('PAPA_CARPA', hit.id)
        self.assertEqual('<unknown description>', hit.description)
        self.assertAlmostEqual(337.7, hit.bitscore)
        self.assertAlmostEqual(9e-102, hit.evalue)
        self.assertEqual(1, hit.domain_obs_num)
        self.assertEqual(1, len(hit))

        # last hit, last hsp
        hsp = hit[-1]
        self.assertEqual('Peptidase_C1', hsp.query_id)
        self.assertEqual('Papain family cysteine protease', hsp.query_description)
        self.assertEqual('PAPA_CARPA', hit.id)
        self.assertEqual('<unknown description>', hit.description)
        self.assertEqual(1, hsp.domain_index)
        self.assertAlmostEqual(337.7, hsp.bitscore)
        self.assertAlmostEqual(9e-102, hsp.evalue)
        self.assertEqual(0, hsp.query_start)
        self.assertEqual(337, hsp.query_end)
        self.assertEqual('[]', hsp.query_endtype)
        self.assertEqual('lPesfDWReWkggaVtpVKdQGiqCGSCWAFSavgalEgr', str(hsp.query.seq)[:40])
        self.assertEqual('IVKNSWGtdWGEnGYfriaRgknksgkneCGIaseasypi', str(hsp.query.seq)[-40:])
        self.assertEqual(337, len(hsp.query.seq))
        self.assertEqual('+Pe +DWR+ kg aVtpVK+QG +CGSCWAFSav ++Eg+',
                str(hsp.aln_annotation['similarity'])[:40])
        self.assertEqual('++KNSWGt WGEnGY+ri+Rg+++s ++ CG+ ++  yp+',
                str(hsp.aln_annotation['similarity'])[-40:])
        self.assertEqual(133, hsp.hit_start)
        self.assertEqual(343, hsp.hit_end)
        self.assertEqual('..', hsp.hit_endtype)
        self.assertEqual('IPEYVDWRQ-KG-AVTPVKNQG-SCGSCWAFSAVVTIEGI', str(hsp.hit.seq)[:40])
        self.assertEqual('LIKNSWGTGWGENGYIRIKRGTGNS-YGVCGLYTSSFYPV', str(hsp.hit.seq)[-40:])
        self.assertEqual(337, len(hsp.hit.seq))
    def test_hmmsearch_22(self):
        """Test parsing hmmsearch 2.2 file (text_22_hmmsearch_001.out)."""
        res = read(path.join("Hmmer", "text_22_hmmsearch_001.out"), self.fmt)

        # first query
        self.assertEqual("Peptidase_C1", res.id)
        self.assertEqual("Papain family cysteine protease", res.description)
        self.assertEqual("hmmsearch", res.program)
        self.assertEqual("2.2g", res.version)
        self.assertEqual("cysprot1b.fa", res.target)
        self.assertEqual(4, len(res))

        # first hit
        hit = res[0]
        self.assertEqual("CATL_RAT", hit.id)
        self.assertEqual("<unknown description>", hit.description)
        self.assertAlmostEqual(449.4, hit.bitscore)
        self.assertAlmostEqual(2e-135, hit.evalue)
        self.assertEqual(1, hit.domain_obs_num)
        self.assertEqual(1, len(hit))

        # first hit, first hsp
        hsp = hit[0]
        self.assertEqual("Peptidase_C1", hsp.query_id)
        self.assertEqual("Papain family cysteine protease",
                         hsp.query_description)
        self.assertEqual("CATL_RAT", hit.id)
        self.assertEqual("<unknown description>", hit.description)
        self.assertEqual(1, hsp.domain_index)
        self.assertAlmostEqual(449.4, hsp.bitscore)
        self.assertAlmostEqual(2e-135, hsp.evalue)
        self.assertEqual(0, hsp.query_start)
        self.assertEqual(337, hsp.query_end)
        self.assertEqual("[]", hsp.query_endtype)
        self.assertEqual("lPesfDWReWkggaVtpVKdQGiqCGSCWAFSavgalEgr",
                         str(hsp.query.seq)[:40])
        self.assertEqual("IVKNSWGtdWGEnGYfriaRgknksgkneCGIaseasypi",
                         str(hsp.query.seq)[-40:])
        self.assertEqual(337, len(hsp.query.seq))
        self.assertEqual(
            "+P+++DWRe kg  VtpVK+QG qCGSCWAFSa g lEg+",
            str(hsp.aln_annotation["similarity"])[:40],
        )
        self.assertEqual(
            "+VKNSWG++WG++GY++ia+++n    n+CG+a+ asypi",
            str(hsp.aln_annotation["similarity"])[-40:],
        )
        self.assertEqual(113, hsp.hit_start)
        self.assertEqual(332, hsp.hit_end)
        self.assertEqual("..", hsp.hit_endtype)
        self.assertEqual("IPKTVDWRE-KG-CVTPVKNQG-QCGSCWAFSASGCLEGQ",
                         str(hsp.hit.seq)[:40])
        self.assertEqual("LVKNSWGKEWGMDGYIKIAKDRN----NHCGLATAASYPI",
                         str(hsp.hit.seq)[-40:])
        self.assertEqual(337, len(hsp.hit.seq))

        # last hit
        hit = res[-1]
        self.assertEqual("PAPA_CARPA", hit.id)
        self.assertEqual("<unknown description>", hit.description)
        self.assertAlmostEqual(337.7, hit.bitscore)
        self.assertAlmostEqual(9e-102, hit.evalue)
        self.assertEqual(1, hit.domain_obs_num)
        self.assertEqual(1, len(hit))

        # last hit, last hsp
        hsp = hit[-1]
        self.assertEqual("Peptidase_C1", hsp.query_id)
        self.assertEqual("Papain family cysteine protease",
                         hsp.query_description)
        self.assertEqual("PAPA_CARPA", hit.id)
        self.assertEqual("<unknown description>", hit.description)
        self.assertEqual(1, hsp.domain_index)
        self.assertAlmostEqual(337.7, hsp.bitscore)
        self.assertAlmostEqual(9e-102, hsp.evalue)
        self.assertEqual(0, hsp.query_start)
        self.assertEqual(337, hsp.query_end)
        self.assertEqual("[]", hsp.query_endtype)
        self.assertEqual("lPesfDWReWkggaVtpVKdQGiqCGSCWAFSavgalEgr",
                         str(hsp.query.seq)[:40])
        self.assertEqual("IVKNSWGtdWGEnGYfriaRgknksgkneCGIaseasypi",
                         str(hsp.query.seq)[-40:])
        self.assertEqual(337, len(hsp.query.seq))
        self.assertEqual(
            "+Pe +DWR+ kg aVtpVK+QG +CGSCWAFSav ++Eg+",
            str(hsp.aln_annotation["similarity"])[:40],
        )
        self.assertEqual(
            "++KNSWGt WGEnGY+ri+Rg+++s ++ CG+ ++  yp+",
            str(hsp.aln_annotation["similarity"])[-40:],
        )
        self.assertEqual(133, hsp.hit_start)
        self.assertEqual(343, hsp.hit_end)
        self.assertEqual("..", hsp.hit_endtype)
        self.assertEqual("IPEYVDWRQ-KG-AVTPVKNQG-SCGSCWAFSAVVTIEGI",
                         str(hsp.hit.seq)[:40])
        self.assertEqual("LIKNSWGTGWGENGYIRIKRGTGNS-YGVCGLYTSSFYPV",
                         str(hsp.hit.seq)[-40:])
        self.assertEqual(337, len(hsp.hit.seq))
    def test_hmmsearch_20(self):
        """Test parsing hmmsearch 2.0 file (text_20_hmmsearch_001.out)"""
        res = read(path.join("Hmmer", "text_20_hmmsearch_001.out"), self.fmt)

        # first query
        self.assertEqual('SEED', res.id)
        self.assertEqual('<unknown description>', res.description)
        self.assertEqual('hmmsearch', res.program)
        self.assertEqual('2.0', res.version)
        self.assertEqual('HMM.dbtemp.29591', res.target)
        self.assertEqual(751, len(res))

        # first hit
        hit = res[0]
        self.assertEqual('PAB2_ARATH', hit.id)
        self.assertEqual('P42731 POLYADENYLATE-BINDING PROTEIN 2 (PO', hit.description)
        self.assertAlmostEqual(393.8, hit.bitscore)
        self.assertAlmostEqual(6.1e-114, hit.evalue)
        self.assertEqual(4, hit.domain_obs_num)
        self.assertEqual(4, len(hit))

        # first hit, first hsp
        hsp = hit[0]
        self.assertEqual('SEED', hsp.query_id)
        self.assertEqual('<unknown description>', hsp.query_description)
        self.assertEqual('PAB2_ARATH', hsp.hit_id)
        self.assertEqual('P42731 POLYADENYLATE-BINDING PROTEIN 2 (PO', hsp.hit_description)
        self.assertEqual(3, hsp.domain_index)
        self.assertAlmostEqual(109.1, hsp.bitscore)
        self.assertAlmostEqual(3e-28, hsp.evalue)
        self.assertEqual(0, hsp.query_start)
        self.assertEqual(77, hsp.query_end)
        self.assertEqual('[]', hsp.query_endtype)
        self.assertEqual(216, hsp.hit_start)
        self.assertEqual(287, hsp.hit_end)
        self.assertEqual('..', hsp.hit_endtype)

        # first hit, last hsp
        hsp = hit[-1]
        self.assertEqual('SEED', hsp.query_id)
        self.assertEqual('<unknown description>', hsp.query_description)
        self.assertEqual('PAB2_ARATH', hsp.hit_id)
        self.assertEqual('P42731 POLYADENYLATE-BINDING PROTEIN 2 (PO', hsp.hit_description)
        self.assertEqual(1, hsp.domain_index)
        self.assertAlmostEqual(92.1, hsp.bitscore)
        self.assertAlmostEqual(3.9e-23, hsp.evalue)
        self.assertEqual(0, hsp.query_start)
        self.assertEqual(77, hsp.query_end)
        self.assertEqual('[]', hsp.query_endtype)
        self.assertEqual(37, hsp.hit_start)
        self.assertEqual(109, hsp.hit_end)
        self.assertEqual('..', hsp.hit_endtype)

        # last hit
        hit = res[-1]
        self.assertEqual('O00369', hit.id)
        self.assertEqual('O00369 L1 ELEMENT L1.20 P40 AND PUTATIVE P', hit.description)
        self.assertAlmostEqual(-23.8, hit.bitscore)
        self.assertAlmostEqual(9.9e+02, hit.evalue)
        self.assertEqual(1, hit.domain_obs_num)
        self.assertEqual(1, len(hit))

        # last hit, first hsp
        hsp = hit[0]
        self.assertEqual('SEED', hsp.query_id)
        self.assertEqual('<unknown description>', hsp.query_description)
        self.assertEqual('O00369', hsp.hit_id)
        self.assertEqual('O00369 L1 ELEMENT L1.20 P40 AND PUTATIVE P', hsp.hit_description)
        self.assertEqual(1, hsp.domain_index)
        self.assertAlmostEqual(-23.8, hsp.bitscore)
        self.assertAlmostEqual(9.9e+02, hsp.evalue)
        self.assertEqual(0, hsp.query_start)
        self.assertEqual(77, hsp.query_end)
        self.assertEqual('[]', hsp.query_endtype)
        self.assertEqual(180, hsp.hit_start)
        self.assertEqual(249, hsp.hit_end)
        self.assertEqual('..', hsp.hit_endtype)
    def test_hmmsearch_20(self):
        """Test parsing hmmsearch 2.0 file (text_20_hmmsearch_001.out)."""
        res = read(path.join("Hmmer", "text_20_hmmsearch_001.out"), self.fmt)

        # first query
        self.assertEqual("SEED", res.id)
        self.assertEqual("<unknown description>", res.description)
        self.assertEqual("hmmsearch", res.program)
        self.assertEqual("2.0", res.version)
        self.assertEqual("HMM.dbtemp.29591", res.target)
        self.assertEqual(751, len(res))

        # first hit
        hit = res[0]
        self.assertEqual("PAB2_ARATH", hit.id)
        self.assertEqual("P42731 POLYADENYLATE-BINDING PROTEIN 2 (PO",
                         hit.description)
        self.assertAlmostEqual(393.8, hit.bitscore)
        self.assertAlmostEqual(6.1e-114, hit.evalue)
        self.assertEqual(4, hit.domain_obs_num)
        self.assertEqual(4, len(hit))

        # first hit, first hsp
        hsp = hit[0]
        self.assertEqual("SEED", hsp.query_id)
        self.assertEqual("<unknown description>", hsp.query_description)
        self.assertEqual("PAB2_ARATH", hsp.hit_id)
        self.assertEqual("P42731 POLYADENYLATE-BINDING PROTEIN 2 (PO",
                         hsp.hit_description)
        self.assertEqual(3, hsp.domain_index)
        self.assertAlmostEqual(109.1, hsp.bitscore)
        self.assertAlmostEqual(3e-28, hsp.evalue)
        self.assertEqual(0, hsp.query_start)
        self.assertEqual(77, hsp.query_end)
        self.assertEqual("[]", hsp.query_endtype)
        self.assertEqual(216, hsp.hit_start)
        self.assertEqual(287, hsp.hit_end)
        self.assertEqual("..", hsp.hit_endtype)

        # first hit, last hsp
        hsp = hit[-1]
        self.assertEqual("SEED", hsp.query_id)
        self.assertEqual("<unknown description>", hsp.query_description)
        self.assertEqual("PAB2_ARATH", hsp.hit_id)
        self.assertEqual("P42731 POLYADENYLATE-BINDING PROTEIN 2 (PO",
                         hsp.hit_description)
        self.assertEqual(1, hsp.domain_index)
        self.assertAlmostEqual(92.1, hsp.bitscore)
        self.assertAlmostEqual(3.9e-23, hsp.evalue)
        self.assertEqual(0, hsp.query_start)
        self.assertEqual(77, hsp.query_end)
        self.assertEqual("[]", hsp.query_endtype)
        self.assertEqual(37, hsp.hit_start)
        self.assertEqual(109, hsp.hit_end)
        self.assertEqual("..", hsp.hit_endtype)

        # last hit
        hit = res[-1]
        self.assertEqual("O00369", hit.id)
        self.assertEqual("O00369 L1 ELEMENT L1.20 P40 AND PUTATIVE P",
                         hit.description)
        self.assertAlmostEqual(-23.8, hit.bitscore)
        self.assertAlmostEqual(9.9e02, hit.evalue)
        self.assertEqual(1, hit.domain_obs_num)
        self.assertEqual(1, len(hit))

        # last hit, first hsp
        hsp = hit[0]
        self.assertEqual("SEED", hsp.query_id)
        self.assertEqual("<unknown description>", hsp.query_description)
        self.assertEqual("O00369", hsp.hit_id)
        self.assertEqual("O00369 L1 ELEMENT L1.20 P40 AND PUTATIVE P",
                         hsp.hit_description)
        self.assertEqual(1, hsp.domain_index)
        self.assertAlmostEqual(-23.8, hsp.bitscore)
        self.assertAlmostEqual(9.9e02, hsp.evalue)
        self.assertEqual(0, hsp.query_start)
        self.assertEqual(77, hsp.query_end)
        self.assertEqual("[]", hsp.query_endtype)
        self.assertEqual(180, hsp.hit_start)
        self.assertEqual(249, hsp.hit_end)
        self.assertEqual("..", hsp.hit_endtype)