001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 * Created on DATE
021 *
022 */
023package org.biojava.nbio.core.sequence;
024
025/**
026 * @author Scooter Willis
027 *
028 */
029import org.biojava.nbio.core.exceptions.CompoundNotFoundException;
030import org.biojava.nbio.core.sequence.compound.NucleotideCompound;
031import org.biojava.nbio.core.sequence.compound.RNACompoundSet;
032import org.biojava.nbio.core.sequence.template.AbstractSequence;
033import org.biojava.nbio.core.sequence.template.CompoundSet;
034import org.biojava.nbio.core.sequence.template.ProxySequenceReader;
035import org.biojava.nbio.core.sequence.template.SequenceView;
036import org.biojava.nbio.core.sequence.transcription.TranscriptionEngine;
037import org.biojava.nbio.core.sequence.views.ComplementSequenceView;
038import org.biojava.nbio.core.sequence.views.ReversedSequenceView;
039
040/**
041 * RNASequence where RNACompoundSet are the allowed values
042 * @author Scooter Willis <willishf at gmail dot com>
043 */
044
045public class RNASequence extends AbstractSequence<NucleotideCompound> {
046
047                /**
048                 * Create a RNA sequence from a String
049                 * @param seqString
050                 * @throws CompoundNotFoundException
051                 */
052        public RNASequence(String seqString) throws CompoundNotFoundException {
053                super(seqString, RNACompoundSet.getRNACompoundSet());
054        }
055
056        /**
057         * Create a RNA aequence from a proxy reader
058         * @param proxyLoader
059         */
060        public RNASequence(ProxySequenceReader<NucleotideCompound> proxyLoader) {
061                super(proxyLoader, RNACompoundSet.getRNACompoundSet());
062        }
063
064        /**
065         * Create a RNA sequence from a string with a user defined RNA compound set
066         * @param seqString
067         * @param compoundSet
068         * @throws CompoundNotFoundException
069         */
070        public RNASequence(String seqString, CompoundSet<NucleotideCompound> compoundSet) throws CompoundNotFoundException {
071                super(seqString, compoundSet);
072        }
073
074        /**
075         * Create a RNA sequence from a proxy reader and user defined RNA compound set
076         * @param proxyLoader
077         * @param compoundSet
078         */
079        public RNASequence(ProxySequenceReader<NucleotideCompound> proxyLoader,
080                        CompoundSet<NucleotideCompound> compoundSet) {
081                super(proxyLoader, compoundSet);
082        }
083
084        /**
085         * Get reverse complement view of the sequence
086         * @return
087         */
088        public SequenceView<NucleotideCompound> getReverseComplement() {
089                return new ComplementSequenceView<NucleotideCompound>(getInverse());
090        }
091
092        /**
093         * Get the inverse view of the sequence. It is the reverse sequence from
094         * end to begin where use reverse could imply complement. Called getInverse()
095         * in the hopes of making less confusing.
096         * @return
097         */
098        @Override
099public SequenceView<NucleotideCompound> getInverse() {
100                return new ReversedSequenceView<NucleotideCompound>(this);
101        }
102
103        /**
104         * Get the complement view of the RNA sequence
105         * @return
106         */
107        public SequenceView<NucleotideCompound> getComplement() {
108                return new ComplementSequenceView<NucleotideCompound>(this);
109        }
110
111        /**
112         * Get the ProteinSequence from the RNA sequence
113         * @return
114         */
115        public ProteinSequence getProteinSequence() {
116                return getProteinSequence(TranscriptionEngine.getDefault());
117        }
118
119        /**
120         * Get the ProteinSequene from the RNA sequence with user defined
121         * transcription engine
122         *
123         * @param engine
124         * @return
125         */
126        public ProteinSequence getProteinSequence(TranscriptionEngine engine) {
127                return (ProteinSequence)engine.getRnaAminoAcidTranslator().createSequence(this);
128        }
129
130        public double getGC() {
131                throw new UnsupportedOperationException("Not supported yet");
132        }
133}