File: SMRTReadUtils.cpp

package info (click to toggle)
pbseqlib 5.3.5%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,020 kB
  • sloc: cpp: 77,250; python: 331; sh: 103; makefile: 41
file content (44 lines) | stat: -rw-r--r-- 1,395 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <pbdata/utils/SMRTReadUtils.hpp>

void GetSMRTReadCoordinates(FASTQSequence &seq, int &x, int &y)
{
    std::string str(seq.title, seq.titleLength);
    std::vector<std::string> titleTokens;
    Splice(str, "_", titleTokens);
    x = y = -1;
    for (size_t i = 0; i < titleTokens.size(); i++) {
        if (titleTokens[i].size() > 1 && titleTokens[i][0] == 'x') {
            x = atoi(&titleTokens[i].c_str()[1]);
        }
        if (titleTokens[i].size() > 1 && titleTokens[i][0] == 'y') {
            y = atoi(&titleTokens[i].c_str()[1]);
        }
    }
    assert("Could not parse a title to find an x coordinate" != 0 or x != -1);
    assert("Could not parse a title to find a y coordiante" != 0 or y != -1);
}

void GetSpringfieldHoleNumberFromTitle(FASTQSequence &seq, unsigned int &holeNumber)
{
    std::vector<std::string> titleTokens;
    Splice(seq.title, "/", titleTokens);
    if (titleTokens.size() < 2) {
        return;
    }
    holeNumber = atoi(titleTokens[1].c_str());
}

bool ParsePBIReadName(std::string &readName, std::string &movieName, int &holeNumber)
{
    std::vector<std::string> tokens;
    ParseSeparatedList(readName, tokens, '/');
    if (tokens.size() < 2) {
        movieName = "";
        holeNumber = 0;
        return false;
    } else {
        movieName = tokens[0];
        holeNumber = atoi(tokens[1].c_str());
        return true;
    }
}