예제 #1
0
 def test_options(self):
     """Constructor should take parser as an option."""
     result = BlastXMLResult(COMPLETE_XML, parser=MinimalBlastParser7)
     self.assertEqual(len(list(result.keys())), 1)
예제 #2
0
 def setUp(self):
     self.result = BlastXMLResult(COMPLETE_XML, xml=True)
예제 #3
0
class BlastXmlResultTests(TestCase):
    """Tests parsing of output of Blast with output mode 7 (XML)."""
    def setUp(self):
        self.result = BlastXMLResult(COMPLETE_XML, xml=True)

    def test_options(self):
        """Constructor should take parser as an option."""
        result = BlastXMLResult(COMPLETE_XML, parser=MinimalBlastParser7)
        self.assertEqual(len(list(result.keys())), 1)
        # make sure whether normal Blast parser still works upon code merge!

    def test_parsed_query_sequence(self):
        """The result dict should have one query sequence as a key."""
        # The full query sequence is not given in the XML file.
        # Thus it is not checked explicitly, only whether there is
        # exactly one found.
        self.assertEqual(len(list(self.result.keys())), 1)

    def test_parsed_iterations(self):
        """The result should have the right number of iterations."""
        n_iter = 0
        for query_id, hits in self.result.iterHitsByQuery():
            n_iter += 1
        self.assertEqual(n_iter, 1)

    def test_parsed_hsps(self):
        """The result should have the right number of hsps."""
        n_hsps = 0
        for query_id, hsps in self.result.iterHitsByQuery():
            n_hsps += len(hsps)
        self.assertEqual(n_hsps, 3)

    def test_parse_hit_details(self):
        """The result should have data from hit fields."""
        for query in self.result:
            first_hsp = self.result[query][0][0]
            self.assertEqual(first_hsp['SUBJECT_ID'],
                             "gi|148670104|gb|EDL02051.1|")
            self.assertEqual(
                first_hsp['HIT_DEF'],
                "insulin-like growth factor 2 receptor, isoform CRA_c [Mus musculus]"
            )
            self.assertEqual(first_hsp['HIT_ACCESSION'], "2001")
            self.assertEqual(first_hsp['HIT_LENGTH'], 707)

    def test_parse_hsp_details(self):
        """The result should have data from hsp fields."""
        for query in self.result:
            # should check integers in next version.
            first_hsp = self.result[query][0][0]
            self.assertEqual(first_hsp['QUERY ID'], 1)
            self.assertEqual(first_hsp['BIT_SCORE'], '1023.46')
            self.assertEqual(first_hsp['SCORE'], '2645')
            self.assertEqual(first_hsp['E_VALUE'], '0.333')
            self.assertEqual(first_hsp['QUERY_START'], '4')
            self.assertEqual(first_hsp['QUERY_END'], '18')
            self.assertEqual(first_hsp['QUERY_ALIGN'],
                             'ELEPHANTTHISISAHITTIGER')
            self.assertEqual(first_hsp['MIDLINE_ALIGN'], 'ORCA-WHALE')
            self.assertEqual(first_hsp['SUBJECT_ALIGN'],
                             'SEALSTHIS---HIT--GER')
            self.assertEqual(first_hsp['SUBJECT_START'], '5')
            self.assertEqual(first_hsp['SUBJECT_END'], '19')
            self.assertEqual(first_hsp['PERCENT_IDENTITY'], '55')
            self.assertEqual(first_hsp['POSITIVE'], '555')
            self.assertEqual(first_hsp['GAP_OPENINGS'], 0)
            self.assertEqual(first_hsp['ALIGNMENT_LENGTH'], '14')

            gap_hsp = self.result[query][0][1]
            self.assertEqual(gap_hsp['GAP_OPENINGS'], '33')
예제 #4
0
 def test_options(self):
     """Constructor should take parser as an option."""
     result = BlastXMLResult(COMPLETE_XML,parser=MinimalBlastParser7)
     self.assertEqual(len(result.keys()),1)
예제 #5
0
 def setUp(self):
     self.result = BlastXMLResult(COMPLETE_XML,xml=True)
예제 #6
0
class BlastXmlResultTests(TestCase):
    """Tests parsing of output of Blast with output mode 7 (XML)."""
    def setUp(self):
        self.result = BlastXMLResult(COMPLETE_XML,xml=True)

    def test_options(self):
        """Constructor should take parser as an option."""
        result = BlastXMLResult(COMPLETE_XML,parser=MinimalBlastParser7)
        self.assertEqual(len(result.keys()),1)
        # make sure whether normal Blast parser still works upon code merge!

    def test_parsed_query_sequence(self):
        """The result dict should have one query sequence as a key."""
        # The full query sequence is not given in the XML file.
        # Thus it is not checked explicitly, only whether there is
        # exactly one found.
        self.assertEqual(len(self.result.keys()),1)

    def test_parsed_iterations(self):
        """The result should have the right number of iterations."""
        n_iter = 0
        for query_id,hits in self.result.iterHitsByQuery():
            n_iter += 1
        self.assertEqual(n_iter,1)
        
    def test_parsed_hsps(self):
        """The result should have the right number of hsps."""
        n_hsps = 0
        for query_id,hsps in self.result.iterHitsByQuery():
            n_hsps += len(hsps)
        self.assertEqual(n_hsps,3)

    def test_parse_hit_details(self):
        """The result should have data from hit fields."""
        for query in self.result:
            first_hsp = self.result[query][0][0]
            self.assertEqual(first_hsp['SUBJECT_ID'],
                "gi|148670104|gb|EDL02051.1|")
            self.assertEqual(first_hsp['HIT_DEF'],
                "insulin-like growth factor 2 receptor, isoform CRA_c [Mus musculus]")
            self.assertEqual(first_hsp['HIT_ACCESSION'],"2001")
            self.assertEqual(first_hsp['HIT_LENGTH'],707)

    def test_parse_hsp_details(self):
        """The result should have data from hsp fields."""
        for query in self.result:
            # should check integers in next version.
            first_hsp = self.result[query][0][0]
            self.assertEqual(first_hsp['QUERY ID'],1)
            self.assertEqual(first_hsp['BIT_SCORE'],'1023.46')
            self.assertEqual(first_hsp['SCORE'],'2645')
            self.assertEqual(first_hsp['E_VALUE'],'0.333')
            self.assertEqual(first_hsp['QUERY_START'],'4')
            self.assertEqual(first_hsp['QUERY_END'],'18')
            self.assertEqual(first_hsp['QUERY_ALIGN'],'ELEPHANTTHISISAHITTIGER')
            self.assertEqual(first_hsp['MIDLINE_ALIGN'],'ORCA-WHALE')
            self.assertEqual(first_hsp['SUBJECT_ALIGN'],'SEALSTHIS---HIT--GER')
            self.assertEqual(first_hsp['SUBJECT_START'],'5')
            self.assertEqual(first_hsp['SUBJECT_END'],'19')
            self.assertEqual(first_hsp['PERCENT_IDENTITY'],'55')
            self.assertEqual(first_hsp['POSITIVE'],'555')
            self.assertEqual(first_hsp['GAP_OPENINGS'],0)
            self.assertEqual(first_hsp['ALIGNMENT_LENGTH'],'14')

            gap_hsp = self.result[query][0][1]
            self.assertEqual(gap_hsp['GAP_OPENINGS'],'33')