Esempio n. 1
0
AjBool ajWriteline(AjPFile file, const AjPStr line)
{
    if(!fwrite(MAJSTRGETPTR(line), MAJSTRGETLEN(line), 1, file->fp))
        return ajFalse;

    return ajTrue;
}
Esempio n. 2
0
void ajXmlClear(AjPXml xml)
{
    if(MAJSTRGETLEN(xml->Id))
        ajStrSetClear(&xml->Id);

    if(MAJSTRGETLEN(xml->Db))
        ajStrSetClear(&xml->Db);

    if(MAJSTRGETLEN(xml->Setdb))
        ajStrSetClear(&xml->Setdb);

    if(MAJSTRGETLEN(xml->Full))
        ajStrSetClear(&xml->Full);

    if(MAJSTRGETLEN(xml->Qry))
        ajStrSetClear(&xml->Qry);

    if(MAJSTRGETLEN(xml->Formatstr))
        ajStrSetClear(&xml->Formatstr);

    if(MAJSTRGETLEN(xml->Filename))
        ajStrSetClear(&xml->Filename);

    ajStrDel(&xml->TextPtr);

    xml->Count = 0;
    xml->Fpos = 0L;
    xml->Format = 0;

    if(xml->Doc)
        ajDomDocumentDestroyNode(xml->Doc, &xml->Doc);

    return;
}
Esempio n. 3
0
AjBool ajWritelineNewline(AjPFile file, const AjPStr line)
{
    if(!fwrite(MAJSTRGETPTR(line), 1, MAJSTRGETLEN(line), file->fp))
        return ajFalse;

#ifdef WIN32
    if(!fwrite("\r\n", 1, 2, file->fp))
        return ajFalse;
#else
    if(!fwrite("\n", 1, 1, file->fp))
        return ajFalse;
#endif

    return ajTrue;
}
Esempio n. 4
0
void ajRefseqClear(AjPRefseq refseq)
{
    AjPSeqRange tmprange = NULL;

    if(MAJSTRGETLEN(refseq->Id))
       ajStrSetClear(&refseq->Id);

    if(MAJSTRGETLEN(refseq->Db))
       ajStrSetClear(&refseq->Db);

    if(MAJSTRGETLEN(refseq->Setdb))
       ajStrSetClear(&refseq->Setdb);

    if(MAJSTRGETLEN(refseq->Full))
       ajStrSetClear(&refseq->Full);

    if(MAJSTRGETLEN(refseq->Qry))
       ajStrSetClear(&refseq->Qry);

    if(MAJSTRGETLEN(refseq->Formatstr))
       ajStrSetClear(&refseq->Formatstr);

    if(MAJSTRGETLEN(refseq->Filename))
       ajStrSetClear(&refseq->Filename);

    ajStrDel(&refseq->TextPtr);

    ajStrDel(&refseq->Desc);
    ajStrDel(&refseq->Seq);

    while(ajListPop(refseq->Seqlist,(void **)&tmprange))
	ajSeqrangeDel(&tmprange);

    ajListFree(&refseq->Seqlist);

    refseq->Count = 0;
    refseq->Fpos = 0L;
    refseq->Format = 0;

    return;
}
Esempio n. 5
0
/* @funcstatic sigscanlig_WriteFastaHit ***************************************
**
** Write a Hit from a Hitlist object to an output file in embl-like format
** (see documentation for the DOMAINATRIX "seqsearch" application).
** Text for Class, Fold, Superfamily and Family is only written if the text
** is available.
** 
** @param [u] outf [AjPFile] Output file stream
** @param [r] hits [const AjPList] List of hit objects.
** @param [r] n  [ajint] Number of hit to generate.
** @param [r] DOSEQ  [AjBool] True if sequence is to be printed. 
**
** @return [AjBool] True on success
** @@
******************************************************************************/
AjBool sigscanlig_WriteFastaHit(AjPFile outf, AjPList hits, ajint n,
				AjBool DOSEQ)
{
/* AjBool sigscanlig_WriteFastaHit(AjPFile outf, AjPList siglist,
                                   AjPList hits, ajint n, AjBool DOSEQ) */
    EmbPHit hit       = NULL;
    EmbPSignature sig = NULL;
    
    /* EmbPSignature *sigarr = NULL; */
    EmbPHit *hitarr = NULL;
    ajint  sizarr=0;
    
        
/*    if(!outf || !siglist || !hits)
	return ajFalse; */

    if(!outf || !hits)
	return ajFalse;

    
    /* sizarr = ajListToarray(siglist, (void ***) &sigarr);
    if(sizarr != ajListToarray(hits, (void ***) &hitarr))
       ajFatal("Arrays are different sizes"); */
        
    sizarr = ajListToarray(hits, (void ***) &hitarr);
    

    if(n>=sizarr)
	ajFatal("Requested hit out of range in sigscanlig_WriteFastaHit");
    
    
    hit = hitarr[n];
    sig = hitarr[n]->Sig;
        
    /* sig = sigarr[n]; */
    
    ajFmtPrintF(outf, "> ");
    
    if(MAJSTRGETLEN(hit->Acc))
	ajFmtPrintF(outf, "%S^", hit->Acc);
    else
	ajFmtPrintF(outf, ".^");
    
    if(MAJSTRGETLEN(hit->Spr))
	ajFmtPrintF(outf, "%S^", hit->Spr);
    else
	ajFmtPrintF(outf, ".^");
    
    ajFmtPrintF(outf, "%d^%d^", hit->Start, hit->End);
    
    ajFmtPrintF(outf, "LIGAND^");
    
    if(MAJSTRGETLEN(sig->Id))
	ajFmtPrintF(outf, "%S^", sig->Id);
    else
	ajFmtPrintF(outf, ".^");
    
    if(MAJSTRGETLEN(sig->Domid))
	ajFmtPrintF(outf, "%S^", sig->Domid);
    else
	ajFmtPrintF(outf, ".^");
    
    if(MAJSTRGETLEN(sig->Ligid))
	ajFmtPrintF(outf, "%S^", sig->Ligid);
    else
	ajFmtPrintF(outf, ".^");
    
    ajFmtPrintF(outf,"%d^", sig->sn);
    ajFmtPrintF(outf,"%d^", sig->ns);
    ajFmtPrintF(outf,"%d^", sig->pn);
    ajFmtPrintF(outf,"%d^", sig->np);
    
    if(sig->Typesig == aj1D)
	ajFmtPrintF(outf,"1D");
    else if(sig->Typesig == aj3D)
	ajFmtPrintF(outf,"3D");
    else
	ajFatal("Signature type unknown in sigscanlig_WriteFasta");
    
    if(sig->np)
	ajFmtPrintF(outf,"P^");
    else
	ajFmtPrintF(outf,"F^");
    
    ajFmtPrintF(outf, "%.2f^", hit->Score);
    
    ajFmtPrintF(outf, "%.3e^", hit->Pval);
    
    ajFmtPrintF(outf, "%.3e", hit->Eval);
    
    if(DOSEQ)
    {
	ajFmtPrintF(outf, "\n");
	ajFmtPrintF(outf, "%S\n", hit->Seq);
    }
    
/*    AJFREE(sigarr); */
    AJFREE(hitarr);
    
    
    return ajTrue;
}
Esempio n. 6
0
AjBool sigscanlig_WriteFasta(AjPFile outf, AjPList hits)
{
    ajint x = 0;
    
    EmbPHit hit       = NULL;
    EmbPSignature sig = NULL;
    
    EmbPSignature *sigarr = NULL;
    EmbPHit *hitarr = NULL;
    ajint  sizarr=0;
    
        
    /* 
    if(!outf || !siglist || !hits)
	return ajFalse;
	*/

    if(!outf || !hits)
	return ajFalse;

    
    /*
    sizarr = ajListToarray(siglist, (void ***) &sigarr);
    if(sizarr != ajListToarray(hits, (void ***) &hitarr))
	ajFatal("Arrays are different sizes");
      */  

    sizarr = ajListToarray(hits, (void ***) &hitarr);
    

    for(x=0; x<sizarr; x++)
    {
	/* There has to be a hit for each signature for correct
	   generation of the LHF by sigscanlig_WriteFasta. Therefore
	   empty hits may have been pushed.  Catch those here. */
	/* if(!MAJSTRGETLEN(hit->Model))
	    continue; */
	
	hit = hitarr[x];
	/* sig = sigarr[x]; */
	sig = hitarr[x]->Sig;	


	ajFmtPrintF(outf, "> ");
	
	if(MAJSTRGETLEN(hit->Acc))
	    ajFmtPrintF(outf, "%S^", hit->Acc);
	else
	    ajFmtPrintF(outf, ".^");

	if(MAJSTRGETLEN(hit->Spr))
	    ajFmtPrintF(outf, "%S^", hit->Spr);
	else
	    ajFmtPrintF(outf, ".^");

	ajFmtPrintF(outf, "%d^%d^", hit->Start, hit->End);
	
	ajFmtPrintF(outf, "LIGAND^");
	
	if(MAJSTRGETLEN(sig->Id))
	    ajFmtPrintF(outf, "%S^", sig->Id);
	else
	    ajFmtPrintF(outf, ".^");

	if(MAJSTRGETLEN(sig->Domid))
	    ajFmtPrintF(outf, "%S^", sig->Domid);
	else
	    ajFmtPrintF(outf, ".^");

	if(MAJSTRGETLEN(sig->Ligid))
	    ajFmtPrintF(outf, "%S^", sig->Ligid);
	else
	    ajFmtPrintF(outf, ".^");

	ajFmtPrintF(outf,"%d^", sig->sn);
	ajFmtPrintF(outf,"%d^", sig->ns);
	ajFmtPrintF(outf,"%d^", sig->pn);
	ajFmtPrintF(outf,"%d^", sig->np);
	
	if(sig->Typesig == aj1D)
	    ajFmtPrintF(outf,"1D");
	else if(sig->Typesig == aj3D)
	    ajFmtPrintF(outf,"3D");
	else
	    ajFatal("Signature type unknown in sigscanlig_WriteFasta");
	
	if(sig->np)
	    ajFmtPrintF(outf,"P^");
	else
	    ajFmtPrintF(outf,"F^");

	ajFmtPrintF(outf, "%.2f^", hit->Score);

	ajFmtPrintF(outf, "%.3e^", hit->Pval);

	ajFmtPrintF(outf, "%.3e", hit->Eval);

	ajFmtPrintF(outf, "\n");
	ajFmtPrintF(outf, "%S\n", hit->Seq);
    }
    
    AJFREE(sigarr);
    AJFREE(hitarr);
    
    
    return ajTrue;
}
Esempio n. 7
0
static AjBool sigscanlig_SignatureAlignWriteBlock(AjPFile outf,
						  AjPList hits)

/*
static AjBool sigscanlig_SignatureAlignWriteBlock(AjPFile outf,
						  AjPList siglist, 
						  AjPList hits)
*/

{
    /*
    ** A line of the alignment (including accession number, a space and the 
    ** sequence) in the output file is 70 characters long. An index number is 
    ** also printed after this 70 character field.
    */
    ajint  wid1  = 0;    /*Temp. width of Accession Number */
    ajint  mwid1 = 0;    /*
			 ** Max. width of Accession Number or the string
			 ** "Number". 
			 ** This is the field width the accession numbers
			 ** will be  printed into
			 */
    ajint  mwid2 = 0;    /* Width of region to print sequence into */
    ajint  len   = 0;    /* Temp. length of sequence */
    ajint  mlen  = 0;    /* Max. length of sequence */
    const char   *ptrp = NULL; /* Pointer to sequence string */ 
    const char   *ptrs = NULL; /* Pointer to alignment string */ 
    ajint  idx   = 0;    /* Start position for printing */
    ajint  niter = 0;    /*
			 ** No. iterations of loop for printing out
			 ** sequence blocks
			 */
    ajint  fwid1 = 70;   /*
			 ** Including accession number, a space, 7 characters 
			 ** for the first index number, and the sequence
			 */
    ajint  fwid2 = 7;    /* Field width for the first index number */
    ajint  num   = 0;    /* Index number for alignment */
    ajint  y     = 0;    /* Loop counter */

    AjIList iter    = NULL;	
    AjIList itersig = NULL;
    EmbPHit hit = NULL;
    ajint hitcnt=0;      /* Counter for current hit */
    AjPStr label = NULL;
    


    /* Check args */
/*    if(!outf || !hits || !siglist)
	return ajFalse; */

    if(!outf || !hits)
	return ajFalse;


    /* Cycle through hits to find longest width of accession number. */
    len=0;
    mlen=0;	
    wid1=0;
    mwid1=0;
    label = ajStrNew();
    
	
    iter = ajListIterNew(hits);
    while((hit = (EmbPHit) ajListIterGet(iter)))
    {
	if((wid1=MAJSTRGETLEN(hit->Sig->Ligid))>mwid1)
	    mwid1 = wid1; 
	if((len=MAJSTRGETLEN(hit->Seq))>mlen)
	    mlen = len;
    }
    ajListIterDel(&iter);
    ajListIterDel(&itersig);



    /* Assign field widths and number of iterations for printing. */
    if((wid1 = strlen("SIGNATURE"))>mwid1)
	mwid1 = wid1;
    mwid1++;   /* A space */
    mwid1 += 8;  /* 2 underscores + 2 integers in 3 char spacing each. */
    mwid2 = fwid1-fwid2-mwid1;
    niter = (ajint)ceil( ((double)mlen/(double)mwid2));
    

    /* Print header info and SCOP classification records of signature */
    ajFmtPrintF(outf,
		"# DE   Alignment of query sequence against library of "
		"signatures\n");

    
    /* Main loop for printing alignment. */
    iter = ajListIterNew(hits);
    while((hit = (EmbPHit) ajListIterGet(iter)))
    {
	/* Get pointer to sequence & alignment string. */
	ptrp = ajStrGetPtr(hit->Seq);
	ptrs = ajStrGetPtr(hit->Alg);

	/* Print spacer */
	ajFmtPrintF(outf, "# XX\n");

	ajFmtPrintF(outf, "# ");
	/*	if((!sigscanlig_WriteFastaHit(outf, siglist, hits,
                                              hitcnt, ajFalse)))
		ajFatal("Bad args to sigscanlig_WriteFasta"); */

	if((!sigscanlig_WriteFastaHit(outf, hits, hitcnt, ajFalse)))
	    ajFatal("Bad args to sigscanlig_WriteFasta");
	ajFmtPrintF(outf, "\n# XX\n");

	/* Loop for each protein in Hitlist. */
	for(num=0, idx=0, y=0;y<niter;y++)
	{
	    num+=mwid2;


	    ajFmtPrintS(&label, "%S_%d_%d",
			hit->Sig->Ligid, hit->Sig->sn, hit->Sig->pn);
	    

	    /* There is some of the sequence left to print. */
	    if(idx<MAJSTRGETLEN(hit->Seq))
	    {
		ajFmtPrintF(outf,"%-*S%-*d%-*.*s %d\n", 
			    mwid1, hit->Acc, fwid2, 
			    (num-mwid2+1), mwid2, mwid2, ptrp+idx, num);
		ajFmtPrintF(outf,"%-*S%-*c%-*.*s\n", 
			    mwid1, label, fwid2, '-', mwid2, 
			    mwid2, ptrs+idx);
	    }	
	    /* Printed all the sequence already. */
	    else
	    {
		ajFmtPrintF(outf,"%-*S%-*d%-*.*s %d\n", 
			    mwid1, hit->Acc, fwid2,  
			    (num-mwid2+1), mwid2, mwid2, ".", num);
		ajFmtPrintF(outf,"%-*S%-*c%-*.*s\n", 
			    mwid1, label, fwid2, '-', mwid2, 
			    mwid2, "." );
	    }
	    idx += mwid2;
	}

	hitcnt++;
    }	 
    ajListIterDel(&iter);
    ajListIterDel(&itersig);
    ajStrDel(&label);
    

    return ajTrue;
}
Esempio n. 8
0
void ajResourceClear(AjPResource resource)
{
    AjPReslink lnk = NULL;
    AjPResquery qry = NULL;
    AjPResterm resterm = NULL;
    AjPStr ptr = NULL;

    if(MAJSTRGETLEN(resource->Id))
       ajStrSetClear(&resource->Id);

    if(ajListGetLength(resource->Idalt)) 
        while(ajListstrPop(resource->Idalt,&ptr))
            ajStrDel(&ptr);

    if(MAJSTRGETLEN(resource->Acc))
       ajStrSetClear(&resource->Acc);

    if(MAJSTRGETLEN(resource->Name))
       ajStrSetClear(&resource->Name);

    if(MAJSTRGETLEN(resource->Desc))
       ajStrSetClear(&resource->Desc);

    if(MAJSTRGETLEN(resource->Url))
       ajStrSetClear(&resource->Url);

    if(MAJSTRGETLEN(resource->Urllink))
       ajStrSetClear(&resource->Urllink);

    if(MAJSTRGETLEN(resource->Urlrest))
       ajStrSetClear(&resource->Urlrest);

    if(MAJSTRGETLEN(resource->Urlsoap))
       ajStrSetClear(&resource->Urlsoap);

    if(ajListGetLength(resource->Cat))
        while(ajListstrPop(resource->Cat,&ptr))
            ajStrDel(&ptr);

    if(ajListGetLength(resource->Taxon))
        while(ajListPop(resource->Taxon,(void**)&resterm))
            ajRestermDel(&resterm);

    if(ajListGetLength(resource->Edamdat))
        while(ajListPop(resource->Edamdat,(void**)&resterm))
            ajRestermDel(&resterm);

    if(ajListGetLength(resource->Edamfmt))
        while(ajListPop(resource->Edamfmt,(void**)&resterm))
            ajRestermDel(&resterm);

    if(ajListGetLength(resource->Edamid))
        while(ajListPop(resource->Edamid,(void**)&resterm))
            ajRestermDel(&resterm);

    if(ajListGetLength(resource->Edamtpc))
        while(ajListPop(resource->Edamtpc,(void**)&resterm))
            ajRestermDel(&resterm);

    if(ajListGetLength(resource->Xref))
        while(ajListPop(resource->Xref,(void**)&lnk))
            ajReslinkDel(&lnk);

    if(ajListGetLength(resource->Query))
        while(ajListPop(resource->Query,(void**)&qry))
            ajResqueryDel(&qry);

    if(ajListGetLength(resource->Example))
        while(ajListstrPop(resource->Example,&ptr))
            ajStrDel(&ptr);

    if(MAJSTRGETLEN(resource->Db))
       ajStrSetClear(&resource->Db);

    if(MAJSTRGETLEN(resource->Setdb))
       ajStrSetClear(&resource->Setdb);

    if(MAJSTRGETLEN(resource->Full))
       ajStrSetClear(&resource->Full);

    if(MAJSTRGETLEN(resource->Qry))
       ajStrSetClear(&resource->Qry);

    if(MAJSTRGETLEN(resource->Formatstr))
       ajStrSetClear(&resource->Formatstr);

    if(MAJSTRGETLEN(resource->Filename))
       ajStrSetClear(&resource->Filename);

    ajStrDel(&resource->TextPtr);

    resource->Count = 0;
    resource->Fpos = 0L;
    resource->Format = 0;

    return;
}
Esempio n. 9
0
AjPMatrixf ajMatrixfNewFile(const AjPStr filename)
{
    AjPMatrixf ret = NULL;
    AjPStr *orderstring = NULL;
    AjPStr buffer       = NULL;
    AjPStr firststring  = NULL;
    AjPStr reststring   = NULL;
    const AjPStr tok    = NULL;

    ajint len  = 0;
    ajint i    = 0;
    ajint l    = 0;
    ajint k    = 0;
    ajint cols = 0;
    ajint rows   = 0;
    
    const char *ptr = NULL;

    AjPFile file    = NULL;
    AjBool  first   = ajTrue;

    float **matrix  = NULL;
    float *templine = NULL;
    float minval    = -1.0;

    AjPList rlabel_list = NULL;
    AjPStr  *rlabel_arr  = NULL;
#ifndef WIN32
    static const char *delimstr = " :\t\n";
#else
    static const char *delimstr = " :\t\n\r";
#endif



    rlabel_list = ajListNew();
    

    
    firststring = ajStrNew();
    reststring  = ajStrNew();

    file = ajDatafileNewInNameS(filename);
    
    if(!file)
    {
	ajStrDel(&firststring);
	ajStrDel(&reststring);

	return NULL;
    }
    

    /* Read row labels */
    while(ajReadline(file,&buffer))
    {
	ptr = ajStrGetPtr(buffer);
#ifndef WIN32
	if(*ptr != '#' && *ptr != '\n')
#else
	if(*ptr != '#' && *ptr != '\n' && *ptr != '\r')
#endif
	{	
	    if(first)
		first = ajFalse;
	    else
	    {
		ajFmtScanC(ptr, "%S", &firststring);
		ajListPushAppend(rlabel_list, firststring);
		firststring = ajStrNew();
	    }
	}
    }
    first = ajTrue;
    ajStrDel(&firststring);
    rows = ajListToarray(rlabel_list, (void ***) &rlabel_arr);
    ajFileSeek(file, 0, 0);


    while(ajReadline(file,&buffer))
    {
	ajStrRemoveWhiteExcess(&buffer);
	ptr = ajStrGetPtr(buffer);

	if(*ptr && *ptr != '#')
	{				
	    if(first)
	    {
		cols = ajStrParseCountC(buffer,delimstr);
		AJCNEW0(orderstring, cols);

		for(i=0; i<cols; i++)   
		    orderstring[i] = ajStrNew();

		tok = ajStrParseC(buffer, " :\t\n");
		ajStrAssignS(&orderstring[l++], tok);

		while((tok = ajStrParseC(NULL, " :\t\n")))
		    ajStrAssignS(&orderstring[l++], tok);

		first = ajFalse;

		ret = ajMatrixfNewAsym(orderstring, cols, 
						 rlabel_arr, rows, 
						 filename);
		matrix = ret->Matrixf;
	    }
	    else
	    {
		ajFmtScanC(ptr, "%S", &firststring);
		/* JISON 19/7/4 
		   k = ajSeqcvtGetCodeK(ret->Cvt,
                   ajStrGetCharFirst(firststring)); */
		k = ajSeqcvtGetCodeS(ret->Cvt, firststring); 

		len = MAJSTRGETLEN(firststring);
		ajStrAssignSubC(&reststring, ptr, len, -1);

		/* 
		** Must discard the first string (label) and use 
		** reststring otherwise ajArrFloatLine would fail (it 
		** cannot convert a string to a float)
		**   
		** Use cols,1,cols in below because although 2nd and 
		** subsequent lines have one more string in them (the
		** residue label in the 1st column) we've discarded that
		** from the string that's passed
		*/
		templine = ajArrFloatLine(reststring,delimstr,1,cols);
		
		for(i=0; i<cols; i++)  
		{
		    if(templine[i] < minval) 
			minval = templine[i];

		    /* JISON 19/7/4
		    matrix[k][ajSeqcvtGetCodeK(ret->Cvt,
					ajStrGetCharFirst(orderstring[i]))] 
					    = templine[i]; */

		    matrix[k][ajSeqcvtGetCodeAsymS(ret->Cvt,
					       orderstring[i])] 
						   = templine[i];
		}
		AJFREE(templine);
	    }
	}
    }
    ajDebug("fill rest with minimum value %d\n", minval);
    

    ajFileClose(&file);
    ajStrDel(&buffer);

    for(i=0; i<cols; i++)   
	ajStrDel(&orderstring[i]);

    AJFREE(orderstring);


    ajDebug("read matrix file %S\n", filename);
    
    ajStrDel(&firststring);
    ajStrDel(&reststring);

   for(i=0; i<rows; i++)   
	ajStrDel(&rlabel_arr[i]);

   AJFREE(rlabel_arr);
   ajListFree(&rlabel_list);

   return ret;
}
Esempio n. 10
0
int main(ajint argc, char **argv)
{
    AjPList    pdb_path     =NULL;  /* Path of pdb files */
    AjPStr     pdb_name     =NULL;  /* Name of pdb file  */
    AjPDirout  ccf_path    =NULL;   /* Path of ccf files */
    AjPStr     ccf_name    =NULL;   /* Name of ccf file  */
    AjPStr     pdbid        =NULL;  /* PDB code          */
    AjPStr     pdbid_temp   =NULL;  /* PDB code          */
    
    AjBool     ccfnaming   =ajFalse;   
    /* True == use the pdbid code to name the output file, 
       False== use the name of the original pdb file*/
    
    /* Mask non-amino acid groups in protein chains that do not 
       contain a C-alpha atom. The group will not appear in either 
       the CO or SQ records of the clean coordinate file */
    AjBool     camask     =ajFalse;  
    
    
    /* Mask amino acids in protein chains that do not contain a 
       C-alpha atom. The amino acid will appear not appear in the 
       CO record but will still be present in the SQ record of the 
       clean coordinate file */
    AjBool     camask1    =ajFalse;   
    
    /* Mask residues or groups in protein chains with a single atom only */
    AjBool     atommask     =ajFalse;  
    
    AjPStr     temp         =NULL; /* Temp string */   
    AjPStr     msg          =NULL; /* Error message */
   AjPStr     base_name    =NULL; /* Name of pdb file w/o path or 
				      extension */
    
    
    AjPFile    pdb_inf      =NULL; /* pdb input file pointer */
    AjPFile    ccf_outf    =NULL; /* ccf output file pointer */
    AjPFile    logf         =NULL; /* log file pointer*/ 
    
    AjPPdb     pdb          =NULL; /* Pdb structure (for parsed data) */
    
    ajint      min_chain_size=0; /* Minimum length of a SEQRES chain 
				    for it to be parsed */
    ajint      max_mismatch=0; /* Max. no. residues to trim when checking
				  for missing C-terminal SEQRES residues. */
    ajint      max_trim=0;   /* Maximum number of permissible 
				  mismatches between the ATOM and 
				  SEQRES sequences */
    ajint      pos          =0; /* Location of the file extension in 
				   the pdb file name */
    
    
    
    
    /*     THIS_DIAGNOSTIC  
	   tempstr=ajStrNew();    
	   ajStrAssignC(&tempstr,     "diagnostics");
	   tempfile=ajFileNewOutNameS(tempstr);
	   ajStrDel(&tempstr);*/
    
    
    /* Initialise strings */
    ccf_name     = ajStrNew();
    pdb_name      = ajStrNew();
    temp          = ajStrNew();
    msg           = ajStrNew();
    base_name     = ajStrNew();
    pdbid         = ajStrNew();    
    pdbid_temp    = ajStrNew();    
    
    
    /* Read data from acd */
    embInitPV("pdbparse",argc,argv,"STRUCTURE",VERSION);

    pdb_path     = ajAcdGetDirlist("pdbpath");
    ccf_path     = ajAcdGetOutdir("ccfoutdir");
    logf         = ajAcdGetOutfile("logfile");
    min_chain_size=ajAcdGetInt("chnsiz");
    max_mismatch =ajAcdGetInt("maxmis");
    max_trim     =ajAcdGetInt("maxtrim");
    ccfnaming    = ajAcdGetBoolean("ccfnaming");
    camask       = ajAcdGetBoolean("camask");
    camask1      = ajAcdGetBoolean("camaska");
    atommask     = ajAcdGetBoolean("atommask");
    
    
    /* Check directories*/
    
    /*Start of main application loop*/
    while(ajListPop(pdb_path,(void **)&temp))
    {
	ajFmtPrint("Processing %S\n", temp);   
	ajFmtPrintF(logf, "%S\n", temp);    
	
	
		
	
	/* Read pdb file*/
	if((pdb_inf=ajFileNewInNameS(temp))==NULL)
	{
	    ajFmtPrintS(&msg, "Could not open for reading %S ", 
			temp);
	    ajWarn(ajStrGetPtr(msg));
	    ajFmtPrintF(logf, "%-15s%S\n//\n", "FILE_OPEN", temp); 
	    ajStrDel(&temp);	
	    continue;	    
	}
	
	
	
	/* Assign pdb id code from file name */
	ajStrAssignS(&pdbid, temp);
	ajFilenameTrimPathExt(&pdbid);

	if(MAJSTRGETLEN(pdbid)>4)
	{
	    /* The file name is longer than expected (and probably contains a 
	       prefix). Take the last four characters to be the pdbid code */
	    ajStrAssignSubS(&pdbid_temp, pdbid, pos-4, pos-1);
	    ajStrAssignS(&pdbid, pdbid_temp);
	}
	else if(MAJSTRGETLEN(pdbid)<4)
	    ajFatal("Could not determine pdbid code from file name (%S)", pdbid);
	

	/* Parse pdb file and write pdb structure */
	if(!(pdb=ajPdbReadRawNew(pdb_inf, pdbid, min_chain_size, max_mismatch, 
				 max_trim, camask, camask1, atommask, logf)))
	{	
	    ajFmtPrintS(&msg, "Clean coordinate file not generated for %S", temp);
	    ajWarn(ajStrGetPtr(msg));
	    ajFmtPrintF(logf, "%-15s%S\n//\n", "NO_OUTPUT", temp); 
	    
	    ajFileClose(&pdb_inf);
	    ajStrDel(&temp);
	    continue;
	}
	
	
	/* Open clean coordinate file for writing*/
	if(ccfnaming)
	    ajStrAssignS(&ccf_name, pdb->Pdb);
	else
	    ajStrAssignS(&ccf_name, temp);
	ajStrFmtLower(&ccf_name);

	
	if(!(ccf_outf=ajFileNewOutNameDirS(ccf_name, ccf_path)))
	{
	    ajFmtPrintS(&msg, "Could not open %S for writing", 
			ccf_name);
	    ajWarn(ajStrGetPtr(msg));
	    ajFmtPrintF(logf, "%-15s%S\n//\n", "FILE_OPEN", ccf_name); 
	    ajFileClose(&pdb_inf);
	    ajPdbDel(&pdb);
	    ajStrDel(&temp);	
	    continue;
	}  
	
	
	
	
	
	/* Write pdb file */
	if(!ajPdbWriteAll(ccf_outf, pdb))
	{
	    ajFmtPrintS(&msg, "Could not write file %S", ccf_name);
	    ajWarn(ajStrGetPtr(msg));
	    ajFmtPrintF(logf, "%-15s%S\n//\n", "FILE_WRITE", ccf_name); 
	    
	    ajFmtPrintS(&temp, "rm %S", ccf_name);
	    ajFmtPrint("%S", temp);
	    ajSysSystem(temp);

	    ajFileClose(&pdb_inf);
	    ajFileClose(&ccf_outf);
	    ajPdbDel(&pdb);
	    ajStrDel(&temp);	
	    continue;
	}
	
	
	
	/* Tidy up*/
	ajFileClose(&pdb_inf);
	ajFileClose(&ccf_outf);
	ajPdbDel(&pdb);   
	ajStrDel(&temp);	
	
	
	ajFmtPrintF(logf, "//\n");    
    }

    /*End of main application loop*/        





    /*Tidy up */
    ajListFree(&pdb_path);
    ajStrDel(&pdb_name);
    ajDiroutDel(&ccf_path);
    ajStrDel(&ccf_name);
    ajStrDel(&base_name);
    ajStrDel(&pdbid);
    ajStrDel(&pdbid_temp);
    ajStrDel(&msg);
    
    ajFileClose(&logf);
    
    
    
    /* DIAGNOSTIC
       ajFileClose(&tempfile);
       */
    
    /* Return */
    ajExit();
    return 0;
}	    
Esempio n. 11
0
int main(int argc, char **argv)
{
    /* ACD data item variables */
    AjPSeqset  dataset   = NULL;
    AjPFile    bfile     = NULL;
    AjPFile    plib      = NULL;
    AjPStr     mod       = NULL;
    ajint      nmotifs   = 0;
    AjBool     text      = ajFalse;
    AjPStr     prior     = NULL;
    float      evt       = 0.0;
    ajint      nsites    = 0;
    ajint      minsites  = 0;
    ajint      maxsites  = 0;
    float      wnsites   = 0.0;
    ajint      w         = 0;
    ajint      minw      = 0;
    ajint      maxw      = 0;
    AjBool     nomatrim  = ajFalse;
    ajint      wg        = 0;
    ajint      ws        = 0;
    AjBool     noendgaps = ajFalse;
    AjBool     revcomp   = ajFalse;
    AjBool     pal       = ajFalse;
    AjBool     nostatus  = ajFalse;
    ajint      maxiter   = 0;
    float      distance  = 0.0;
    float      b         = 0.0;
    float      spfuzz    = 0.0;
    AjPStr     spmap     = NULL;
    AjPStr     cons      = NULL;
    ajint      maxsize   = 0;
    ajint      p         = 0;
    ajint      time      = 0;
    AjPStr     sf        = NULL;
    ajint      heapsize  = 64;
    AjBool     xbranch   = ajFalse;
    AjBool     wbranch   = ajFalse;
    ajint      bfactor   = 0;
    AjPFile    outtext   = NULL;
    
    /* Housekeeping variables */
    AjPStr     cmd       = NULL;
    AjPStr     ssname    = NULL;      
    AjPSeqout  outseq    = NULL;   
    AjPStr     tmp       = NULL;
    char       option;



    
    /* ACD file processing */
    embInitPV("ememetext",argc,argv,"MEME",VERSION);
    dataset   = ajAcdGetSeqset("dataset");
    bfile     = ajAcdGetInfile("bfile");
    plib      = ajAcdGetInfile("plibfile");
    mod       = ajAcdGetSelectSingle("mod");
    nmotifs   = ajAcdGetInt("nmotifs");
    text      = ajAcdGetBoolean("text");
    prior     = ajAcdGetSelectSingle("prior");
    evt       = ajAcdGetFloat("evt");
    nsites    = ajAcdGetInt("nsites");
    minsites  = ajAcdGetInt("minsites");
    maxsites  = ajAcdGetInt("maxsites");
    wnsites   = ajAcdGetFloat("wnsites");
    w         = ajAcdGetInt("w");
    minw      = ajAcdGetInt("minw");
    maxw      = ajAcdGetInt("maxw");
    nomatrim  = ajAcdGetBoolean("nomatrim");
    wg        = ajAcdGetInt("wg");
    ws        = ajAcdGetInt("ws");
    noendgaps = ajAcdGetBoolean("noendgaps");
    revcomp   = ajAcdGetBoolean("revcomp");
    pal       = ajAcdGetBoolean("pal");
    nostatus  = ajAcdGetBoolean("nostatus");
    maxiter   = ajAcdGetInt("maxiter");
    distance  = ajAcdGetFloat("distance");
    b         = ajAcdGetFloat("b");
    spfuzz    = ajAcdGetFloat("spfuzz");
    spmap     = ajAcdGetSelectSingle("spmap");
    cons      = ajAcdGetString("cons");
    maxsize   = ajAcdGetInt("maxsize");
    p         = ajAcdGetInt("p");
    time      = ajAcdGetInt("time");
    sf        = ajAcdGetString("sf");
    heapsize  = ajAcdGetInt("heapsize");
    xbranch   = ajAcdGetBoolean("xbranch");
    wbranch   = ajAcdGetBoolean("wbranch");
    bfactor   = ajAcdGetInt("bfactor");    

    outtext   = ajAcdGetOutfile("outtext");
    outseq    = ajAcdGetSeqoutset("outseq");
    
    

    /* MAIN APPLICATION CODE */
    /* 1. Housekeeping */
    cmd      = ajStrNew();
    tmp      = ajStrNew();
    
    /* 2. Re-write dataset to a temporary file in a format (fasta) MEME
    ** can understand.
    ** Can't just pass the name of dataset to MEME as the name provided
    ** might be a USA which MEME would not understand.
    */

    ssname = ajStrNewS(ajFileGetNameS(outseq->File));
    
    ajSeqoutSetFormatC(outseq, "fasta");
    ajSeqoutWriteSet(outseq, dataset);
    ajSeqoutClose(outseq);
    ajSeqoutDel(&outseq);


    /* 3. Build ememe command line */
    /* Command line is built in this order: 
       i.  Application name.
       ii. Original MEME options (in order they appear in ACD file)
       iii.Original MEME options (that don't appear in ACD file)
       iv. EMBASSY MEME new qualifiers and parameters.
       */
    ajStrAssignS(&cmd, ajAcdGetpathC("meme"));
    ajFmtPrintAppS(&cmd, " %S", ssname);

    if(bfile)
	ajFmtPrintAppS(&cmd, " -bfile %s ", ajFileGetNameC(bfile));

    if(plib)
	ajFmtPrintAppS(&cmd, " -plib %s ", ajFileGetNameC(plib));

    option = ajStrGetCharFirst(mod);
    if(option == 'o')
	ajStrAppendC(&cmd, " -mod oops ");
    else if(option == 'z')
	ajStrAppendC(&cmd, " -mod zoops ");
    else if(option == 'a')
	ajStrAppendC(&cmd, " -mod anr ");

    if(nmotifs != 1)
        ajFmtPrintAppS(&cmd, " -nmotifs %d ", nmotifs);

    if(text)
	ajFmtPrintAppS(&cmd, " -text ");

    ajFmtPrintAppS(&cmd,  " -prior %S ", prior);

    if(evt != -1)
	ajFmtPrintAppS(&cmd, " -evt %f ", evt);

    if(nsites != -1)
	ajFmtPrintAppS(&cmd, " -nsites %d ", nsites);
    else
    {
	if(minsites != -1)
	    ajFmtPrintAppS(&cmd, " -minsites %d ", minsites);
	if(maxsites != -1)
	    ajFmtPrintAppS(&cmd, " -maxsites %d ", maxsites);
    }

    if(wnsites < 0.7999 || wnsites > .8001)
        ajFmtPrintAppS(&cmd, " -wnsites %f ", wnsites);

    if(w != -1)
	ajFmtPrintAppS(&cmd, " -w %d ", w);

    if(minw != 8)
        ajFmtPrintAppS(&cmd, " -minw %d ", minw);

    if(maxw != 50)
        ajFmtPrintAppS(&cmd, " -maxw %d ", maxw);

    if(nomatrim)
	ajFmtPrintAppS(&cmd, " -nomatrim ");


    if(wg != 11)
        ajFmtPrintAppS(&cmd, " -wg %d ", wg);

    if(ws != 1)
        ajFmtPrintAppS(&cmd, " -ws %d ", ws);

    if(noendgaps)
	ajFmtPrintAppS(&cmd, " -noendgaps ");

    if(revcomp)
	ajFmtPrintAppS(&cmd, " -revcomp ");

    if(pal && ajSeqsetIsNuc(dataset))
	ajFmtPrintAppS(&cmd, " -pal ");

    if(nostatus)
	ajFmtPrintAppS(&cmd, " -nostatus ");

    if(maxiter != 50)
        ajFmtPrintAppS(&cmd, " -maxiter %d ", maxiter);

    if(distance < 0.00099 || distance > 0.00101)
        ajFmtPrintAppS(&cmd, " -distance %f ", distance);

    if(b != -1)
	ajFmtPrintAppS(&cmd, " -b %f ", b);

    if(spfuzz != -1)
	ajFmtPrintAppS(&cmd, " -spfuzz %f ", spfuzz);

    
    if(!ajStrMatchC(spmap,"default"))
        ajFmtPrintAppS(&cmd,  " -spmap %S ", spmap);

    if(MAJSTRGETLEN(cons))
	ajFmtPrintAppS(&cmd, "-cons %S", cons);

    if(maxsize != -1)
        ajFmtPrintAppS(&cmd, " -maxsize %d ", maxsize);

    if(p > 0)
	ajFmtPrintAppS(&cmd, " -p %d ", p);

    if(time > 0)
	ajFmtPrintAppS(&cmd, " -time %d ", time);

    if(MAJSTRGETLEN(sf))
	ajFmtPrintAppS(&cmd, " -sf %S", sf);

    if(heapsize != 64)
 	ajFmtPrintAppS(&cmd, " -heapsize %d ", heapsize);

    if(xbranch)
        ajFmtPrintAppS(&cmd, " -x_branch");

    if(wbranch)
        ajFmtPrintAppS(&cmd, " -w_branch");
    
    if(bfactor != 3)
 	ajFmtPrintAppS(&cmd, " -bfactor %d ", bfactor);

    if(ajSeqsetIsProt(dataset))
	ajFmtPrintAppS(&cmd, "-protein ");
    else
	ajFmtPrintAppS(&cmd, "-dna ");

    ajFmtPrintAppS(&cmd, " -text");

    ajFmtPrintAppS(&cmd, " > %S ", ajFileGetNameS(outtext));


    /* 4. Close files from ACD before calling meme */	
    ajFileClose(&bfile);	
    ajFileClose(&plib);


    /* 5. Call meme */
    /* ajFmtPrint("\n%S\n", cmd); */
    system(ajStrGetPtr(cmd));    


    /* 6. Exit cleanly */

    ajSeqsetDel(&dataset);
    ajStrDel(&cons);
    ajStrDel(&sf);
    ajStrDel(&mod);
    ajStrDel(&prior);
    ajStrDel(&spmap);

    ajStrDel(&cmd);
    ajStrDel(&ssname);
    ajStrDel(&tmp);
    
    ajFileClose(&bfile);
    ajFileClose(&plib);
    ajFileClose(&outtext);
    ajSeqoutDel(&outseq);
    
    embExit();

    return 0;
}
Esempio n. 12
0
/* @funcstatic domainalign_keepsinglets ***************************************
**
** Write singlet sequences to file.
**
** @param [r] domain [AjPDomain] 
** @param [r] noden [ajint] 
** @param [r] singlets [AjPDirout] 
** @param [r] logf [AjPFile] 
**
** @return [void] True on success
** @@
****************************************************************************/
static void domainalign_keepsinglets(AjPDomain domain,
				     ajint     noden, 
				     AjPDirout singlets, 	
				     AjPFile   logf)
{
    AjPStr      temp2     = NULL;   /* A temporary string. */
    AjPFile     singf     = NULL;   /* File pointer for singlets file. */
    EmbPHitlist  hitlist   = NULL;   /* Hitlist object for output of data. */
    
    temp2    = ajStrNew();


    domainalign_writesid(domain, noden, &temp2);
    
    if(MAJSTRGETLEN(ajDomainGetSeqPdb(domain)))
    {
	/* Write Hit object. */
	hitlist = embHitlistNew(1);
	hitlist->Type = domain->Type;
	ajStrAssignS(&hitlist->hits[0]->Seq, ajDomainGetSeqPdb(domain));
	ajStrAssignS(&hitlist->hits[0]->Acc, ajDomainGetAcc(domain));
	ajStrAssignS(&hitlist->hits[0]->Spr, ajDomainGetSpr(domain));
	ajStrAssignS(&hitlist->hits[0]->Dom, ajDomainGetId(domain));
	

	if((domain->Type == ajSCOP))
	{
	    ajStrAssignS(&hitlist->Class, domain->Scop->Class);
	    ajStrAssignS(&hitlist->Fold, domain->Scop->Fold);
	    ajStrAssignS(&hitlist->Superfamily, domain->Scop->Superfamily);
	    ajStrAssignS(&hitlist->Family, domain->Scop->Family);
	    if(noden==4)
		hitlist->Sunid_Family = domain->Scop->Sunid_Family;
	    else if(noden==3)
		hitlist->Sunid_Family = domain->Scop->Sunid_Superfamily;
	    else if(noden==2)
		hitlist->Sunid_Family = domain->Scop->Sunid_Fold;
	    else if(noden==1)
		hitlist->Sunid_Family = domain->Scop->Sunid_Class;
	}
	else
	{	
	    ajStrAssignS(&hitlist->Class, domain->Cath->Class);
	    ajStrAssignS(&hitlist->Architecture, domain->Cath->Architecture);
	    ajStrAssignS(&hitlist->Topology, domain->Cath->Topology);
	    ajStrAssignS(&hitlist->Superfamily, domain->Cath->Superfamily);

	    if(noden==9)
		hitlist->Sunid_Family = domain->Cath->Family_Id;
	    if(noden==8)
		hitlist->Sunid_Family = domain->Cath->Superfamily_Id;
	    else if(noden==7)
		hitlist->Sunid_Family = domain->Cath->Topology_Id;
	    else if(noden==6)
		hitlist->Sunid_Family = domain->Cath->Arch_Id;
	    else if(noden==5)
		hitlist->Sunid_Family = domain->Cath->Class_Id;

	}

	singf = ajFileNewOutNameDirS(temp2, singlets);
	embHitlistWriteFasta(singf, hitlist);
	/* ajFmtPrintF(singf, ">%S\n%S\n", temp2, ajDomainGetSeqPdb(domain)); */
	ajFileClose(&singf);
    }
    else
    {
	ajWarn("No sequence found (no 'DS' record in DCF file) for singlet %S "
	       "despite configuring to save singlets. "
	       "NO file written!", ajDomainGetId(domain)); 
	ajFmtPrintF(logf, "No sequence found (no 'DS' record in DCF file) for "
		    "singlet %S despite configuring to save singlets. "
		    "NO file written!", ajDomainGetId(domain));
    }		

    ajStrDel(&temp2); 

    return;
}    
Esempio n. 13
0
static AjBool dbxflat_ParseFastq(EmbPBtreeEntry entry, AjPFile inf)
{
    AjPStr line = NULL;
    ajlong pos  = 0L;
    ajuint seqlen = 0;
    ajuint qlen = 0;
    AjPStr tmpfd  = NULL;
    AjPStr str = NULL;
    AjPStr de = NULL;
    AjBool ok;

    if(!dbxflat_wrdexp)
	dbxflat_wrdexp = ajRegCompC("([A-Za-z0-9.:=]+)");

    line = ajStrNewC("");
    
    pos = ajFileResetPos(inf);

    if(!ajReadlineTrim(inf,&line))
    {
        ajStrDel(&line);
        return ajFalse;
    }

    /* first line of entry */

    if(!ajStrPrefixC(line,"@"))
        return ajFalse;

    entry->fpos = pos;
    ajStrCutStart(&line, 1);
    ajStrExtractFirst(line, &de, &entry->id);

    if(desfield && ajStrGetLen(de))
    {
	while(ajRegExec(dbxflat_wrdexp,de))
	{
	    ajRegSubI(dbxflat_wrdexp, 1, &tmpfd);
	    str = ajStrNew();
	    ajStrAssignS(&str,tmpfd);
	    ajListPush(desfield->data,(void *)str);
	    ajRegPost(dbxflat_wrdexp, &de);
	}
    }

/* now read sequence */
    ok = ajReadlineTrim(inf,&line);
    while(ok && !ajStrPrefixC(line, "+"))
    {
        ajStrRemoveWhite(&line);
        seqlen += MAJSTRGETLEN(line);
        ok = ajReadlineTrim(inf,&line);
    }

    if(!ok)
        return ajFalse;

    ok = ajReadlineTrim(inf,&line);
    while(ok)
    {
        qlen += MAJSTRGETLEN(line);
        if(qlen < seqlen)
            ok = ajReadlineTrim(inf,&line);
        else
            ok = ajFalse;
    }

    ajStrDel(&de);
    ajStrDel(&tmpfd);
    ajStrDel(&line);
    
    return ajTrue;
}
Esempio n. 14
0
int main(int argc, char **argv)
{
    /* Variable declarations */
    AjPStr   dbname = NULL;
    AjPStr   svrname = NULL;
    AjPFile  outfile = NULL;    
    AjPResource resource = NULL;
    AjPResourcein resourcein = NULL;
    AjPStr resourceqry = NULL;
    AjPStr type     = NULL;
    AjBool id;
    AjBool qry;
    AjBool all;
    AjBool verbose;
    AjPStr methods = NULL;
    AjPStr release = NULL;
    AjPStr comment = NULL;
    AjPStr defined = NULL;
    AjPList list = NULL;
    AjPTagval tagval = NULL;
    AjIList iter = NULL;
    ajuint space = 0;
    AjPList aliaslist = NULL;
    AjIList aliter = NULL;
    const AjPStr alias = NULL;
    ajuint maxlen;
    AjPStr truedbname = NULL;
    AjBool isalias = ajFalse;

    /* ACD processing */
    embInit("dbtell", argc, argv);

    dbname   = ajAcdGetString("database");
    svrname   = ajAcdGetString("server");
    verbose  = ajAcdGetBoolean("full");
    outfile  = ajAcdGetOutfile("outfile");
    
    ajStrAssignS(&truedbname, dbname);
    ajNamAliasDatabase(&truedbname);
    ajStrFmtLower(&truedbname);

    if(!ajStrMatchS(dbname, truedbname))
        isalias = ajTrue;

    /* Application logic */
    /* Check EMBOSS database information.
       Write output file */

    if(ajNamDbDetailsSvr(truedbname, svrname, &type, &id, &qry, &all,
                         &comment, &release, &methods, &defined))
    {
        if(isalias)
            ajFmtPrintF(outfile, "# %S is an alias for %S defined in %S\n",
                        dbname, truedbname, defined);
        else
            ajFmtPrintF(outfile, "# %S is defined in %S\n",
                        truedbname, defined);

        ajFmtPrintF(outfile, "# access levels id: %B query: %B all: %B\n\n",
                    id, qry, all);
        ajFmtPrintF(outfile, "DBNAME %S [\n", truedbname);

        if(ajStrGetLen(svrname))
            list = ajNamDbGetAttrlistSvr(truedbname, svrname);
        else
            list = ajNamDbGetAttrlist(truedbname);

        iter = ajListIterNewread(list);
        while(!ajListIterDone(iter))
        {
            tagval = ajListIterGet(iter);
            space = 15 - ajStrGetLen(ajTagvalGetTag(tagval));
            ajFmtPrintF(outfile, "   %S:%.*s\"%S\"\n",
                        ajTagvalGetTag(tagval),
                        space, "                    ",
                        ajTagvalGetValue(tagval));
            ajTagvalDel(&tagval);
        }
        ajListIterDel(&iter);
        ajListFree(&list);

        ajFmtPrintF(outfile, "]\n");

        if(verbose)
        {
            aliaslist = ajListNew();
            ajNamListFindAliases(truedbname, aliaslist);

            if(ajListGetLength(aliaslist))
            {
                ajFmtPrintF(outfile, "\n");
                    
                aliter = ajListIterNewread(aliaslist);

                maxlen = 1;
                while(!ajListIterDone(aliter))
                {
                    alias = ajListIterGet(aliter);
                    if(MAJSTRGETLEN(alias) > maxlen)
                        maxlen = MAJSTRGETLEN(alias);
                }
                
                ajListIterDel(&aliter);
                aliter = ajListIterNewread(aliaslist);

                while(!ajListIterDone(aliter))
                {
                    alias = ajListIterGet(aliter);

                    if(ajStrFindK(alias, ':') < 0)
                        ajFmtPrintF(outfile, "ALIAS %-*S %S\n",
                                    maxlen, alias, truedbname);
                }

                ajListIterDel(&aliter);
            }

            ajListstrFree(&aliaslist);
        }

        ajStrDel(&type);
        ajStrDel(&methods);
        ajStrDel(&release);
        ajStrDel(&comment);
        ajStrDel(&defined);
    }
    else
    {
/* try looking in DRCAT */
        resourcein = ajResourceinNew();
        resource = ajResourceNew();

        ajFmtPrintS(&resourceqry, "drcat:%S", dbname);
        ajResourceinQryS(resourcein, resourceqry);
        if(ajResourceinRead(resourcein, resource))
        {
            ajFmtPrintF(outfile, "DBNAME %S [\n", dbname);
            ajFmtPrintF(outfile, "   comment: \"defined in DRCAT\"\n");
            ajFmtPrintF(outfile, "]\n");
         }
        ajResourceinDel(&resourcein);
        ajResourceDel(&resource);
        ajStrDel(&resourceqry);
    }

    /* Memory clean-up and exit */

    ajFileClose(&outfile);
    ajStrDel(&truedbname);
    ajStrDel(&dbname);
    ajStrDel(&svrname);

    embExit();

    return 0;
}