/* @source freak application ** ** Calculate residue frequencies using sliding window ** ** @author Copyright (C) Alan Bleasby (ableasby@hgmp.mrc.ac.uk) ** @@ ** ** This program is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License ** as published by the Free Software Foundation; either version 2 ** of the License, or (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ******************************************************************************/ #include "emboss.h" /* @prog freak **************************************************************** ** ** Residue/base frequency table or plot ** ******************************************************************************/ int main(int argc, char **argv) { AjPSeqall seqall; AjPSeq seq; AjPFile outf; AjPStr bases = NULL; AjPStr str = NULL; AjBool plot; AjPGraph graph=NULL; AjPGraphdata fgraph=NULL; AjPStr st = NULL; ajint c; ajint pos; ajint end; ajint step; ajint window; ajint t; ajint i; ajint j; ajint k; const char *p; const char *q; float f; float *x = NULL; float *y = NULL; float max = 0.; float min = 0.; embInit("freak", argc, argv); seqall = ajAcdGetSeqall("seqall"); plot = ajAcdGetToggle("plot"); step = ajAcdGetInt("step"); window = ajAcdGetInt("window"); bases = ajAcdGetString("letters"); /* only one will be used - see variable 'plot' */ outf = ajAcdGetOutfile("outfile"); graph = ajAcdGetGraphxy("graph"); st = ajStrNew(); ajStrFmtUpper(&bases); q = ajStrGetPtr(bases); while(ajSeqallNext(seqall, &seq)) { pos = ajSeqallGetseqBegin(seqall); end = ajSeqallGetseqEnd(seqall); str = ajSeqGetSeqCopyS(seq); ajStrFmtUpper(&str); p = ajStrGetPtr(str); c = 0; --pos; --end; t = pos; while(t+window <= end+1) { ++c; t += step; } if(c) { x = (float *) AJALLOC(c * sizeof(float)); y = (float *) AJALLOC(c * sizeof(float)); } for(i=0;i