Search in sources :

Example 1 with Gene2GeneProteinAssociation

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();
    }
}
Also used : Gene2GeneProteinAssociation(ubic.gemma.model.association.Gene2GeneProteinAssociation) Test(org.junit.Test)

Example 2 with Gene2GeneProteinAssociation

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);
}
Also used : Gene(ubic.gemma.model.genome.Gene) Gene2GeneProteinAssociation(ubic.gemma.model.association.Gene2GeneProteinAssociation) ArrayList(java.util.ArrayList)

Example 3 with Gene2GeneProteinAssociation

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);
}
Also used : Gene(ubic.gemma.model.genome.Gene) Gene2GeneProteinAssociation(ubic.gemma.model.association.Gene2GeneProteinAssociation) IOException(java.io.IOException)

Example 4 with Gene2GeneProteinAssociation

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);
    }
}
Also used : Gene2GeneProteinAssociation(ubic.gemma.model.association.Gene2GeneProteinAssociation) Criteria(org.hibernate.Criteria) Comparator(java.util.Comparator)

Example 5 with Gene2GeneProteinAssociation

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;
}
Also used : Gene2GeneProteinAssociation(ubic.gemma.model.association.Gene2GeneProteinAssociation)

Aggregations

Gene2GeneProteinAssociation (ubic.gemma.model.association.Gene2GeneProteinAssociation)10 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 Gene (ubic.gemma.model.genome.Gene)5 File (java.io.File)3 IOException (java.io.IOException)3 URL (java.net.URL)3 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)3 ConnectException (java.net.ConnectException)2 Taxon (ubic.gemma.model.genome.Taxon)2 Collection (java.util.Collection)1 Comparator (java.util.Comparator)1 Criteria (org.hibernate.Criteria)1 Ensembl2NcbiValueObject (ubic.gemma.core.loader.protein.biomart.model.Ensembl2NcbiValueObject)1