static void tranalign_AddGaps(AjPSeq newseq, const AjPSeq nseq, const AjPSeq pseq, ajlong npos) { AjPStr newstr = NULL; ajuint ppos = 0; newstr = ajStrNew(); for(; ppos<ajSeqGetLen(pseq); ppos++) if(ajSeqGetSeqC(pseq)[ppos] == '-') ajStrAppendC(&newstr, "---"); else { ajStrAppendSubS(&newstr, ajSeqGetSeqS(nseq), npos, npos+2); npos+=3; } ajDebug("aligned seq=%S\n", newstr); ajSeqAssignSeqS(newseq, newstr); ajStrDel(&newstr); return; }
static void trimest_tolower(AjPStr *strng, ajint start, ajint end) { AjPStr substr; substr = ajStrNew(); /* extract the region and lowercase */ ajStrAppendSubS(&substr, *strng, start, end); ajStrFmtLower(&substr); /* remove and replace the lowercased region */ ajStrCutRange(strng, start, end); ajStrInsertS(strng, start, substr); ajStrDel(&substr); return; }
static void extractfeat_GetRegionPad(const AjPSeq seq, AjPStr *featstr, ajint start, ajint end, AjBool sense, AjBool beginning) { ajint tmp; ajint pad; AjPStr result; ajDebug("In extractfeat_GetRegionPad start=%d, end=%d\n", start, end); result = ajStrNew(); if(start > end) return; if(start < 0) { pad = -start; if(ajSeqIsNuc(seq)) ajStrAppendCountK(&result, 'N', pad); else ajStrAppendCountK(&result, 'X', pad); start = 0; } if(end > (ajint) ajSeqGetLen(seq)-1) tmp = ajSeqGetLen(seq)-1; else tmp = end; if(start <= (ajint) ajSeqGetLen(seq) && tmp >= 0) { ajDebug("Get subsequence %d-%d\n", start, tmp); ajStrAppendSubS(&result, ajSeqGetSeqS(seq), start, tmp); ajDebug("result=%S\n", result); } if(end > (ajint) ajSeqGetLen(seq)-1) { pad = end - ajSeqGetLen(seq)+1; if(ajSeqIsNuc(seq)) ajStrAppendCountK(&result, 'N', pad); else ajStrAppendCountK(&result, 'X', pad); ajDebug("result=%S\n", result); } /* if feature was in reverse sense, then get reverse complement */ if(!sense) { ajDebug("get reverse sense of subsequence\n"); ajSeqstrReverse(&result); ajDebug("result=%S\n", result); } if(beginning) { ajDebug("Prepend to featstr: %S\n", result); ajStrInsertS(featstr, 0, result); } else { ajDebug("Append to featstr: %S\n", result); ajStrAppendS(featstr, result); } ajDebug("featstr=%S\n", *featstr); ajStrDel(&result); return; }