-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
318 additions
and
140 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
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,22 @@ | ||
sourceSets { | ||
main { | ||
java { | ||
srcDirs = ['src/main/java', 'build/gen'] | ||
} | ||
resources { | ||
srcDirs = ['src/main/resources'] | ||
} | ||
} | ||
test { | ||
java { | ||
srcDirs = ['src/test/java'] | ||
} | ||
resources { | ||
srcDirs = ['src/test/resources'] | ||
} | ||
} | ||
} | ||
|
||
processResources { | ||
from('.') { include ("*.properties")} | ||
} |
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 @@ | ||
|
||
compile.dependencies = intermine/objectstore/main, \ | ||
bio/core/main, \ | ||
intermine/integrate/main, \ | ||
bio/sources/sgd-complementation-db/main | ||
have.db.tgt = true | ||
converter.class = org.intermine.bio.dataconversion.SgdComplementationDbConverter | ||
|
192 changes: 192 additions & 0 deletions
192
...tion-db/src/main/java/org/intermine/bio/dataconversion/SgdComplementationDbConverter.java
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,192 @@ | ||
package org.intermine.bio.dataconversion; | ||
/* | ||
* Copyright (C) 2002-2016 FlyMine | ||
* | ||
* This code may be freely distributed and modified under the | ||
* terms of the GNU Lesser General Public Licence. This should | ||
* be distributed with the code. See the LICENSE file for more | ||
* information or http://www.gnu.org/copyleft/lesser.html. | ||
* | ||
*/ | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.sql.Connection; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
|
||
|
||
import org.intermine.objectstore.ObjectStoreException; | ||
import org.intermine.dataconversion.ItemWriter; | ||
import org.intermine.metadata.Model; | ||
import org.intermine.sql.Database; | ||
import org.intermine.xml.full.Item; | ||
import org.apache.commons.lang.StringUtils; | ||
|
||
|
||
/** | ||
* | ||
* @author | ||
*/ | ||
public class SgdComplementationDbConverter extends BioDBConverter { | ||
// | ||
private static final String DATASET_TITLE = "Yeast Complementation"; | ||
private static final String DATA_SOURCE_NAME = "SGD-BioGRID curated complementation"; | ||
private final Map<String, Item> genes = new HashMap<String, Item>(); | ||
private final Map<String, Item> publications = new HashMap<String, Item>(); | ||
private static final String TAXON_ID = "4932"; | ||
private static final String H_TAXON_ID = "9606"; | ||
private Item yorganism; | ||
private Item horganism; | ||
private String licence; | ||
private static final SgdComplementationDbProcessor PROCESSOR = new SgdComplementationDbProcessor(); | ||
|
||
|
||
/** | ||
* Construct a new SgdComplementationDbConverter. | ||
* @param database the database to read from | ||
* @param model the Model used by the object store we will write to with the ItemWriter | ||
* @param writer an ItemWriter used to handle Items created | ||
*/ | ||
public SgdComplementationDbConverter(Database database, Model model, ItemWriter writer) throws ObjectStoreException{ | ||
super(database, model, writer, DATA_SOURCE_NAME, DATASET_TITLE); | ||
yorganism = createItem("Organism"); | ||
yorganism.setAttribute("taxonId", TAXON_ID); | ||
store(yorganism); | ||
horganism = createItem("Organism"); | ||
horganism.setAttribute("taxonId", H_TAXON_ID); | ||
store(horganism); | ||
} | ||
|
||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public void process() throws Exception { | ||
Connection connection = getDatabase().getConnection(); | ||
processComplements(connection); | ||
storeGenes(); | ||
} | ||
|
||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public void processComplements(Connection connection) throws SQLException, ObjectStoreException { | ||
|
||
ResultSet res = PROCESSOR.getComplements(connection); | ||
|
||
while (res.next()) { | ||
|
||
String yeastGene = res.getString("yeast_gene"); | ||
String pmid = res.getString("pmid"); | ||
String direction = res.getString("direction"); | ||
String dbxref_id = res.getString("dbxref_id"); | ||
String notes = res.getString("curator_comment"); | ||
String source= res.getString("format_name"); | ||
|
||
System.out.println("Processing line..." + yeastGene + " "+ dbxref_id); | ||
|
||
Item ygene = getGeneItem(yeastGene, "secondaryIdentifier", yorganism); | ||
Item hgene = getGeneItem(dbxref_id, "secondaryIdentifier", horganism); | ||
|
||
getComplement(notes, direction, source, pmid, ygene, hgene); | ||
getComplement(notes, direction, source, pmid, hgene, ygene); | ||
|
||
} | ||
} | ||
/** | ||
* | ||
* @param c | ||
* @param n | ||
* @param source | ||
* @param pmid | ||
* @return | ||
* @throws ObjectStoreException | ||
*/ | ||
private void getComplement(String n, String d, String s, String pmid, | ||
Item yg, Item hg) throws ObjectStoreException { | ||
|
||
Item pub = publications.get(pmid); | ||
if (pub == null) { | ||
pub = createItem("Publication"); | ||
pub.setAttribute("pubMedId", pmid); | ||
publications.put(pmid, pub); | ||
store(pub); | ||
} | ||
|
||
Item comp = createItem("Complement"); | ||
|
||
if(StringUtils.isNotEmpty(n)) comp.setAttribute("notes", n); | ||
comp.setAttribute("source", s); | ||
comp.setAttribute("direction", d); | ||
comp.setReference("publication", pub); | ||
comp.setReference("gene", yg); | ||
comp.setReference("complement", hg); | ||
store(comp); | ||
|
||
} | ||
|
||
/** | ||
* | ||
* @param geneId | ||
* @return | ||
* @throws ObjectStoreException | ||
*/ | ||
private Item getGeneItem(String geneId, String identifier, Item org) | ||
throws ObjectStoreException { | ||
|
||
Item gene = genes.get(geneId); | ||
|
||
if (gene == null) { | ||
gene = createItem("Gene"); | ||
genes.put(geneId, gene); | ||
gene.setAttribute(identifier, geneId); | ||
gene.setReference("organism", org); | ||
} | ||
|
||
return gene; | ||
|
||
} | ||
|
||
/** | ||
* | ||
* @throws ObjectStoreException | ||
*/ | ||
|
||
private void storeGenes() throws ObjectStoreException { | ||
for (Item gene : genes.values()) { | ||
try { | ||
store(gene); | ||
} catch (ObjectStoreException e) { | ||
throw new ObjectStoreException(e); | ||
} | ||
} | ||
} | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public String getDataSetTitle(String taxonId) { | ||
return DATASET_TITLE; | ||
} | ||
/** | ||
* Set the data licence for these data. | ||
* | ||
* @param licence should be URI to data licence. | ||
*/ | ||
public void setLicence(String licence) { | ||
this.licence = licence; | ||
} | ||
/** | ||
* Get the data licence for these data. | ||
* | ||
* @return URI to data licence. | ||
*/ | ||
public String getLicence() { | ||
return licence; | ||
} | ||
|
||
} | ||
|
||
|
37 changes: 37 additions & 0 deletions
37
...tion-db/src/main/java/org/intermine/bio/dataconversion/SgdComplementationDbProcessor.java
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,37 @@ | ||
package org.intermine.bio.dataconversion; | ||
|
||
import java.sql.Connection; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
import org.apache.log4j.Logger; | ||
|
||
|
||
public class SgdComplementationDbProcessor { | ||
|
||
private static final Logger LOG = Logger.getLogger(SgdComplementationDbProcessor.class); | ||
|
||
/** | ||
* Return the results of getting complements | ||
* @param connection the connection | ||
* @return the results | ||
* @throws SQLException if there is a database problem | ||
*/ | ||
protected ResultSet getComplements(Connection connection) | ||
throws SQLException { | ||
|
||
String query = "select db.format_name as yeast_gene, rdb.pmid, " | ||
+ "direction, dbxref_id, curator_comment, s.format_name " | ||
+ "from nex.dbentity db " | ||
+ "inner join nex.functionalcomplementannotation fca on fca.dbentity_id = db.dbentity_id " | ||
+ "inner join nex.referencedbentity rdb on rdb.dbentity_id = fca.reference_id " | ||
+ "inner join nex.source s on s.source_id = fca.source_id "; | ||
LOG.info("executing: " + query); | ||
Statement stmt = connection.createStatement(); | ||
ResultSet res = stmt.executeQuery(query); | ||
return res; | ||
} | ||
|
||
|
||
} | ||
|
7 changes: 7 additions & 0 deletions
7
sgd-complementation-db/src/main/resources/sgd-complementation-db_additions.xml
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,7 @@ | ||
<?xml version="1.0"?> | ||
<!-- This file details any extensions needed to the data model to store data from this source, everything else is automatically generated from the model description so this is all we need to do to add to the model. --> | ||
|
||
<classes> | ||
<!-- add any <class> elements here --> | ||
|
||
</classes> |
9 changes: 9 additions & 0 deletions
9
sgd-complementation-db/src/main/resources/sgd-complementation-db_keys.properties
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,9 @@ | ||
DataSet.key_name = name | ||
DataSource.key_name = name | ||
SOTerm.key_name_ontology = name, ontology | ||
Organism.key_taxonid = taxonId | ||
Ontology.key_name = name | ||
Publication.key_pubmedid = pubMedId | ||
Gene.key_primaryidentifier=primaryIdentifier | ||
Gene.key_secondaryidentifier=secondaryIdentifier, organism | ||
|
34 changes: 34 additions & 0 deletions
34
...-db/src/test/java/org/intermine/bio/dataconversion/SgdComplementationDbConverterTest.java
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,34 @@ | ||
package org.intermine.bio.dataconversion; | ||
|
||
/* | ||
* Copyright (C) 2002-2018 FlyMine | ||
* | ||
* This code may be freely distributed and modified under the | ||
* terms of the GNU Lesser General Public Licence. This should | ||
* be distributed with the code. See the LICENSE file for more | ||
* information or http://www.gnu.org/copyleft/lesser.html. | ||
* | ||
*/ | ||
|
||
public class SgdComplementationDbConverterTest extends ItemsTestCase | ||
{ | ||
Model model = Model.getInstanceByName("genomic"); | ||
SgdComplementationDbConverter converter; | ||
MockItemWriter itemWriter; | ||
|
||
public SgdComplementationDbConverterTest(String arg) { | ||
super(arg); | ||
} | ||
|
||
public void setUp() throws Exception { | ||
super.setUp(); | ||
// if you need to do some preprocessing and set up, do that here | ||
} | ||
|
||
public void testProcess() throws Exception { | ||
// read in a test file (place in test/resources so it's on the classpath) | ||
// process using your converter | ||
// compare results to expected results | ||
// look at the other intermine unit tests for help! | ||
} | ||
} |
Oops, something went wrong.