function write_type_relation_type_counts($fh, $counts)
{
    global $options;
    if ($counts !== null) {
        foreach ($counts as $pred => $count) {
            fwrite($fh, Quad("http://bio2rdf.org/dataset_resource:" . md5($options['url']), "http://bio2rdf.org/dataset_vocabulary:has_type_relation_type_count", "http://bio2rdf.org/dataset_resource:" . md5($options['url'] . $pred . "type_relation_type_count")));
            fwrite($fh, Quad("http://bio2rdf.org/dataset_resource:" . md5($options['url'] . $pred . "type_relation_type_count"), "http://bio2rdf.org/dataset_vocabulary:has_predicate", $pred));
            fwrite($fh, Quad("http://bio2rdf.org/dataset_resource:" . md5($options['url'] . $pred . "type_relation_type_count"), "http://bio2rdf.org/dataset_vocabulary:has_subject_type", $count["count"]["subject_type"]));
            fwrite($fh, QuadLiteral("http://bio2rdf.org/dataset_resource:" . md5($options['url'] . $pred . "type_relation_type_count"), "http://bio2rdf.org/dataset_vocabulary:has_subject_count", $count["count"]["subject_count"]));
            fwrite($fh, Quad("http://bio2rdf.org/dataset_resource:" . md5($options['url'] . $pred . "type_relation_type_count"), "http://bio2rdf.org/dataset_vocabulary:has_object_type", $count["count"]["object_type"]));
            fwrite($fh, QuadLiteral("http://bio2rdf.org/dataset_resource:" . md5($options['url'] . $pred . "type_relation_type_count"), "http://bio2rdf.org/dataset_vocabulary:has_object_count", $count["count"]["object_count"]));
        }
    }
}
Example #2
0
function rdfize_counts($counts_arr, $dataset_name)
{
    $rdf = "";
    foreach ($counts_arr as $i => $nscount) {
        $ns1 = $nscount['ns1'];
        $ns2 = $nscount['ns2'];
        $count = $nscount['count'];
        $dataset_uri = "http://bio2rdf.org/dataset_resource:" . md5("http://" . $dataset_name . ".bio2rdf.org/sparql");
        $count_uri = "http://bio2rdf.org/dataset_resource:" . md5($dataset_name . $ns1 . $ns2 . $count);
        $rdf .= Quad($dataset_uri, "http://bio2rdf.org/dataset_vocabulary:has_nsns_count", $count_uri);
        $rdf .= Quad($count_uri, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://bio2rdf.org/dataset_vocabulary:Namespace_Namespace_Count");
        $rdf .= Quad($count_uri, "http://bio2rdf.org/dataset_vocabulary:namespace1", "http://bio2rdf.org/" . $ns1);
        $rdf .= Quad($count_uri, "http://bio2rdf.org/dataset_vocabulary:namespace2", "http://bio2rdf.org/" . $ns2);
        $rdf .= QuadLiteral($count_uri, "http://bio2rdforg/dataset_vocabulary:has_nsns_count_value", $count);
    }
    return $rdf;
}
function addDatasetPropertyDatasetCount()
{
    global $options;
    $sparql = "SELECT DISTINCT ?p ?stype ?otype (COUNT(?s) AS ?n)\n" . $options['from-graph'] . " \n{\n\t?s ?p ?o .\n\t?s a ?stype .\n\t?o a ?otype .\n\tFILTER regex (?stype, \"vocabulary:Resource\")\n\tFILTER regex (?otype, \"vocabulary:Resource\")\n\tFILTER (?stype != ?otype)\n}";
    $r = query($sparql);
    foreach ($r as $c) {
        $id = getID($c);
        preg_match("/http:\\/\\/bio2rdf.org\\/([^_]+)_vocabulary/", $c->stype->value, $m1);
        preg_match("/http:\\/\\/bio2rdf.org\\/([^_]+)_vocabulary/", $c->otype->value, $m2);
        if (isset($m1[1]) and isset($m2[1])) {
            $d1 = $m1[1];
            $d2 = $m2[1];
            $r = $c->p->value;
            $label = "{$d1} connected to {$d2} through " . $c->n->value . " <{$r}> in " . $options['dataset_name'];
            write(Quad($options['uri'], "http://rdfs.org/ns/void#subset", $id) . Quad($id, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://rdfs.org/ns/void#LinkSet") . Quad($id, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://bio2rdf.org/bio2rdf.dataset_vocabulary:Dataset-Dataset-Property-Dataset-Count") . QuadLiteral($id, "http://www.w3.org/2000/01/rdf-schema#label", $label, null, "en") . Quad($id, "http://rdfs.org/ns/void#linkPredicate", $c->p->value) . Quad($id, "http://rdfs.org/ns/void#subjectsTarget", $c->stype->value) . Quad($id, "http://rdfs.org/ns/void#objectsTarget", $c->otype->value) . QuadLiteral($id, "http://rdfs.org/ns/void#triples", $c->n->value, "long") . Quad("http://bio2rdf.org/bio2rdf.dataset_vocabulary:Dataset-Dataset-Property-Dataset-Count", "http://www.w3.org/2000/01/rdf-schema#subClassOf", "http://bio2rdf.org/bio2rdf.dataset_vocabulary:Dataset-Descriptor"));
        }
    }
}
Example #4
0
function QQuadL($subject, $predicate, $literal, $lang = null, $graph = null)
{
    global $gns;
    $s = explode(":", $subject);
    $p = explode(":", $predicate);
    if (!isset($gns[$s[0]])) {
        trigger_error("Invalid subject qname " . $s[0]);
        exit;
    }
    if (!isset($gns[$p[0]])) {
        trigger_error("Invalid predicate qname " . $s[0]);
        exit;
    }
    return QuadLiteral($gns[$s[0]] . $s[1], $gns[$p[0]] . $p[1], $literal, $lang, $graph);
}