def _check_blast(blast, expected):
    'It matches a blast results against the expected result'
    if 'query' in expected:
        _check_sequence(blast['query'], expected['query'])
    if 'matches' in expected:
        for match_index, expt_match in enumerate(expected['matches']):
            real_match = blast['matches'][match_index]
            if 'subject' in expt_match:
                _check_sequence(real_match['subject'],
                                expt_match['subject'])
            if 'match_parts' in expt_match:
                for match_part_index, expt_match_part in \
                                        enumerate(expt_match['match_parts']):
                    bl_match_part = real_match['match_parts'][match_part_index]
                    _check_match_part(bl_match_part, expt_match_part)
            if 'scores' in expt_match:
                for key in expt_match['scores']:
                    assert floats_are_equal(real_match['scores'][key],
                                             expt_match['scores'][key])
            if 'start' in expt_match:
                assert real_match['start'] == expt_match['start']
            if 'end' in expt_match:
                assert real_match['end'] == expt_match['end']
            if 'subject_start' in expt_match:
                assert real_match['subject_start'] == expt_match['subject_start']
            if 'subject_end' in expt_match:
                assert real_match['subject_end'] == expt_match['subject_end']
def _check_match_part(match_part, expected):
    'It matches a match_part against an expected result'
    if 'query_start' in expected:
        assert match_part['query_start'] == expected['query_start']
    if 'query_end' in expected:
        assert match_part['query_end'] == expected['query_end']
    if 'query_strand' in expected:
        assert match_part['query_strand'] == expected['query_strand']
    if 'subject_start' in expected:
        assert match_part['subject_start'] == expected['subject_start']
    if 'subject_end' in expected:
        assert match_part['subject_end'] == expected['subject_end']
    if 'subject_strand' in expected:
        assert match_part['subject_strand'] == expected['subject_strand']
    for key in expected['scores']:
        assert floats_are_equal(match_part['scores'][key],
                                 expected['scores'][key])