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 */ 021 022package org.biojava.nbio.core.sequence.io; 023 024import org.biojava.nbio.core.exceptions.CompoundNotFoundException; 025import org.biojava.nbio.core.sequence.RNASequence; 026import org.biojava.nbio.core.sequence.compound.NucleotideCompound; 027import org.biojava.nbio.core.sequence.io.template.SequenceCreatorInterface; 028import org.biojava.nbio.core.sequence.loader.ArrayListProxySequenceReader; 029import org.biojava.nbio.core.sequence.template.AbstractSequence; 030import org.biojava.nbio.core.sequence.template.CompoundSet; 031import org.biojava.nbio.core.sequence.template.ProxySequenceReader; 032 033import java.util.List; 034 035/** 036 * Used to create a RNA sequence 037 * 038 * @author Scooter Willis <willishf at gmail dot com> 039 */ 040public class RNASequenceCreator implements 041 SequenceCreatorInterface<NucleotideCompound> { 042 043 private final CompoundSet<NucleotideCompound> compoundSet; 044/** 045 * 046 * @param compoundSet 047 */ 048 public RNASequenceCreator(CompoundSet<NucleotideCompound> compoundSet) { 049 this.compoundSet = compoundSet; 050 } 051/** 052 * 053 * @param sequence 054 * @param index 055 * @return 056 * @throws CompoundNotFoundException 057 */ 058 @Override 059public AbstractSequence<NucleotideCompound> getSequence(String sequence, long index) throws CompoundNotFoundException { 060 return new RNASequence(sequence, compoundSet); 061 } 062/** 063 * 064 * @param proxyLoader 065 * @param index 066 * @return 067 */ 068 @Override 069public AbstractSequence<NucleotideCompound> getSequence( 070 ProxySequenceReader<NucleotideCompound> proxyLoader, long index) { 071 return new RNASequence(proxyLoader, compoundSet); 072 } 073/** 074 * 075 * @param list 076 * @return 077 */ 078 @Override 079public AbstractSequence<NucleotideCompound> getSequence(List<NucleotideCompound> list) { 080 ArrayListProxySequenceReader<NucleotideCompound> store = 081 new ArrayListProxySequenceReader<NucleotideCompound>(); 082 store.setCompoundSet(compoundSet); 083 store.setContents(list); 084 return new RNASequence(store); 085 } 086}