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.datasourceaware.core; 023 024import org.biojava3.core.sequence.DNASequence; 025import org.slf4j.Logger; 026import org.slf4j.LoggerFactory; 027import uk.ac.roslin.ensembl.config.FeatureType; 028import uk.ac.roslin.ensembl.dao.factory.DAOCoreFactory; 029import uk.ac.roslin.ensembl.model.Coordinate; 030import uk.ac.roslin.ensembl.model.ObjectType; 031import uk.ac.roslin.ensembl.model.core.Exon; 032import uk.ac.roslin.ensembl.model.core.Transcript; 033 034public class DAExon extends DAFeature implements Exon { 035 036 private DATranscript transcript = null; 037 private Integer transcriptID = null; 038 //the position of this exon from the 5' end of the trancript, starting with 1 039 private Integer rank = null; 040 private int phase = Phase.NONE; 041 private int endPhase = Phase.NONE; 042 private Boolean constitutive; 043 private Coordinate targetCoordinates = null; 044 private DNASequence target = null; 045 046 final static Logger LOGGER = LoggerFactory.getLogger(DAExon.class); 047 048 public DAExon() { 049 super(); 050 } 051 052 public DAExon(DAOCoreFactory factory) { 053 super(factory); 054 } 055 056 @Override 057 void reinitialize() { 058 if (!this.isLazyloadAllowed() || this.isInitialized()) { 059 return; 060 } 061 try { 062 //nb getDaoFActory() will try and make a factory if we have at least species and ensembl version 063 this.getDaoFactory().getExonDAO().reInitialize(this); 064 } catch (Exception ex) { 065 LOGGER.info("Failed to reinitialize the Exon from the Database (using its stableID: " 066 +this.stableID+").", ex); 067 } finally { 068 //always set this so dont try again 069 this.setInitialized(true); 070 } 071 } 072 073 @Override 074 public ObjectType getType() { 075 return FeatureType.exon; 076 } 077 078 public DATranscript getTranscript() { 079 this.reinitialize(); 080 if (transcript==null && this.transcriptID != null) { 081 try { 082 transcript = (DATranscript) this.getDaoFactory().getTranscriptDAO().getTranscriptByID(transcriptID); 083 } catch (Exception e) { 084 LOGGER.info("Error thrown whilst trying to retrieve Transcript for an exon", e ); 085 } 086 } 087 088 return this.transcript; 089 } 090 091 public void setTranscript(Transcript transcript) { 092 this.transcript = (DATranscript)transcript; 093 } 094 095 public Integer getTranscriptID() { 096 this.reinitialize(); 097 return transcriptID; 098 } 099 100 public void setTranscriptID(Integer transcriptID) { 101 this.transcriptID = transcriptID; 102 } 103 104 @Override 105 public String getDisplayName() { 106 this.reinitialize(); 107 return (displayName!=null) ? displayName : stableID ; 108 } 109 110 @Override 111 public int getPhase() { 112 this.reinitialize(); 113 return phase; 114 } 115 116 public void setPhase(int phase) { 117 this.phase=Phase.getPhase(phase); 118 119 } 120 121 public int getEndPhase() { 122 this.reinitialize(); 123 return endPhase; 124 } 125 126 public void setEndPhase(int endPhase) { 127 this.endPhase=Phase.getPhase(endPhase); 128 129 } 130 131 @Override 132 public Boolean isConstitutive() { 133 this.reinitialize(); 134 return constitutive; 135 } 136 137 public void setConstitutive(Boolean constitutive) { 138 this.constitutive = constitutive; 139 } 140 141 public Integer getRank() { 142 this.reinitialize(); 143 return rank; 144 } 145 146 public void setRank(Integer rank) { 147 this.rank = rank; 148 } 149 150}