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.Collection; 025import java.util.List; 026import uk.ac.roslin.ensembl.config.DBConnection.DataSource; 027import uk.ac.roslin.ensembl.dao.database.DBRegistry; 028import uk.ac.roslin.ensembl.dao.database.DBSpecies; 029import uk.ac.roslin.ensembl.datasourceaware.DAXRef; 030import uk.ac.roslin.ensembl.datasourceaware.core.DAGene; 031import uk.ac.roslin.ensembl.datasourceaware.core.DATranscript; 032import uk.ac.roslin.ensembl.datasourceaware.core.DATranslation; 033import uk.ac.roslin.ensembl.model.core.Species; 034 035public class Synonyms { 036 037 public static void main(String[] args) throws Exception { 038 039 040 DBRegistry reg2 = DBRegistry.createRegistryForDataSourceCurrentRelease(DataSource.ENSEMBLBACTERIA); 041 042 Collection<? extends Species> setOfEverySpeciesByAlias = reg2.getSetOfEverySpeciesByAlias("k-12"); 043 044 System.out.println("there are "+setOfEverySpeciesByAlias.size()+" species with name 'k-12'."); 045 046 Collection<? extends Species> setOfSpeciesByAlias = reg2.getSetOfSpeciesByAlias("k-12"); 047 048 System.out.println("there are "+setOfSpeciesByAlias.size()+" CURRENT species with name 'k-12'."); 049 050 DBSpecies ek = reg2.getSpeciesByAlias("escherichia_coli_str_k_12_substr_mg1655"); 051 052 System.out.println("ek.getGenesForExactName(\"thrL\")"); 053 054 List<DAGene> genesForExactName = ek.getGenesForExactName("thrL"); 055 056 System.out.println("count is: "+genesForExactName.size()); 057 058 for (DAGene g : genesForExactName) { 059 060 System.out.println("GENE: " + g.getStableID()); 061 062 System.out.println("DisplayXref displayID: " + g.getDisplayXRef().getDisplayID()); 063 System.out.println("DisplayXref primary accession: " + g.getDisplayXRef().getPrimaryAccession()); 064 System.out.println("DisplayXref version: " + g.getDisplayXRef().getVersion()); 065 System.out.println("DisplayXref database: " + g.getDisplayXRef().getDBDisplayName()); 066 System.out.println("DisplayXref db version: " + g.getDisplayXRef().getDBVersion()); 067 System.out.println("DisplayXref description: " + g.getDisplayXRef().getDescription()); 068 System.out.print("DisplayXref synonyms (method1): "); 069 for (String s : g.getDisplayXRef().getSynonyms()) { 070 System.out.print(s + " | "); 071 } 072 System.out.println(""); 073 System.out.print("DisplayXref synonyms (method2): "); 074 for (String s : g.getSynonyms(g.getDisplayXRef())) { 075 System.out.print(s + " | "); 076 } 077 System.out.println(""); 078 System.out.println("VEGA XREFS"); 079 080 for (DAXRef x : g.getVegaXRefs()) { 081 System.out.println(" displayID: " + x.getDisplayID()); 082 System.out.println(" primary accession: " + x.getPrimaryAccession()); 083 System.out.println(" version: " + x.getVersion()); 084 System.out.println(" database: " + x.getDBDisplayName()); 085 System.out.println(" db version: " + x.getDBVersion()); 086 System.out.println(" description: " + x.getDescription()); 087 System.out.print("Synonyms: "); 088 for (String s : x.getSynonyms()) { 089 System.out.print(s + " | "); 090 } 091 System.out.println(""); 092 } 093 094 System.out.print("ALL SYNONYMS: "); 095 096 for (String s : g.getAllSynonyms()) { 097 System.out.print(s + " | "); 098 } 099 System.out.println(""); 100 101 } 102 103 System.out.println(""); 104 System.out.println("----------------------------------"); 105 System.out.println(""); 106 107 108 DBRegistry reg = DBRegistry.createRegistryForDataSource(DataSource.ENSEMBLDB); 109 DBSpecies hs = reg.getSpeciesByAlias("human"); 110 111 System.out.println("hs.getGenesForExactName(\"MAPK13\")"); 112 113 genesForExactName = hs.getGenesForExactName("MAPK13"); 114 115 System.out.println("count is: "+genesForExactName.size()); 116 117 for (DAGene g : genesForExactName) { 118 119 System.out.println("GENE: " + g.getStableID()); 120 121 System.out.println("DisplayXref displayID: " + g.getDisplayXRef().getDisplayID()); 122 System.out.println("DisplayXref primary accession: " + g.getDisplayXRef().getPrimaryAccession()); 123 System.out.println("DisplayXref version: " + g.getDisplayXRef().getVersion()); 124 System.out.println("DisplayXref database: " + g.getDisplayXRef().getDBDisplayName()); 125 System.out.println("DisplayXref db version: " + g.getDisplayXRef().getDBVersion()); 126 System.out.println("DisplayXref description: " + g.getDisplayXRef().getDescription()); 127 System.out.print("DisplayXref synonyms (method1): "); 128 for (String s : g.getDisplayXRef().getSynonyms()) { 129 System.out.print(s + " | "); 130 } 131 System.out.println(""); 132 System.out.print("DisplayXref synonyms (method2): "); 133 for (String s : g.getSynonyms(g.getDisplayXRef())) { 134 System.out.print(s + " | "); 135 } 136 System.out.println(""); 137 System.out.println("VEGA XREFS"); 138 139 for (DAXRef x : g.getVegaXRefs()) { 140 System.out.println(" displayID: " + x.getDisplayID()); 141 System.out.println(" primary accession: " + x.getPrimaryAccession()); 142 System.out.println(" version: " + x.getVersion()); 143 System.out.println(" database: " + x.getDBDisplayName()); 144 System.out.println(" db version: " + x.getDBVersion()); 145 System.out.println(" description: " + x.getDescription()); 146 System.out.print("Synonyms: "); 147 for (String s : x.getSynonyms()) { 148 System.out.print(s + " | "); 149 } 150 System.out.println(""); 151 } 152 153 System.out.print("ALL SYNONYMS: "); 154 155 for (String s : g.getAllSynonyms()) { 156 System.out.print(s + " | "); 157 } 158 System.out.println(""); 159 160 } 161 System.out.println(""); 162 System.out.println("----------------------------------"); 163 System.out.println(""); 164 165 166 System.out.println("hs.getGenesForExactName(\"SAPK4\");"); 167 //SAPK4 is infact an a synonym 168 genesForExactName = hs.getGenesForExactName("SAPK4"); 169 System.out.println("count is: "+genesForExactName.size()); 170 for (DAGene g : genesForExactName) { 171 172 System.out.println("GENE: " + g.getStableID()); 173 174 System.out.println("DisplayXref displayID: " + g.getDisplayXRef().getDisplayID()); 175 System.out.println("DisplayXref primary accession: " + g.getDisplayXRef().getPrimaryAccession()); 176 System.out.println("DisplayXref version: " + g.getDisplayXRef().getVersion()); 177 System.out.println("DisplayXref database: " + g.getDisplayXRef().getDBDisplayName()); 178 System.out.println("DisplayXref db version: " + g.getDisplayXRef().getDBVersion()); 179 System.out.println("DisplayXref description: " + g.getDisplayXRef().getDescription()); 180 System.out.print("DisplayXref synonyms (method1): "); 181 for (String s : g.getDisplayXRef().getSynonyms()) { 182 System.out.print(s + " | "); 183 } 184 System.out.println(""); 185 System.out.print("DisplayXref synonyms (method2): "); 186 for (String s : g.getSynonyms(g.getDisplayXRef())) { 187 System.out.print(s + " | "); 188 } 189 System.out.println(""); 190 System.out.println("VEGA XREFS"); 191 192 for (DAXRef x : g.getVegaXRefs()) { 193 System.out.println(" displayID: " + x.getDisplayID()); 194 System.out.println(" primary accession: " + x.getPrimaryAccession()); 195 System.out.println(" version: " + x.getVersion()); 196 System.out.println(" database: " + x.getDBDisplayName()); 197 System.out.println(" db version: " + x.getDBVersion()); 198 System.out.println(" description: " + x.getDescription()); 199 System.out.print("Synonyms: "); 200 for (String s : x.getSynonyms()) { 201 System.out.print(s + " | "); 202 } 203 System.out.println(""); 204 } 205 206 System.out.print("ALL SYNONYMS: "); 207 208 for (String s : g.getAllSynonyms()) { 209 System.out.print(s + " | "); 210 } 211 System.out.println(""); 212 } 213 214 System.out.println(""); 215 System.out.println("----------------------------------"); 216 System.out.println(""); 217 218 System.out.println("hs.getGenesForNameBeginning(\"MAPK13\");"); 219 //SAPK4 is infact an a synonym 220 genesForExactName = hs.getGenesForNameBeginning("MAPK13"); 221 System.out.println("count is: "+genesForExactName.size()); 222 for (DAGene g : genesForExactName) { 223 224 System.out.println("GENE: " + g.getStableID()); 225 226 System.out.println("DisplayXref displayID: " + g.getDisplayXRef().getDisplayID()); 227 System.out.println("DisplayXref primary accession: " + g.getDisplayXRef().getPrimaryAccession()); 228 System.out.println("DisplayXref version: " + g.getDisplayXRef().getVersion()); 229 System.out.println("DisplayXref database: " + g.getDisplayXRef().getDBDisplayName()); 230 System.out.println("DisplayXref db version: " + g.getDisplayXRef().getDBVersion()); 231 System.out.println("DisplayXref description: " + g.getDisplayXRef().getDescription()); 232 System.out.print("DisplayXref synonyms (method1): "); 233 for (String s : g.getDisplayXRef().getSynonyms()) { 234 System.out.print(s + " | "); 235 } 236 System.out.println(""); 237 System.out.print("DisplayXref synonyms (method2): "); 238 for (String s : g.getSynonyms(g.getDisplayXRef())) { 239 System.out.print(s + " | "); 240 } 241 System.out.println(""); 242 System.out.println("VEGA XREFS"); 243 244 for (DAXRef x : g.getVegaXRefs()) { 245 System.out.println(" displayID: " + x.getDisplayID()); 246 System.out.println(" primary accession: " + x.getPrimaryAccession()); 247 System.out.println(" version: " + x.getVersion()); 248 System.out.println(" database: " + x.getDBDisplayName()); 249 System.out.println(" db version: " + x.getDBVersion()); 250 System.out.println(" description: " + x.getDescription()); 251 System.out.print("Synonyms: "); 252 for (String s : x.getSynonyms()) { 253 System.out.print(s + " | "); 254 } 255 System.out.println(""); 256 } 257 258 System.out.print("ALL SYNONYMS: "); 259 260 for (String s : g.getAllSynonyms()) { 261 System.out.print(s + " | "); 262 } 263 System.out.println(""); 264 265 } 266 267 System.out.println(""); 268 System.out.println("----------------------------------"); 269 System.out.println(""); 270 271 System.out.println("hs.getGenesForNameBeginning(\"MAPK1\");"); 272 //SAPK4 is infact an a synonym 273 genesForExactName = hs.getGenesForNameBeginning("MAPK1"); 274 System.out.println("count is: "+genesForExactName.size()); 275 for (DAGene g : genesForExactName) { 276 277 System.out.println("GENE: " + g.getStableID()); 278 279 System.out.println("DisplayXref displayID: " + g.getDisplayXRef().getDisplayID()); 280 System.out.println("DisplayXref primary accession: " + g.getDisplayXRef().getPrimaryAccession()); 281 System.out.println("DisplayXref version: " + g.getDisplayXRef().getVersion()); 282 System.out.println("DisplayXref database: " + g.getDisplayXRef().getDBDisplayName()); 283 System.out.println("DisplayXref db version: " + g.getDisplayXRef().getDBVersion()); 284 System.out.println("DisplayXref description: " + g.getDisplayXRef().getDescription()); 285 System.out.print("DisplayXref synonyms (method1): "); 286 for (String s : g.getDisplayXRef().getSynonyms()) { 287 System.out.print(s + " | "); 288 } 289 System.out.println(""); 290 System.out.print("DisplayXref synonyms (method2): "); 291 for (String s : g.getSynonyms(g.getDisplayXRef())) { 292 System.out.print(s + " | "); 293 } 294 System.out.println(""); 295 System.out.println("VEGA XREFS"); 296 297 for (DAXRef x : g.getVegaXRefs()) { 298 System.out.println(" displayID: " + x.getDisplayID()); 299 System.out.println(" primary accession: " + x.getPrimaryAccession()); 300 System.out.println(" version: " + x.getVersion()); 301 System.out.println(" database: " + x.getDBDisplayName()); 302 System.out.println(" db version: " + x.getDBVersion()); 303 System.out.println(" description: " + x.getDescription()); 304 System.out.print("Synonyms: "); 305 for (String s : x.getSynonyms()) { 306 System.out.print(s + " | "); 307 } 308 System.out.println(""); 309 } 310 311 System.out.print("ALL SYNONYMS: "); 312 313 for (String s : g.getAllSynonyms()) { 314 System.out.print(s + " | "); 315 } 316 System.out.println(""); 317 318 } 319 320 System.out.println(""); 321 System.out.println("----------------------------------"); 322 System.out.println(""); 323 324 325 System.out.println("hs.getGenesForNameBeginning(\"SAPK\", \"57\");"); 326 //SAPK4 is infact an a synonym 327 genesForExactName = hs.getGenesForNameBeginning("SAPK", "57"); 328 System.out.println("count is: "+genesForExactName.size()); 329 330 int count = 1; 331 for (DAGene g : genesForExactName) { 332 333 System.out.println("GENE: " + count++ +" - "+ g.getStableID()); 334 335 System.out.println("DisplayXref displayID: " + g.getDisplayXRef().getDisplayID()); 336 System.out.println("DisplayXref primary accession: " + g.getDisplayXRef().getPrimaryAccession()); 337 System.out.println("DisplayXref version: " + g.getDisplayXRef().getVersion()); 338 System.out.println("DisplayXref database: " + g.getDisplayXRef().getDBDisplayName()); 339 System.out.println("DisplayXref db version: " + g.getDisplayXRef().getDBVersion()); 340 System.out.println("DisplayXref description: " + g.getDisplayXRef().getDescription()); 341 System.out.print("DisplayXref synonyms (method1): "); 342 for (String s : g.getDisplayXRef().getSynonyms()) { 343 System.out.print(s + " | "); 344 } 345 System.out.println(""); 346 System.out.print("DisplayXref synonyms (method2): "); 347 for (String s : g.getSynonyms(g.getDisplayXRef())) { 348 System.out.print(s + " | "); 349 } 350 System.out.println(""); 351 System.out.println("VEGA XREFS"); 352 353 for (DAXRef x : g.getVegaXRefs()) { 354 System.out.println(" displayID: " + x.getDisplayID()); 355 System.out.println(" primary accession: " + x.getPrimaryAccession()); 356 System.out.println(" version: " + x.getVersion()); 357 System.out.println(" database: " + x.getDBDisplayName()); 358 System.out.println(" db version: " + x.getDBVersion()); 359 System.out.println(" description: " + x.getDescription()); 360 System.out.print("Synonyms: "); 361 for (String s : x.getSynonyms()) { 362 System.out.print(s + " | "); 363 } 364 System.out.println(""); 365 } 366 367 System.out.print("ALL SYNONYMS: "); 368 369 for (String s : g.getAllSynonyms()) { 370 System.out.print(s + " | "); 371 } 372 System.out.println(""); 373 } 374 375 System.out.println(""); 376 System.out.println("----------------------------------"); 377 System.out.println(""); 378 379 380 DAGene gene = hs.getGeneByStableID("ENSG00000156711"); 381 382 System.out.println("GENE: " + gene.getStableID()); 383 384 System.out.println("DisplayXref displayID: " + gene.getDisplayXRef().getDisplayID()); 385 System.out.println("DisplayXref primary accession: " + gene.getDisplayXRef().getPrimaryAccession()); 386 System.out.println("DisplayXref version: " + gene.getDisplayXRef().getVersion()); 387 System.out.println("DisplayXref database: " + gene.getDisplayXRef().getDBDisplayName()); 388 System.out.println("DisplayXref db version: " + gene.getDisplayXRef().getDBVersion()); 389 System.out.println("DisplayXref description: " + gene.getDisplayXRef().getDescription()); 390 System.out.print("DisplayXref synonyms (method1): "); 391 for (String s : gene.getDisplayXRef().getSynonyms()) { 392 System.out.print(s + " | "); 393 } 394 System.out.println(""); 395 System.out.print("DisplayXref synonyms (method2): "); 396 for (String s : gene.getSynonyms(gene.getDisplayXRef())) { 397 System.out.print(s + " | "); 398 } 399 System.out.println(""); 400 System.out.println("VEGA XREFS"); 401 402 for (DAXRef x : gene.getVegaXRefs()) { 403 System.out.println(" displayID: " + x.getDisplayID()); 404 System.out.println(" primary accession: " + x.getPrimaryAccession()); 405 System.out.println(" version: " + x.getVersion()); 406 System.out.println(" database: " + x.getDBDisplayName()); 407 System.out.println(" db version: " + x.getDBVersion()); 408 System.out.println(" description: " + x.getDescription()); 409 System.out.print("Synonyms: "); 410 for (String s : x.getSynonyms()) { 411 System.out.print(s + " | "); 412 } 413 System.out.println(""); 414 } 415 416 System.out.print("ALL SYNONYMS: "); 417 418 for (String s : gene.getAllSynonyms()) { 419 System.out.print(s + " | "); 420 } 421 System.out.println(""); 422 System.out.println(""); 423 System.out.println(""); 424 425 DATranscript transcript = hs.getTranscriptByStableID("ENST00000368759"); 426 System.out.println("TRANSCRIPT: " + transcript.getStableID()); 427 428 System.out.println("DisplayXref displayID: " + transcript.getDisplayXRef().getDisplayID()); 429 System.out.println("DisplayXref primary accession: " + transcript.getDisplayXRef().getPrimaryAccession()); 430 System.out.println("DisplayXref version: " + transcript.getDisplayXRef().getVersion()); 431 System.out.println("DisplayXref database: " + transcript.getDisplayXRef().getDBDisplayName()); 432 System.out.println("DisplayXref db version: " + transcript.getDisplayXRef().getDBVersion()); 433 System.out.println("DisplayXref description: " + transcript.getDisplayXRef().getDescription()); 434 System.out.print("DisplayXref synonyms (method1): "); 435 for (String s : transcript.getDisplayXRef().getSynonyms()) { 436 System.out.print(s + " | "); 437 } 438 System.out.println(""); 439 System.out.print("DisplayXref synonyms (method2): "); 440 for (String s : transcript.getSynonyms(transcript.getDisplayXRef())) { 441 System.out.print(s + " | "); 442 } 443 System.out.println(""); 444 System.out.println("VEGA XREFS"); 445 446 for (DAXRef x : transcript.getVegaXRefs()) { 447 System.out.println(" displayID: " + x.getDisplayID()); 448 System.out.println(" primary accession: " + x.getPrimaryAccession()); 449 System.out.println(" version: " + x.getVersion()); 450 System.out.println(" database: " + x.getDBDisplayName()); 451 System.out.println(" db version: " + x.getDBVersion()); 452 System.out.println(" description: " + x.getDescription()); 453 System.out.print("Synonyms: "); 454 for (String s : x.getSynonyms()) { 455 System.out.print(s + " | "); 456 } 457 System.out.println(""); 458 } 459 460 System.out.print("ALL SYNONYMS: "); 461 462 for (String s : transcript.getAllSynonyms()) { 463 System.out.print(s + " | "); 464 } 465 System.out.println(""); 466 System.out.println(""); 467 System.out.println(""); 468 469 DATranslation translation = hs.getTranslationByStableID("ENSP00000261584"); 470 System.out.println("TRANSLATION: " + translation.getStableID()); 471 472 473 System.out.println(""); 474 System.out.println("VEGA XREFS"); 475 476 for (DAXRef x : translation.getVegaXRefs()) { 477 System.out.println(" displayID: " + x.getDisplayID()); 478 System.out.println(" primary accession: " + x.getPrimaryAccession()); 479 System.out.println(" version: " + x.getVersion()); 480 System.out.println(" database: " + x.getDBDisplayName()); 481 System.out.println(" db version: " + x.getDBVersion()); 482 System.out.println(" description: " + x.getDescription()); 483 System.out.print("Synonyms: "); 484 for (String s : x.getSynonyms()) { 485 System.out.print(s + " | "); 486 } 487 System.out.println(""); 488 } 489 490 System.out.print("ALL SYNONYMS: "); 491 492 for (String s : translation.getAllSynonyms()) { 493 System.out.print(s + " | "); 494 } 495 System.out.println(""); 496 497 } 498 }