/* @prog scopparse ************************************************************ ** ** Converts raw scop classification files to a file in embl-like format. ** ******************************************************************************/ int main(int argc, char **argv) { AjPFile inf1 = NULL; AjPFile inf2 = NULL; AjPFile outf = NULL; AjPList list = NULL; AjPScop tmp = NULL; AjBool nosegments = ajFalse; AjBool nomultichain = ajFalse; AjBool nominor = ajFalse; /* Read data from acd. */ embInitPV("scopparse", argc, argv, "DOMAINATRIX",VERSION); inf1 = ajAcdGetInfile("classfile"); inf2 = ajAcdGetInfile("desinfile"); outf = ajAcdGetOutfile("dcffile"); nosegments = ajAcdGetBoolean("nosegments"); nomultichain = ajAcdGetBoolean("nomultichain"); nominor = ajAcdGetBoolean("nominor"); /* ajFmtPrint("nosegments: %B\n", nosegments); ajFmtPrint("nomultichain: %B\n", nomultichain); ajFmtPrint("nominor: %B\n", nominor); */ /* Main body of code. */ list = ajScopReadAllRawNew(inf1, inf2, nomultichain); while(ajListPop(list, (void **) &tmp)) { if(((!nosegments) || (tmp->N == 1)) && ((!nominor) || ((tmp->Sunid_Class == 46456) || /* All alpha*/ (tmp->Sunid_Class == 48724) || /* All beta */ (tmp->Sunid_Class == 51349) || /* a/b */ (tmp->Sunid_Class == 53931)))) /* a+b */ ajScopWrite(outf, tmp); ajScopDel(&tmp); } /* Memory management. */ ajFileClose(&outf); ajFileClose(&inf1); ajFileClose(&inf2); ajListFree(&list); ajExit(); return 0; }
/* @prog ssematch *********************************************************** ** ** Searches a DCF file (domain classification file) for secondary structure ** matches. ** ****************************************************************************/ int main(int argc, char **argv) { /* Variables declarations */ AjPFile dcfin = NULL; /* Domain classification file */ AjPFile ssin = NULL; /* Secondary structure input file*/ AjPMatrixf matrix = NULL; /* Substitution matrix */ AjPFile out_ss = NULL; /* For ss top matches*/ AjPFile out_se = NULL; /* For se top matches*/ AjPFile outfile = NULL; /* Output file*/ AjPFile logf = NULL; /* Log file */ float gapopen_sss = 0.0; /* Gap insertion penalty */ float gapopen_sse = 0.0; float gapopen = 0.0; float gapextend_sss = 0.0; /* Gap extension penalty */ float gapextend_sse = 0.0; float gapextend = 0.0; ajint max_hits = 0; /* number of top alignments to display*/ ajint mode = 0; ajint x = 0; AjPScop temp_scop = NULL; /* scop object pointer*/ AjPList scop_list = NULL; /* list of scop objects for entire domain classification file */ AjIList iter = NULL; AjPStr msg = NULL; /* Pointer to String used for messages */ AjPStr line = NULL; AjPStr qse = NULL; /* query secondary structure elements*/ AjPStr qss = NULL; /* query secondary structure (by residue)*/ AjPSeq q3se = NULL; /* query secondary structure elements, 3-letter code*/ AjPSeq q3ss = NULL; /* query secondary structure (by residue), 3-letter code*/ AjPSeq query = NULL; /* Read data from acd */ embInitPV("ssematch",argc,argv,"DOMAINATRIX",VERSION); dcfin = ajAcdGetInfile("dcfinfile"); ssin = ajAcdGetInfile("ssinfile"); max_hits = ajAcdGetInt("maxhits"); matrix = ajAcdGetMatrixf("datafile"); gapopen_sss = ajAcdGetFloat("rgapopen"); gapextend_sss = ajAcdGetFloat("rgapextend"); gapopen_sse = ajAcdGetFloat("egapopen"); gapextend_sse = ajAcdGetFloat("egapextend"); out_ss = ajAcdGetOutfile("outssfile"); out_se = ajAcdGetOutfile("outsefile"); logf = ajAcdGetOutfile("logfile"); /* Create list of scop objects for entire input domain classification file. */ scop_list = ajListNew(); while((temp_scop = (ajScopReadCNew(dcfin, "*")))) ajListPushAppend(scop_list,temp_scop); /* Error handing if domain classification file was empty. */ if(!(ajListGetLength(scop_list))) { ajWarn("Empty list from scop input file\n"); ajFileClose(&dcfin); ajFileClose(&ssin); ajMatrixfDel(&matrix); ajFileClose(&out_ss); ajFileClose(&out_se); ajFileClose(&logf); while(ajListPop(scop_list, (void *) &temp_scop)) ajScopDel(&temp_scop); ajListFree(&scop_list); ajListIterDel(&iter); ajExit(); return 1; } /* Error handling in case of empty query file. */ if(ssin == NULL) { ajWarn("Empty secondary structure query file\n"); ajFileClose(&dcfin); ajFileClose(&ssin); ajMatrixfDel(&matrix); ajFileClose(&out_ss); ajFileClose(&out_se); ajFileClose(&logf); while(ajListPop(scop_list, (void *) &temp_scop)) ajScopDel(&temp_scop); ajListFree(&scop_list); ajListIterDel(&iter); ajExit(); return 1; } /* Assign sequences in query file to sequence objects. */ qse = ajStrNew(); qss = ajStrNew(); while(ajReadlineTrim(ssin,&line)) { /* SE string */ if(ajStrPrefixC(line,"SE")) { ajFmtScanS(line, "%*s %S", &qse); /* Convert this string to 3-letter code & then convert to AjPSeq object. */ q3se = ssematch_convertbases(qse); } /* SS string */ else if(ajStrPrefixC(line,"SS")) { while((ajReadlineTrim(ssin,&line)) && !ajStrPrefixC(line,"XX")) ajStrAppendS(&qss,line); ajStrRemoveWhite(&qss); /* Convert this string to 3-letter code & then to AjPSeq object. */ q3ss = ssematch_convertbases(qss); } } /* For se & then for ss, modes 0 & 1. */ for(mode = 0; mode <= 1; mode++) { /* Assign arguments for alignment function. */ if (mode == 0) { query = q3se; gapopen = gapopen_sse; gapextend = gapextend_sse; outfile = out_se; } else if(mode == 1) { query = q3ss; gapopen = gapopen_sss; gapextend = gapextend_sss; outfile = out_ss; } /* Iterate through list of scop objects & calculate alignment scores. */ iter=ajListIterNew(scop_list); while((temp_scop=(AjPScop)ajListIterGet(iter))) { /* The function extracts the se (mode 0) or ss (mode 1) subject sequences from the scop object, performs a Needleman-Wunsch global alignment with the query sequence & allocates the score to the Score element of the scop object*/ if(!(ssematch_NWScore(temp_scop , query, mode, matrix, gapopen, gapextend))) { ajFmtPrintF(logf, "%-15s\n", "ALIGNMENT"); ajFmtPrintF(logf, "Could not align sequence in scop domain %S\n ", temp_scop->Entry); ajFmtPrintS(&msg, "Could not align sequence in scop domain %S\n ", temp_scop->Entry); ajWarn(ajStrGetPtr(msg)); continue; } } ajListIterDel(&iter); temp_scop = NULL; /* Sort list of Scop objects by Score */ ajListSort(scop_list, ssematch_CompScoreInv); iter=ajListIterNew(scop_list); /* Write top-scoring hits to outfile. */ for(x=0; x < max_hits; x++ ) { temp_scop=(AjPScop)ajListIterGet(iter); /* Print score to output file. */ ajFmtPrintF(outfile, "XX ALIGNMENT SCORE %.3f\nXX\n", temp_scop->Score); /* Could also write alignment - later modification. */ if(!ajScopWrite(outfile, temp_scop)) ajFatal("Could not write output file %S\n", outfile); } ajListIterDel(&iter); temp_scop = NULL; } /* Memoryt management. */ ajFileClose(&dcfin); ajFileClose(&ssin); ajMatrixfDel(&matrix); ajFileClose(&out_ss); ajFileClose(&out_se); ajFileClose(&logf); while(ajListPop(scop_list, (void *) &temp_scop)) ajScopDel(&temp_scop); ajListFree(&scop_list); ajStrDel(&msg); ajStrDel(&line); ajStrDel(&qse); ajStrDel(&qss); ajSeqDel(&q3se); ajSeqDel(&q3ss); ajExit(); return 0; }