|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.biojava3.core.sequence.template.SequenceMixin
public class SequenceMixin
Provides a set of static methods to be used as static imports when needed
across multiple Sequence implementations but inheritance gets in the way.
It also provides a place to put utility methods whose application can
be to a single class of Sequence e.g. NucleotideCompound
Sequence
; or to any Sequence e.g. looking for the
getComposition(Sequence)
or getDistribution(Sequence)
for any type of Sequence.
All of these methods assume that you can use the Iterable
interface
offered by the implementations of Sequence
to provide all the
compounds that implementation allows you to see. Since sequence should know
nothing about its backing stores (apart from calling out to it) this should
be true.
Nested Class Summary | |
---|---|
static class |
SequenceMixin.SequenceIterator<C extends Compound>
A basic sequence iterator which iterates over the given Sequence by biological index. |
Constructor Summary | |
---|---|
SequenceMixin()
|
Method Summary | ||
---|---|---|
static
|
checksum(Sequence<C> sequence)
Performs a simple CRC64 checksum on any given sequence. |
|
static int |
countAT(Sequence<NucleotideCompound> sequence)
Returns the count of AT in the given sequence |
|
static
|
countCompounds(Sequence<C> sequence,
C... compounds)
For the given vargs of compounds this method counts the number of times those compounds appear in the given sequence |
|
static int |
countGC(Sequence<NucleotideCompound> sequence)
Returns the count of GC in the given sequence |
|
static
|
createIterator(Sequence<C> sequence)
Creates a simple sequence iterator which moves through a sequence going from 1 to the length of the Sequence. |
|
static
|
createSubSequence(Sequence<C> sequence,
int start,
int end)
Creates a simple sub sequence view delimited by the given start and end. |
|
static
|
getComposition(Sequence<C> sequence)
Does a linear scan over the given Sequence and records the number of times each base appears. |
|
static
|
getDistribution(Sequence<C> sequence)
Analogous to getComposition(Sequence) but returns the
distribution of that Compound over the given sequence. |
|
static
|
indexOf(Sequence<C> sequence,
C compound)
Performs a linear search of the given Sequence for the given compound. |
|
static
|
inverse(Sequence<C> sequence)
A method which attempts to do the right thing when is comes to a reverse/reverse complement |
|
static
|
lastIndexOf(Sequence<C> sequence,
C compound)
Performs a reversed linear search of the given Sequence by wrapping it in a ReversedSequenceView and passing it into
indexOf(Sequence, Compound) . |
|
static
|
nonOverlappingKmers(Sequence<C> sequence,
int kmer)
Produces kmers of the specified size e.g. |
|
static
|
overlappingKmers(Sequence<C> sequence,
int kmer)
Used to generate overlapping k-mers such i.e. |
|
static
|
sequenceEquality(Sequence<C> source,
Sequence<C> target)
A case-sensitive manner of comparing two sequence objects together. |
|
static
|
sequenceEqualityIgnoreCase(Sequence<C> source,
Sequence<C> target)
A case-insensitive manner of comparing two sequence objects together. |
|
static
|
shuffle(Sequence<C> sequence)
Implements sequence shuffling by first materializing the given Sequence into a List , applying
Collections.shuffle(List) and then returning the shuffled
elements in a new instance of SequenceBackingStore which behaves
as a Sequence . |
|
static
|
toList(Sequence<C> sequence)
For the given Sequence this will return a List filled with
the Compounds of that Sequence . |
|
static
|
toString(Sequence<C> sequence)
Shortcut to toStringBuilder(org.biojava3.core.sequence.template.Sequence)
which calls toString() on the resulting object. |
|
static
|
toStringBuilder(Sequence<C> sequence)
For the given Sequence this will return a StringBuilder object
filled with the results of Compound#toString() . |
|
static
|
write(Appendable appendable,
Sequence<C> sequence)
Used as a way of sending a Sequence to a writer without the cost of converting to a full length String and then writing the data out |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SequenceMixin()
Method Detail |
---|
public static <C extends Compound> int countCompounds(Sequence<C> sequence, C... compounds)
C
- The type of compound we are looking forsequence
- The Sequence
to perform the count oncompounds
- The compounds to look for
public static int countGC(Sequence<NucleotideCompound> sequence)
sequence
- The NucleotideCompound
Sequence
to perform
the GC analysis on
public static int countAT(Sequence<NucleotideCompound> sequence)
sequence
- The NucleotideCompound
Sequence
to perform
the AT analysis on
public static <C extends Compound> Map<C,Double> getDistribution(Sequence<C> sequence)
getComposition(Sequence)
but returns the
distribution of that Compound
over the given sequence.
C
- The type of compound to look forsequence
- The type of sequence to look over
public static <C extends Compound> Map<C,Integer> getComposition(Sequence<C> sequence)
C
- The type of compound to look forsequence
- The type of sequence to look over
public static <C extends Compound> void write(Appendable appendable, Sequence<C> sequence) throws IOException
C
- Type of compoundwriter
- The writer to send data tosequence
- The sequence to write out
IOException
- Thrown if we encounter a problempublic static <C extends Compound> StringBuilder toStringBuilder(Sequence<C> sequence)
StringBuilder
object
filled with the results of Compound#toString()
. Does not
used write(java.lang.Appendable, org.biojava3.core.sequence.template.Sequence)
because of its IOException
signature.
public static <C extends Compound> String toString(Sequence<C> sequence)
toStringBuilder(org.biojava3.core.sequence.template.Sequence)
which calls toString() on the resulting object.
public static <C extends Compound> List<C> toList(Sequence<C> sequence)
Sequence
this will return a List
filled with
the Compounds of that Sequence
.
public static <C extends Compound> int indexOf(Sequence<C> sequence, C compound)
public static <C extends Compound> int lastIndexOf(Sequence<C> sequence, C compound)
ReversedSequenceView
and passing it into
indexOf(Sequence, Compound)
. We then inverse the index coming
out of it.
public static <C extends Compound> Iterator<C> createIterator(Sequence<C> sequence)
public static <C extends Compound> SequenceView<C> createSubSequence(Sequence<C> sequence, int start, int end)
public static <C extends Compound> Sequence<C> shuffle(Sequence<C> sequence)
Sequence
into a List
, applying
Collections.shuffle(List)
and then returning the shuffled
elements in a new instance of SequenceBackingStore
which behaves
as a Sequence
.
public static <C extends Compound> String checksum(Sequence<C> sequence)
public static <C extends Compound> List<SequenceView<C>> nonOverlappingKmers(Sequence<C> sequence, int kmer)
C
- Compound to usesequence
- Sequence to build fromkmer
- Kmer size
public static <C extends Compound> List<SequenceView<C>> overlappingKmers(Sequence<C> sequence, int kmer)
C
- Compound to usesequence
- Sequence to build fromkmer
- Kmer size
public static <C extends Compound> SequenceView<C> inverse(Sequence<C> sequence)
C
- The type of compoundsequence
- The input sequence
public static <C extends Compound> boolean sequenceEqualityIgnoreCase(Sequence<C> source, Sequence<C> target)
C
- The type of compoundsource
- Source sequence to assesstarget
- Target sequence to assess
public static <C extends Compound> boolean sequenceEquality(Sequence<C> source, Sequence<C> target)
C
- The type of compoundsource
- Source sequence to assesstarget
- Target sequence to assess
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |