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.Set;
025import uk.ac.roslin.ensembl.config.DBConnection;
026import uk.ac.roslin.ensembl.dao.database.DBRegistry;
027import uk.ac.roslin.ensembl.dao.database.DBSpecies;
028import uk.ac.roslin.ensembl.datasourceaware.core.DAGene;
029
030public class HomologyCounts {
031    
032    public static void main(String[] args) throws Exception {
033        
034        System.out.println("VERTEBRATES");
035        System.out.println("-----------");
036        
037        DBRegistry eReg = DBRegistry.createRegistryForDataSource(DBConnection.DataSource.ENSEMBLDB);
038        DBSpecies cow = eReg.getSpeciesByAlias("cow");
039        DAGene gene = cow.getGeneByStableID("ENSBTAG00000021527");
040        
041        System.out.println("retrieved "+gene.getStableID()+" version "+gene.getDBVersion());
042        System.out.println("\torthologueCount "+gene.getOrthologueCount());
043        System.out.println("\thomoeologueCount "+gene.getHomoeologueCount());
044        System.out.println("\tparalogueCount "+gene.getParalogueCount());
045        
046        DAGene gene1 = cow.getGeneByStableID("ENSBTAG00000021527", "75");
047        
048        System.out.println("retrieved "+gene1.getStableID()+" version "+gene1.getDBVersion());
049        System.out.println("\torthologueCount "+gene1.getOrthologueCount());
050        System.out.println("\thomoeologueCount "+gene1.getHomoeologueCount());
051        System.out.println("\tparalogueCount "+gene1.getParalogueCount());
052
053        DAGene gene2 = new DAGene();
054        gene2.setStableID("ENSBTAG00000021531");
055        gene2.setDaoFactory(gene.getDaoFactory());
056        Integer homoeologueCount = gene2.getHomoeologueCount();
057        Integer paralogueCount = gene2.getParalogueCount();
058        
059        System.out.println("retrieved "+gene2.getStableID()+" version "+gene2.getDBVersion());
060        System.out.println("\torthologueCount "+gene2.getOrthologueCount());
061        System.out.println("\thomoeologueCount "+gene2.getHomoeologueCount());
062        System.out.println("\tparalogueCount "+gene2.getParalogueCount());
063
064        System.out.println("BACTERIA");
065        System.out.println("--------");
066        
067        eReg = DBRegistry.createRegistryForDataSourceCurrentRelease(DBConnection.DataSource.ENSEMBLBACTERIA);
068        DBRegistry eReg1 = DBRegistry.createRegistryForDataSourceAtReleaseVersion(DBConnection.DataSource.ENSEMBLBACTERIA, 22);
069        
070        Set<DBSpecies> panComparaSpecies = eReg.getPanComparaSpecies(null);
071        String release = ""+eReg.getHighestReleaseVersion();
072        
073        System.out.println("DBVersion "+release +" pan compara species: ["+panComparaSpecies.size() +" in total]:");
074        for (DBSpecies sp: panComparaSpecies) {
075            System.out.println("\t"+sp.getSpeciesBinomial()+
076                    "\t\t"+sp.getComparaName(release));
077        }
078        System.out.println("");
079
080        System.out.println("SPECIES NOT IN PAN_HOMOLOGY");
081        System.out.println("---------------------------");
082        DBSpecies sp =  eReg.getSpeciesByAlias("bacillus_pumilus_safr_032");       
083        DBSpecies sp1 =  eReg1.getSpeciesByAlias("bacillus_pumilus_safr_032");       
084
085        //from release17 - only 100 odd species are in compara - and this is now the pancompara - not a bacterial compara
086        gene = sp.getGeneByStableID("BPUM_0001");
087                
088        System.out.println("retrieved "+gene.getStableID()+" version "+gene.getDBVersion());
089        System.out.println("\torthologueCount "+gene.getOrthologueCount());
090        System.out.println("\thomoeologueCount "+gene.getHomoeologueCount());
091        System.out.println("\tparalogueCount "+gene.getParalogueCount());
092        
093        gene1 = sp1.getGeneByStableID("BPUM_0001", "22");
094                
095        System.out.println("retrieved "+gene1.getStableID()+" version "+gene1.getDBVersion());
096        System.out.println("\torthologueCount "+gene1.getOrthologueCount());
097        System.out.println("\thomoeologueCount "+gene1.getHomoeologueCount());
098        System.out.println("\tparalogueCount "+gene1.getParalogueCount());
099        
100         gene2 = new DAGene();
101        gene2.setStableID("BPUM_0002");
102        gene2.setDaoFactory(gene.getDaoFactory());
103         homoeologueCount = gene2.getHomoeologueCount();
104         paralogueCount = gene2.getParalogueCount();    
105         
106        System.out.println("retrieved "+gene2.getStableID()+" version "+gene2.getDBVersion());
107        System.out.println("\torthologueCount "+gene2.getOrthologueCount());
108        System.out.println("\thomoeologueCount "+gene2.getHomoeologueCount());
109        System.out.println("\tparalogueCount "+gene2.getParalogueCount());
110    
111        System.out.println("\nSPECIES IN PAN_HOMOLOGY");
112        System.out.println("---------------------------");
113         sp =  eReg.getSpeciesByAlias("mannheimia_haemolytica_serotype_a2_str_ovine");
114         sp1 =  eReg1.getSpeciesByAlias("mannheimia_haemolytica_serotype_a2_str_ovine");
115         
116        gene = sp.getGeneByStableID("COI_1025");
117        
118        System.out.println("retrieved "+gene.getStableID()+" version "+gene.getDBVersion());
119        System.out.println("\torthologueCount "+gene.getOrthologueCount());
120        System.out.println("\thomoeologueCount "+gene.getHomoeologueCount());
121        System.out.println("\tparalogueCount "+gene.getParalogueCount());
122        
123        gene1 = sp1.getGeneByStableID("COI_1025", "22");
124        
125        System.out.println("retrieved "+gene1.getStableID()+" version "+gene1.getDBVersion());
126        System.out.println("\torthologueCount "+gene1.getOrthologueCount());
127        System.out.println("\thomoeologueCount "+gene1.getHomoeologueCount());
128        System.out.println("\tparalogueCount "+gene1.getParalogueCount());
129                
130        gene2 = new DAGene();
131        gene2.setStableID("COI_1024");
132        gene2.setDaoFactory(gene.getDaoFactory());
133        homoeologueCount = gene2.getHomoeologueCount();
134        paralogueCount = gene2.getParalogueCount();
135        
136        System.out.println("retrieved "+gene2.getStableID()+" version "+gene2.getDBVersion());
137        System.out.println("\torthologueCount "+gene2.getOrthologueCount());
138        System.out.println("\thomoeologueCount "+gene2.getHomoeologueCount());
139        System.out.println("\tparalogueCount "+gene2.getParalogueCount());
140        
141        System.out.println("PLANTS");
142        System.out.println("------");
143        
144         eReg = DBRegistry.createRegistryForDataSource(DBConnection.DataSource.ENSEMBLGENOMES);
145         DBSpecies wheat = eReg.getSpeciesByAlias("wheat");
146         gene = wheat.getGeneByStableID("Traes_6DL_7FFFE462C");
147        
148        System.out.println("retrieved "+gene.getStableID()+" version "+gene.getDBVersion());
149        System.out.println("\torthologueCount "+gene.getOrthologueCount());
150        System.out.println("\thomoeologueCount "+gene.getHomoeologueCount());
151        System.out.println("\tparalogueCount "+gene.getParalogueCount());
152        
153        gene1 = wheat.getGeneByStableID("Traes_6DL_7FFFE462C","22");
154        System.out.println("retrieved "+gene1.getStableID()+" version "+gene1.getDBVersion());
155        System.out.println("\torthologueCount "+gene1.getOrthologueCount());
156        System.out.println("\thomoeologueCount "+gene1.getHomoeologueCount());
157        System.out.println("\tparalogueCount "+gene1.getParalogueCount());
158
159         gene2 = new DAGene();
160        gene2.setStableID("Traes_5DL_A83547043");
161        gene2.setDaoFactory(gene.getDaoFactory());
162         homoeologueCount = gene2.getHomoeologueCount();
163         paralogueCount = gene2.getParalogueCount();
164        
165        System.out.println("retrieved "+gene2.getStableID()+" version "+gene2.getDBVersion());
166        System.out.println("\torthologueCount "+gene2.getOrthologueCount());
167        System.out.println("\thomoeologueCount "+gene2.getHomoeologueCount());
168        System.out.println("\tparalogueCount "+gene2.getParalogueCount());        
169        
170        System.out.println("---------------------------");
171        System.out.println("FINISHED HOMOLOGY COUNT FUNCTIONAL TEST");
172        System.out.println("---------------------------");
173        
174    }
175}