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. Every
List
returned is unmodifiable.- Author:
- Mark Chapman, Paolo Pavan
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.biojava.nbio.core.alignment.template.Profile
Profile.StringFormat
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionSimpleProfile
(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
Modifier and TypeMethodDescriptiongetAlignedSequence
(int listIndex) ReturnsAlignedSequence
at given index.getAlignedSequence
(S sequence) Searches for the givenSequence
within this alignment profile.Returns aList
containing the individualAlignedSequence
s of this alignment.getAlignedSequences
(int... listIndices) Returns aList
containing some of the individualAlignedSequence
s of this alignment.getAlignedSequences
(S... sequences) Returns aList
containing some of the individualAlignedSequence
s of this alignment.getCompoundAt
(int listIndex, int alignmentIndex) Returns theCompound
at row of given sequence and column of alignment index.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.getCompoundsAt
(int alignmentIndex) 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
Returns the number of columns in the alignment profile.int
getSize()
Returns the number of rows in this profile.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
Returns true if anyAlignedSequence
is circular.iterator()
toString()
Returns a simple view of the alignment profile.toString
(int width) Returns a formatted view of the alignment profile.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 Details
-
matrix
-
-
Constructor Details
-
SimpleProfile
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
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
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 Details
-
getAlignedSequence
Description copied from interface:Profile
ReturnsAlignedSequence
at given index. -
getAlignedSequence
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
Description copied from interface:Profile
Returns aList
containing the individualAlignedSequence
s of this alignment. -
getAlignedSequences
Description copied from interface:Profile
Returns aList
containing some of the individualAlignedSequence
s of this alignment. -
getAlignedSequences
Description copied from interface:Profile
Returns aList
containing some of the individualAlignedSequence
s of this alignment. -
getCompoundAt
Description copied from interface:Profile
-
getCompoundAt
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
Description copied from interface:Profile
Returns the number of eachCompound
in the given column only for compounds in the given list. -
getCompoundsAt
Description copied from interface:Profile
-
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
Description copied from interface:Profile
Returns the fraction of eachCompound
in the given column only for compounds in the given list. -
getIndexOf
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
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
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
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
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
Description copied from interface:Profile
Returns a formatted view of the alignment profile. Details depend on the format given. -
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. -
iterator
-