
org.biojava.nbio.structure.align.BioJavaStructureAlignment Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of biojava-structure Show documentation
Show all versions of biojava-structure Show documentation
The protein structure modules of BioJava.
/*
* BioJava development code
*
* This code may be freely distributed and modified under the
* terms of the GNU Lesser General Public Licence. This should
* be distributed with the code. If you do not have a copy,
* see:
*
* http://www.gnu.org/copyleft/lesser.html
*
* Copyright for this code is held jointly by the individual
* authors. These should be listed in @author doc comments.
*
* For more information on the BioJava project and its aims,
* or to join the biojava-l mailing list, visit the home page
* at:
*
* http://www.biojava.org/
*
* Created on Oct 2, 2009
* Author: Andreas Prlic
*
*/
package org.biojava.nbio.structure.align;
import org.biojava.nbio.structure.Atom;
import org.biojava.nbio.structure.Group;
import org.biojava.nbio.structure.StructureException;
import org.biojava.nbio.structure.StructureTools;
import org.biojava.nbio.structure.align.ce.ConfigStrucAligParams;
import org.biojava.nbio.structure.align.helper.IndexPair;
import org.biojava.nbio.structure.align.model.AFPChain;
import org.biojava.nbio.structure.align.pairwise.AlternativeAlignment;
import org.biojava.nbio.structure.jama.Matrix;
/** Wrapper for the BioJava Structure Alignment Implementation
*
* @author Andreas Prlic
*
*/
public class BioJavaStructureAlignment
implements StructureAlignment {
public static final String algorithmName = "BioJava_structure";
private static final float versionNr = 0.1f;
StrucAligParameters params;
public BioJavaStructureAlignment(){
params = new StrucAligParameters();
}
@Override
public String getAlgorithmName() {
return algorithmName;
}
@Override
public ConfigStrucAligParams getParameters() {
return null;//TODO shall we update it?
}
@Override
public void setParameters(ConfigStrucAligParams o){
//TODO what is the relation between StrucAligParameters and ConfigStrucAligParams?
if ( ! (o instanceof StrucAligParameters)){
throw new IllegalArgumentException("Provided parameters are not of type StrucAligParameters!");
}
params = (StrucAligParameters) o;
}
@Override
public String getVersion() {
return versionNr+"";
}
public String printHelp() {
return "not implemented yet. Algorithm still under development.";
}
@Override
public AFPChain align(Atom[] ca1, Atom[] ca2) throws StructureException {
StrucAligParameters params = StrucAligParameters.getDefaultParameters();
return align(ca1,ca2,params);
}
@Override
public AFPChain align(Atom[] ca1, Atom[] ca2, Object params)
throws StructureException {
if ( ! (params instanceof StrucAligParameters)){
throw new IllegalArgumentException("BioJava structure alignment requires a StrucAligParameters class for the arguments.");
}
this.params = (StrucAligParameters) params;
AFPChain afpChain = new AFPChain(algorithmName);
StructurePairAligner aligner = new StructurePairAligner();
aligner.align(ca1,ca2,this.params);
// copy the results over into the AFPChain...
AlternativeAlignment[] aligs = aligner.getAlignments();
if ( aligs.length > 0){
AlternativeAlignment altAlig = aligs[0];
// copy the results over!
copyResults(afpChain,altAlig,ca1,ca2);
}
return afpChain;
}
private void copyResults(AFPChain afpChain, AlternativeAlignment altAlig, Atom[] ca1, Atom[] ca2) {
afpChain.setAlgorithmName(getAlgorithmName());
afpChain.setVersion(getVersion());
afpChain.setAlignScore(altAlig.getScore());
afpChain.setOptLength(altAlig.getEqr());
afpChain.setBlockRotationMatrix(new Matrix[]{altAlig.getRotationMatrix()});
afpChain.setBlockShiftVector(new Atom[]{altAlig.getShift() });
afpChain.setBlockNum(1);
double rmsd = altAlig.getRmsd();
afpChain.setBlockRmsd(new double[]{rmsd});
int nAtom = altAlig.getEqr();
int lcmp = altAlig.getPath().length;
int[] optLen = new int[]{nAtom};
afpChain.setOptLen(optLen);
afpChain.setOptLength(nAtom);
afpChain.setAlnLength(lcmp);
int[][][] optAln = new int[1][2][lcmp];
afpChain.setOptAln(optAln);
afpChain.setOptRmsd(new double[]{rmsd});
afpChain.setTotalRmsdOpt(rmsd);
afpChain.setChainRmsd(rmsd);
//afpChain.setProbability(-1);
int nse1 = ca1.length;
int nse2 = ca2.length;
char[] alnseq1 = new char[nse1+nse2+1];
char[] alnseq2 = new char[nse1+nse2+1] ;
char[] alnsymb = new char[nse1+nse2+1];
IndexPair[] path = altAlig.getPath();
int pos = 0;
for(int ia=0; ia
© 2015 - 2025 Weber Informatics LLC | Privacy Policy