001/* This class is based on the original FATCAT implementation by
002 * <pre>
003 * Yuzhen Ye & Adam Godzik (2003)
004 * Flexible structure alignment by chaining aligned fragment pairs allowing twists.
005 * Bioinformatics vol.19 suppl. 2. ii246-ii255.
006 * https://www.ncbi.nlm.nih.gov/pubmed/14534198
007 * </pre>
008 *
009 * Thanks to Yuzhen Ye and A. Godzik for granting permission to freely use and redistribute this code.
010 *
011 * This code may be freely distributed and modified under the
012 * terms of the GNU Lesser General Public Licence.  This should
013 * be distributed with the code.  If you do not have a copy,
014 * see:
015 *
016 *      http://www.gnu.org/copyleft/lesser.html
017 *
018 * Copyright for this code is held jointly by the individual
019 * authors.  These should be listed in @author doc comments.
020 *
021 *
022 * Created on Jun 17, 2009
023 * Created by Andreas Prlic - RCSB PDB
024 *
025 */
026
027package org.biojava.nbio.structure.align.fatcat;
028
029import org.biojava.nbio.structure.Atom;
030import org.biojava.nbio.structure.StructureException;
031import org.biojava.nbio.structure.align.StructureAlignment;
032import org.biojava.nbio.structure.align.fatcat.calc.FatCatAligner;
033import org.biojava.nbio.structure.align.fatcat.calc.FatCatParameters;
034import org.biojava.nbio.structure.align.model.AFPChain;
035import org.biojava.nbio.structure.align.util.ConfigurationException;
036
037
038public class FatCat
039{
040
041        /**
042         *  version history:
043         *  1.1 - Added more parameters to the command line
044         *  1.0 - Initial version
045         */
046        public static final String VERSION = "1.1";
047
048        public static String newline = System.getProperty("line.separator");
049
050        FatCatAligner aligner;
051
052        public static final String algorithmName = "jFatCat";
053
054
055        /** See demo/FatCatDemo.java for an example how to run.
056         *
057         * Launch FatCat from command line.
058         *
059         * Parameters are:
060         *
061         * @param argv
062         */
063        public static void main(String[] argv) throws ConfigurationException {
064                FatCatUserArgumentProcessor processor = new FatCatUserArgumentProcessor();
065                processor.process(argv);
066        }
067
068        @Override
069        public String toString(){
070                return "JFatCat v. " + VERSION;
071        }
072
073
074        public AFPChain alignRigid(Atom[] ca1, Atom[] ca2) throws StructureException{
075                StructureAlignment fatCat = new FatCatRigid();
076                return fatCat.align(ca1,ca2);
077        }
078
079        public AFPChain alignRigid(Atom[] ca1, Atom[] ca2, FatCatParameters params) throws StructureException{
080
081                AFPChain afpChain = align(ca1,ca2,params,true);
082                afpChain.setAlgorithmName(FatCatRigid.algorithmName);
083                afpChain.setVersion(VERSION+"");
084                return afpChain;
085        }
086
087        public AFPChain alignFlexible(Atom[] ca1, Atom[] ca2, FatCatParameters params) throws StructureException{
088
089                AFPChain afpChain = align(ca1,ca2,params,false);
090                afpChain.setAlgorithmName(FatCatFlexible.algorithmName);
091                afpChain.setVersion(VERSION+"");
092                return afpChain;
093        }
094
095
096        protected AFPChain align(Atom[] ca1, Atom[] ca2, FatCatParameters params, boolean doRigid) throws StructureException{
097
098                aligner = new FatCatAligner();
099
100                aligner.align(ca1, ca2, doRigid, params);
101
102                return aligner.getAfpChain();
103
104
105        }
106
107        public FatCatAligner getFatCatAligner(){
108                if ( aligner == null)
109                        aligner = new FatCatAligner();
110                return aligner;
111        }
112
113}