forked from egonw/chembl.rdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompounds_ls_ebi.php
73 lines (60 loc) · 2.78 KB
/
compounds_ls_ebi.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php header('Content-type: text/n3');
include 'namespaces.php';
include 'functions.php';
$ini = parse_ini_file("vars.properties");
$rooturi = $ini["rooturi"];
$importedBy = $ini["importedBy"];
$db = $ini["dbprefix"] . $ini["version"];
$con = mysqli_connect(ini_get("mysqli.default_host"), ini_get("mysqli.default_user"), ini_get("mysqli.default_pw"), $db);
if (mysqli_connect_errno($con)) die(mysqli_connect_errno($con));
# VOID
$mastervoid = $rooturi . "void.ttl#";
$masterset = $mastervoid . "ChEMBLRDF";
$thisset = $mastervoid . "ChEMBLChEBIMapping";
$thisSetTitle = "ChEMBL - ChEBI OWL mappings";
$thisSetDescription = "Mappings between ChEMBL compounds and the ChEBI ontology.";
$sourceSet = $mastervoid . "ChEMBLCompound";
$sourceSpace = $CHEMBL;
$targetSet = $mastervoid . "ChEBI";
$targetSpace = "http://purl.obolibrary.org/obo/";
$linkPredicate = $SKOS . "exactMatch";
$expresses = $CHEMINF . "CHEMINF_000407";
$current_date = gmDate("Y-m-d\TH:i:s");
echo triple( $thisset , $PAV . "createdBy", $importedBy );
echo typeddata_triple( $thisset, $PAV . "createdOn", $current_date, $XSD . "dateTime" );
echo triple( $thisset , $PAV . "authoredBy", $importedBy );
echo typeddata_triple( $thisset, $PAV . "authoredOn", $current_date, $XSD . "dateTime" );
echo triple( $thisset, $RDF . "type", $VOID . "Linkset" );
echo triple( $masterset, $VOID . "subset" , $thisset );
# echo triple( $molset, $RDF . "type", $VOID . "Dataset" );
echo data_triple( $sourceSet, $VOID . "uriSpace", $sourceSpace );
echo triple( $masterset, $VOID . "subset" , $sourceSet );
# echo triple( $chebiset, $RDF . "type", $VOID . "Dataset" );
echo data_triple( $targetSet, $VOID . "uriSpace", $targetSpace );
echo triple( $masterset, $VOID . "subset" , $thisset );
echo "\n";
echo data_triple( $thisset, $DCT . "title", $thisSetTitle ) ;
echo data_triple( $thisset, $DCT . "description", $thisSetDescription ) ;
echo triple( $thisset, $VOID . "subjectsTarget", $sourceSet) ;
echo triple( $thisset, $VOID . "objectsTarget", $targetSet);
echo triple( $thisset, $VOID . "linkPredicate", $linkPredicate );
echo triple( $thisset, $DCT . "license", $ini["license"] ) ;
echo triple( $thisset, $DUL . "expresses", $expresses);
echo "\n";
# DATA
$allIDs = mysqli_query($con,
"SELECT DISTINCT molregno, chembl_id FROM molecule_dictionary " . $ini["limit"]
);
while ($row = mysqli_fetch_assoc($allIDs)) {
$molregno = $row['molregno'];
$molecule = $CHEMBL . $row['chembl_id'];
# get the compound type, ChEBI, and ChEMBL identifiers
$chebi = mysqli_query($con, "SELECT DISTINCT chebi_par_id FROM molecule_dictionary WHERE molregno = $molregno");
if ($chebiRow = mysqli_fetch_assoc($chebi)) {
$chebiid = $chebiRow['chebi_par_id'];
if ($chebiid) {
echo triple( $molecule, $SKOS . "exactMatch", $chebiSpace . "CHEBI_" . $chebiid );
}
}
}
?>