| 1282 | } |
| 1283 | |
| 1284 | void processSAMBlock(splitLine_t * block, state_t * state) |
| 1285 | { |
| 1286 | idCount += 1; |
| 1287 | // First mark dups and find the discordants. |
| 1288 | // These share a lot of looking at flag bits, so make sense to put together. |
| 1289 | markDupsDiscordants(block, state); |
| 1290 | // Look for splitters. |
| 1291 | // Since this is expensive, don't do it unless the user asked for them. |
| 1292 | if (state->splitterFile != NULL || state->unmappedClippedFile != NULL) |
| 1293 | { |
| 1294 | // Check the first read for splitter. |
| 1295 | markSplitterUnmappedClipped(block, state, FIRST_SEG, true); |
| 1296 | // Check the second read for splitter. |
| 1297 | markSplitterUnmappedClipped(block, state, SECOND_SEG, true); |
| 1298 | // Check for a singleton read |
| 1299 | markSplitterUnmappedClipped(block, state, MULTI_SEGS, false); |
| 1300 | } |
| 1301 | |
| 1302 | // Now do the output. |
| 1303 | for (splitLine_t * line = block; line != NULL; line = line->next) |
| 1304 | { |
| 1305 | // Do the unmapped file first, as it is not sam, and doesn't sew the line back together. |
| 1306 | if (state->unmappedClippedFile != NULL && line->unmappedClipped && !(state->excludeDups && isDuplicate(line))) |
| 1307 | { |
| 1308 | writeUnmappedClipped(line, state); |
| 1309 | unmapClipCount += 1; |
| 1310 | } |
| 1311 | |
| 1312 | // Write to the output file. |
| 1313 | if (!(state->removeDups && isDuplicate(line))) |
| 1314 | { |
| 1315 | writeLine(line, state->outputFile); |
| 1316 | } |
| 1317 | |
| 1318 | // Write to discordant file if appropriate. |
| 1319 | if (state->discordantFile != NULL && line->discordant && !(state->excludeDups && isDuplicate(line))) |
| 1320 | { |
| 1321 | writeLine(line, state->discordantFile); |
| 1322 | discCount += 1; |
| 1323 | } |
| 1324 | // Write to splitter file if appropriate. |
| 1325 | if (state->splitterFile != NULL && line->splitter && !(state->excludeDups && isDuplicate(line))) |
| 1326 | { |
| 1327 | writeSAMlineWithIdNum(line, state->splitterFile); |
| 1328 | splitCount += 1; |
| 1329 | } |
| 1330 | } |
| 1331 | |
| 1332 | disposeSplitLines(block); |
| 1333 | } |
| 1334 | |
| 1335 | /////////////////////////////////////////////////////////////////////////////// |
| 1336 | // Main Routine with helpers. |
no test coverage detected