Class MultipleAlignmentImpl
- java.lang.Object
-
- org.biojava.nbio.structure.align.multiple.AbstractScoresCache
-
- org.biojava.nbio.structure.align.multiple.MultipleAlignmentImpl
-
- All Implemented Interfaces:
Serializable
,Cloneable
,MultipleAlignment
,ScoresCache
public class MultipleAlignmentImpl extends AbstractScoresCache implements Serializable, MultipleAlignment, Cloneable
A general implementation of aMultipleAlignment
.- Since:
- 4.1.0
- Author:
- Aleix Lafita
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MultipleAlignmentImpl()
Default Constructor.MultipleAlignmentImpl(MultipleAlignmentEnsemble ensemble)
Constructor linking to an existing ensemble.MultipleAlignmentImpl(MultipleAlignmentImpl ma)
Copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear the cached scores.MultipleAlignmentImpl
clone()
Creates and returns an identical copy of this alignment, including a deep copy of all constituent BlockSets.List<Integer>
getAlignResCounts()
Returns the number of non null positions (residues) of each structure in the alignment.List<Atom[]>
getAtomArrays()
Returns the array of Atoms for each structure from its parent Ensemble.Block
getBlock(int index)
Returns the Block with the specified index of the MultipleAlignment.List<Block>
getBlocks()
Convenience method to get a List of all Blocks from all BlockSets.BlockSet
getBlockSet(int index)
Returns the BlockSet with the specified index of the MultipleAlignment.List<BlockSet>
getBlockSets()
Returns the BlockSet List of the multiple structure alignment.int
getCoreLength()
Returns the number of aligned residues (columns) without gaps in the alignment: the sum of all BlockSet core lengths.List<Double>
getCoverages()
Returns the coverage of the alignment for each structure in the alignment as a fraction between 0.0 and 1.0.MultipleAlignmentEnsemble
getEnsemble()
Returns the parent Ensemble of the MultipleAlignment.StructureIdentifier
getStructureIdentifier(int index)
Returns the StructureIdentifier associated with the structure index from its parent Ensemble.int
length()
Returns the total number of aligned residues (columns) in the multiple alignment: the sum of all BlockSet lengths.void
setBlockSets(List<BlockSet> blockSets)
Sets the List of BlockSet List of the specified alignment.void
setEnsemble(MultipleAlignmentEnsemble parent)
Set the back-reference to its parent Ensemble.int
size()
Returns the number of aligned structures in the MultipleAlignment.String
toString()
Return a summary of the MultipleAlignment, containing the structures, the lengths and the cached scores.protected void
updateCache()
Updates all cached propertiesprotected void
updateCoreLength()
Force recalculation of the core length (ungapped columns) based on the BlockSet core lengths.protected void
updateLength()
Force recalculation of the length (aligned columns) based on the BlockSet lengths.-
Methods inherited from class org.biojava.nbio.structure.align.multiple.AbstractScoresCache
clone, getScore, getScores, putScore
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.biojava.nbio.structure.align.multiple.ScoresCache
getScore, getScores, putScore
-
-
-
-
Constructor Detail
-
MultipleAlignmentImpl
public MultipleAlignmentImpl()
Default Constructor. Empty alignment. No structures assigned.
-
MultipleAlignmentImpl
public MultipleAlignmentImpl(MultipleAlignmentEnsemble ensemble)
Constructor linking to an existing ensemble. Automatically adds this alignment to the parent ensemble.- Parameters:
ensemble
- parent MultipleAlignmentEnsemble.
-
MultipleAlignmentImpl
public MultipleAlignmentImpl(MultipleAlignmentImpl ma)
Copy constructor. Recursively copies member BlockSets.- Parameters:
ma
- MultipleAlignmentImpl to copy.
-
-
Method Detail
-
clear
public void clear()
Description copied from class:AbstractScoresCache
Clear the cached scores. This frees memory after the alignment changed.- Specified by:
clear
in interfaceMultipleAlignment
- Overrides:
clear
in classAbstractScoresCache
-
clone
public MultipleAlignmentImpl clone()
Description copied from interface:MultipleAlignment
Creates and returns an identical copy of this alignment, including a deep copy of all constituent BlockSets.- Specified by:
clone
in interfaceMultipleAlignment
- Overrides:
clone
in classObject
- Returns:
- MultipleAlignment identical copy of this object.
-
toString
public String toString()
Description copied from interface:MultipleAlignment
Return a summary of the MultipleAlignment, containing the structures, the lengths and the cached scores. Can be used as a header for the differnt display options.- Specified by:
toString
in interfaceMultipleAlignment
- Overrides:
toString
in classObject
- Returns:
- String header summary of the MultipleAlignment
-
getBlockSets
public List<BlockSet> getBlockSets()
Description copied from interface:MultipleAlignment
Returns the BlockSet List of the multiple structure alignment. Initializes the variable if it is null.- Specified by:
getBlockSets
in interfaceMultipleAlignment
- Returns:
- List of BlockSets that describe the aligned residues of all the structures.
- See Also:
MultipleAlignment.getBlocks()
,MultipleAlignment.setBlockSets(List)
-
getBlocks
public List<Block> getBlocks()
Description copied from interface:MultipleAlignment
Convenience method to get a List of all Blocks from all BlockSets. Modifications of this List will not alter the MultipleAlignment, but modifications to the Blocks will.- Specified by:
getBlocks
in interfaceMultipleAlignment
- Returns:
- List of Blocks
- See Also:
MultipleAlignment.getBlockSets()
-
setBlockSets
public void setBlockSets(List<BlockSet> blockSets)
Description copied from interface:MultipleAlignment
Sets the List of BlockSet List of the specified alignment.- Specified by:
setBlockSets
in interfaceMultipleAlignment
- Parameters:
blockSets
- the List of BlockSets that describe the aligned residues.- See Also:
MultipleAlignment.getBlockSets()
-
getBlockSet
public BlockSet getBlockSet(int index)
Description copied from interface:MultipleAlignment
Returns the BlockSet with the specified index of the MultipleAlignment. Throws an Exception if the index is out of bounds, like accessing a normal List.- Specified by:
getBlockSet
in interfaceMultipleAlignment
- Parameters:
index
- of the BlockSet- Returns:
- BlockSets at the specified index
- See Also:
MultipleAlignment.getBlocks()
,MultipleAlignment.getBlockSets()
-
getBlock
public Block getBlock(int index)
Description copied from interface:MultipleAlignment
Returns the Block with the specified index of the MultipleAlignment. Throws an Exception if the index is out of bounds, like accessing a normal List.- Specified by:
getBlock
in interfaceMultipleAlignment
- Parameters:
index
- of the BlockSet- Returns:
- Block at the specified index
- See Also:
MultipleAlignment.getBlocks()
,MultipleAlignment.getBlockSets()
-
getAtomArrays
public List<Atom[]> getAtomArrays()
Description copied from interface:MultipleAlignment
Returns the array of Atoms for each structure from its parent Ensemble. Throws an Exception if the parent ensemble is null or the Atom variables are not previously set.- Specified by:
getAtomArrays
in interfaceMultipleAlignment
- Returns:
- List of Atom arrays
- See Also:
MultipleAlignment.getEnsemble()
-
getStructureIdentifier
public StructureIdentifier getStructureIdentifier(int index)
Description copied from interface:MultipleAlignment
Returns the StructureIdentifier associated with the structure index from its parent Ensemble. Throws an Exception if the parent ensemble is null or the StructureIdentifiers are not previously set.- Specified by:
getStructureIdentifier
in interfaceMultipleAlignment
- Returns:
- StructureIdentifier
- See Also:
MultipleAlignment.getEnsemble()
-
size
public int size()
Description copied from interface:MultipleAlignment
Returns the number of aligned structures in the MultipleAlignment.- Specified by:
size
in interfaceMultipleAlignment
- Returns:
- int number of aligned structures
- See Also:
MultipleAlignment.length()
,MultipleAlignment.getCoreLength()
-
length
public int length()
Description copied from interface:MultipleAlignment
Returns the total number of aligned residues (columns) in the multiple alignment: the sum of all BlockSet lengths.- Specified by:
length
in interfaceMultipleAlignment
- Returns:
- int the total number of aligned residues in the alignment.
- See Also:
MultipleAlignment.getCoreLength()
,MultipleAlignment.size()
-
getCoreLength
public int getCoreLength()
Description copied from interface:MultipleAlignment
Returns the number of aligned residues (columns) without gaps in the alignment: the sum of all BlockSet core lengths.- Specified by:
getCoreLength
in interfaceMultipleAlignment
- Returns:
- int the total number of aligned residues.
- See Also:
MultipleAlignment.length()
,MultipleAlignment.size()
-
updateLength
protected void updateLength()
Force recalculation of the length (aligned columns) based on the BlockSet lengths.
-
updateCoreLength
protected void updateCoreLength()
Force recalculation of the core length (ungapped columns) based on the BlockSet core lengths.
-
updateCache
protected void updateCache()
Updates all cached properties- Throws:
StructureException
-
getEnsemble
public MultipleAlignmentEnsemble getEnsemble()
Description copied from interface:MultipleAlignment
Returns the parent Ensemble of the MultipleAlignment. Returns null if there is no referenced object.- Specified by:
getEnsemble
in interfaceMultipleAlignment
- Returns:
- MultipleAlignmentEnsemble the parent MultipleAlignment of the BlockSet, or null.
- See Also:
MultipleAlignment.setEnsemble(MultipleAlignmentEnsemble)
-
setEnsemble
public void setEnsemble(MultipleAlignmentEnsemble parent)
Description copied from interface:MultipleAlignment
Set the back-reference to its parent Ensemble.Neither removes this alignment from its previous ensemble, if any, nor adds it to the new parent. Calling code should assure that links to and from the ensemble are consistent and free of memory leaks.
- Specified by:
setEnsemble
in interfaceMultipleAlignment
- Parameters:
parent
- the parent MultipleAlignmentEnsemble.- See Also:
MultipleAlignment.getEnsemble()
-
getAlignResCounts
public List<Integer> getAlignResCounts()
Description copied from interface:MultipleAlignment
Returns the number of non null positions (residues) of each structure in the alignment. The values can be used to compute the coverages.- Specified by:
getAlignResCounts
in interfaceMultipleAlignment
- Returns:
- List of residue counts for each structure
-
getCoverages
public List<Double> getCoverages()
Description copied from interface:MultipleAlignment
Returns the coverage of the alignment for each structure in the alignment as a fraction between 0.0 and 1.0.- Specified by:
getCoverages
in interfaceMultipleAlignment
- Returns:
- List coverage for each structure
-
-