static void digest_report_hits(AjPFeattable TabRpt, AjPList l, ajint be, const char* s) { AjPFeature gf = NULL; EmbPPropFrag fr; AjPStr t; ajint len; AjPStr tmpStr = NULL; size_t stlen; t = ajStrNew(); stlen = strlen(s); len = (ajint) stlen; while(ajListPop(l,(void **)&fr)) { ajStrAssignSubC(&t,s,fr->start,fr->end); gf = ajFeatNewII(TabRpt,fr->start+be,fr->end+be); ajFmtPrintS(&tmpStr, "*molwt %.3f", fr->molwt); ajFeatTagAdd(gf, NULL, tmpStr); if(fr->start>0) { ajFmtPrintS(&tmpStr, "*cterm %c", *(s+(fr->start)-1)); ajFeatTagAdd(gf, NULL, tmpStr); } if(fr->end<len-1) { ajFmtPrintS(&tmpStr, "*nterm %c", *(s+(fr->end+1))); ajFeatTagAdd(gf, NULL, tmpStr); } AJFREE(fr); } ajStrDel(&t); ajStrDel(&tmpStr); return; }
static void silent_fmt_hits(AjPList hits, AjPFeattable feat, AjBool silent, AjBool rev) { PSilent res; AjPFeature sf = NULL; AjPStr tmpFeatStr = NULL; ajListSort(hits,silent_basecompare); while(ajListPop(hits,(void **)&res)) { if (rev) sf = ajFeatNewIIRev(feat, res->match, res->match+ajStrGetLen(res->site)-1); else sf = ajFeatNewII(feat, res->match, res->match+ajStrGetLen(res->site)-1); if (silent) { ajFmtPrintS(&tmpFeatStr, "*silent Yes"); ajFeatTagAdd (sf, NULL, tmpFeatStr); } ajFmtPrintS(&tmpFeatStr, "*enzyme %S", res->code); ajFeatTagAdd (sf, NULL, tmpFeatStr); ajFmtPrintS(&tmpFeatStr, "*rspattern %S", res->site); ajFeatTagAdd (sf, NULL, tmpFeatStr); ajFmtPrintS(&tmpFeatStr, "*baseposn %d", res->base); ajFeatTagAdd (sf, NULL, tmpFeatStr); ajFmtPrintS(&tmpFeatStr, "*aa %S.%S", res->seqaa, res->reaa); ajFeatTagAdd (sf, NULL, tmpFeatStr); ajFmtPrintS(&tmpFeatStr, "*mutation %c->%c", res->obase,res->nbase); ajFeatTagAdd (sf, NULL, tmpFeatStr); ajStrDel(&res->code); ajStrDel(&res->site); ajStrDel(&res->seqaa); ajStrDel(&res->reaa); AJFREE(res); } ajStrDel(&tmpFeatStr); return; }
static void jaspscan_ReportHits(AjPFeattable TabRpt, const AjPTable mattab, AjPList hits) { PJsphits hit = NULL; PJspmat info = NULL; AjPFeature feat = NULL; AjPStr str = NULL; float fnum = 0.; str = ajStrNew(); while(ajListPop(hits,(void **)&hit)) { if(hit->start <= hit->end) feat = ajFeatNewII(TabRpt,hit->start,hit->end); else feat = ajFeatNewIIRev(TabRpt,hit->start,hit->end); ajFmtPrintS(&str,"*pc %.3f",hit->scorepc); ajFeatTagAdd(feat, NULL, str); ajFmtPrintS(&str,"*id %S",hit->matname); ajFeatTagAdd(feat, NULL, str); info = ajTableFetch(mattab,hit->matname); if(!info) ajWarn("No info for matrix %S",hit->matname); if(ajStrGetLen(info->name)) { ajFmtPrintS(&str,"*name %S",info->name); ajFeatTagAdd(feat, NULL, str); } if(ajStrGetLen(info->species)) { ajFmtPrintS(&str,"*species %S",info->species); ajFeatTagAdd(feat, NULL, str); } if(ajStrGetLen(info->klass)) { ajFmtPrintS(&str,"*class %S",info->klass); ajFeatTagAdd(feat, NULL, str); } if(ajStrGetLen(info->sgroup)) { ajFmtPrintS(&str,"*supergroup %S",info->sgroup); ajFeatTagAdd(feat, NULL, str); } if(ajStrGetLen(info->protseq)) { ajFmtPrintS(&str,"*pseq %S",info->protseq); ajFeatTagAdd(feat, NULL, str); } if(ajStrGetLen(info->exp)) { ajFmtPrintS(&str,"*exp %S",info->exp); ajFeatTagAdd(feat, NULL, str); } if(ajStrGetLen(info->pmid)) { ajFmtPrintS(&str,"*pmid %S",info->pmid); ajFeatTagAdd(feat, NULL, str); } if(ajStrGetLen(info->num)) { ajStrToFloat(info->num,&fnum); ajFmtPrintS(&str,"*info %.3f",fnum); ajFeatTagAdd(feat, NULL, str); } if(ajStrGetLen(info->jaspar)) { ajFmtPrintS(&str,"*jaspar %S",info->jaspar); ajFeatTagAdd(feat, NULL, str); } if(ajStrGetLen(info->transfac)) { ajFmtPrintS(&str,"*transfac %S",info->transfac); ajFeatTagAdd(feat, NULL, str); } if(ajStrGetLen(info->mcs)) { ajStrToFloat(info->mcs,&fnum); ajFmtPrintS(&str,"*mcs %.3f",fnum); ajFeatTagAdd(feat, NULL, str); } if(ajStrGetLen(info->models)) { ajFmtPrintS(&str,"*built %S",info->models); ajFeatTagAdd(feat, NULL, str); } jaspscan_hitsdel(&hit); } ajStrDel(&str); return; }
void embPatternSeqSearch (AjPFeattable ftable, const AjPSeq seq, const AjPPatternSeq pat, AjBool reverse) { const void *tidy; ajuint hits; ajuint i; AjPPatComp pattern; EmbPMatMatch m = NULL; AjPFeature sf = NULL; AjPSeq revseq = NULL; AjPList list = ajListNew(); AjPStr seqstr = ajStrNew(); AjPStr seqname = ajStrNew(); AjPStr tmp = ajStrNew(); ajint adj; ajint begin; AjBool isreversed; ajint seqlen; seqlen = ajSeqGetLen(seq); if(!seqlen) return; isreversed = ajSeqIsReversedTrue(seq); if(isreversed) seqlen += ajSeqGetOffset(seq); begin = ajSeqGetBeginTrue(seq); adj = ajSeqGetEndTrue(seq); if(!ajStrGetLen(featMotifProt)) ajStrAssignC(&featMotifProt, "SO:0001067"); if(!ajStrGetLen(featMotifNuc)) ajStrAssignC(&featMotifNuc, "SO:0000714"); ajStrAssignS(&seqname,ajSeqGetNameS(seq)); pattern = ajPatternSeqGetCompiled(pat); if (reverse) { revseq = ajSeqNewSeq(seq); ajStrAssignSubS(&seqstr, ajSeqGetSeqS(revseq), begin-1,adj-1); ajSeqstrReverse(&seqstr); } else ajStrAssignSubS(&seqstr, ajSeqGetSeqS(seq), begin-1,adj-1); ajStrFmtUpper(&seqstr); /*ajDebug("seqlen:%d len: %d offset: %d offend: %d begin: %d end: %d\n" "'%S'\n", seqlen , ajSeqGetLen(seq), ajSeqGetOffset(seq), ajSeqGetOffend(seq), ajSeqGetBegin(seq), ajSeqGetEnd(seq), seqstr);*/ ajDebug("embPatternSeqSearch '%S' protein: %B reverse: %B\n", pattern->pattern, pat->Protein, reverse); embPatFuzzSearchII(pattern,begin,seqname,seqstr,list, ajPatternSeqGetMismatch(pat),&hits,&tidy); ajDebug ("embPatternSeqSearch: found %d hits\n",hits); if(!reverse) ajListReverse(list); for(i=0;i<hits;++i) { ajListPop(list,(void **)&m); if (reverse) sf = ajFeatNew(ftable, NULL, featMotifNuc, adj - m->start - m->len + begin + 1, adj - m->start + begin, 0.0, '-', 0); else { if(ajSeqIsProt(seq) || ajFeattableIsProt(ftable)) sf = ajFeatNewProt(ftable, NULL, featMotifProt, m->start, m->start + m->len - 1, 0.0); else sf = ajFeatNew(ftable, NULL, featMotifNuc, m->start, m->start + m->len - 1, 0.0, '.', 0); } if(isreversed) ajFeatReverse(sf, seqlen); /* ajUser("isrev: %B reverse: %B begin: %d adj: %d " "start: %d len: %d seqlen: %d %d..%d '%c'\n", isreversed, reverse, begin, adj, m->start, m->len, seqlen, sf->Start, sf->End, sf->Strand); */ ajFeatSetScore(sf, (float) (m->len - m->mm)); ajFmtPrintS(&tmp, "*pat %S: %S", ajPatternSeqGetName(pat), ajPatternSeqGetPattern(pat)); ajFeatTagAdd(sf,NULL,tmp); if(m->mm) { ajFmtPrintS(&tmp, "*mismatch %d", m->mm); ajFeatTagAdd(sf, NULL, tmp); } embMatMatchDel(&m); } ajStrDel(&seqname); ajStrDel(&seqstr); ajStrDel(&tmp); ajListFree(&list); if (reverse) ajSeqDel(&revseq); return; }
void embPatternRegexSearch (AjPFeattable ftable, const AjPSeq seq, const AjPPatternRegex pat, AjBool reverse) { ajint pos=0; ajint off; ajint len; AjPFeature sf = NULL; AjPStr substr = NULL; AjPStr seqstr = NULL; AjPStr tmpstr = NULL; AjPStr tmp = ajStrNew(); AjPRegexp patexp = ajPatternRegexGetCompiled(pat); ajint adj; AjBool isreversed; AjPSeq revseq; ajint seqlen; seqlen = ajSeqGetLen(seq); if(!seqlen) return; isreversed = ajSeqIsReversedTrue(seq); if(isreversed) seqlen += ajSeqGetOffset(seq); pos = ajSeqGetBeginTrue(seq); adj = ajSeqGetEndTrue(seq); if(!ajStrGetLen(featMotifProt)) ajStrAssignC(&featMotifProt, "SO:0001067"); if(!ajStrGetLen(featMotifNuc)) ajStrAssignC(&featMotifNuc, "SO:0000714"); /*ajDebug("embPatternRegexSearch pos: %d adj: %d reverse: %B\n", pos, adj, reverse, isreversed);*/ /*ajDebug("seqlen:%d len: %d offset: %d offend: %d begin: %d end: %d\n", seqlen , ajSeqGetLen(seq), ajSeqGetOffset(seq), ajSeqGetOffend(seq), ajSeqGetBegin(seq), ajSeqGetEnd(seq));*/ if (reverse) { revseq = ajSeqNewSeq(seq); ajStrAssignSubS(&seqstr, ajSeqGetSeqS(revseq), pos-1, adj-1); ajSeqstrReverse(&seqstr); } ajStrAssignSubS(&seqstr, ajSeqGetSeqS(seq), pos-1, adj-1); ajStrFmtUpper(&seqstr); while(ajStrGetLen(seqstr) && ajRegExec(patexp, seqstr)) { off = ajRegOffset(patexp); len = ajRegLenI(patexp, 0); if(off || len) { ajRegSubI(patexp, 0, &substr); ajRegPost(patexp, &tmp); ajStrAssignS(&seqstr, substr); ajStrAppendS(&seqstr, tmp); pos += off; /*ajDebug("match pos: %d adj: %d len: %d off:%d\n", pos, adj, len, off);*/ if (reverse) sf = ajFeatNew(ftable, NULL, featMotifNuc, adj - pos - len + 2, adj - pos + 1, 0.0, '-', 0); else { if(ajSeqIsProt(seq) || ajFeattableIsProt(ftable)) sf = ajFeatNewProt(ftable, NULL, featMotifProt, pos, pos + len - 1, 0.0); else sf = ajFeatNew(ftable, NULL, featMotifNuc, pos, pos + len - 1, 0.0, '.', 0); } if(isreversed) ajFeatReverse(sf, seqlen); ajFmtPrintS (&tmpstr,"*pat %S: %S", ajPatternRegexGetName(pat), ajPatternRegexGetPattern(pat)); ajFeatTagAdd (sf,NULL,tmpstr); pos += 1; ajStrCutStart(&seqstr, 1); } else { pos++; ajStrCutStart(&seqstr, 1); } } ajStrDel(&tmpstr); ajStrDel(&tmp); ajStrDel(&substr); ajStrDel(&seqstr); if(reverse) ajSeqDel(&revseq); return; }