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 java.util.List; 025import uk.ac.roslin.ensembl.config.DBConnection.DataSource; 026import uk.ac.roslin.ensembl.dao.database.DBRegistry; 027import uk.ac.roslin.ensembl.dao.database.DBSpecies; 028import uk.ac.roslin.ensembl.datasourceaware.core.DAChromosome; 029import uk.ac.roslin.ensembl.datasourceaware.core.DAExon; 030import uk.ac.roslin.ensembl.datasourceaware.core.DAGene; 031import uk.ac.roslin.ensembl.datasourceaware.core.DATranscript; 032import uk.ac.roslin.ensembl.datasourceaware.variation.VariationMapping; 033 034public class UserJeanPhilippe { 035 036 public static void main(String[] args) throws Exception { 037 038 DBRegistry ensembldbRegistry = DBRegistry.createRegistryForDataSource(DataSource.ENSEMBLDB); 039 DBSpecies human = ensembldbRegistry.getSpeciesByAlias("human"); 040 041 //release 76 changes assembly used... 042 //so 043 System.out.println("Version 75"); 044 DAChromosome chr1 = human.getChromosomeByName("1","75"); 045 046// for (VariationMapping vm : (List<VariationMapping>) 047// chr1.getVariationMappingsOnRegion(1000000, 1001000)) { 048// 049// 050// System.out.print("Source: " + vm.getSource().getHashID()); 051// System.out.print("\tTarget: " + vm.getTarget().getHashID()); 052// System.out.println("\t" + vm.getSourceCoordinates()); 053// 054// System.out.println("Allele: " +vm.getAlleleString()); 055// 056// System.out.println("Consequences: " +vm.getConsequences().toString()); 057// List<VariationType> consequences = vm.getConsequences(); 058// 059// for (VariationType type: consequences) { 060// System.out.print("\tType: " + type.getSOTerm()); 061// System.out.print(" "+type.getSOAccession()); 062// System.out.println(" " + type.getDisplayTerm()); 063// } 064// 065// DAVariation var = (DAVariation) vm.getTarget(); 066// 067// System.out.println("VARIATION"); 068// 069// System.out.println("\tName: " + var.getName()); 070// System.out.println("\tSynonyms: " + var.getAllSynonyms().toString()); 071// System.out.println("\tAncestral: " + var.getAncestralAllele()); 072// System.out.println("\tOccurrences: " + var.getOccurrences()); 073// System.out.println("\tStrand Flipped?: " + var.isFlipped()); 074// System.out.println("\tSomatic?: " + var.isSomatic()); 075// 076// 077// VariationType type = var.getType(); 078// if (type!=null) { 079// System.out.print("\tType: " + type.getSOTerm()); 080// System.out.print(" " + type.getSOAccession()); 081// System.out.println(" " + type.getDisplayTerm()); 082// } 083// 084// DAVariationXRef xRef = var.getXRef(); 085// if (xRef!=null) { 086// System.out.println("XREF"); 087// System.out.println("\tAssay: " + xRef.getAssayType()); 088// System.out.println("\tTissue source: " + xRef.getTissueSource()); 089// System.out.println("\tURL: " + xRef.getUrl()); 090// } 091// } 092 093 094 //chr1.getDaoFactory().getVariationFactory() 095 096 List<DAGene> genesOnRegion = chr1.getGenesOnRegion(860000, 865000); 097 List<VariationMapping> variations = (List<VariationMapping>) chr1.getVariationMappingsOnRegion(860000, 865000); 098 099 for (DAGene gene : genesOnRegion) { 100 System.out.println(gene.getDisplayName() + " " + gene.getStableID() + " "+gene.getChromosomeMapping(chr1).getTargetCoordinates()); 101 DATranscript canonicalTranscript = gene.getCanonicalTranscript(); 102 System.out.println(canonicalTranscript.getDisplayName() + " " + canonicalTranscript.getStableID()); 103 104 System.out.println("Exons:"); 105 for (DAExon e : canonicalTranscript.getExons()) { 106 System.out.print("\t" + e.getRank() + " " + e.getStableID() + " " + e.getTopLevelTargetCoordinates()); 107 108 for (VariationMapping vm : variations) { 109 if (e.getTopLevelTargetCoordinates().overlaps(vm.getSourceCoordinates())) { 110 System.out.print("\tSNP: "+vm.getId()+" "+vm.getSourceCoordinates()); 111 } 112 } 113 System.out.println(""); 114 } 115 } 116 117 //release 76 changes assembly used... 118 119 System.out.println("Current Version"); 120 121 chr1 = human.getChromosomeByName("1"); 122 123// 124 125 genesOnRegion = chr1.getGenesOnRegion(800000, 805000); 126 variations = (List<VariationMapping>) chr1.getVariationMappingsOnRegion(800000, 805000); 127 128 for (DAGene gene : genesOnRegion) { 129 System.out.println(gene.getDisplayName() + " " + gene.getStableID() + " "+gene.getChromosomeMapping(chr1).getTargetCoordinates()); 130 DATranscript canonicalTranscript = gene.getCanonicalTranscript(); 131 System.out.println(canonicalTranscript.getDisplayName() + " " + canonicalTranscript.getStableID()); 132 133 System.out.println("Exons:"); 134 for (DAExon e : canonicalTranscript.getExons()) { 135 System.out.print("\t" + e.getRank() + " " + e.getStableID() + " " + e.getTopLevelTargetCoordinates()); 136 137 for (VariationMapping vm : variations) { 138 if (e.getTopLevelTargetCoordinates().overlaps(vm.getSourceCoordinates())) { 139 System.out.print("\tSNP: "+vm.getId()+" "+vm.getSourceCoordinates()); 140 } 141 } 142 System.out.println(""); 143 } 144 } 145 146 147 } 148}