def _convert_kg2_edge_to_swagger_edge(self, neo4j_edge): swagger_edge = Edge() swagger_edge.type = neo4j_edge.get('simplified_edge_label') swagger_edge.source_id = neo4j_edge.get('subject') swagger_edge.target_id = neo4j_edge.get('object') swagger_edge.id = self._create_edge_id(swagger_edge) swagger_edge.relation = neo4j_edge.get('relation') swagger_edge.publications = ast.literal_eval( neo4j_edge.get('publications')) swagger_edge.provided_by = self._convert_strange_provided_by_field_to_list( neo4j_edge.get('provided_by') ) # Temporary hack until provided_by is fixed in KG2 swagger_edge.negated = ast.literal_eval(neo4j_edge.get('negated')) swagger_edge.is_defined_by = "ARAX/KG2" swagger_edge.edge_attributes = [] # Add additional properties on KG2 edges as swagger EdgeAttribute objects # TODO: fix issues coming from strange characters in 'publications_info'! (EOF error) additional_kg2_edge_properties = [ 'relation_curie', 'simplified_relation_curie', 'simplified_relation', 'edge_label' ] edge_attributes = self._create_swagger_attributes( "edge", additional_kg2_edge_properties, neo4j_edge) swagger_edge.edge_attributes += edge_attributes return swagger_edge
def _convert_kg2_edge_to_swagger_edge(self, neo4j_edge: Dict[str, any]) -> Edge: swagger_edge = Edge() swagger_edge.id = f"KG2:{neo4j_edge.get('id')}" swagger_edge.type = neo4j_edge.get("simplified_edge_label") swagger_edge.source_id = neo4j_edge.get("subject") swagger_edge.target_id = neo4j_edge.get("object") swagger_edge.relation = neo4j_edge.get("relation") swagger_edge.publications = ast.literal_eval(neo4j_edge.get("publications")) swagger_edge.provided_by = self._convert_strange_provided_by_field_to_list(neo4j_edge.get("provided_by")) # Temporary hack until provided_by is fixed in KG2 swagger_edge.negated = ast.literal_eval(neo4j_edge.get("negated")) swagger_edge.is_defined_by = "ARAX/KG2" swagger_edge.edge_attributes = [] # Add additional properties on KG2 edges as swagger EdgeAttribute objects # TODO: fix issues coming from strange characters in 'publications_info'! (EOF error) additional_kg2_edge_properties = ["relation_curie", "simplified_relation_curie", "simplified_relation", "edge_label"] edge_attributes = self._create_swagger_attributes("edge", additional_kg2_edge_properties, neo4j_edge) swagger_edge.edge_attributes += edge_attributes return swagger_edge