Exemple #1
0
    def test_control_compound(self, mock_get):
        text_location = 'TextLocation'
        lines = [
            ANNOTATION_URL_FMT.format(MESH_DISEASES_KEYWORD,
                                      MESH_DISEASES_URL),
            NAMESPACE_URL_FMT.format(HGNC_KEYWORD, HGNC_URL),
            'DEFINE ANNOTATION TextLocation AS LIST {"Abstract","Results","Legend","Review"}'
        ]
        self.parser.parse_lines(lines)

        self.assertIn(MESH_DISEASES_KEYWORD, self.parser.annotation_to_term)
        self.assertIn(HGNC_KEYWORD, self.parser.namespace_to_term_to_encoding)
        self._help_test_local_annotation(text_location)
Exemple #2
0
    def test_annotation_name_persistience_2(self):
        """Tests that an annotation defined by a list can't be overwritten by a definition by URL"""
        s = 'DEFINE ANNOTATION TextLocation AS LIST {"Abstract","Results","Legend","Review"}'
        self.parser.parseString(s)
        self._help_test_local_annotation('TextLocation')

        s = ANNOTATION_URL_FMT.format('TextLocation', MESH_DISEASES_URL)
        with self.assertRaises(RedefinedAnnotationError):
            self.parser.parseString(s)

        self._help_test_local_annotation('TextLocation')
        self.assertIn('Abstract',
                      self.parser.annotation_to_local['TextLocation'])
Exemple #3
0
    def test_annotation_name_persistience_1(self, mock_get):
        """Test that an annotation defined by a URL can't be overwritten by a definition by a list."""
        s = ANNOTATION_URL_FMT.format(MESH_DISEASES_KEYWORD, MESH_DISEASES_URL)
        self.parser.parseString(s)
        self.assertIn(MESH_DISEASES_KEYWORD, self.parser.annotation_to_term)

        s = 'DEFINE ANNOTATION {} AS LIST {{"A","B","C"}}'.format(
            MESH_DISEASES_KEYWORD)
        with self.assertRaises(RedefinedAnnotationError):
            self.parser.parseString(s)

        self.assertIn(MESH_DISEASES_KEYWORD, self.parser.annotation_to_term)
        self.assertNotIn('A',
                         self.parser.annotation_to_term[MESH_DISEASES_KEYWORD])
        self.assertIn('46, XX Disorders of Sex Development',
                      self.parser.annotation_to_term[MESH_DISEASES_KEYWORD])
Exemple #4
0
    def test_parse_annotation_url_file(self):
        """Tests parsing an annotation by file URL"""
        keyword = 'TESTAN1'
        url = Path(test_an_1).as_uri()
        line = ANNOTATION_URL_FMT.format(keyword, url)
        self.parser.parseString(line)

        expected_values = {
            'TestAnnot1': 'O',
            'TestAnnot2': 'O',
            'TestAnnot3': 'O',
            'TestAnnot4': 'O',
            'TestAnnot5': 'O'
        }

        self.assertEqual(set(expected_values),
                         self.parser.manager.get_annotation_entry_names(url))
    def test_parse_annotation_url_file(self):
        """Tests parsing an annotation by file URL"""
        keyword = 'TESTAN1'
        url = Path(test_an_1).as_uri()
        line = ANNOTATION_URL_FMT.format(keyword, url)
        self.parser.parseString(line)
        self.parser.ensure_resources()

        expected_values = {
            'TestAnnot1': 'O',
            'TestAnnot2': 'O',
            'TestAnnot3': 'O',
            'TestAnnot4': 'O',
            'TestAnnot5': 'O'
        }

        annotation = self.parser.manager.get_namespace_by_url(url)
        self.assertIsNotNone(annotation)
        self.assertEqual(set(expected_values),
                         {e.name
                          for e in annotation.entries})