Example #1
0
int main(int argc, char **argv)
{
    AjPFile     key_inf=NULL;	/* File pointer for keywords file.           */
    AjPFile     sp_inf =NULL;	/* File pointer for swissprot database.      */
    AjPFile     outf   =NULL;	/* File pointer for output file.             */
    AjPTerms    keyptr =NULL;	/* Pointer to terms structure.               */
    EmbPHitlist  hitptr =NULL;	/* Pointer to hitlist structure.             */
    


 
   
    /* Read data from acd */
    embInitPV("seqwords",argc,argv,"DOMSEARCH",VERSION);

    key_inf  = ajAcdGetInfile("keyfile");
    sp_inf  = ajAcdGetInfile("spfile");
    outf =  ajAcdGetOutfile("outfile");
    

    /* Start of main application loop. */
    /* Read next list of terms from input file. */
    while((seqwords_TermsRead(key_inf, &keyptr)))
    {
	/* Rewind swissprot file pointer to the top. */
	ajFileSeek(sp_inf, 0, 0);
	

	/* Allocate memory for hitlist. */
	AJNEW0(hitptr);


	/* Do search of swissprot. */
	seqwords_keysearch(sp_inf, keyptr, &hitptr);


	/* Copy scop records from terms to hitlist structure. */
	hitptr->Type = keyptr->Type;
	ajStrAssignRef(&hitptr->Class, keyptr->Class); 
	ajStrAssignRef(&hitptr->Architecture, keyptr->Architecture); 
	ajStrAssignRef(&hitptr->Topology, keyptr->Topology); 
	ajStrAssignRef(&hitptr->Fold, keyptr->Fold); 
	ajStrAssignRef(&hitptr->Superfamily, keyptr->Superfamily);
	ajStrAssignRef(&hitptr->Family, keyptr->Family);
	

	/* Write output file. */
	embHitlistWriteFasta(outf, hitptr);


	/* Free memory for hitlist & keyptr*/
	embHitlistDel(&hitptr);
	seqwords_TermsDel(&keyptr);
    }
    seqwords_TermsDel(&keyptr);    
    
    /* Tidy up*/
    ajFileClose(&key_inf);
    ajFileClose(&sp_inf);
    ajFileClose(&outf);

    embExit();
    return 0;
}
Example #2
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;
}