ACNUC C query API example

#include "dir_acnuc.h"        /* these are necessary includes */
#include "requete_acnuc.h"

int main(int argc, char **argv)
char requete[100], message[100], nom_liste[20];
char ligne[100], sequence[100];
int numliste, total, *debut_liste, num, erreur, lu, slength, debut;
char *protein;

/* initialize access to the acnuc database
environment variables acnuc and gcgacnuc should be defined

while( TRUE ) {
/* ask for a list name and for a query */
	printf("\List name? (or stop) "); gets(nom_liste);
	if( strcmp(nom_liste, "stop") == 0) break;
	printf("Query? " ); gets(requete);
/* evaluate the query */
	erreur = proc_requete(requete, message, nom_liste, &numliste);
	if(erreur) {
/* display the nature of error and its location in the query */
		printf("Error message:\n%s\n\n",message);
/* get the number of seqs selected by the query */
	total = defllen[numliste];
	printf("\nNbr of selected sequences = %d\n", total);
/* this while construct loops for all selected sequences
[it is interrupted after 10 sequences here] */
	debut_liste = defbitlist + numliste*lenw;
	num = 1; total = 0;
	while( (num = irbit(debut_liste, num, nseq)) != 0 ) {
/* num is the rank in ACNUC of the processed sequence */
		if(total > 10 ) {
			printf("\n.... etc ....\n");
/* get the length of this sequence */
		readsub(num); slength = psub->length;
		printf("\nName: %.16s Length: %d\n", psub->name, slength);
/* get a short description of the seq */
		short_descr(num, ligne, sizeof(ligne)-1);
		printf("Short description :\n%s\n",ligne);
/* access to the sequence itself through function gfrag:
	1st arg = rank of the seq
	2nd arg = number in seq of the 1st desired base (conting from 1)
	3rd arg = number of desired bases (can be large or small)
	4th arg = charcater string to be loaded with bases read
	return value = nbr of effectively read bases; 
		can be < arg3 when seq end was reached
		lu = gfrag(num, 1, 60, sequence);
		"The %d first bases of the sequence:\n%s\n", lu, sequence);
		debut = slength - 59; if(debut < 1) debut = 1;
		lu = gfrag(num, debut, 60, sequence);
		"The  %d last bases of the sequence:\n%s\n", lu, sequence);
Function  translate_cds translates to dynamically allocated memory
using the adequate genetic code all of the sequence of rank num and returns the string.
The start codon is specially translated according to the adequate genetic code.
The last codon is translated as '*' if it is a stop codon
la traduction du codon initiateur est faite selon le code genetique adequat
		protein = translate_cds(num);
		printf("Translation of the first 10 codons\n");
		printf("%.10s\n\n", protein);
	free_list(numliste); /* release memory */
return 0;