#include <ncbi.h>
#include <gishlib.h>
#include "blastapp.h"

BLAST_StrPtr LIBCALL
revcomp(sp)
	BLAST_StrPtr	sp;
{
	BLAST_StrPtr	sprc;
	register size_t	len;
	register BLAST_LetterPtr	s, t, map;

	map = BlastAlphaMapFind(sp->ap, sp->ap)->map;

	sprc = BlastStrNew(sp->len, sp->ap, 1);
	if (sprc == NULL)
		return sprc;

	sprc->frame = -sp->frame;
	sprc->offset = sp->offset;
	sprc->fulllen = sp->fulllen;
	s = sp->str;
	t = sprc->str;
	len = sprc->len = sprc->enclen = sp->len;
	sprc->efflen = sp->efflen;
	sprc->str[len] = sp->ap->sentinel;
	while (len-- > 0)
		t[len] = map[*s++];

	return sprc;
}
