#include "common.h"#include "pslTransMap.h"#include "psl.h"Include dependency graph for pslTransMap.c:

Go to the source code of this file.
Data Structures | |
| struct | block |
Functions | |
| static void | pslProtToNA (struct psl *psl) |
| static void | pslNAToProt (struct psl *psl) |
| static struct psl * | createMappedPsl (struct psl *inPsl, struct psl *mapPsl, int mappedPslMax) |
| static struct block | blockFromPslBlock (struct psl *psl, int iBlock) |
| static void | addPslBlock (struct psl *psl, struct block *blk, int *pslMax) |
| static void | setPslBounds (struct psl *mappedPsl) |
| static void | adjustOrientation (unsigned opts, struct psl *inPsl, char *inPslOrigStrand, struct psl *mappedPsl) |
| static struct block | getBeforeBlockMapping (unsigned mqStart, unsigned mqEnd, struct block *align1Blk) |
| static struct block | getOverBlockMapping (unsigned mqStart, unsigned mqEnd, unsigned mtStart, struct block *align1Blk) |
| static struct block | getBlockMapping (struct psl *inPsl, struct psl *mapPsl, int *iMapBlkPtr, struct block *align1Blk) |
| static boolean | mapBlock (struct psl *inPsl, struct psl *mapPsl, int *iMapBlkPtr, struct block *align1Blk, struct psl *mappedPsl, int *mappedPslMax) |
| psl * | pslTransMap (unsigned opts, struct psl *inPsl, struct psl *mapPsl) |
Definition at line 91 of file pslTransMap.c.
References psl::blockCount, pslGrow(), block::qEnd, block::qStart, block::tEnd, and block::tStart.
Referenced by mapBlock().
00093 { 00094 unsigned newIBlk = psl->blockCount; 00095 00096 assert((blk->qEnd - blk->qStart) == (blk->tEnd - blk->tStart)); 00097 if (newIBlk >= *pslMax) 00098 pslGrow(psl, pslMax); 00099 psl->qStarts[newIBlk] = blk->qStart; 00100 psl->tStarts[newIBlk] = blk->tStart; 00101 psl->blockSizes[newIBlk] = blk->qEnd - blk->qStart; 00102 /* lie about match counts. */ 00103 psl->match += psl->blockSizes[newIBlk]; 00104 psl->blockCount++; 00105 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void adjustOrientation | ( | unsigned | opts, | |
| struct psl * | inPsl, | |||
| char * | inPslOrigStrand, | |||
| struct psl * | mappedPsl | |||
| ) | [static] |
Definition at line 124 of file pslTransMap.c.
References pslRc(), pslTransMapKeepTrans, pslTStrand, and psl::strand.
Referenced by pslTransMap().
00128 { 00129 if (!(opts&pslTransMapKeepTrans) || ((inPslOrigStrand[1] == '\0') && (mappedPsl->strand[1] == '\0'))) 00130 { 00131 /* make untranslated */ 00132 if (pslTStrand(mappedPsl) == '-') 00133 pslRc(mappedPsl); 00134 mappedPsl->strand[1] = '\0'; /* implied target strand */ 00135 } 00136 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 80 of file pslTransMap.c.
References block::qEnd, block::qStart, block::tEnd, and block::tStart.
Referenced by pslTransMap().
00082 { 00083 struct block block; 00084 block.qStart = psl->qStarts[iBlock]; 00085 block.qEnd = psl->qStarts[iBlock] + psl->blockSizes[iBlock]; 00086 block.tStart = psl->tStarts[iBlock]; 00087 block.tEnd = psl->tStarts[iBlock] + psl->blockSizes[iBlock]; 00088 return block; 00089 }
Here is the caller graph for this function:

| static struct psl* createMappedPsl | ( | struct psl * | inPsl, | |
| struct psl * | mapPsl, | |||
| int | mappedPslMax | |||
| ) | [static, read] |
Definition at line 62 of file pslTransMap.c.
References pslNew(), pslQStrand, pslTStrand, psl::qName, psl::qSize, psl::strand, psl::tName, and psl::tSize.
Referenced by pslTransMap().
00065 { 00066 char strand[3]; 00067 assert(pslTStrand(inPsl) == pslQStrand(mapPsl)); 00068 00069 /* strand can be taken from both alignments, since common sequence is in same 00070 * orientation. */ 00071 strand[0] = pslQStrand(inPsl); 00072 strand[1] = pslTStrand(mapPsl); 00073 strand[2] = '\n'; 00074 00075 return pslNew(inPsl->qName, inPsl->qSize, 0, 0, 00076 mapPsl->tName, mapPsl->tSize, 0, 0, 00077 strand, mappedPslMax, 0); 00078 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static struct block getBeforeBlockMapping | ( | unsigned | mqStart, | |
| unsigned | mqEnd, | |||
| struct block * | align1Blk | |||
| ) | [static, read] |
Definition at line 138 of file pslTransMap.c.
References block::tStart, and ZeroVar.
Referenced by getBlockMapping().
00141 { 00142 struct block mappedBlk; 00143 00144 /* mRNA start in genomic gap before this block, this will 00145 * be an inPsl insert */ 00146 unsigned size = (align1Blk->tEnd < mqStart) 00147 ? (align1Blk->tEnd - align1Blk->tStart) 00148 : (mqStart - align1Blk->tStart); 00149 ZeroVar(&mappedBlk); 00150 mappedBlk.qStart = align1Blk->qStart; 00151 mappedBlk.qEnd = align1Blk->qStart + size; 00152 return mappedBlk; 00153 }
Here is the caller graph for this function:

| static struct block getBlockMapping | ( | struct psl * | inPsl, | |
| struct psl * | mapPsl, | |||
| int * | iMapBlkPtr, | |||
| struct block * | align1Blk | |||
| ) | [static, read] |
Definition at line 175 of file pslTransMap.c.
References psl::blockCount, psl::blockSizes, getBeforeBlockMapping(), getOverBlockMapping(), psl::qStarts, and psl::tStarts.
Referenced by mapBlock().
00183 { 00184 int iBlk; 00185 struct block mappedBlk; 00186 00187 /* search for block or gap containing start of mrna block */ 00188 for (iBlk = *iMapBlkPtr; iBlk < mapPsl->blockCount; iBlk++) 00189 { 00190 unsigned mqStart = mapPsl->qStarts[iBlk]; 00191 unsigned mqEnd = mapPsl->qStarts[iBlk]+mapPsl->blockSizes[iBlk]; 00192 if (align1Blk->tStart < mqStart) 00193 { 00194 *iMapBlkPtr = iBlk; 00195 return getBeforeBlockMapping(mqStart, mqEnd, align1Blk); 00196 } 00197 if ((align1Blk->tStart >= mqStart) && (align1Blk->tStart < mqEnd)) 00198 { 00199 *iMapBlkPtr = iBlk; 00200 return getOverBlockMapping(mqStart, mqEnd, mapPsl->tStarts[iBlk], align1Blk); 00201 } 00202 } 00203 00204 /* reached the end of the mRNA->genome alignment, finish off the 00205 * rest of the the protein as an insert */ 00206 ZeroVar(&mappedBlk); 00207 mappedBlk.qStart = align1Blk->qStart; 00208 mappedBlk.qEnd = align1Blk->qEnd; 00209 *iMapBlkPtr = iBlk; 00210 return mappedBlk; 00211 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static struct block getOverBlockMapping | ( | unsigned | mqStart, | |
| unsigned | mqEnd, | |||
| unsigned | mtStart, | |||
| struct block * | align1Blk | |||
| ) | [static, read] |
Definition at line 155 of file pslTransMap.c.
References block::tEnd, block::tStart, and ZeroVar.
Referenced by getBlockMapping().
00158 { 00159 struct block mappedBlk; 00160 00161 /* common sequence start contained in this block, this handles aligned 00162 * and genomic inserts */ 00163 unsigned off = align1Blk->tStart - mqStart; 00164 unsigned size = (align1Blk->tEnd > mqEnd) 00165 ? (mqEnd - align1Blk->tStart) 00166 : (align1Blk->tEnd - align1Blk->tStart); 00167 ZeroVar(&mappedBlk); 00168 mappedBlk.qStart = align1Blk->qStart; 00169 mappedBlk.qEnd = align1Blk->qStart + size; 00170 mappedBlk.tStart = mtStart + off; 00171 mappedBlk.tEnd = mtStart + off + size; 00172 return mappedBlk; 00173 }
Here is the caller graph for this function:

| static boolean mapBlock | ( | struct psl * | inPsl, | |
| struct psl * | mapPsl, | |||
| int * | iMapBlkPtr, | |||
| struct block * | align1Blk, | |||
| struct psl * | mappedPsl, | |||
| int * | mappedPslMax | |||
| ) | [static] |
Definition at line 213 of file pslTransMap.c.
References addPslBlock(), FALSE, getBlockMapping(), block::qEnd, block::qStart, block::tEnd, TRUE, and block::tStart.
Referenced by pslTransMap().
00221 { 00222 struct block mappedBlk; 00223 unsigned size; 00224 assert(align1Blk->qStart <= align1Blk->qEnd); 00225 assert(align1Blk->tStart <= align1Blk->tEnd); 00226 assert((align1Blk->qEnd - align1Blk->qStart) == (align1Blk->tEnd - align1Blk->tStart)); 00227 00228 if ((align1Blk->qStart >= align1Blk->qEnd) || (align1Blk->tStart >= align1Blk->tEnd)) 00229 return FALSE; /* end of ungapped block. */ 00230 00231 /* find block or gap with start coordinates of mrna */ 00232 mappedBlk = getBlockMapping(inPsl, mapPsl, iMapBlkPtr, align1Blk); 00233 00234 if ((mappedBlk.qEnd != 0) && (mappedBlk.tEnd != 0)) 00235 addPslBlock(mappedPsl, &mappedBlk, mappedPslMax); 00236 00237 /* advance past block or gap */ 00238 size = (mappedBlk.qEnd != 0) 00239 ? (mappedBlk.qEnd - mappedBlk.qStart) 00240 : (mappedBlk.tEnd - mappedBlk.tStart); 00241 align1Blk->qStart += size; 00242 align1Blk->tStart += size; 00243 00244 return TRUE; 00245 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void pslNAToProt | ( | struct psl * | psl | ) | [static] |
Definition at line 47 of file pslTransMap.c.
References psl::blockCount, psl::blockSizes, psl::qEnd, psl::qSize, psl::qStart, and psl::qStarts.
Referenced by pslTransMap().
00049 { 00050 int iBlk; 00051 00052 psl->qStart /= 3; 00053 psl->qEnd /= 3; 00054 psl->qSize /= 3; 00055 for (iBlk = 0; iBlk < psl->blockCount; iBlk++) 00056 { 00057 psl->blockSizes[iBlk] /= 3; 00058 psl->qStarts[iBlk] /= 3; 00059 } 00060 }
Here is the caller graph for this function:

| static void pslProtToNA | ( | struct psl * | psl | ) | [static] |
Definition at line 32 of file pslTransMap.c.
References psl::blockCount, psl::blockSizes, psl::qEnd, psl::qSize, psl::qStart, and psl::qStarts.
Referenced by pslTransMap().
00034 { 00035 int iBlk; 00036 00037 psl->qStart *= 3; 00038 psl->qEnd *= 3; 00039 psl->qSize *= 3; 00040 for (iBlk = 0; iBlk < psl->blockCount; iBlk++) 00041 { 00042 psl->blockSizes[iBlk] *= 3; 00043 psl->qStarts[iBlk] *= 3; 00044 } 00045 }
Here is the caller graph for this function:

Definition at line 247 of file pslTransMap.c.
References adjustOrientation(), psl::blockCount, blockFromPslBlock(), createMappedPsl(), errAbort(), mapBlock(), pslFree(), pslIsProtein(), pslNAToProt(), pslProtToNA(), pslQStrand, pslRc(), pslTStrand, psl::qName, psl::qSize, safef(), sameString, setPslBounds(), psl::tName, and psl::tSize.
00250 { 00251 int mappedPslMax = 8; /* allocated space in output psl */ 00252 int iMapBlk = 0; 00253 char inPslOrigStrand[3]; 00254 boolean rcInPsl = (pslTStrand(inPsl) != pslQStrand(mapPsl)); 00255 boolean cnv1 = (pslIsProtein(inPsl) && !pslIsProtein(mapPsl)); 00256 boolean cnv2 = (pslIsProtein(mapPsl) && !pslIsProtein(inPsl)); 00257 int iBlock; 00258 struct psl* mappedPsl; 00259 00260 if (!sameString(inPsl->tName, mapPsl->qName)) 00261 errAbort("Error: inPsl tName %s != mapPsl tName %s)", 00262 inPsl->tName, mapPsl->qName); 00263 if (inPsl->tSize != mapPsl->qSize) 00264 errAbort("Error: inPsl %s tSize (%d) != mapPsl %s qSize (%d)", 00265 inPsl->tName, inPsl->tSize, mapPsl->qName, mapPsl->qSize); 00266 00267 /* convert protein PSLs */ 00268 if (cnv1) 00269 pslProtToNA(inPsl); 00270 if (cnv2) 00271 pslProtToNA(mapPsl); 00272 00273 /* need to ensure common sequence is in same orientation, save strand for later */ 00274 safef(inPslOrigStrand, sizeof(inPslOrigStrand), "%s", inPsl->strand); 00275 if (rcInPsl) 00276 pslRc(inPsl); 00277 00278 mappedPsl = createMappedPsl(inPsl, mapPsl, mappedPslMax); 00279 00280 /* Fill in ungapped blocks. */ 00281 for (iBlock = 0; iBlock < inPsl->blockCount; iBlock++) 00282 { 00283 struct block align1Blk = blockFromPslBlock(inPsl, iBlock); 00284 while (mapBlock(inPsl, mapPsl, &iMapBlk, &align1Blk, mappedPsl, 00285 &mappedPslMax)) 00286 continue; 00287 } 00288 00289 /* finish up psl, or free if no blocks were added */ 00290 assert(mappedPsl->blockCount <= mappedPslMax); 00291 if (mappedPsl->blockCount == 0) 00292 pslFree(&mappedPsl); /* nothing made it */ 00293 else 00294 { 00295 setPslBounds(mappedPsl); 00296 adjustOrientation(opts, inPsl, inPslOrigStrand, mappedPsl); 00297 } 00298 00299 /* restore input */ 00300 if (rcInPsl) 00301 { 00302 pslRc(inPsl); 00303 strcpy(inPsl->strand, inPslOrigStrand); 00304 } 00305 if (cnv1) 00306 pslNAToProt(inPsl); 00307 if (cnv2) 00308 pslNAToProt(mapPsl); 00309 00310 return mappedPsl; 00311 }
Here is the call graph for this function:

| static void setPslBounds | ( | struct psl * | mappedPsl | ) | [static] |
Definition at line 107 of file pslTransMap.c.
References psl::blockCount, psl::blockSizes, pslQStrand, pslTStrand, psl::qEnd, psl::qSize, psl::qStart, psl::qStarts, reverseIntRange(), psl::tEnd, psl::tSize, psl::tStart, and psl::tStarts.
Referenced by pslTransMap().
00109 { 00110 int lastBlk = mappedPsl->blockCount-1; 00111 00112 /* set start/end of sequences */ 00113 mappedPsl->qStart = mappedPsl->qStarts[0]; 00114 mappedPsl->qEnd = mappedPsl->qStarts[lastBlk] + mappedPsl->blockSizes[lastBlk]; 00115 if (pslQStrand(mappedPsl) == '-') 00116 reverseIntRange(&mappedPsl->qStart, &mappedPsl->qEnd, mappedPsl->qSize); 00117 00118 mappedPsl->tStart = mappedPsl->tStarts[0]; 00119 mappedPsl->tEnd = mappedPsl->tStarts[lastBlk] + mappedPsl->blockSizes[lastBlk]; 00120 if (pslTStrand(mappedPsl) == '-') 00121 reverseIntRange(&mappedPsl->tStart, &mappedPsl->tEnd, mappedPsl->tSize); 00122 }
Here is the call graph for this function:

Here is the caller graph for this function:

1.5.2