use of ubic.gemma.model.association.Gene2GeneProteinAssociation in project Gemma by PavlidisLab.
the class StringBiomartProteinConverterTest method testConvertStringProteinProteinInteraction.
/*
* ENSMUSP00000111623 is mapped to two ncbi ids (100040601 and 245269). ENSMUSP00000100396: is mapped to three ncbi
* ids 100044026, 100043270, 100043197 Should result in returning a collection of 6 which is 2 *3 =6 Test method for
* {@link ubic.gemma.core.loader.protein.StringProteinProteinInteractionConverter#convert(ubic.gemma.core.loader.protein.string.model.StringProteinProteinInteraction)}
*/
@Test
public void testConvertStringProteinProteinInteraction() {
try {
Collection<Gene2GeneProteinAssociation> objects = stringBiomartProteinConverter.convert(stringProteinProteinInteractionOne);
if (objects != null) {
assertEquals(6, objects.size());
for (Gene2GeneProteinAssociation gene2GeneProteinAssociation : objects) {
assertNotNull(gene2GeneProteinAssociation.getDatabaseEntry().getAccession());
assertNotNull(gene2GeneProteinAssociation.getFirstGene());
assertNotNull(gene2GeneProteinAssociation.getSecondGene());
}
} else {
fail();
}
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
use of ubic.gemma.model.association.Gene2GeneProteinAssociation in project Gemma by PavlidisLab.
the class StringBiomartGene2GeneProteinLoaderTest method getTestPeristentGenesZebra.
public void getTestPeristentGenesZebra() {
Gene geneZebraOne = this.makeGene(zebraFish, "zgc.153184", "751652");
Gene geneZebraTwo = this.makeGene(zebraFish, "appl1", "571540");
Gene geneZebraThree = this.makeGene(zebraFish, "LOC568371", "568371");
Gene geneZebraFour = this.makeGene(zebraFish, "TESTGENE", "30425");
Gene geneZebraFive = this.makeGene(zebraFish, "TESTGENE2", "503936");
genesZebra.add(this.makeGene(zebraFish, "FOO1", "562059"));
genesZebra.add(geneZebraOne);
genesZebra.add(geneZebraTwo);
genesZebra.add(geneZebraThree);
genesZebra.add(geneZebraFour);
genesZebra.add(geneZebraFive);
Gene2GeneProteinAssociation existingGene2GeneProteinAssociationOne = Gene2GeneProteinAssociation.Factory.newInstance(geneZebraOne, geneZebraThree, null, null, null);
Gene2GeneProteinAssociation existingGene2GeneProteinAssociationTwo = Gene2GeneProteinAssociation.Factory.newInstance(geneZebraOne, geneZebraTwo, null, null, null);
// noinspection MismatchedQueryAndUpdateOfCollection
Collection<Gene2GeneProteinAssociation> geneAssociationZebra = new ArrayList<>();
geneAssociationZebra.add(existingGene2GeneProteinAssociationTwo);
geneAssociationZebra.add(existingGene2GeneProteinAssociationOne);
}
use of ubic.gemma.model.association.Gene2GeneProteinAssociation in project Gemma by PavlidisLab.
the class StringProteinInteractionLoader method doLoad.
/**
* Poll the queue to see if any Gene2GeneProteinAssociation to load into database. If so firstly check to see if the
* genes are in the gemma db as these identifiers came from biomart If both genes found load.
*
* @param gene2GeneProteinAssociationQueue queue of Gene2GeneProteinAssociation to load
*/
private void doLoad(final BlockingQueue<Gene2GeneProteinAssociation> gene2GeneProteinAssociationQueue) {
StringProteinInteractionLoader.log.info("starting processing ");
while (!(converterDone.get() && gene2GeneProteinAssociationQueue.isEmpty())) {
try {
Gene2GeneProteinAssociation gene2GeneProteinAssociation = gene2GeneProteinAssociationQueue.poll();
if (gene2GeneProteinAssociation == null) {
continue;
}
// check they are genes gemma knows about
Gene geneOne = geneService.findByNCBIId(gene2GeneProteinAssociation.getFirstGene().getNcbiGeneId());
Gene geneTwo = geneService.findByNCBIId(gene2GeneProteinAssociation.getSecondGene().getNcbiGeneId());
if (geneOne == null) {
StringProteinInteractionLoader.log.warn("Gene with NCBI id=" + gene2GeneProteinAssociation.getFirstGene().getNcbiGeneId() + " not in Gemma");
continue;
}
if (geneTwo == null) {
StringProteinInteractionLoader.log.warn("Gene with NCBI id=" + gene2GeneProteinAssociation.getSecondGene().getNcbiGeneId() + " not in Gemma");
continue;
}
FieldUtils.writeField(gene2GeneProteinAssociation, "firstGene", geneOne, true);
FieldUtils.writeField(gene2GeneProteinAssociation, "secondGene", geneTwo, true);
persisterHelper.persist(gene2GeneProteinAssociation);
if (++loadedGeneCount % 1000 == 0) {
StringProteinInteractionLoader.log.info("Proceesed " + loadedGeneCount + " protein protein interactions. " + "Current queue has " + gene2GeneProteinAssociationQueue.size() + " items.");
}
} catch (Exception e) {
StringProteinInteractionLoader.log.error(e, e);
loaderDone.set(true);
throw new RuntimeException(e);
}
}
StringProteinInteractionLoader.log.info("Loaded " + loadedGeneCount + " protein protein interactions. ");
loaderDone.set(true);
}
use of ubic.gemma.model.association.Gene2GeneProteinAssociation in project Gemma by PavlidisLab.
the class Gene2GeneProteinAssociationDaoImpl method find.
@Override
public Gene2GeneProteinAssociation find(Gene2GeneProteinAssociation gene2GeneProteinAssociation) {
try {
Criteria queryObject = this.getSessionFactory().getCurrentSession().createCriteria(Gene2GeneProteinAssociation.class);
// have to have gene 1 and gene 2 there
BusinessKey.checkKey(gene2GeneProteinAssociation);
BusinessKey.createQueryObject(queryObject, gene2GeneProteinAssociation);
// noinspection unchecked
java.util.List<Gene2GeneProteinAssociation> results = queryObject.list();
Object result = null;
if (results != null) {
if (results.size() == 1) {
result = results.iterator().next();
} else if (results.size() > 1) {
AbstractDao.log.error("Multiple interactions found for " + gene2GeneProteinAssociation + ":");
Collections.sort(results, new Comparator<Gene2GeneProteinAssociation>() {
@Override
public int compare(Gene2GeneProteinAssociation arg0, Gene2GeneProteinAssociation arg1) {
return arg0.getId().compareTo(arg1.getId());
}
});
result = results.iterator().next();
AbstractDao.log.error("Returning arbitrary gene2GeneProteinAssociation: " + result);
}
}
return (Gene2GeneProteinAssociation) result;
} catch (org.hibernate.HibernateException ex) {
throw super.convertHibernateAccessException(ex);
}
}
use of ubic.gemma.model.association.Gene2GeneProteinAssociation in project Gemma by PavlidisLab.
the class Gene2GeneProteinAssociationDaoImpl method create.
@Override
public Gene2GeneProteinAssociation create(final Gene2GeneProteinAssociation gene2GeneProteinAssociation) {
Gene2GeneProteinAssociation old = this.find(gene2GeneProteinAssociation);
if (old != null) {
this.remove(old);
}
super.create(gene2GeneProteinAssociation);
return gene2GeneProteinAssociation;
}
Aggregations