public class AlignmentTools extends Object
Current methods: replace optimal alignment, create new AFPChain, format conversion, update superposition, etc.
Modifier and Type | Class and Description |
---|---|
static class |
AlignmentTools.IdentityMap<K>
A Map
|
Modifier and Type | Field and Description |
---|---|
static boolean |
debug |
Constructor and Description |
---|
AlignmentTools() |
Modifier and Type | Method and Description |
---|---|
static Map<Integer,Integer> |
alignmentAsMap(AFPChain afpChain)
Creates a Map specifying the alignment as a mapping between residue indices
of protein 1 and residue indices of protein 2.
|
static void |
alignmentToSIF(Writer out,
AFPChain afpChain,
Atom[] ca1,
Atom[] ca2,
String backboneInteraction,
String alignmentInteraction)
Creates a simple interaction format (SIF) file for an alignment.
|
static <S,T> Map<S,T> |
applyAlignment(Map<S,T> alignmentMap,
Map<T,S> identity,
int k)
Applies an alignment k times.
|
static <T> Map<T,T> |
applyAlignment(Map<T,T> alignmentMap,
int k)
Applies an alignment k times.
|
static int[] |
calculateBlockGap(int[][][] optAln)
Method that calculates the number of gaps in each subunit block of an optimal AFP alignment.
|
static AFPChain |
createAFPChain(Atom[] ca1,
Atom[] ca2,
ResidueNumber[] aligned1,
ResidueNumber[] aligned2)
Fundamentally, an alignment is just a list of aligned residues in each
protein.
|
static Map<Integer,Integer> |
fromConciseAlignmentString(String string) |
static List<List<List<Integer>>> |
getOptAlnAsList(AFPChain afpChain)
Retrieves the optimum alignment from an AFPChain and returns it as a
java collection.
|
static int |
getSymmetryOrder(AFPChain afpChain,
int maxSymmetry,
float minimumMetricChange)
Guesses the order of symmetry in an alignment
|
static int |
getSymmetryOrder(Map<Integer,Integer> alignment,
int maxSymmetry,
float minimumMetricChange)
Helper for
getSymmetryOrder(Map, Map, int, float) with a true
identity function (X->X). |
static int |
getSymmetryOrder(Map<Integer,Integer> alignment,
Map<Integer,Integer> identity,
int maxSymmetry,
float minimumMetricChange)
Tries to detect symmetry in an alignment.
|
static Map<Integer,Integer> |
guessSequentialAlignment(Map<Integer,Integer> alignment,
boolean inverseAlignment)
Takes a potentially non-sequential alignment and guesses a sequential
version of it.
|
static boolean |
isSequentialAlignment(AFPChain afpChain,
boolean checkWithinBlocks)
Checks that the alignment given by afpChain is sequential.
|
static AFPChain |
replaceOptAln(AFPChain afpChain,
Atom[] ca1,
Atom[] ca2,
int blockNum,
int[] optLens,
int[][][] optAln) |
static AFPChain |
replaceOptAln(AFPChain afpChain,
Atom[] ca1,
Atom[] ca2,
Map<Integer,Integer> alignment)
Takes an AFPChain and replaces the optimal alignment based on an alignment map
|
static AFPChain |
replaceOptAln(int[][][] newAlgn,
AFPChain afpChain,
Atom[] ca1,
Atom[] ca2)
It replaces an optimal alignment of an AFPChain and calculates all the new alignment scores and variables.
|
static Object |
resizeArray(Object oldArray,
int newSize)
Reallocates an array with a new size, and copies the contents
of the old array to the new array.
|
static AFPChain |
splitBlocksByTopology(AFPChain a,
Atom[] ca1,
Atom[] ca2) |
static <S,T> String |
toConciseAlignmentString(Map<S,T> alignment,
Map<T,S> identity)
Print an alignment map in a concise representation.
|
static <T> String |
toConciseAlignmentString(Map<T,T> alignment) |
static void |
updateSuperposition(AFPChain afpChain,
Atom[] ca1,
Atom[] ca2)
After the alignment changes (optAln, optLen, blockNum, at a minimum),
many other properties which depend on the superposition will be invalid.
|
public static boolean isSequentialAlignment(AFPChain afpChain, boolean checkWithinBlocks)
AFPChain.isSequentialAlignment()
. However, the AFPChain version
relies on the StructureAlignment algorithm correctly setting this
parameter, which is sadly not always the case.afpChain
- An alignmentcheckWithinBlocks
- Indicates whether individual blocks should be
checked for sequentialitypublic static Map<Integer,Integer> alignmentAsMap(AFPChain afpChain) throws StructureException
For example,
1234 5678becomes
1->5 2->6 3->7 4->8
afpChain
- An alignmentStructureException
- If afpChain is not one-to-onepublic static <T> Map<T,T> applyAlignment(Map<T,T> alignmentMap, int k)
T
- alignmentMap
- The input function, as a map (see alignmentAsMap(AFPChain)
)k
- The number of times to apply the alignmentpublic static <S,T> Map<S,T> applyAlignment(Map<S,T> alignmentMap, Map<T,S> identity, int k)
S
- T
- alignmentMap
- The input function, as a map (see alignmentAsMap(AFPChain)
)identity
- An identity-like function providing the isomorphism between
the codomain of alignmentMap (of type k
- The number of times to apply the alignmentpublic static int getSymmetryOrder(Map<Integer,Integer> alignment, int maxSymmetry, float minimumMetricChange)
getSymmetryOrder(Map, Map, int, float)
with a true
identity function (X->X).
This method should only be used in cases where the two proteins
aligned have identical numbering, as for self-alignments. See
getSymmetryOrder(AFPChain, int, float)
for a way to guess
the sequential correspondence between two proteins.
alignment
- maxSymmetry
- minimumMetricChange
- public static int getSymmetryOrder(Map<Integer,Integer> alignment, Map<Integer,Integer> identity, int maxSymmetry, float minimumMetricChange)
Conceptually, an alignment is a function f:A->B between two sets of integers. The function may have simple topology (meaning that if two elements of A are close, then their images in B will also be close), or may have more complex topology (such as a circular permutation). This function checks alignment against a reference function identity, which should have simple topology. It then tries to determine the symmetry order of alignment relative to identity, up to a maximum order of maxSymmetry.
Details
Considers the offset (in number of residues) which a residue moves
after undergoing n alternating transforms by alignment and
identity. If n corresponds to the intrinsic order of the alignment,
this will be small. This algorithm tries increasing values of n
and looks for abrupt decreases in the root mean squared offset.
If none are found at n<=maxSymmetry, the alignment is reported as
non-symmetric.
alignment
- The alignment to test for symmetryidentity
- An alignment with simple topology which approximates
the sequential relationship between the two proteins. Should map in the
reverse direction from alignment.maxSymmetry
- Maximum symmetry to consider. High values increase
the calculation time and can lead to overfitting.minimumMetricChange
- Percent decrease in root mean squared offsets
in order to declare symmetry. 0.4f seems to work well for CeSymm.For a simple identity function
public static int getSymmetryOrder(AFPChain afpChain, int maxSymmetry, float minimumMetricChange) throws StructureException
Uses getSymmetryOrder(Map alignment, Map identity, int, float)
to determine the the symmetry order. For the identity alignment, sorts
the aligned residues of each protein sequentially, then defines the ith
residues of each protein to be equivalent.
Note that the selection of the identity alignment here is very
naive, and only works for proteins with very good coverage. Wherever
possible, it is better to construct an identity function explicitly
from a sequence alignment (or use an AlignmentTools.IdentityMap
for internally
symmetric proteins) and use getSymmetryOrder(Map, Map, int, float)
.
StructureException
public static Map<Integer,Integer> guessSequentialAlignment(Map<Integer,Integer> alignment, boolean inverseAlignment)
The results of this method are consistent with what one might expect
from an identity function, and are therefore useful with
getSymmetryOrder(Map, Map identity, int, float)
.
12456789 78912345would result in a map
12456789 12345789
alignment
- The non-sequential input alignmentinverseAlignment
- If false, map from structure1 to structure2. If
true, generate the inverse of that map.IllegalArgumentException
- if the input alignment is not one-to-one.public static List<List<List<Integer>>> getOptAlnAsList(AFPChain afpChain)
AFPChain.getOptAln()
, but has the correct size().
List>> aln = getOptAlnAsList(AFPChain afpChain); aln.get(blockNum).get(structureNum={0,1}).get(pos)
afpChain
- public static AFPChain createAFPChain(Atom[] ca1, Atom[] ca2, ResidueNumber[] aligned1, ResidueNumber[] aligned2) throws StructureException
Parameters are filled with defaults (often null) or sometimes calculated.
For a way to modify the alignment of an existing AFPChain, see
replaceOptAln(AFPChain, Atom[], Atom[], Map)
ca1
- CA atoms of the first proteinca2
- CA atoms of the second proteinaligned1
- A list of aligned residues from the first proteinaligned2
- A list of aligned residues from the second protein.
Must be the same length as aligned1.StructureException
- if an error occured during superpositionIllegalArgumentException
- if aligned1 and aligned2 have different
lengthsreplaceOptAln(AFPChain, Atom[], Atom[], Map)
public static AFPChain splitBlocksByTopology(AFPChain a, Atom[] ca1, Atom[] ca2) throws StructureException
a
- ca1
- ca2
- StructureException
- if an error occurred during superpositionpublic static AFPChain replaceOptAln(int[][][] newAlgn, AFPChain afpChain, Atom[] ca1, Atom[] ca2) throws StructureException
StructureException
public static AFPChain replaceOptAln(AFPChain afpChain, Atom[] ca1, Atom[] ca2, Map<Integer,Integer> alignment) throws StructureException
Parameters are filled with defaults (often null) or sometimes calculated.
For a way to create a new AFPChain, see
createAFPChain(Atom[], Atom[], ResidueNumber[], ResidueNumber[])
afpChain
- The alignment to be modifiedalignment
- The new alignment, as a MapStructureException
- if an error occurred during superpositioncreateAFPChain(Atom[], Atom[], ResidueNumber[], ResidueNumber[])
public static AFPChain replaceOptAln(AFPChain afpChain, Atom[] ca1, Atom[] ca2, int blockNum, int[] optLens, int[][][] optAln) throws StructureException
afpChain
- Input afpchain. UNMODIFIEDca1
- ca2
- optLens
- optAln
- StructureException
- if an error occured during superpositionpublic static void updateSuperposition(AFPChain afpChain, Atom[] ca1, Atom[] ca2) throws StructureException
afpChain
- ca1
- ca2
- Second set of ca atoms. Will be modified based on the superpositionStructureException
CECalculator#calc_rmsd(Atom[], Atom[], int, boolean)}
contains much of the same code, but stores results in a CECalculator
instance rather than an AFPChain
public static Object resizeArray(Object oldArray, int newSize)
oldArray
- the old array, to be reallocated.newSize
- the new array size.public static <S,T> String toConciseAlignmentString(Map<S,T> alignment, Map<T,S> identity)
Note that more concise representations may be possible.
Examples:alignment
- The input function, as a map (see alignmentAsMap(AFPChain)
)identity
- An identity-like function providing the isomorphism between
the codomain of alignment (of type public static <T> String toConciseAlignmentString(Map<T,T> alignment)
toConciseAlignmentString(Map, Map)
public static Map<Integer,Integer> fromConciseAlignmentString(String string)
toConciseAlignmentString(Map, Map)
public static int[] calculateBlockGap(int[][][] optAln)
public static void alignmentToSIF(Writer out, AFPChain afpChain, Atom[] ca1, Atom[] ca2, String backboneInteraction, String alignmentInteraction) throws IOException
out
- Stream to write toafpChain
- alignment to writeca1
- First protein, used to generate node namesca2
- Second protein, used to generate node namesbackboneInteraction
- Two-letter string used to identify backbone edgesalignmentInteraction
- Two-letter string used to identify alignment edgesIOException
Copyright © 2000–2016 BioJava. All rights reserved.