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 June 30, 2010
021 * Author: Mark Chapman
022 */
023
024package org.biojava.nbio.alignment;
025
026import org.biojava.nbio.core.alignment.template.ProfilePair;
027import org.biojava.nbio.core.alignment.template.Profile;
028import org.biojava.nbio.core.alignment.template.SubstitutionMatrix;
029import org.biojava.nbio.core.alignment.SimpleProfilePair;
030import org.biojava.nbio.alignment.template.*;
031import org.biojava.nbio.core.alignment.template.AlignedSequence.Step;
032import org.biojava.nbio.core.sequence.template.Compound;
033import org.biojava.nbio.core.sequence.template.Sequence;
034
035import java.util.List;
036import java.util.concurrent.Future;
037
038/**
039 * Implements a simple (naive) {@link Aligner} for a pair of {@link Profile}s.  This is basically an extension of the
040 * {@link NeedlemanWunsch} pairwise sequence aligner to pairwise profile alignment using a sum-of-pairs score.
041 *
042 * @author Mark Chapman
043 * @param <S> each {@link Sequence} in the pair of alignment {@link Profile}s is of type S
044 * @param <C> each element of an {@link AlignedSequence} is a {@link Compound} of type C
045 */
046public class SimpleProfileProfileAligner<S extends Sequence<C>, C extends Compound>
047                extends AbstractProfileProfileAligner<S, C> {
048
049        /**
050         * Before running a profile-profile alignment, data must be sent in via calls to
051         * {@link #setQuery(Profile)}, {@link #setTarget(Profile)}, {@link #setGapPenalty(GapPenalty)}, and
052         * {@link #setSubstitutionMatrix(SubstitutionMatrix)}.
053         */
054        public SimpleProfileProfileAligner() {
055        }
056
057        /**
058         * Prepares for a profile-profile alignment.
059         *
060         * @param query the first {@link Profile} of the pair to align
061         * @param target the second {@link Profile} of the pair to align
062         * @param gapPenalty the gap penalties used during alignment
063         * @param subMatrix the set of substitution scores used during alignment
064         */
065        public SimpleProfileProfileAligner(Profile<S, C> query, Profile<S, C> target, GapPenalty gapPenalty,
066                        SubstitutionMatrix<C> subMatrix) {
067                super(query, target, gapPenalty, subMatrix);
068        }
069
070        /**
071         * Prepares for a profile-profile alignment run concurrently.
072         *
073         * @param query the first {@link Profile} of the pair to align, still to be calculated
074         * @param target the second {@link Profile} of the pair to align, still to be calculated
075         * @param gapPenalty the gap penalties used during alignment
076         * @param subMatrix the set of substitution scores used during alignment
077         */
078        public SimpleProfileProfileAligner(Future<ProfilePair<S, C>> query, Future<ProfilePair<S, C>> target,
079                        GapPenalty gapPenalty, SubstitutionMatrix<C> subMatrix) {
080                super(query, target, gapPenalty, subMatrix);
081        }
082
083        /**
084         * Prepares for a profile-profile alignment run concurrently.
085         *
086         * @param query the first {@link Profile} of the pair to align
087         * @param target the second {@link Profile} of the pair to align, still to be calculated
088         * @param gapPenalty the gap penalties used during alignment
089         * @param subMatrix the set of substitution scores used during alignment
090         */
091        public SimpleProfileProfileAligner(Profile<S, C> query, Future<ProfilePair<S, C>> target, GapPenalty gapPenalty,
092                        SubstitutionMatrix<C> subMatrix) {
093                super(query, target, gapPenalty, subMatrix);
094        }
095
096        /**
097         * Prepares for a profile-profile alignment run concurrently.
098         *
099         * @param query the first {@link Profile} of the pair to align, still to be calculated
100         * @param target the second {@link Profile} of the pair to align
101         * @param gapPenalty the gap penalties used during alignment
102         * @param subMatrix the set of substitution scores used during alignment
103         */
104        public SimpleProfileProfileAligner(Future<ProfilePair<S, C>> query, Profile<S, C> target, GapPenalty gapPenalty,
105                        SubstitutionMatrix<C> subMatrix) {
106                super(query, target, gapPenalty, subMatrix);
107        }
108
109        // method for AbstractMatrixAligner
110
111        @Override
112        protected void setProfile(List<Step> sx, List<Step> sy) {
113                profile = pair = new SimpleProfilePair<S, C>(getQuery(), getTarget(), sx, sy);
114        }
115
116}