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     */
023    package org.biojava3.core.sequence;
024    
025    /**
026     * @author Scooter Willis
027     *
028     */
029    import org.biojava3.core.sequence.compound.NucleotideCompound;
030    import org.biojava3.core.sequence.compound.RNACompoundSet;
031    import org.biojava3.core.sequence.template.AbstractSequence;
032    import org.biojava3.core.sequence.template.CompoundSet;
033    import org.biojava3.core.sequence.template.ProxySequenceReader;
034    import org.biojava3.core.sequence.template.SequenceView;
035    import org.biojava3.core.sequence.transcription.TranscriptionEngine;
036    import org.biojava3.core.sequence.views.ComplementSequenceView;
037    import org.biojava3.core.sequence.views.ReversedSequenceView;
038    
039    /**
040     * RNASequence where RNACompoundSet are the allowed values
041     * @author Scooter Willis <willishf at gmail dot com>
042     */
043    
044    public class RNASequence extends AbstractSequence<NucleotideCompound> {
045    
046        /**
047         * Create a RNA sequence from a String
048         * @param seqString
049         */
050      public RNASequence(String seqString) {
051        super(seqString, RNACompoundSet.getRNACompoundSet());
052      }
053    
054      /**
055       * Create a RNA aequence from a proxy reader
056       * @param proxyLoader
057       */
058      public RNASequence(ProxySequenceReader<NucleotideCompound> proxyLoader) {
059        super(proxyLoader, RNACompoundSet.getRNACompoundSet());
060      }
061    
062      /**
063       * Create a RNA sequence from a string with a user defined RNA compound set
064       * @param seqString
065       * @param compoundSet
066       */
067      public RNASequence(String seqString, CompoundSet<NucleotideCompound> compoundSet) {
068        super(seqString, compoundSet);
069      }
070    
071      /**
072       * Create a RNA sequence from a proxy reader and user defined RNA compound set
073       * @param proxyLoader
074       * @param compoundSet
075       */
076      public RNASequence(ProxySequenceReader<NucleotideCompound> proxyLoader,
077          CompoundSet<NucleotideCompound> compoundSet) {
078        super(proxyLoader, compoundSet);
079      }
080    
081      /**
082       * Get reverse complement view of the sequence
083       * @return
084       */
085      public SequenceView<NucleotideCompound> getReverseComplement() {
086        return new ComplementSequenceView<NucleotideCompound>(getInverse());
087      }
088    
089      /**
090       * Get the inverse view of the sequence. It is the reverse sequence from
091       * end to begin where use reverse could imply complement. Called getInverse()
092       * in the hopes of making less confusing.
093       * @return
094       */
095      public SequenceView<NucleotideCompound> getInverse() {
096        return new ReversedSequenceView<NucleotideCompound>(this);
097      }
098    
099      /**
100       * Get the complement view of the RNA sequence
101       * @return
102       */
103      public SequenceView<NucleotideCompound> getComplement() {
104        return new ComplementSequenceView<NucleotideCompound>(this);
105      }
106    
107      /**
108       * Get the ProteinSequence from the RNA sequence
109       * @return
110       */
111      public ProteinSequence getProteinSequence() {
112        return getProteinSequence(TranscriptionEngine.getDefault());
113      }
114    
115      /**
116       * Get the ProteinSequene from the RNA sequence with user defined
117       * transcription engine
118       *
119       * @param engine
120       * @return
121       */
122      public ProteinSequence getProteinSequence(TranscriptionEngine engine) {
123        return (ProteinSequence)engine.getRnaAminoAcidTranslator().createSequence(this);
124      }
125    
126      public double getGC() {
127        throw new UnsupportedOperationException("Not supported yet");
128      }
129    }