001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 * Created on Mar 26, 2010
021 *
022 */
023package demo;
024
025import org.biojava.nbio.structure.Atom;
026import org.biojava.nbio.structure.Structure;
027import org.biojava.nbio.structure.StructureTools;
028import org.biojava.nbio.structure.align.StructureAlignment;
029import org.biojava.nbio.structure.align.StructureAlignmentFactory;
030import org.biojava.nbio.structure.align.gui.StructureAlignmentDisplay;
031import org.biojava.nbio.structure.align.model.AFPChain;
032import org.biojava.nbio.structure.align.seq.SmithWaterman3DParameters;
033import org.biojava.nbio.structure.align.seq.SmithWaterman3Daligner;
034import org.biojava.nbio.structure.align.util.AtomCache;
035
036public class DemoSW3DAligner {
037
038
039
040        public static void main(String[] args){
041
042                String name1 = "1MBN.A";
043                String name2 = "4ODC.A";
044
045                AtomCache cache = new AtomCache();
046
047                Structure structure1 = null;
048                Structure structure2 = null;
049
050                try {
051
052                        StructureAlignment algorithm  = StructureAlignmentFactory.getAlgorithm(SmithWaterman3Daligner.algorithmName);
053
054                        System.out.println("using " + algorithm.getAlgorithmName());
055
056                        SmithWaterman3DParameters params = new SmithWaterman3DParameters();
057
058                        System.out.println("Gap open:" + params.getGapOpen());
059                        System.out.println("Gap extension:" + params.getGapExtend());
060
061                        structure1 = cache.getStructure(name1);
062                        structure2 = cache.getStructure(name2);
063
064                        Atom[] ca1 = StructureTools.getAtomCAArray(structure1);
065                        Atom[] ca2 = StructureTools.getAtomCAArray(structure2);
066
067
068                        AFPChain afpChain = algorithm.align(ca1,ca2,params);
069
070                        afpChain.setName1(name1);
071                        afpChain.setName2(name2);
072
073                        // flexible original results:
074                        System.out.println(afpChain.toFatcat(ca1,ca2));
075
076                        // print rotation matrices
077                        System.out.println(afpChain.toRotMat());
078                        //System.out.println(afpChain.toCE(ca1, ca2));
079
080                        // print XML representation
081                        //System.out.println(AFPChainXMLConverter.toXML(afpChain,ca1,ca2));
082
083                        StructureAlignmentDisplay.display(afpChain, ca1, ca2);
084
085                } catch (Exception e) {
086                        e.printStackTrace();
087                        return;
088                }
089        }
090
091
092}