Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Names and synonyms are now generated using Groovy / Open RDF
- Loading branch information
Showing
9 changed files
with
55 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
vars.php | ||
vars.properties | ||
*~ | ||
mysql*.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import groovy.sql.Sql | ||
import org.openrdf.repository.Repository | ||
import org.openrdf.repository.sail.SailRepository | ||
import org.openrdf.sail.memory.MemoryStore | ||
import org.openrdf.model.vocabulary.RDFS | ||
import org.openrdf.model.vocabulary.RDF | ||
import org.openrdf.rio.ntriples.NTriplesWriter | ||
|
||
// export CLASSPATH=$(JARS=(*.jar); IFS=:; echo "${JARS[*]}") | ||
|
||
def props = new Properties() | ||
new File("vars.properties").withInputStream { stream -> props.load(stream) } | ||
|
||
def url = "jdbc:mysql://localhost/" + props.dbprefix + props.version | ||
def sql = Sql.newInstance(url, props.user, props.pwd, "com.mysql.jdbc.Driver") | ||
|
||
allMolregno = "SELECT DISTINCT molregno FROM compound_records " + props.limit | ||
|
||
sql.eachRow(allMolregno) { row -> | ||
def repos = new SailRepository(new MemoryStore()) | ||
repos.initialize() | ||
con = repos.getConnection(); | ||
factory = repos.getValueFactory(); | ||
|
||
molURI = factory.createURI("http://data.kasabi.com/dataset/chembl-rdf/molecule/m" + row.molregno) | ||
|
||
// the names | ||
allNames = "SELECT DISTINCT compound_name FROM compound_records WHERE molregno = " + row.molregno | ||
sql.eachRow(allNames) { nameRow -> | ||
if (nameRow['compound_name'] != null) { | ||
con.add(molURI, RDFS.LABEL, factory.createLiteral(nameRow['compound_name'])) | ||
} | ||
} | ||
|
||
// the synonyms | ||
allNames = "SELECT DISTINCT synonyms FROM molecule_synonyms WHERE molregno = " + row.molregno | ||
sql.eachRow(allNames) { nameRow -> | ||
if (nameRow['synonyms'] != null) { | ||
con.add(molURI, RDFS.LABEL, factory.createLiteral(nameRow['synonyms'])) | ||
} | ||
} | ||
|
||
con.export(new NTriplesWriter(System.out)) | ||
con.close() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version=13 | ||
rooturi=http://data.kasabi.com/dataset/chembl-rdf/ | ||
|
||
dbprefix=chembl_ | ||
user=user | ||
pwd=secret | ||
|
||
limit=LIMIT 1 |