org.biojava3.core.sequence.loader
Class StringProxySequenceReader<C extends Compound>

java.lang.Object
  extended by org.biojava3.core.sequence.loader.StringProxySequenceReader<C>
Type Parameters:
C -
All Implemented Interfaces:
Iterable<C>, Accessioned, ProxySequenceReader<C>, Sequence<C>, SequenceReader<C>

public class StringProxySequenceReader<C extends Compound>
extends Object
implements ProxySequenceReader<C>

An example of a ProxySequenceReader that is created from a String. Used for testing

Author:
Scooter Willis

Constructor Summary
StringProxySequenceReader(String sequence, CompoundSet<C> compoundSet)
           
 
Method Summary
 int countCompounds(C... compounds)
          Returns the number of times we found a compound in the Sequence
 AccessionID getAccession()
          Returns the AccessionID this location is currently bound with
 List<C> getAsList()
          Returns the Sequence as a List of compounds
 C getCompoundAt(int position)
          Returns the Compound at the given biological index
 CompoundSet<C> getCompoundSet()
          Gets the compound set used to back this Sequence
 int getIndexOf(C compound)
          Scans through the Sequence looking for the first occurrence of the given compound
 SequenceView<C> getInverse()
          Does the right thing to get the inverse of the current Sequence.
 int getLastIndexOf(C compound)
          Scans through the Sequence looking for the last occurrence of the given compound
 int getLength()
          Returns the length of the Sequence
 String getSequenceAsString()
          Returns the String representation of the Sequence
 String getSequenceAsString(Integer bioBegin, Integer bioEnd, Strand strand)
           
 SequenceView<C> getSubSequence(Integer bioBegin, Integer bioEnd)
          Returns a portion of the sequence from the different positions.
 Iterator<C> iterator()
           
 void setCompoundSet(CompoundSet<C> compoundSet)
           
 void setContents(String sequence)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringProxySequenceReader

public StringProxySequenceReader(String sequence,
                                 CompoundSet<C> compoundSet)
Method Detail

setCompoundSet

public void setCompoundSet(CompoundSet<C> compoundSet)
Specified by:
setCompoundSet in interface SequenceReader<C extends Compound>

setContents

public void setContents(String sequence)
Specified by:
setContents in interface SequenceReader<C extends Compound>

getLength

public int getLength()
Description copied from interface: Sequence
Returns the length of the Sequence

Specified by:
getLength in interface Sequence<C extends Compound>

getCompoundAt

public C getCompoundAt(int position)
Description copied from interface: Sequence
Returns the Compound at the given biological index

Specified by:
getCompoundAt in interface Sequence<C extends Compound>
Parameters:
position - Biological index (1 to n)
Returns:
Compound at the specified position

getIndexOf

public int getIndexOf(C compound)
Description copied from interface: Sequence
Scans through the Sequence looking for the first occurrence of the given compound

Specified by:
getIndexOf in interface Sequence<C extends Compound>
Parameters:
compound - Compounds to look for
Returns:
Index of the first position of the compound in the sequence (1 to n)

getLastIndexOf

public int getLastIndexOf(C compound)
Description copied from interface: Sequence
Scans through the Sequence looking for the last occurrence of the given compound

Specified by:
getLastIndexOf in interface Sequence<C extends Compound>
Parameters:
compound - Compounds to look for
Returns:
Index of the last position of the compound in the sequence (1 to n)

toString

public String toString()
Overrides:
toString in class Object

getSequenceAsString

public String getSequenceAsString()
Description copied from interface: Sequence
Returns the String representation of the Sequence

Specified by:
getSequenceAsString in interface Sequence<C extends Compound>

getAsList

public List<C> getAsList()
Description copied from interface: Sequence
Returns the Sequence as a List of compounds

Specified by:
getAsList in interface Sequence<C extends Compound>

getSequenceAsString

public String getSequenceAsString(Integer bioBegin,
                                  Integer bioEnd,
                                  Strand strand)

getSubSequence

public SequenceView<C> getSubSequence(Integer bioBegin,
                                      Integer bioEnd)
Description copied from interface: Sequence
Returns a portion of the sequence from the different positions. This is indexed from 1

Specified by:
getSubSequence in interface Sequence<C extends Compound>
Parameters:
bioBegin - Biological index start; must be greater than 0
bioEnd - Biological end; must be less than length + 1
Returns:
A SequenceView of the offset

iterator

public Iterator<C> iterator()
Specified by:
iterator in interface Iterable<C extends Compound>

getCompoundSet

public CompoundSet<C> getCompoundSet()
Description copied from interface: Sequence
Gets the compound set used to back this Sequence

Specified by:
getCompoundSet in interface Sequence<C extends Compound>

getAccession

public AccessionID getAccession()
Description copied from interface: Accessioned
Returns the AccessionID this location is currently bound with

Specified by:
getAccession in interface Accessioned

countCompounds

public int countCompounds(C... compounds)
Description copied from interface: Sequence
Returns the number of times we found a compound in the Sequence

Specified by:
countCompounds in interface Sequence<C extends Compound>
Parameters:
compounds - Vargs of the compounds to count
Returns:
Number of times a compound was found

getInverse

public SequenceView<C> getInverse()
Description copied from interface: Sequence
Does the right thing to get the inverse of the current Sequence. This means either reversing the Sequence and optionally complementing the Sequence.

Specified by:
getInverse in interface Sequence<C extends Compound>