예제 #1
0
 def __parse_annotation(self, tree):
     annotation = BioCAnnotation()
     annotation.id = tree.attrib['id']
     annotation.infons = self.__parse_infons(tree)
     annotation.text = tree.findtext('text')
     for child in tree.findall('location'):
         annotation.add_location(
             BioCLocation(int(child.attrib['offset']), int(child.attrib['length'])))
     return annotation
예제 #2
0
    def test_should_get_gene_names_normalised(self, list_dict, expected_genes):
        # Arrange
        sut = BiocAnnotationGenes()
        bioc_doc = BioCDocument()
        bioc_passage = BioCPassage()
        bioc_doc.add_passage(bioc_passage)

        for dict in list_dict:
            annotation = BioCAnnotation()
            annotation.infons = dict
            bioc_passage.add_annotation(annotation)

        # act
        actual = sut.get_gene_names_normalised(bioc_doc)

        # assert
        self.assertEqual(set(expected_genes), actual)
예제 #3
0
    def test_should_get_gene_names_to_normalised_dict(
            self, list_gene_dict_in_passage, expected_dict):
        # Arrange
        sut = BiocAnnotationGenes()
        bioc_doc = BioCDocument()
        for list_gene_dict in list_gene_dict_in_passage:
            bioc_passage = BioCPassage()
            bioc_doc.add_passage(bioc_passage)

            for dict in list_gene_dict:
                annotation = BioCAnnotation()
                annotation.text = dict["text"]
                annotation.infons = dict
                bioc_passage.add_annotation(annotation)

        # act
        actual = sut.get_gene_names_to_normalised_dict(bioc_doc)

        # assert
        self.assertEqual(expected_dict, actual)