/* File: stockace.c * Author: Richard Durbin * Copyright (c) J Thierry-Mieg and R Durbin, 1999 * ------------------------------------------------------------------- * Acedb 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. * or see the on-line version at http://www.gnu.org/copyleft/gpl.txt * ------------------------------------------------------------------- * This file is part of the ACEDB genome database package, written by * Richard Durbin (Sanger Centre, UK) rd@sanger.ac.uk, and * Jean Thierry-Mieg (CRBM du CNRS, France) mieg@kaa.crbm.cnrs-mop.fr * * Description: Analyse the cgcstrn data of Mark Edgley * Run this as part 2 of the script wlex/strains * Stand alone program * Exported functions: * HISTORY: * Last edited: Aug 26 16:37 1999 (fw) * Created: Thu Aug 26 16:34:15 1999 (fw) * CVS info: $Id: stockace.c,v 1.4 1999/09/01 11:27:21 fw Exp $ *------------------------------------------------------------------- */ #include "regular.h" #include "array.h" #include "ace.h" #include static void complain(char * errmess) ; /***********************************************************************/ #define MAXTAG 5 /* Number of tags in the following list */ static char tag[40][36] = { "Stock", "Junk", "splitGenotype", "Males", "Reference_Allele","Genotype" }; enum {STOCK, JUNK, GENOTYPE, MALE, REF , JUNK2 } ; static FILE *input, *outFile, *errFile , *rejectFile ; static int line = 0 ; static Stack stack[MAXTAG] ; static Stack s = 0 ; /* general text stack */ typedef struct { int g; int a; int def ; int ch; int ref ;} FG ; static Array genes = 0 ; static Stack buffer = 0 ; /***********************************************************/ /***********************************************************/ static BOOL matchTag(char *cp, int *jp) { int i = MAXTAG ; while(i--) if(!strcmp(tag[i], cp)) break ; *jp = i ; return (i>=0) ; } /***********************************************************/ static int getObj(void) { int found = 0 , i ; char cutter, *cp ; stackClear(s) ; i = MAXTAG ; while (i--) stackClear(stack[i]) ; pushText(s,"Begin") ; /* avoids first stackMark(s) == 0 */ while (++line, freeread(input)) if(freenext() , cp = freewordcut(" :",&cutter)) { found = 2 ; /* I did get something, I assume it is good ! */ if (!matchTag(cp,&i)) { complain(messprintf("Unknown tag %s", cp)) ; return 1 ; } freenext() ; freestep(':') ; freenext() ; freestep('\"') ; freenext() ; cp = freewordcut("\"",&cutter) ; if (cp) pushText(stack[i], cp) ; } else if(found) /* Allows several empty lines between objects */ break ; /* cleanGenotype() ;*/ return found ; } /***********************************************************************/ static void complain(char * errmess) { Stack sC ; int i ; fprintf (errFile,"line %d : \"%s\" \n", line,errmess) ; for(i=0; i