File: SMRTReadUtils.cpp

package info (click to toggle)
pbseqlib 0~20161219-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,924 kB
  • ctags: 5,123
  • sloc: cpp: 82,727; makefile: 305; python: 239; sh: 8
file content (43 lines) | stat: -rw-r--r-- 1,268 bytes parent folder | download | duplicates (2)
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

#include "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;
  }
}