static Palindrome palindrome_New(ajint fstart, ajint fend, ajint rstart, ajint rend) { Palindrome pal; AJNEW(pal); pal->forwardStart = fstart; pal->forwardEnd = fend; pal->revStart = rstart; pal->revEnd = rend; pal->next = NULL; return pal; }
static void supermatcher_matchListOrder(void **x,void *cl) { EmbPWordMatch p; AjPList ordered; ajint offset; AjIList listIter; concat *con; concat *c=NULL; p = (EmbPWordMatch)*x; ordered = (AjPList) cl; offset = (*p).seq1start-(*p).seq2start; /* iterate through ordered list to find if it exists already*/ listIter = ajListIterNewread(ordered); while(!ajListIterDone( listIter)) { con = ajListIterGet(listIter); if(con->offset == offset) { /* found so add count and set offset to the new value */ con->offset = offset; con->total+= (*p).length; con->count++; ajListPushAppend(con->list,p); ajListIterDel(&listIter); return; } } ajListIterDel(&listIter); /* not found so add it */ AJNEW(c); c->offset = offset; c->total = (*p).length; c->count = 1; c->list = ajListNew(); ajListPushAppend(c->list,p); ajListPushAppend(ordered, c); return; }
static AjPTable dastestGetTitleCount(const AjPDasServer server) { AjIList iter = NULL; AjPTable titlecount = NULL; AjPDasSource source = NULL; AjPStr title = NULL; ajuint* count = NULL; titlecount = ajTablestrNewCaseConst(ajListGetLength(server->sources)+20); iter = ajListIterNew(server->sources); while(!ajListIterDone(iter)) { source = ajListIterGet(iter); title = source->title; count = ajTableFetchmodS(titlecount,title); if (count != NULL) { (*count)++; } else { AJNEW(count); *count = 1; ajTablePut(titlecount, title, (void*)count); } } ajListIterDel(&iter); return titlecount; }
static void primersearch_initialise_pguts(PGuts* primer) { AJNEW(*primer); (*primer)->patstr = NULL; (*primer)->origpat = ajStrNew(); (*primer)->type = 0; (*primer)->len = 0; (*primer)->real_len = 0; (*primer)->re = NULL; (*primer)->amino = 0; (*primer)->carboxyl = 0; (*primer)->tidy = NULL; (*primer)->mm = 0; (*primer)->buf = NULL; (*primer)->sotable = NULL; (*primer)->solimit = 0; (*primer)->re = NULL; (*primer)->skipm = NULL; return; }
static void primersearch_store_hits(const Primer primdata, AjPList fhits, AjPList rhits, const AjPSeq seq, AjBool reverse) { ajint amplen = 0; AjIList fi; AjIList ri; PHit primerhit = NULL; fi = ajListIterNewread(fhits); while(!ajListIterDone(fi)) { EmbPMatMatch fm = NULL; EmbPMatMatch rm = NULL; amplen = 0; fm = ajListIterGet(fi); ri = ajListIterNewread(rhits); while(!ajListIterDone(ri)) { ajint seqlen = ajSeqGetLen(seq); ajint s = (fm->start); ajint e; rm = ajListIterGet(ri); e = (rm->start-1); amplen = seqlen-(s-1)-e; if (amplen > 0) /* no point making a hit if -ve length! */ { primerhit = NULL; AJNEW(primerhit); primerhit->desc=NULL; /* must be NULL for ajStrAss */ primerhit->seqname=NULL; /* must be NULL for ajStrAss */ primerhit->acc=NULL; primerhit->forward=NULL; primerhit->reverse=NULL; ajStrAssignC(&primerhit->seqname,ajSeqGetNameC(seq)); ajStrAssignS(&primerhit->desc, ajSeqGetDescS(seq)); ajStrAssignS(&primerhit->acc, ajSeqGetAccS(seq)); primerhit->forward_pos = fm->start; primerhit->reverse_pos = rm->start; primerhit->forward_mismatch = fm->mm; primerhit->reverse_mismatch = rm->mm; primerhit->amplen = amplen; if(!reverse) { ajStrAssignS(&primerhit->forward, primdata->forward->patstr); ajStrAssignS(&primerhit->reverse, primdata->reverse->patstr); } else { ajStrAssignS(&primerhit->forward, primdata->reverse->patstr); ajStrAssignS(&primerhit->reverse, primdata->forward->patstr); } ajListPushAppend(primdata->hitlist, primerhit); } } /* ** clean up rListIter here as it will be new'ed again next ** time through */ ajListIterDel(&ri); } ajListIterDel(&fi); return; }
static void primersearch_read_primers(AjPList *primerList, AjPFile primerFile, ajint mmp) { AjPStr rdline = NULL; AjPStrTok handle = NULL; ajint nprimers = 0; Primer primdata = NULL; while (ajReadlineTrim(primerFile, &rdline)) { primdata = NULL; if (ajStrGetCharFirst(rdline) == '#') continue; if (ajStrSuffixC(rdline, "..")) continue; AJNEW(primdata); primdata->Name = NULL; primersearch_initialise_pguts(&primdata->forward); primersearch_initialise_pguts(&primdata->reverse); primdata->hitlist = ajListNew(); handle = ajStrTokenNewC(rdline, " \t"); ajStrTokenNextParse(&handle, &primdata->Name); ajStrTokenNextParse(&handle, &primdata->forward->patstr); ajStrFmtUpper(&primdata->forward->patstr); ajStrTokenNextParse(&handle, &primdata->reverse->patstr); ajStrFmtUpper(&primdata->reverse->patstr); ajStrTokenDel(&handle); /* copy patterns for Henry Spencer code */ ajStrAssignC(&primdata->forward->origpat, ajStrGetPtr(primdata->forward->patstr)); ajStrAssignC(&primdata->reverse->origpat, ajStrGetPtr(primdata->reverse->patstr)); /* set the mismatch level */ primdata->forward->mm = (ajint) (ajStrGetLen(primdata->forward->patstr)*mmp)/100; primdata->reverse->mm = (ajint) (ajStrGetLen(primdata->reverse->patstr)*mmp)/100; if(primersearch_classify_and_compile(&primdata)) { ajListPushAppend(*primerList, primdata); nprimers++; } else /* there was something funny about the primer sequences */ { ajUser("Cannot use %s\n", ajStrGetPtr(primdata->Name)); primersearch_free_pguts(&primdata->forward); primersearch_free_pguts(&primdata->reverse); ajStrDel(&primdata->Name); ajListFree(&primdata->hitlist); ajListFree(&primdata->hitlist); AJFREE(primdata); } } ajStrDel(&rdline); return; }
int main(int argc, char **argv) { AjPSeqall seqall; AjPFile primfile; AjPStr rdline = NULL; Primer primdata; AjPStrTok handle = NULL; AjPList primList = NULL; embInit("stssearch", argc, argv); primfile = ajAcdGetInfile("infile"); out = ajAcdGetOutfile("outfile"); seqall = ajAcdGetSeqall("seqall"); while(ajReadlineTrim(primfile, &rdline)) { if(ajStrGetCharFirst(rdline) == '#') continue; if(ajStrSuffixC(rdline, "..")) continue; AJNEW(primdata); primdata->Name = NULL; primdata->Oligoa = NULL; primdata->Oligob = NULL; handle = ajStrTokenNewC(rdline, " \t"); ajStrTokenNextParse(&handle, &primdata->Name); if(!(nprimers % 1000)) ajDebug("Name [%d]: '%S'\n", nprimers, primdata->Name); ajStrTokenNextParse(&handle, &primdata->Oligoa); ajStrFmtUpper(&primdata->Oligoa); primdata->Prima = ajRegComp(primdata->Oligoa); ajStrTokenNextParse(&handle, &primdata->Oligob); ajStrFmtUpper(&primdata->Oligob); primdata->Primb = ajRegComp(primdata->Oligob); ajStrTokenDel(&handle); if(!nprimers) primList = ajListNew(); ajListPushAppend(primList, primdata); nprimers++; } if(!nprimers) ajFatal("No primers read\n"); ajDebug("%d primers read\n", nprimers); while(ajSeqallNext(seqall, &seq)) { ajSeqFmtUpper(seq); ajStrAssignS(&seqstr, ajSeqGetSeqS(seq)); ajStrAssignS(&revstr, ajSeqGetSeqS(seq)); ajSeqstrReverse(&revstr); ajDebug("Testing: %s\n", ajSeqGetNameC(seq)); ntests = 0; ajListMap(primList, stssearch_primTest, NULL); } ajFileClose(&out); ajSeqallDel(&seqall); ajSeqDel(&seq); ajFileClose(&out); ajStrDel(&revstr); ajStrDel(&seqstr); ajFileClose(&primfile); ajListMap(primList, stssearch_primDel, NULL); ajListFree(&primList); ajStrDel(&rdline); embExit(); return 0; }
static PSilent silent_checktrans(const AjPStr seq,const EmbPMatMatch match, const PRinfo rlp, ajint begin, ajint radj, AjBool rev, ajint end) { PSilent ret; const char *p = NULL; const char *q = NULL; const char *s = NULL; char *t; const char *u; ajint matchpos; ajint framep; ajint count; AjPTrn table = NULL; AjPStr s1 = NULL; AjPStr s2 = NULL; char c; char rc; ajint min = INT_MAX; /* Reverse sense intentional! */ ajint max = -INT_MAX; ajint fpos; ajint rpos; ajint x; AjPStr tstr = NULL; matchpos = match->start; fpos = matchpos; rpos=radj-fpos-match->len; tstr = ajStrNewS(seq); t = ajStrGetuniquePtr(&tstr); p = t+fpos-(begin+1); u = q = ajStrGetPtr(rlp->site); /* Test here for whether cut site is within sequence substring */ if(rlp->ncuts==4) { min = AJMIN(rlp->cut1,rlp->cut2); max = AJMAX(rlp->cut3,rlp->cut4); } else if(rlp->ncuts==2) { min = AJMIN(rlp->cut1,rlp->cut2); max = AJMAX(rlp->cut1,rlp->cut2); } else { ajWarn("Possibly corrupt RE file"); ajStrDel(&tstr); return NULL; } if(!rev) /* forward strand */ { if(matchpos+min<0||matchpos+max>end+1) { /*Cut site not in sequence range*/ ajStrDel(&tstr); return NULL; } } else /* reverse strand */ { if(radj-matchpos-1-min>end+1||radj-matchpos-1-max<begin) { /*Cut site not in sequence range*/ ajStrDel(&tstr); return NULL; } } count=0; while(ajBaseAlphaToBin(*q++) & ajBaseAlphaToBin(*p++)) ++count; /* Changed base postion */ x = fpos+count-(begin+1); /* Where the frame starts on the reverse strand */ framep = (end-begin+1)%3; c = t[x]; rc = u[count]; if(!rev) /* forward strand */ s = t+x-x%3; else /* reverse strand */ s = t+x-(x-framep)%3; table = ajTrnNewI(0); /* translates codon pointed to by s (original seq) */ s1 = ajStrNewK(ajTrnCodonC(table,s)); t[x] = rc; /* translates codon pointed to by s (mutated base from RS pattern */ s2 = ajStrNewK(ajTrnCodonC(table,s)); t[x] = c; /* changes mutated base in seq back to original base */ AJNEW(ret); ret->obase = c; ret->nbase = rc; ret->code = ajStrNewC(ajStrGetPtr(rlp->code)); ret->site = ajStrNewC(ajStrGetPtr(rlp->site)); ret->seqaa = ajStrNewC(ajStrGetPtr(s1)); ret->reaa = ajStrNewC(ajStrGetPtr(s2)); if(ajStrMatchS(s1,s2)) ret->issilent = ajTrue; else ret->issilent = ajFalse; if(!rev) { ret->match = matchpos; ret->base = matchpos+count; } else { ret->match = rpos; ret->base = rpos+match->len-1-count; } ajStrDel(&tstr); ajStrDel(&s1); ajStrDel(&s2); ajTrnDel(&table); return ret; }
static ajint silent_restr_read(AjPList *relist,const AjPStr enzymes) { EmbPPatRestrict rptr = NULL; AjPFile fin = NULL; AjPStr refilename = NULL; register ajint RStotal = 0; PRinfo rinfo = NULL; AjBool isall = ajFalse; ajint ne = 0; ajint i; AjPStr *ea = NULL; refilename = ajStrNewC("REBASE/embossre.enz"); rptr = embPatRestrictNew(); *relist = ajListNew(); fin = ajDatafileNewInNameS(refilename); if(!fin) ajFatal("Aborting...restriction file '%S' not found", refilename); /* Parse the user-selected enzyme list */ if(!enzymes) isall = ajTrue; else { ne = ajArrCommaList(enzymes,&ea); for(i=0;i<ne;++i) ajStrRemoveWhite(&ea[i]); if(ajStrMatchCaseC(ea[0],"all")) isall = ajTrue; else isall = ajFalse; } while(!ajFileIsEof(fin)) { if(!embPatRestrictReadEntry(rptr,fin)) continue; if(!isall) { for(i=0;i<ne;++i) if(ajStrMatchCaseS(ea[i],rptr->cod)) break; if(i==ne) continue; } AJNEW(rinfo); /* reading in RE info into rinfo from EmbPPatRestrict structure */ rinfo->code = ajStrNewC(ajStrGetPtr(rptr->cod)); rinfo->site = ajStrNewC(ajStrGetPtr(rptr->pat)); rinfo->ncuts = rptr->ncuts; rinfo->cut1 = rptr->cut1; rinfo->cut2 = rptr->cut2; rinfo->cut3 = rptr->cut3; rinfo->cut4 = rptr->cut4; ajListPush(*relist,(void *)rinfo); RStotal++; } for(i=0;i<ne;++i) ajStrDel(&ea[i]); AJFREE(ea); embPatRestrictDel(&rptr); ajFileClose(&fin); ajStrDel(&refilename); return RStotal; }
int main(int argc, char **argv) { AjPFile outf = NULL; AjPSeq sequence = NULL; AjPStr substr = NULL; AjPStr seqstr = NULL; AjPStr revstr = NULL; AjPStr p1; AjPStr p2; PPrimer eric = NULL; PPrimer fred = NULL; PPrimer f; PPrimer r; PPair pair; AjPList forlist = NULL; AjPList revlist = NULL; AjPList pairlist = NULL; AjBool targetrange; AjBool isDNA = ajTrue; AjBool dolist = ajFalse; ajint primerlen = 0; ajint minprimerlen = 0; ajint maxprimerlen = 0; ajint minprodlen = 0; ajint maxprodlen = 0; ajint prodlen = 0; ajint seqlen = 0; ajint stepping_value = 1; ajint targetstart = 0; ajint targetend = 0; ajint limit = 0; ajint limit2 = 0; ajint lastpos = 0; ajint startpos = 0; ajint endpos = 0; ajint begin; ajint end; ajint v1; ajint v2; ajint overlap; float minpmGCcont = 0.; float maxpmGCcont = 0.; float minprodGCcont = 0.; float maxprodGCcont = 0.; float prodTm; float prodGC; ajint i; ajint j; ajint neric=0; ajint nfred=0; ajint npair=0; float minprimerTm = 0.0; float maxprimerTm = 0.0; float saltconc = 0.0; float dnaconc = 0.0; embInit ("prima", argc, argv); substr = ajStrNew(); forlist = ajListNew(); revlist = ajListNew(); pairlist = ajListNew(); p1 = ajStrNew(); p2 = ajStrNew(); sequence = ajAcdGetSeq("sequence"); outf = ajAcdGetOutfile("outfile"); minprimerlen = ajAcdGetInt("minprimerlen"); maxprimerlen = ajAcdGetInt("maxprimerlen"); minpmGCcont = ajAcdGetFloat("minpmGCcont"); maxpmGCcont = ajAcdGetFloat("maxpmGCcont"); minprimerTm = ajAcdGetFloat("mintmprimer"); maxprimerTm = ajAcdGetFloat("maxtmprimer"); minprodlen = ajAcdGetInt("minplen"); maxprodlen = ajAcdGetInt("maxplen"); minprodGCcont = ajAcdGetFloat("minpgccont"); maxprodGCcont = ajAcdGetFloat("maxpgccont"); saltconc = ajAcdGetFloat("saltconc"); dnaconc = ajAcdGetFloat("dnaconc"); targetrange = ajAcdGetToggle("targetrange"); targetstart = ajAcdGetInt("targetstart"); targetend = ajAcdGetInt("targetend"); overlap = ajAcdGetInt("overlap"); dolist = ajAcdGetBoolean("list"); seqstr = ajSeqGetSeqCopyS(sequence); ajStrFmtUpper(&seqstr); begin = ajSeqGetBegin(sequence); end = ajSeqGetEnd(sequence); seqlen = end-begin+1; ajStrAssignSubC(&substr,ajStrGetPtr(seqstr),begin-1,end-1); revstr = ajStrNewC(ajStrGetPtr(substr)); ajSeqstrReverse(&revstr); AJCNEW0(entropy, seqlen); AJCNEW0(enthalpy, seqlen); AJCNEW0(energy, seqlen); /* Initialise Tm calculation arrays */ ajMeltTempSave(ajStrGetPtr(substr),0,seqlen,saltconc,dnaconc,1, &entropy, &enthalpy, &energy); ajFmtPrintF(outf, "\n\nINPUT SUMMARY\n"); ajFmtPrintF(outf, "*************\n\n"); if(targetrange) ajFmtPrintF (outf, "Prima of %s from positions %d to %d bps\n", ajSeqGetNameC(sequence),targetstart, targetend); else ajFmtPrintF(outf, "Prima of %s\n", ajSeqGetNameC(sequence)); ajFmtPrintF(outf, "PRIMER CONSTRAINTS:\n"); ajFmtPrintF (outf, "PRIMA DOES NOT ALLOW PRIMER SEQUENCE AMBIGUITY OR "); ajFmtPrintF(outf,"DUPLICATE PRIMER ENDPOINTS\n"); ajFmtPrintF(outf, "Primer size range is %d-%d\n",minprimerlen,maxprimerlen); ajFmtPrintF(outf, "Primer GC content range is %.2f-%.2f\n",minpmGCcont, maxpmGCcont); ajFmtPrintF(outf,"Primer melting Temp range is %.2f - %.2f C\n", minprimerTm, maxprimerTm); ajFmtPrintF (outf, "PRODUCT CONSTRAINTS:\n"); ajFmtPrintF(outf,"Product GC content range is %.2f-%.2f\n", minprodGCcont, maxprodGCcont); ajFmtPrintF(outf, "Salt concentration is %.2f (mM)\n", saltconc); ajFmtPrintF(outf, "DNA concentration is %.2f (nM)\n", dnaconc); if(targetrange) ajFmtPrintF(outf, "Targeted range to amplify is from %d to %d\n", targetstart,targetend); else { ajFmtPrintF(outf,"Considering all suitable Primer pairs with "); ajFmtPrintF(outf,"Product length ranges %d to %d\n\n\n", minprodlen, maxprodlen); } ajFmtPrintF(outf, "\n\nPRIMER/PRODUCT PAIR CALCULATIONS & OUTPUT\n"); ajFmtPrintF(outf, "*****************************************\n\n"); if(seqlen-minprimerlen < 0) ajFatal("Sequence too short"); if(targetrange) { ajStrAssignSubC(&p1,ajStrGetPtr(substr),targetstart-begin,targetend-begin); prodGC = ajMeltGC(substr,seqlen); prodTm = ajMeltTempProd(prodGC,saltconc,seqlen); if(prodGC<minprodGCcont || prodGC>maxprodGCcont) { ajFmtPrintF(outf, "Product GC content [%.2f] outside acceptable range\n", prodGC); embExitBad(); return 0; } prima_testtarget(substr, revstr, targetstart-begin, targetend-begin, minprimerlen, maxprimerlen, seqlen, minprimerTm, maxprimerTm, minpmGCcont, maxpmGCcont, minprodGCcont, maxprodGCcont, saltconc, dnaconc, pairlist, &npair); } if(!targetrange) { limit = seqlen-minprimerlen-minprodlen+1; lastpos = seqlen-minprodlen; limit2 = maxprodlen-minprodlen; /* Outer loop selects all possible product start points */ for(i=minprimerlen; i<limit; ++i) { startpos = i; ajDebug("Position in sequence %d\n",startpos); endpos = i+minprodlen-1; /* Inner loop selects all possible product lengths */ for(j=0; j<limit2; ++j, ++endpos) { if(endpos>lastpos) break; v1 = endpos-startpos+1; ajStrAssignSubC(&p1,ajStrGetPtr(substr),startpos,endpos); prodGC = ajMeltGC(p1,v1); prodTm = ajMeltTempProd(prodGC,saltconc,v1); if(prodGC<minprodGCcont || prodGC>maxprodGCcont) continue; /* Only accept primers with acceptable Tm and GC */ neric = 0; nfred = 0; prima_testproduct(substr, startpos, endpos, primerlen, minprimerlen, maxprimerlen,minpmGCcont, maxpmGCcont, minprimerTm, maxprimerTm, minprodlen, maxprodlen, prodTm, prodGC, seqlen, &eric,&fred,forlist,revlist,&neric,&nfred, stepping_value, saltconc,dnaconc, isDNA, begin); if(!neric) continue; /* Now reject those primers with self-complementarity */ prima_reject_self(forlist,revlist,&neric,&nfred); if(!neric) continue; /* Reject any primers that could bind elsewhere in the sequence */ prima_test_multi(forlist,revlist,&neric,&nfred,substr,revstr, seqlen); /* Now select the least complementary pair (if any) */ prima_best_primer(forlist, revlist, &neric, &nfred); if(!neric) continue; AJNEW(pair); ajListPop(forlist,(void **)&f); ajListPop(revlist,(void **)&r); pair->f = f; pair->r = r; ++npair; ajListPush(pairlist,(void *)pair); } } } if(!targetrange) { /* Get rid of primer pairs nearby the top scoring ones */ prima_TwoSortscorepos(&pairlist); prima_prune_nearby(pairlist, &npair, maxprimerlen-1); ajListSort(pairlist,prima_PosCompare); prima_check_overlap(pairlist,&npair,overlap); } if(npair) { if(!targetrange) ajFmtPrintF(outf,"%d pairs found\n\n",npair); else ajFmtPrintF(outf, "Closest primer pair to specified product is:\n\n"); if((maxprimerlen<26 && seqlen<999999 && !dolist)) ajFmtPrintF(outf,"\n\t\tForward\t\t\t\t\tReverse\n\n"); } for(i=0;i<npair;++i) { if(!targetrange) ajFmtPrintF(outf,"[%d]\n",i+1); ajListPop(pairlist,(void **)&pair); prodlen = pair->r->start - (pair->f->start + pair->f->primerlen); if((maxprimerlen<26 && seqlen<999999 && !dolist)) { v1 = pair->f->start; v2 = v1 + pair->f->primerlen -1; ajStrAssignSubS(&p1,substr,v1,v2); ajFmtPrintF(outf,"%6d %-25.25s %d\t", v1+begin, ajStrGetPtr(p1), v2+begin); v1 = pair->r->start; v2 = v1 + pair->r->primerlen -1; ajStrAssignSubS(&p2,substr,v1,v2); ajSeqstrReverse(&p2); ajFmtPrintF(outf, "%6d %-25.25s %d\n", v1+begin, ajStrGetPtr(p2), v2+begin); ajFmtPrintF(outf," Tm %.2f C (GC %.2f%%)\t\t ", pair->f->primerTm,pair->f->primGCcont*100.); ajFmtPrintF(outf,"Tm %.2f C (GC %.2f%%)\n", pair->r->primerTm,pair->r->primGCcont*100.); ajFmtPrintF(outf," Length: %-32dLength: %d\n", pair->f->primerlen,pair->r->primerlen); ajFmtPrintF(outf," Tma: %.2f C\t\t\t", ajAnneal(pair->f->primerTm,pair->f->prodTm)); ajFmtPrintF(outf," Tma: %.2f C\n\n\n", ajAnneal(pair->r->primerTm,pair->f->prodTm)); ajFmtPrintF(outf," Product GC: %.2f%%\n", pair->f->prodGC * 100.0); ajFmtPrintF(outf," Product Tm: %.2f C\n", pair->f->prodTm); ajFmtPrintF(outf," Length: %d\n\n\n",prodlen); } else { ajFmtPrintF(outf," Product from %d to %d\n",pair->f->start+ pair->f->primerlen+begin,pair->r->start-1+begin); ajFmtPrintF(outf," Tm: %.2f C GC: %.2f%%\n", pair->f->prodTm,pair->f->prodGC*(float)100.); ajFmtPrintF(outf," Length: %d\n\n\n",prodlen); v1 = pair->f->start; v2 = v1 + pair->f->primerlen -1; ajStrAssignSubS(&p1,substr,v1,v2); ajFmtPrintF(outf," Forward: 5' %s 3'\n",ajStrGetPtr(p1)); ajFmtPrintF(outf," Start: %d\n",v1+begin); ajFmtPrintF(outf," End: %d\n",v2+begin); ajFmtPrintF(outf," Tm: %.2f C\n", pair->f->primerTm); ajFmtPrintF(outf," GC: %.2f%%\n", pair->f->primGCcont*(float)100.); ajFmtPrintF(outf," Len: %d\n", pair->f->primerlen); ajFmtPrintF(outf," Tma: %.2f C\n\n\n", ajAnneal(pair->f->primerTm,pair->f->prodTm)); v1 = pair->r->start; v2 = v1 + pair->r->primerlen -1; ajStrAssignSubS(&p2,substr,v1,v2); ajSeqstrReverse(&p2); ajStrAssignSubS(&p1,substr,v1,v2); ajFmtPrintF(outf," Reverse: 5' %s 3'\n",ajStrGetPtr(p1)); ajFmtPrintF(outf," Start: %d\n",v1+begin); ajFmtPrintF(outf," End: %d\n",v2+begin); ajFmtPrintF(outf," Tm: %.2f C\n", pair->r->primerTm); ajFmtPrintF(outf," GC: %.2f%%\n", pair->r->primGCcont*(float)100.); ajFmtPrintF(outf," Len: %d\n", pair->r->primerlen); ajFmtPrintF(outf," Tma: %.2f C\n\n\n", ajAnneal(pair->r->primerTm,pair->f->prodTm)); } prima_PrimerDel(&pair->f); prima_PrimerDel(&pair->r); AJFREE(pair); } ajStrDel(&seqstr); ajStrDel(&revstr); ajStrDel(&substr); ajStrDel(&p1); ajStrDel(&p2); ajListFree(&forlist); ajListFree(&revlist); ajListFree(&pairlist); ajFileClose(&outf); ajSeqDel(&sequence); AJFREE(entropy); AJFREE(enthalpy); AJFREE(energy); embExit(); return 0; }
/* @funcstatic newcoils_read_matrix ******************************************* ** ** Reads the matrix and stores in a hept_pref structure ** ** @param [u] inf [AjPFile] matrix input file ** @return [struct hept_pref*] Matrix data for heptad preference ******************************************************************************/ static struct hept_pref* newcoils_read_matrix(AjPFile inf) { ajint i; ajint j; ajint pt; ajint aa_len; ajint win; float m_g; float sd_g; float m_cc; float sd_cc; float sc; float hept[NCHEPTAD]; AjPStr buff; const char *pbuff; struct hept_pref *h; buff = ajStrNew(); aa_len = strlen(NCAAs); AJNEW(h); AJCNEW(h->m,aa_len); for(i=0; i<aa_len; ++i) { AJCNEW(h->m[i],NCHEPTAD); for(j=0; j<NCHEPTAD; ++j) h->m[i][j] = -1; } AJNEW(h->f); h->n = 0; h->smallest = 1.0; while(ajReadlineTrim(inf,&buff)) { pbuff = ajStrGetPtr(buff); if(*pbuff != '%') { if((strncmp(pbuff,"uw ",3)==0) || (strncmp(pbuff,"w ",2)==0)) { i = h->n; if(strncmp(pbuff,"uw ",3)==0) h->f[i].w = 0; else h->f[i].w = 1; ajFmtScanS(buff,"%*s %d %f %f %f %f %f",&win,&m_cc, &sd_cc,&m_g,&sd_g,&sc); h->f[i].win = win; h->f[i].m_cc = (float)m_cc; h->f[i].sd_cc = (float)sd_cc; h->f[i].m_g = (float)m_g; h->f[i].sd_g = (float)sd_g; h->f[i].sc = (float)sc; h->n++; AJCRESIZE(h->f,(h->n)+1); if((h->n)>=9) ajFatal("Too many window parms in matrix file\n"); } else if(*pbuff>='A' && *pbuff<='Z') { /* AA data */ pt = (int)(pbuff[0]-'A'); if(h->m[pt][0]==-1) { ajFmtScanS(buff,"%*s%f%f%f%f%f%f%f",&hept[0], &hept[1],&hept[2],&hept[3],&hept[4], &hept[5],&hept[6]); for(i=0; i<NCHEPTAD; ++i) { h->m[pt][i] = (float)hept[i]; if(h->m[pt][i]>0) { if(h->m[pt][i]<h->smallest) h->smallest = h->m[pt][i]; } else h->m[pt][i]=-1; /* Don't permit zero values */ } } else ajWarn("multiple entries for AA %c in matrix file\n", *pbuff); } else { ajWarn("strange characters in matrix file\n"); ajWarn("Ignoring line: %S\n",buff); } } } ajStrDel(&buff); return h; }