import charite.christo.strap.StrapProtein;
import charite.christo.ByteArray;
import charite.christo.ChUtils;
import charite.christo.CacheResult;
import charite.christo.interfaces.ProteinWriter;
import charite.christo.interfaces.Superimpose3D;
import charite.christo.protein.Matrix3D;
import charite.christo.protein.PDB_Parser;
import charite.christo.protein.ProteinWriter1;
import charite.christo.strap.extensions.Superimpose3D_TM_align;
import java.io.File;
import static java.lang.System.*;
/*
java DemoSuperimpose1 a1_SaccharomycesCerevisiae.pdb hs_EscherichiaColi.pdb
The protein hs_EscherichiaColi.pdb is superimposed on a2_SaccharomycesCerevisiae.
The first protein (reference) is superimposed upon the 2nd (mobile) protein.
The result is a transformation matrix for hs_EscherichiaColi.
The proteins are not changed by the Superimpose3D class.
But with the method Protein#setRotationAndTranslation(Matrix3D) the resulting
transformation can be set to the protein.
*/
public class DemoSuperimpose1 {
public static void main(String[] argv){
/* The cache is located in ~/.StrapAlign/cached/ */
CacheResult.setEnabled(true);
/* prepare both protein objects */
final StrapProtein pReference=StrapProtein.newInstance(new File(argv[0]));
out.println("pReference="+pReference.getResidueTypeAsString());
final StrapProtein pMobile=StrapProtein.newInstance(new File(argv[1]));
out.println("pMobile="+pMobile.getResidueTypeAsString());
/* Initialize the Superimpose3D object with the two proteins to be superimposed */
final Superimpose3D_TM_align sup=new Superimpose3D_TM_align();
sup.setMobileProtein(pMobile);
sup.setReferenceProtein(pReference);
/* start computation */
sup.compute();
/* Obtain the result */
/* The Matrix3D object contains the coordinate transformation (rotation + translatio) */
final Superimpose3D.Result result=sup.getResult();
final Matrix3D transformation= result.toMatrix3D();
/* Print the original coordinates of the mobile protein */
final ByteArray sb=new ByteArray(100*1000)
.append("*********************************************\n")
.append("*** original *** \n");
myPrint(pMobile,sb);
/* Now change the coordinate system of the mobile protein and print the changed coordinates */
pMobile.setRotationAndTranslation(transformation);
sb.append("*** transformed *** \n");
myPrint(pMobile,sb);
out.println(sb);
/* Save the Cache containing computed results */
CacheResult.save();
System.exit(0);
}
/* show only 3 amino acids */
private static void myPrint(StrapProtein p,ByteArray sb) {
final ProteinWriter pw=new ProteinWriter1();
pw.selectResidues(new boolean[]{false,true,true});
pw.toText(p,new Matrix3D[]{p.getRotationAndTranslation()},ProteinWriter.PDB|ProteinWriter.ATOM_LINES,sb);
}
}