use of ubic.gemma.model.genome.Chromosome 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;
}
use of ubic.gemma.model.genome.Chromosome 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);
}
use of ubic.gemma.model.genome.Chromosome 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);
}
use of ubic.gemma.model.genome.Chromosome 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);
}
use of ubic.gemma.model.genome.Chromosome in project Gemma by PavlidisLab.
the class GeneCoreServiceTest method testSearchGenes.
@Test
public void testSearchGenes() {
Gene gene = Gene.Factory.newInstance();
Integer id = Integer.parseInt(RandomStringUtils.randomNumeric(5));
gene.setNcbiGeneId(id);
gene.setName("test_search");
gene.setOfficialName("test_search");
gene.setOfficialSymbol("test_search");
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);
Collection<GeneValueObject> searchResults = geneCoreService.searchGenes("test_search", 1L);
assertNotNull(searchResults);
GeneValueObject gvo = searchResults.iterator().next();
assertNotNull(gvo);
geneDao.remove(gene);
}
Aggregations