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 01-21-2010
021     */
022    
023    package org.biojava3.core.sequence.io;
024    
025    import java.util.List;
026    
027    import org.biojava3.core.sequence.ProteinSequence;
028    import org.biojava3.core.sequence.compound.AminoAcidCompound;
029    import org.biojava3.core.sequence.io.template.SequenceCreatorInterface;
030    import org.biojava3.core.sequence.loader.ArrayListProxySequenceReader;
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    
035    /**
036     * Used to create a ProteinSequence from a String to allow for details
037     * about the location of the sequence etc.
038     *
039     * @author Scooter Willis <willishf at gmail dot com>
040     */
041    public class ProteinSequenceCreator implements
042        SequenceCreatorInterface<AminoAcidCompound> {
043    
044      private CompoundSet<AminoAcidCompound> compoundSet;
045    /**
046     *
047     * @param compoundSet
048     */
049      public ProteinSequenceCreator(CompoundSet<AminoAcidCompound> compoundSet) {
050        this.compoundSet = compoundSet;
051      }
052    /**
053     *
054     * @param sequence
055     * @param index not used in this implementation
056     * @return
057     */
058      public AbstractSequence<AminoAcidCompound> getSequence(String sequence,
059          long index) {
060        return new ProteinSequence(sequence, compoundSet);
061      }
062    /**
063     *
064     * @param list
065     * @return
066     */
067      public AbstractSequence<AminoAcidCompound> getSequence(
068          List<AminoAcidCompound> list) {
069        ArrayListProxySequenceReader<AminoAcidCompound> store = new ArrayListProxySequenceReader<AminoAcidCompound>();
070        store.setCompoundSet(compoundSet);
071        store.setContents(list);
072        return new ProteinSequence(store);
073      }
074    /**
075     *
076     * @param proxyLoader
077     * @param index not used in this implementation
078     * @return
079     */
080      public AbstractSequence<AminoAcidCompound> getSequence(
081          ProxySequenceReader<AminoAcidCompound> proxyLoader, long index) {
082        return new ProteinSequence(proxyLoader, compoundSet);
083      }
084    }