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 1, 2006
021 *
022 */
023package org.biojava.nbio.structure.align.pairwise;
024
025import org.biojava.nbio.structure.align.StrucAligParameters;
026import org.biojava.nbio.structure.align.helper.AligMatEl;
027import org.biojava.nbio.structure.jama.Matrix;
028
029public class AligNPE {
030
031        public AligNPE() {
032                super();
033
034        }
035
036        /**
037         * Align without penalizing end-gaps. Return alignment and score
038         *
039         * @param sim the similarity matrix
040         * @param params the structure alignment parameters to be used
041         * @return an Alignable
042         */
043        public static Alignable align_NPE(Matrix sim,StrucAligParameters params){
044                //System.out.println("align_NPE");
045
046                float gapOpen = params.getGapOpen();
047                float gapExtension = params.getGapExtension();
048
049                int rows = sim.getRowDimension();
050                int cols = sim.getColumnDimension();
051
052                Alignable al = new StrCompAlignment(rows,cols);
053                al.setGapExtCol(gapExtension);
054                al.setGapExtRow(gapExtension);
055                al.setGapOpenCol(gapOpen);
056                al.setGapOpenRow(gapOpen);
057                //System.out.println("size of aligmat: " + rows+1 + " " + cols+1);
058                //AligMatEl[][] aligmat = new AligMatEl[rows+1][cols+1];
059                AligMatEl[][] aligmat = al.getAligMat();
060
061                for (int i = 0; i < rows; i++) {
062                        for (int j = 0; j < cols; j++) {
063
064                                int e=0;
065                                //if ( ( i < rows) &&
066                                //        ( j < cols)) {
067                                        //TODO: the ALIGFACTOR calc should be hidden in Gotoh!!
068
069                                e = (int)Math.round(Gotoh.ALIGFACTOR * sim.get(i,j));
070                                //}
071                                //System.out.println(e);
072                                AligMatEl am = new AligMatEl();
073                                am.setValue(e);
074                                //am.setTrack(new IndexPair((short)-99,(short)-99));
075                                aligmat[i+1][j+1] = am;
076
077                        }
078                }
079                //al.setAligMat(aligmat);
080
081                 new Gotoh(al);
082
083                return al;
084        }
085
086
087
088}