001 /** 002 * Copyright (C) 2010 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.biojava3.core.sequence.Strand; 024 import uk.ac.roslin.ensembl.dao.factory.DAOCoreFactory; 025 import uk.ac.roslin.ensembl.exception.DAOException; 026 import uk.ac.roslin.ensembl.exception.RangeException; 027 import uk.ac.roslin.ensembl.model.core.AssembledDNASequence; 028 029 /** 030 * 031 * @author paterson 032 */ 033 public class DAAssembledDNASequence extends DADNASequence implements AssembledDNASequence { 034 035 DAAssembly completeAssembly = null; 036 037 public DAAssembledDNASequence() { 038 super(); 039 } 040 041 public DAAssembledDNASequence(DAOCoreFactory factory) { 042 super(factory); 043 } 044 045 public DAAssembly getCompleteAssembly() { 046 if (completeAssembly == null) { 047 completeAssembly = DAAssembly.getAssembly(this); 048 } 049 return completeAssembly; 050 } 051 052 /** 053 * 054 * @param begin 055 * @param end 056 * @return 057 */ 058 @Override 059 public String getSequenceAsString(Integer begin, Integer end) { 060 return this.getSequenceAsString(begin, end, Strand.POSITIVE); 061 } 062 /** 063 * 064 * @param begin 065 * @param end 066 * @param strand 067 * @return 068 */ 069 @Override 070 public String getSequenceAsString(Integer begin, Integer end, Strand strand) { 071 072 String out = ""; 073 074 try { 075 out = this.getCompleteAssembly().getSequenceAsString(begin, end, strand).toString(); 076 } catch (RangeException ex) { 077 078 } catch (DAOException ex) { 079 080 } 081 082 return out; 083 } 084 085 /** 086 * Default case is to assume strand is positive because only CDSSequence can be either positive or negative Strand. 087 * @return 088 */ 089 @Override 090 public String getSequenceAsString() { 091 if (this.getBioEnd()==0) { 092 return ""; 093 } 094 return getSequenceAsString(this.getBioBegin(), this.getBioEnd(), Strand.POSITIVE); 095 } 096 097 /** 098 * 099 * @param begin 100 * @param end 101 * @param strand 102 * @return 103 */ 104 @Override 105 public String getReverseComplementSequenceAsString(Integer begin, Integer end) { 106 107 String out = ""; 108 109 try { 110 out = this.getCompleteAssembly().getReverseComplementSequenceAsString(begin, end).toString(); 111 } catch (RangeException ex) { 112 113 } catch (DAOException ex) { 114 115 } 116 117 return out; 118 } 119 120 /** 121 * Default case is to assume strand is positive because only CDSSequence can be either positive or negative Strand. 122 * @return 123 */ 124 @Override 125 public String getReverseComplementSequenceAsString() { 126 if (this.getBioEnd()==0) { 127 return ""; 128 } 129 return getReverseComplementSequenceAsString(this.getBioBegin(), this.getBioEnd()); 130 } 131 132 133 }