Package org.biojava.nbio.core.alignment
Class SimpleProfile<S extends Sequence<C>,C extends Compound>
- java.lang.Object
-
- org.biojava.nbio.core.alignment.SimpleProfile<S,C>
-
- Type Parameters:
S
- each element of the alignmentProfile
is of type SC
- each element of anAlignedSequence
is aCompound
of type C
- All Implemented Interfaces:
Serializable
,Iterable<AlignedSequence<S,C>>
,Profile<S,C>
- Direct Known Subclasses:
SimpleProfilePair
,SimpleSequencePair
public class SimpleProfile<S extends Sequence<C>,C extends Compound> extends Object implements Serializable, Profile<S,C>
Implements a data structure for the results of sequence alignment. EveryList
returned is unmodifiable.- Author:
- Mark Chapman, Paolo Pavan
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.biojava.nbio.core.alignment.template.Profile
Profile.StringFormat
-
-
Field Summary
Fields Modifier and Type Field Description protected static SubstitutionMatrix<AminoAcidCompound>
matrix
-
Constructor Summary
Constructors Modifier Constructor Description SimpleProfile(Collection<AlignedSequence<S,C>> alignedSequences)
Creates a profile for the already aligned sequences.protected
SimpleProfile(AlignedSequence<S,C> query, AlignedSequence<S,C> target)
Creates a pair profile for the given already aligned sequences.protected
SimpleProfile(Profile<S,C> query, Profile<S,C> target, List<AlignedSequence.Step> sx, List<AlignedSequence.Step> sy)
Creates a pair profile for the given profiles.SimpleProfile(S sequence)
Creates a profile from a single sequence.protected
SimpleProfile(S query, S target, List<AlignedSequence.Step> sx, int xb, int xa, List<AlignedSequence.Step> sy, int yb, int ya)
Creates a pair profile for the given sequences.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AlignedSequence<S,C>
getAlignedSequence(int listIndex)
ReturnsAlignedSequence
at given index.AlignedSequence<S,C>
getAlignedSequence(S sequence)
Searches for the givenSequence
within this alignment profile.List<AlignedSequence<S,C>>
getAlignedSequences()
Returns aList
containing the individualAlignedSequence
s of this alignment.List<AlignedSequence<S,C>>
getAlignedSequences(int... listIndices)
Returns aList
containing some of the individualAlignedSequence
s of this alignment.List<AlignedSequence<S,C>>
getAlignedSequences(S... sequences)
Returns aList
containing some of the individualAlignedSequence
s of this alignment.C
getCompoundAt(int listIndex, int alignmentIndex)
Returns theCompound
at row of given sequence and column of alignment index.C
getCompoundAt(S sequence, int alignmentIndex)
Returns theCompound
at row of given sequence and column of alignment index.int[]
getCompoundCountsAt(int alignmentIndex)
Returns the number of eachCompound
in the given column for all compounds inCompoundSet
.int[]
getCompoundCountsAt(int alignmentIndex, List<C> compounds)
Returns the number of eachCompound
in the given column only for compounds in the given list.List<C>
getCompoundsAt(int alignmentIndex)
CompoundSet<C>
getCompoundSet()
ReturnsCompoundSet
of allAlignedSequence
sfloat[]
getCompoundWeightsAt(int alignmentIndex)
Returns the fraction of eachCompound
in the given column for all compounds inCompoundSet
.float[]
getCompoundWeightsAt(int alignmentIndex, List<C> compounds)
Returns the fraction of eachCompound
in the given column only for compounds in the given list.int
getIndexOf(C compound)
Searches for the givenCompound
within this alignment profile.int[]
getIndicesAt(int alignmentIndex)
Returns the indices in the originalSequence
s corresponding to the given column.int
getLastIndexOf(C compound)
Searches for the givenCompound
within this alignment profile.int
getLength()
Returns the number of columns in the alignment profile.List<S>
getOriginalSequences()
int
getSize()
Returns the number of rows in this profile.ProfileView<S,C>
getSubProfile(Location location)
Returns aProfileView
windowed to contain only the givenLocation
.boolean
hasGap(int alignmentIndex)
Returns true if anyAlignedSequence
has a gap at the given index.boolean
isCircular()
Returns true if anyAlignedSequence
is circular.Iterator<AlignedSequence<S,C>>
iterator()
String
toString()
Returns a simple view of the alignment profile.String
toString(int width)
Returns a formatted view of the alignment profile.String
toString(Profile.StringFormat format)
Returns a formatted view of the alignment profile.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
matrix
protected static final SubstitutionMatrix<AminoAcidCompound> matrix
-
-
Constructor Detail
-
SimpleProfile
protected SimpleProfile(AlignedSequence<S,C> query, AlignedSequence<S,C> target)
Creates a pair profile for the given already aligned sequences.- Parameters:
query
- the first sequence of the pairtarget
- the second sequence of the pair- Throws:
IllegalArgumentException
- if sequences differ in size
-
SimpleProfile
public SimpleProfile(S sequence)
Creates a profile from a single sequence.- Parameters:
sequence
- sequence to seed profile
-
SimpleProfile
protected SimpleProfile(S query, S target, List<AlignedSequence.Step> sx, int xb, int xa, List<AlignedSequence.Step> sy, int yb, int ya)
Creates a pair profile for the given sequences.- Parameters:
query
- the first sequence of the pairtarget
- the second sequence of the pairsx
- lists whether the query sequence aligns aCompound
or gap at each index of the alignmentxb
- number ofCompound
s skipped in the query sequence before the aligned regionxa
- number ofCompound
s skipped in the query sequence after the aligned regionsy
- lists whether the target sequence aligns aCompound
or gap at each index of the alignmentyb
- number ofCompound
s skipped in the target sequence before the aligned regionya
- number ofCompound
s skipped in the target sequence after the aligned region- Throws:
IllegalArgumentException
- if alignments differ in size or given sequences do not fit in alignments
-
SimpleProfile
protected SimpleProfile(Profile<S,C> query, Profile<S,C> target, List<AlignedSequence.Step> sx, List<AlignedSequence.Step> sy)
Creates a pair profile for the given profiles.- Parameters:
query
- the first profile of the pairtarget
- the second profile of the pairsx
- lists whether the query profile aligns aCompound
or gap at each index of the alignmentsy
- lists whether the target profile aligns aCompound
or gap at each index of the alignment- Throws:
IllegalArgumentException
- if alignments differ in size or given profiles do not fit in alignments
-
SimpleProfile
public SimpleProfile(Collection<AlignedSequence<S,C>> alignedSequences)
Creates a profile for the already aligned sequences.- Parameters:
alignedSequences
- the already aligned sequences- Throws:
IllegalArgument
- if aligned sequences differ in length or collection is empty.
-
-
Method Detail
-
getAlignedSequence
public AlignedSequence<S,C> getAlignedSequence(int listIndex)
Description copied from interface:Profile
ReturnsAlignedSequence
at given index.
-
getAlignedSequence
public AlignedSequence<S,C> getAlignedSequence(S sequence)
Description copied from interface:Profile
Searches for the givenSequence
within this alignment profile. Returns the correspondingAlignedSequence
.- Specified by:
getAlignedSequence
in interfaceProfile<S extends Sequence<C>,C extends Compound>
- Parameters:
sequence
- an originalSequence
- Returns:
- the corresponding
AlignedSequence
-
getAlignedSequences
public List<AlignedSequence<S,C>> getAlignedSequences()
Description copied from interface:Profile
Returns aList
containing the individualAlignedSequence
s of this alignment.
-
getAlignedSequences
public List<AlignedSequence<S,C>> getAlignedSequences(int... listIndices)
Description copied from interface:Profile
Returns aList
containing some of the individualAlignedSequence
s of this alignment.
-
getAlignedSequences
public List<AlignedSequence<S,C>> getAlignedSequences(S... sequences)
Description copied from interface:Profile
Returns aList
containing some of the individualAlignedSequence
s of this alignment.
-
getCompoundAt
public C getCompoundAt(int listIndex, int alignmentIndex)
Description copied from interface:Profile
-
getCompoundAt
public C getCompoundAt(S sequence, int alignmentIndex)
Description copied from interface:Profile
Returns theCompound
at row of given sequence and column of alignment index. If the given sequence has overlap, this will return theCompound
from the top row of the sequence.- Specified by:
getCompoundAt
in interfaceProfile<S extends Sequence<C>,C extends Compound>
- Parameters:
sequence
- either anAlignedSequence
or an originalSequence
alignmentIndex
- column index within an alignment- Returns:
- the sequence element
-
getCompoundCountsAt
public int[] getCompoundCountsAt(int alignmentIndex)
Description copied from interface:Profile
Returns the number of eachCompound
in the given column for all compounds inCompoundSet
.
-
getCompoundCountsAt
public int[] getCompoundCountsAt(int alignmentIndex, List<C> compounds)
Description copied from interface:Profile
Returns the number of eachCompound
in the given column only for compounds in the given list.
-
getCompoundsAt
public List<C> getCompoundsAt(int alignmentIndex)
Description copied from interface:Profile
-
getCompoundSet
public CompoundSet<C> getCompoundSet()
Description copied from interface:Profile
ReturnsCompoundSet
of allAlignedSequence
s
-
getCompoundWeightsAt
public float[] getCompoundWeightsAt(int alignmentIndex)
Description copied from interface:Profile
Returns the fraction of eachCompound
in the given column for all compounds inCompoundSet
.
-
getCompoundWeightsAt
public float[] getCompoundWeightsAt(int alignmentIndex, List<C> compounds)
Description copied from interface:Profile
Returns the fraction of eachCompound
in the given column only for compounds in the given list.
-
getIndexOf
public int getIndexOf(C compound)
Description copied from interface:Profile
Searches for the givenCompound
within this alignment profile. Returns column index nearest to the start of the alignment profile, or -1 if not found.
-
getIndicesAt
public int[] getIndicesAt(int alignmentIndex)
Description copied from interface:Profile
Returns the indices in the originalSequence
s corresponding to the given column. All indices are 1-indexed and inclusive.
-
getLastIndexOf
public int getLastIndexOf(C compound)
Description copied from interface:Profile
Searches for the givenCompound
within this alignment profile. Returns column index nearest to the end of the alignment profile, or -1 if not found.
-
getLength
public int getLength()
Description copied from interface:Profile
Returns the number of columns in the alignment profile.
-
getOriginalSequences
public List<S> getOriginalSequences()
Description copied from interface:Profile
-
getSize
public int getSize()
Description copied from interface:Profile
Returns the number of rows in this profile. If anyAlignedSequence
s are circular and overlap within the alignment, the returned size will be greater than the number of sequences, otherwise the numbers will be equal.
-
getSubProfile
public ProfileView<S,C> getSubProfile(Location location)
Description copied from interface:Profile
Returns aProfileView
windowed to contain only the givenLocation
. This only includes theAlignedSequence
s which overlap the location.
-
hasGap
public boolean hasGap(int alignmentIndex)
Description copied from interface:Profile
Returns true if anyAlignedSequence
has a gap at the given index.
-
isCircular
public boolean isCircular()
Description copied from interface:Profile
Returns true if anyAlignedSequence
is circular. If so, sequences may simply wrap around from the end to the start of the alignment or they may contribute multiple overlapping lines to the profile.- Specified by:
isCircular
in interfaceProfile<S extends Sequence<C>,C extends Compound>
- Returns:
- true if any
AlignedSequence
is circular
-
toString
public String toString(int width)
Description copied from interface:Profile
Returns a formatted view of the alignment profile. This shows the start and end indices of the profile and each sequence for each group of lines of the given width. Each line may also be labeled.
-
toString
public String toString(Profile.StringFormat format)
Description copied from interface:Profile
Returns a formatted view of the alignment profile. Details depend on the format given.
-
toString
public String toString()
Description copied from interface:Profile
Returns a simple view of the alignment profile. This shows each sequence on a separate line (or multiple lines, if circular) and nothing more. This should result inProfile.getSize()
lines withProfile.getLength()
Compound
s per line.
-
-