001/** 002 * Copyright (C) 2010-2015 The Roslin Institute <contact andy.law@roslin.ed.ac.uk> 003 * 004 * This file is part of JEnsembl: a Java API to Ensembl data sources developed by the 005 * Bioinformatics Group at The Roslin Institute, The Royal (Dick) School of 006 * Veterinary Studies, University of Edinburgh. 007 * 008 * Project hosted at: http://jensembl.sourceforge.net 009 * 010 * This is free software: you can redistribute it and/or modify 011 * it under the terms of the GNU General Public License (version 3) as published by 012 * the Free Software Foundation. 013 * 014 * This software is distributed in the hope that it will be useful, 015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 017 * GNU General Public License for more details. 018 * 019 * You should have received a copy of the GNU General Public License 020 * in this software distribution. If not, see: http://opensource.org/licenses/gpl-3.0.html 021 */ 022package uk.ac.roslin.ensembl.demo; 023 024import uk.ac.roslin.ensembl.config.DBConnection; 025import uk.ac.roslin.ensembl.config.DBConnection.DataSource; 026import uk.ac.roslin.ensembl.config.EnsemblCoordSystemType; 027import uk.ac.roslin.ensembl.config.FeatureType; 028import uk.ac.roslin.ensembl.dao.database.DBRegistry; 029import uk.ac.roslin.ensembl.dao.database.DBSpecies; 030import uk.ac.roslin.ensembl.datasourceaware.core.DAChromosome; 031import uk.ac.roslin.ensembl.datasourceaware.core.DAGene; 032import uk.ac.roslin.ensembl.model.Mapping; 033 034/* 035 * 036 * mainly of use for developers... 037 * 038 * in order to to keep track of objects and to create caches 039 */ 040public class ExaminingObjectHashCodes { 041 042 public static void main(String[] args) throws Exception { 043 044 045 DBRegistry ensembldbRegistry = DBRegistry.createRegistryForDataSource(DBConnection.DataSource.ENSEMBLDB); 046 047 DBSpecies sp = ensembldbRegistry.getSpeciesByAlias("chicken"); 048 DAChromosome chr = sp.getChromosomeByName("25"); 049 System.out.println("CHROMOSOME " + chr.getChromosomeName() + " FROM SPECIES: HashID: " + chr.getHashID() 050 + " VMID:" + chr.hashCode()); 051 052 053 for (DAChromosome c : sp.getChromosomes().values()) { 054 if (c.getName().equalsIgnoreCase("25")) { 055 System.out.println("CHROMOSOME " + c.getChromosomeName() + " FROM SPECIES: HashID: " + c.getHashID() 056 + " VMID:" + c.hashCode()); 057 } 058 } 059 060 for (DAChromosome c : sp.getChromosomes("58").values()) { 061 if (c.getName().equalsIgnoreCase("25")) { 062 System.out.println("CHROMOSOME " + c.getChromosomeName() + " FROM SPECIES: HashID: " + c.getHashID() 063 + " VMID:" + c.hashCode()); 064 } 065 } 066 067 068 DAGene gene = sp.getGeneByStableID("ENSGALG00000009011"); 069 070 System.out.println("GENE FROM SPECIES: HashID: " + gene.getHashID() 071 + " VMID:" + gene.hashCode()); 072 073 System.out.println("Gene -> Chromosome mappings "); 074 075 for (Mapping m : gene.getLoadedMappings(EnsemblCoordSystemType.chromosome)) { 076 System.out.println(m.getTarget().getClass().getSimpleName() 077 + " chr name: " 078 + ((DAChromosome) m.getTarget()).getChromosomeName() 079 + " id: " + m.getTarget().getId()); 080 System.out.println("CHROMOSOME FROM GENE MAPPING: HashID: " + m.getTarget().getHashID() 081 + " VMID:" + m.getTarget().hashCode()); 082 } 083 084 gene = chr.getGenesOnRegion(3080, 12536).get(0); 085 086 System.out.println("GENE FROM CHROMOSOME: HashID: " + gene.getHashID() 087 + " VMID:" + ((Object) gene).hashCode()); 088 089 090 System.out.println("Chromosome -> gene mappings "); 091 092 for (Mapping m : chr.getLoadedMappings(FeatureType.gene)) { 093 System.out.println(m.getTarget().getClass().getSimpleName() 094 + " gene stableID: " 095 + ((DAGene) m.getTarget()).getStableID() 096 + " id: " + m.getTarget().getId()); 097 System.out.println("Gene on chromosome: HashID: " + m.getTarget().getHashID() 098 + " VMID:" + m.getTarget().hashCode()); 099 } 100 101 System.out.println("Gene -> Chromosome mappings "); 102 103 for (Mapping m : gene.getLoadedMappings(EnsemblCoordSystemType.chromosome)) { 104 System.out.println(m.getTarget().getClass().getSimpleName() 105 + " chr name: " 106 + ((DAChromosome) m.getTarget()).getChromosomeName() 107 + " id: " + m.getTarget().getId()); 108 System.out.println("Chr on Gene: HashID: " + m.getTarget().getHashID() 109 + " VMID:" + m.getTarget().hashCode()); 110 } 111 112 System.out.println("\n\n*****************************\n* COMPLETED FUNCTIONAL TEST *\n*****************************\n"); 113 114 } 115}