001    /**
002     * Copyright (C) 2011 The Roslin Institute <contact andy.law@roslin.ed.ac.uk>
003     *
004     * This file is part of the Ensembl Java API demonstration project developed by the
005     * Bioinformatics Group at The Roslin Institute, The Royal (Dick) School of
006     * Veterinary Studies, University of Edinburgh.
007     *
008     * This is free software: you can redistribute it and/or modify
009     * it under the terms of the GNU General Public License (version 3) as published by
010     * the Free Software Foundation.
011     *
012     * This software is distributed in the hope that it will be useful,
013     * but WITHOUT ANY WARRANTY; without even the implied warranty of
014     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015     * GNU General Public License for more details.
016     *
017     * You should have received a copy of the GNU General Public License
018     * in this software distribution. If not, see <http://www.gnu.org/licenses/gpl-3.0.html/>.
019     */
020    
021    package uk.ac.roslin.ensembl.datasourceaware.core;
022    
023    import org.apache.log4j.Logger;
024    import uk.ac.roslin.ensembl.dao.factory.DAOCoreFactory;
025    import uk.ac.roslin.ensembl.exception.DAOException;
026    import uk.ac.roslin.ensembl.model.ObjectType;
027    import uk.ac.roslin.ensembl.model.core.Transcript;
028    import uk.ac.roslin.ensembl.config.FeatureType;
029    import uk.ac.roslin.ensembl.model.core.Exon;
030    
031    public class DAExon extends DAFeature implements Exon {
032    
033        private String stableID = null;
034        private DATranscript transcript = null;
035        private Integer transcriptID  = null;
036        //the position of this exon from the 5' end of the trancript, starting with 1
037        private Integer rank  = null;
038        private int phase = Phase.NONE;
039        private int endPhase = Phase.NONE;
040        private Boolean constitutive;
041    
042        final static Logger LOGGER = Logger.getLogger(DATranscript.class);
043    
044        public DAExon() {
045            super();
046        }
047    
048        public DAExon(DAOCoreFactory factory) {
049            super(factory);
050         }
051    
052        @Override
053        void reinitialize() throws DAOException {
054           //not used yet
055        }
056    
057        @Override
058        public ObjectType getType() {
059            return FeatureType.exon;
060        }
061    
062        public DATranscript getTranscript() {
063            if (transcript==null && this.transcriptID != null) {
064                try {
065                    transcript = (DATranscript) this.getDaoFactory().getTranscriptDAO().getTranscriptByID(transcriptID);
066                } catch (Exception e) {
067                    LOGGER.info("Error thrown whilst trying to retrieve Transcript for an exon", e );
068                }
069            }
070    
071            return this.transcript;
072        }
073    
074        public void setTranscript(Transcript transcript) {
075            this.transcript = (DATranscript)transcript;
076        }
077    
078        public Integer getTranscriptID() {
079            return transcriptID;
080        }
081    
082        public void setTranscriptID(Integer transcriptID) {
083            this.transcriptID = transcriptID;
084        }
085    
086        public String getStableID() {
087            return stableID;
088        }
089    
090        public void setStableID(String stableID) {
091            this.stableID = stableID;
092        }
093    
094        @Override
095        public String getDisplayName() {
096            return (displayName!=null) ? displayName : stableID ;
097        }
098    
099        public int getPhase() {
100            return phase;
101        }
102    
103        public void setPhase(int phase) {
104           this.phase=Phase.getPhase(phase);
105    
106        }
107    
108        public int getEndPhase() {
109            return endPhase;
110        }
111    
112        public void setEndPhase(int endPhase) {
113           this.endPhase=Phase.getPhase(endPhase);
114    
115        }
116    
117        public Boolean isConstitutive() {
118            return constitutive;
119        }
120    
121        public void setConstitutive(Boolean constitutive) {
122            this.constitutive = constitutive;
123        }
124    
125        public Integer getRank() {
126            return rank;
127        }
128    
129        public void setRank(Integer rank) {
130            this.rank = rank;
131        }
132    
133    }