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 alignmentProfileis of type SC- each element of anAlignedSequenceis aCompoundof 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. EveryListreturned 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.protectedSimpleProfile(AlignedSequence<S,C> query, AlignedSequence<S,C> target)Creates a pair profile for the given already aligned sequences.protectedSimpleProfile(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.protectedSimpleProfile(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)ReturnsAlignedSequenceat given index.AlignedSequence<S,C>getAlignedSequence(S sequence)Searches for the givenSequencewithin this alignment profile.List<AlignedSequence<S,C>>getAlignedSequences()Returns aListcontaining the individualAlignedSequences of this alignment.List<AlignedSequence<S,C>>getAlignedSequences(int... listIndices)Returns aListcontaining some of the individualAlignedSequences of this alignment.List<AlignedSequence<S,C>>getAlignedSequences(S... sequences)Returns aListcontaining some of the individualAlignedSequences of this alignment.CgetCompoundAt(int listIndex, int alignmentIndex)Returns theCompoundat row of given sequence and column of alignment index.CgetCompoundAt(S sequence, int alignmentIndex)Returns theCompoundat row of given sequence and column of alignment index.int[]getCompoundCountsAt(int alignmentIndex)Returns the number of eachCompoundin the given column for all compounds inCompoundSet.int[]getCompoundCountsAt(int alignmentIndex, List<C> compounds)Returns the number of eachCompoundin the given column only for compounds in the given list.List<C>getCompoundsAt(int alignmentIndex)CompoundSet<C>getCompoundSet()ReturnsCompoundSetof allAlignedSequencesfloat[]getCompoundWeightsAt(int alignmentIndex)Returns the fraction of eachCompoundin the given column for all compounds inCompoundSet.float[]getCompoundWeightsAt(int alignmentIndex, List<C> compounds)Returns the fraction of eachCompoundin the given column only for compounds in the given list.intgetIndexOf(C compound)Searches for the givenCompoundwithin this alignment profile.int[]getIndicesAt(int alignmentIndex)Returns the indices in the originalSequences corresponding to the given column.intgetLastIndexOf(C compound)Searches for the givenCompoundwithin this alignment profile.intgetLength()Returns the number of columns in the alignment profile.List<S>getOriginalSequences()intgetSize()Returns the number of rows in this profile.ProfileView<S,C>getSubProfile(Location location)Returns aProfileViewwindowed to contain only the givenLocation.booleanhasGap(int alignmentIndex)Returns true if anyAlignedSequencehas a gap at the given index.booleanisCircular()Returns true if anyAlignedSequenceis circular.Iterator<AlignedSequence<S,C>>iterator()StringtoString()Returns a simple view of the alignment profile.StringtoString(int width)Returns a formatted view of the alignment profile.StringtoString(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 aCompoundor gap at each index of the alignmentxb- number ofCompounds skipped in the query sequence before the aligned regionxa- number ofCompounds skipped in the query sequence after the aligned regionsy- lists whether the target sequence aligns aCompoundor gap at each index of the alignmentyb- number ofCompounds skipped in the target sequence before the aligned regionya- number ofCompounds 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 aCompoundor gap at each index of the alignmentsy- lists whether the target profile aligns aCompoundor 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:ProfileReturnsAlignedSequenceat given index.
-
getAlignedSequence
public AlignedSequence<S,C> getAlignedSequence(S sequence)
Description copied from interface:ProfileSearches for the givenSequencewithin this alignment profile. Returns the correspondingAlignedSequence.- Specified by:
getAlignedSequencein 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:ProfileReturns aListcontaining the individualAlignedSequences of this alignment.
-
getAlignedSequences
public List<AlignedSequence<S,C>> getAlignedSequences(int... listIndices)
Description copied from interface:ProfileReturns aListcontaining some of the individualAlignedSequences of this alignment.
-
getAlignedSequences
public List<AlignedSequence<S,C>> getAlignedSequences(S... sequences)
Description copied from interface:ProfileReturns aListcontaining some of the individualAlignedSequences 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:ProfileReturns theCompoundat row of given sequence and column of alignment index. If the given sequence has overlap, this will return theCompoundfrom the top row of the sequence.- Specified by:
getCompoundAtin interfaceProfile<S extends Sequence<C>,C extends Compound>- Parameters:
sequence- either anAlignedSequenceor an originalSequencealignmentIndex- column index within an alignment- Returns:
- the sequence element
-
getCompoundCountsAt
public int[] getCompoundCountsAt(int alignmentIndex)
Description copied from interface:ProfileReturns the number of eachCompoundin the given column for all compounds inCompoundSet.
-
getCompoundCountsAt
public int[] getCompoundCountsAt(int alignmentIndex, List<C> compounds)
Description copied from interface:ProfileReturns the number of eachCompoundin 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:ProfileReturnsCompoundSetof allAlignedSequences
-
getCompoundWeightsAt
public float[] getCompoundWeightsAt(int alignmentIndex)
Description copied from interface:ProfileReturns the fraction of eachCompoundin the given column for all compounds inCompoundSet.
-
getCompoundWeightsAt
public float[] getCompoundWeightsAt(int alignmentIndex, List<C> compounds)
Description copied from interface:ProfileReturns the fraction of eachCompoundin the given column only for compounds in the given list.
-
getIndexOf
public int getIndexOf(C compound)
Description copied from interface:ProfileSearches for the givenCompoundwithin 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:ProfileReturns the indices in the originalSequences corresponding to the given column. All indices are 1-indexed and inclusive.
-
getLastIndexOf
public int getLastIndexOf(C compound)
Description copied from interface:ProfileSearches for the givenCompoundwithin 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:ProfileReturns 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:ProfileReturns the number of rows in this profile. If anyAlignedSequences 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:ProfileReturns aProfileViewwindowed to contain only the givenLocation. This only includes theAlignedSequences which overlap the location.
-
hasGap
public boolean hasGap(int alignmentIndex)
Description copied from interface:ProfileReturns true if anyAlignedSequencehas a gap at the given index.
-
isCircular
public boolean isCircular()
Description copied from interface:ProfileReturns true if anyAlignedSequenceis 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:
isCircularin interfaceProfile<S extends Sequence<C>,C extends Compound>- Returns:
- true if any
AlignedSequenceis circular
-
toString
public String toString(int width)
Description copied from interface:ProfileReturns 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:ProfileReturns a formatted view of the alignment profile. Details depend on the format given.
-
toString
public String toString()
Description copied from interface:ProfileReturns 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()Compounds per line.
-
-