[]"); $string = substr($string, 0, $position_of_first_bad_character); // if string ends with ) and there is no prior ( in string, then the ) does not belong to the id if (((strpos($string, ")") !== false)) && (strpos($string, "(") !== true)) { $position_of_first_bad_character = strcspn($string, ")"); $string = substr($string, 0, $position_of_first_bad_character); } return $string; } // write namespace prefixes fputs($output_file_handle, "@prefix rdfs: . \n\n"); // ------- hasDbXref/hasURI query ------- $config = array( 'remote_store_endpoint' => 'http://sparql.obo.neurocommons.org/sparql', ); $store = ARC2::getRemoteStore($config); $q = 'PREFIX rdfs: PREFIX obo: SELECT DISTINCT ?entity ?wikipedia_uri WHERE { ?entity obo:hasDefinition ?definition_bnode . ?definition_bnode obo:hasDbXref ?dbxref_bnode . ?dbxref_bnode obo:hasURI ?wikipedia_uri . FILTER regex(str(?wikipedia_uri), "wikipedia", "i") } '; if ($rows = $store->query($q, 'rows')) { foreach ($rows as $row) { $id = extract_id($row['wikipedia_uri']); if ($id != "") { fputs($output_file_handle, '<' . $row['entity'] . '> rdfs:seeAlso . \n"); } } } // ------- OBI query ------- $config = array( 'remote_store_endpoint' => 'http://sparql.obo.neurocommons.org/sparql', ); $store = ARC2::getRemoteStore($config); $q =' PREFIX owl: PREFIX obi: PREFIX rdfs: SELECT DISTINCT ?entity ?wikipedia_uri WHERE { ?entity obi:IAO_0000119 ?wikipedia_uri. FILTER regex(str(?wikipedia_uri), "en.wikipedia.org/wiki/", "i") } '; if ($rows = $store->query($q, 'rows')) { foreach ($rows as $row) { $id = extract_id($row['wikipedia_uri']); if ($id != "") { fputs($output_file_handle, '<' . $row['entity'] . '> rdfs:seeAlso . \n"); } } } fclose($output_file_handle); print " script succesfully executed. "; ?>