/**************************************************************************
*                                                                         *
*                             COPYRIGHT NOTICE                            *
*                                                                         *
* This software/database is categorized as "United States Government      *
* Work" under the terms of the United States Copyright Act.  It was       *
* produced as part of the author's official duties as a Government        *
* employee and thus can not be copyrighted.  This software/database is    *
* freely available to the public for use without a copyright notice.      *
* Restrictions can not be placed on its present or future use.            *
*                                                                         *
* Although all reasonable efforts have been taken to ensure the accuracy  *
* and reliability of the software and data, the National Library of       *
* Medicine (NLM) and the U.S. Government do not and can not warrant the   *
* performance or results that may be obtained by using this software,     *
* data, or derivative works thereof.  The NLM and the U.S. Government     *
* disclaim any and all warranties, expressed or implied, as to the        *
* performance, merchantability or fitness for any particular purpose or   *
* use.                                                                    *
*                                                                         *
* In any work or product derived from this material, proper attribution   *
* of the author(s) as the source of the software or data would be         *
* appreciated.                                                            *
*                                                                         *
**************************************************************************/
#include <ncbi.h>
#include "blastapp.h"

/*
	fmaxscore(seq, len, maxscore)
	returns the maximum achievable segment score

Note:  effect of BLAST parameter X is not taken into consideration.
*/
Score_t
fmaxscore(seq, len, maxscore)
	register CharPtr	seq;
	register Coord_t	len;
	register Score_t	PNTR maxscore; /* max. score for each letter */
{
	register CharPtr	maxseq;
	register Score_t	sum, maxsum;

	maxseq = seq+len;
	sum = 0;
	maxsum = SCORE_MIN/2;
	while (seq < maxseq) {
		if ((sum += maxscore[*seq++]) > maxsum)
			maxsum = sum;
		if (sum < 0)
			sum = 0;
	}
	return maxsum;
}
