Search in sources :

Example 1 with PhysicalLocation

use of ubic.gemma.model.genome.PhysicalLocation in project Gemma by PavlidisLab.

the class TaxonArg method getGenesOnChromosome.

/**
 * Lists Genes overlapping a location on a specific chromosome on a taxon that this TaxonArg represents.
 *
 * @param taxonService      the service that will be used to retrieve the persistent Taxon object.
 * @param chromosomeService the service that will be used to find the Chromosome object.
 * @param geneService       the service that will be used to retrieve the Gene VOs
 * @param chromosomeName    name of the chromosome to look on
 * @param start             the start nucleotide denoting the location to look for genes at.
 * @param size              the size (in nucleotides) of the location from the 'start' nucleotide.
 * @return collection of Gene VOs overlapping the location defined by the 'start' and 'size' parameters.
 */
public Collection<GeneValueObject> getGenesOnChromosome(TaxonService taxonService, ChromosomeService chromosomeService, GeneService geneService, String chromosomeName, long start, int size) {
    // Taxon argument
    Taxon taxon = this.getPersistentObject(taxonService);
    // Chromosome argument
    Collection<Chromosome> chromosomes = chromosomeService.find(chromosomeName, taxon);
    if (chromosomes.isEmpty()) {
        WellComposedErrorBody errorBody = new WellComposedErrorBody(Response.Status.NOT_FOUND, "Chromosome " + chromosomeName + " not found for taxon " + taxon.getScientificName());
        throw new GemmaApiException(errorBody);
    }
    Chromosome chromosome = chromosomes.iterator().next();
    // Setup chromosome location
    PhysicalLocation region = PhysicalLocation.Factory.newInstance(chromosome);
    region.setNucleotide(start);
    region.setNucleotideLength(size);
    // region.setStrand( strand );
    Collection<GeneValueObject> GVOs = geneService.loadValueObjects(geneService.find(region));
    if (GVOs == null) {
        WellComposedErrorBody errorBody = new WellComposedErrorBody(Response.Status.NOT_FOUND, "No genes found on chromosome " + chromosomeName + " between positions " + start + " and " + start + size + ".");
        throw new GemmaApiException(errorBody);
    }
    return GVOs;
}
Also used : GeneValueObject(ubic.gemma.model.genome.gene.GeneValueObject) Taxon(ubic.gemma.model.genome.Taxon) Chromosome(ubic.gemma.model.genome.Chromosome) WellComposedErrorBody(ubic.gemma.web.services.rest.util.WellComposedErrorBody) GemmaApiException(ubic.gemma.web.services.rest.util.GemmaApiException) PhysicalLocation(ubic.gemma.model.genome.PhysicalLocation)

Example 2 with PhysicalLocation

use of ubic.gemma.model.genome.PhysicalLocation in project Gemma by PavlidisLab.

the class GoldenPathSequenceAnalysis method blocksToPhysicalLocations.

private Collection<PhysicalLocation> blocksToPhysicalLocations(int[] blockSizes, int[] blockStarts, Chromosome chromosome) {
    Collection<PhysicalLocation> blocks = new HashSet<>();
    for (int i = 0; i < blockSizes.length; i++) {
        long exonStart = blockStarts[i];
        int exonSize = blockSizes[i];
        PhysicalLocation block = PhysicalLocation.Factory.newInstance();
        block.setChromosome(chromosome);
        block.setNucleotide(exonStart);
        block.setNucleotideLength(exonSize);
        block.setBin(SequenceBinUtils.binFromRange((int) exonStart, (int) (exonStart + exonSize)));
        blocks.add(block);
    }
    return blocks;
}
Also used : PhysicalLocation(ubic.gemma.model.genome.PhysicalLocation) HashSet(java.util.HashSet)

Example 3 with PhysicalLocation

use of ubic.gemma.model.genome.PhysicalLocation in project Gemma by PavlidisLab.

the class GoldenPathSequenceAnalysis method setBlocks.

/**
 * Handle the format used by the all_mrna and other GoldenPath tables, which go by sizes of blocks and their starts,
 * not the starts and ends.
 * Be sure to pass the right Blob arguments!
 *
 * @param gene gene
 * @param blockSizes sizes
 * @param blockStarts starts
 */
private void setBlocks(Gene gene, Blob blockSizes, Blob blockStarts) throws SQLException {
    if (blockSizes == null || blockStarts == null)
        return;
    String exonSizes = SQLUtils.blobToString(blockSizes);
    String exonStarts = SQLUtils.blobToString(blockStarts);
    int[] exonSizeInts = SequenceManipulation.blatLocationsToIntArray(exonSizes);
    int[] exonStartInts = SequenceManipulation.blatLocationsToIntArray(exonStarts);
    assert exonSizeInts.length == exonStartInts.length;
    GeneProduct gp = GeneProduct.Factory.newInstance();
    Chromosome chromosome = null;
    if (gene.getPhysicalLocation() != null)
        chromosome = gene.getPhysicalLocation().getChromosome();
    Collection<PhysicalLocation> exons = this.blocksToPhysicalLocations(exonSizeInts, exonStartInts, chromosome);
    gp.setExons(exons);
    // this isn't right?
    gp.setName(gene.getNcbiGeneId().toString());
    Collection<GeneProduct> products = new HashSet<>();
    products.add(gp);
    gene.setProducts(products);
}
Also used : BioSequence2GeneProduct(ubic.gemma.model.association.BioSequence2GeneProduct) GeneProduct(ubic.gemma.model.genome.gene.GeneProduct) Chromosome(ubic.gemma.model.genome.Chromosome) PhysicalLocation(ubic.gemma.model.genome.PhysicalLocation) HashSet(java.util.HashSet)

Example 4 with PhysicalLocation

use of ubic.gemma.model.genome.PhysicalLocation in project Gemma by PavlidisLab.

the class GeneServiceImplTest method setUp.

@Before
public void setUp() throws Exception {
    geneDaoMock = createMock(GeneDaoImpl.class);
    svc = new GeneServiceImpl(geneDaoMock);
    Taxon t = Taxon.Factory.newInstance();
    t.setCommonName("moose");
    t.setScientificName("moose");
    t.setIsSpecies(true);
    t.setIsGenesUsable(true);
    // tDAO.create( t );
    g = Gene.Factory.newInstance();
    g.setOfficialName("rabble");
    g.setOfficialSymbol("rab");
    allThree.add(g);
    justRab.add(g);
    g2 = Gene.Factory.newInstance();
    g2.setOfficialName("rabblebong");
    g2.setTaxon(t);
    allThree.add(g2);
    g3 = Gene.Factory.newInstance();
    g3.setOfficialName("rabble");
    g3.setNcbiGeneId(12345);
    g3.setOfficialSymbol("rab3");
    g3.setId((long) 1234);
    // For testing need to add physical locations to the gene products of a given gene.
    Chromosome chromosome = new Chromosome("fakeChromosome", t);
    FieldUtils.writeField(chromosome, "id", 54321L, true);
    // Gene product 1 (Min=100 max=200)
    PhysicalLocation ploc1 = PhysicalLocation.Factory.newInstance();
    ploc1.setChromosome(chromosome);
    ploc1.setStrand(GeneServiceImplTest.STRAND);
    ploc1.setNucleotide((long) 100);
    ploc1.setNucleotideLength(100);
    GeneProduct gp1 = GeneProduct.Factory.newInstance();
    gp1.setPhysicalLocation(ploc1);
    gp1.setGene(g3);
    gp1.setName("gp1");
    // gene product 2 (min=110 max = 210)
    PhysicalLocation ploc2 = PhysicalLocation.Factory.newInstance();
    ploc2.setChromosome(chromosome);
    ploc2.setStrand(GeneServiceImplTest.STRAND);
    ploc2.setNucleotide((long) 110);
    ploc2.setNucleotideLength(100);
    GeneProduct gp2 = GeneProduct.Factory.newInstance();
    gp2.setPhysicalLocation(ploc2);
    gp2.setGene(g3);
    gp2.setName("gp2");
    // Gene Product 3 (min=90 max=140)
    PhysicalLocation ploc3 = PhysicalLocation.Factory.newInstance();
    ploc3.setChromosome(chromosome);
    ploc3.setStrand(GeneServiceImplTest.STRAND);
    ploc3.setNucleotide((long) 90);
    ploc3.setNucleotideLength(50);
    GeneProduct gp3 = GeneProduct.Factory.newInstance();
    gp3.setPhysicalLocation(ploc3);
    gp3.setGene(g3);
    gp3.setName("gp3");
    // Gene Product 4 (wrong strand should get regected, min 10 max 210)
    PhysicalLocation ploc4 = PhysicalLocation.Factory.newInstance();
    ploc4.setChromosome(chromosome);
    ploc4.setStrand("-");
    ploc4.setNucleotide((long) 10);
    ploc4.setNucleotideLength(200);
    GeneProduct gp4 = GeneProduct.Factory.newInstance();
    gp4.setPhysicalLocation(ploc4);
    gp4.setGene(g3);
    gp4.setName("wrong strand gp4");
    gp4.setId((long) 3456);
    // Gene Product 5 (right strand wrong chromosome should get regected, min 20 max 220)
    Chromosome wrongChromosome = new Chromosome("wrongFakeChromosome", t);
    FieldUtils.writeField(chromosome, "id", 43215L, true);
    PhysicalLocation ploc5 = PhysicalLocation.Factory.newInstance();
    ploc5.setChromosome(wrongChromosome);
    ploc5.setStrand(GeneServiceImplTest.STRAND);
    ploc5.setNucleotide((long) 20);
    ploc5.setNucleotideLength(200);
    GeneProduct gp5 = GeneProduct.Factory.newInstance();
    gp5.setPhysicalLocation(ploc5);
    gp5.setGene(g3);
    gp5.setName("wrong chromosome gp5");
    gp5.setId((long) 4567);
    Collection<GeneProduct> gps = new ArrayList<>();
    gps.add(gp1);
    gps.add(gp2);
    gps.add(gp4);
    gps.add(gp5);
    gps.add(gp3);
    g3.setProducts(gps);
    allThree.add(g3);
    justRabble.add(g3);
}
Also used : GeneServiceImpl(ubic.gemma.core.genome.gene.service.GeneServiceImpl) Taxon(ubic.gemma.model.genome.Taxon) ArrayList(java.util.ArrayList) Chromosome(ubic.gemma.model.genome.Chromosome) GeneDaoImpl(ubic.gemma.persistence.service.genome.GeneDaoImpl) PhysicalLocation(ubic.gemma.model.genome.PhysicalLocation) Before(org.junit.Before)

Example 5 with PhysicalLocation

use of ubic.gemma.model.genome.PhysicalLocation in project Gemma by PavlidisLab.

the class GeneServiceTest method testFindEvenThoughHaveSameSymbol.

@Test
public void testFindEvenThoughHaveSameSymbol() {
    Gene gene = Gene.Factory.newInstance();
    Integer id = Integer.parseInt(RandomStringUtils.randomNumeric(5));
    gene.setNcbiGeneId(id);
    gene.setName(GeneServiceTest.TEST_GENE_NAME);
    gene.setOfficialName(GeneServiceTest.TEST_GENE_NAME);
    gene.setOfficialSymbol(GeneServiceTest.TEST_GENE_NAME);
    Taxon human = taxonService.findByCommonName("human");
    gene.setTaxon(human);
    PhysicalLocation pl1 = PhysicalLocation.Factory.newInstance();
    Chromosome chromosome = new Chromosome("X", null, this.getTestPersistentBioSequence(), human);
    chromosome = (Chromosome) persisterHelper.persist(chromosome);
    pl1.setChromosome(chromosome);
    pl1.setNucleotide(10000010L);
    pl1.setNucleotideLength(1001);
    pl1.setStrand("-");
    gene.setPhysicalLocation(pl1);
    gene = geneDao.create(gene);
    Long idWeWant = gene.getId();
    Gene gene2 = Gene.Factory.newInstance();
    gene2.setNcbiGeneId(null);
    gene2.setName(GeneServiceTest.TEST_GENE_NAME);
    gene2.setOfficialName(GeneServiceTest.TEST_GENE_NAME);
    gene2.setOfficialSymbol(GeneServiceTest.TEST_GENE_NAME);
    gene2.setTaxon(human);
    PhysicalLocation pl2 = PhysicalLocation.Factory.newInstance();
    Chromosome chromosome2 = new Chromosome("Y", null, this.getTestPersistentBioSequence(), human);
    chromosome2 = (Chromosome) persisterHelper.persist(chromosome2);
    pl2.setChromosome(chromosome2);
    pl2.setChromosome(chromosome);
    pl2.setNucleotide(10000010L);
    pl2.setNucleotideLength(1001);
    pl2.setStrand("-");
    gene2.setPhysicalLocation(pl2);
    gene2 = geneDao.create(gene2);
    gene.setId(null);
    Gene g = geneDao.find(gene);
    assertNotNull(g);
    assertEquals(idWeWant, g.getId());
    geneDao.remove(g);
    geneDao.remove(gene2);
}
Also used : Gene(ubic.gemma.model.genome.Gene) Taxon(ubic.gemma.model.genome.Taxon) Chromosome(ubic.gemma.model.genome.Chromosome) PhysicalLocation(ubic.gemma.model.genome.PhysicalLocation) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Aggregations

PhysicalLocation (ubic.gemma.model.genome.PhysicalLocation)22 Chromosome (ubic.gemma.model.genome.Chromosome)9 Gene (ubic.gemma.model.genome.Gene)7 Taxon (ubic.gemma.model.genome.Taxon)7 HashSet (java.util.HashSet)5 GeneProduct (ubic.gemma.model.genome.gene.GeneProduct)4 BlatAssociation (ubic.gemma.model.genome.sequenceAnalysis.BlatAssociation)4 BlatResult (ubic.gemma.model.genome.sequenceAnalysis.BlatResult)4 Collection (java.util.Collection)3 Test (org.junit.Test)3 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)3 BioSequence2GeneProduct (ubic.gemma.model.association.BioSequence2GeneProduct)3 HashMap (java.util.HashMap)2 DatabaseEntry (ubic.gemma.model.common.description.DatabaseEntry)2 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 Transactional (org.springframework.transaction.annotation.Transactional)1 GeneServiceImpl (ubic.gemma.core.genome.gene.service.GeneServiceImpl)1 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)1 CompositeSequenceValueObject (ubic.gemma.model.expression.designElement.CompositeSequenceValueObject)1