File: indel.cpp

package info (click to toggle)
fastml 3.11-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,772 kB
  • sloc: cpp: 48,522; perl: 3,588; ansic: 819; makefile: 386; python: 83; sh: 55
file content (58 lines) | stat: -rw-r--r-- 1,418 bytes parent folder | download | duplicates (5)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// 	$Id: indel.cpp 962 2006-11-07 15:13:34Z privmane $	

#include "indel.h"

indel::indel() {}

int indel::fromChar(const char s) const{
	switch (s) {
		case 'x' : case'X' : return 0; break;	
		case '-' : case'_' : return 1; break;
		default:
			vector<string> err;
			err.push_back(" The indel sequences contained the character: ");
			err[0]+=s;
			err.push_back(" Indel was not one of the following: ");
			err.push_back(" -, X");
			err.push_back(" _, x");
			errorMsg::reportError(err);
	}// end of switch
	return -99; // never suppose to be here.	
}// end of function

vector<int> indel::fromString(const string &str) const {
	vector<int> vec;
	for (int i=0;i<str.size();i++)
	  vec.push_back(fromChar(str[i]));
	return vec;
}

string indel::fromInt(const int in_id) const{
  char res = 0;
	switch (in_id) {
		case 0 : res = 'X'  ; break;
		case 1 : res = '-'  ; break;
		default:
		vector<string> err;
		err.push_back("unable to print indel_id. indel_id was not one of the following: ");
		err.push_back("X, -");
		err.push_back("x, _");
		errorMsg::reportError(err);
		}//end of switch
	string vRes;
	vRes.append(1,res);
	return vRes;
}// end of function

// There are no relations here.
int indel::relations(const int charInSeq, const int charToCheck) const{
	if (charInSeq == charToCheck)
		return 1;
	return 0;
}

int indel::fromChar(const string& str, const int pos) const{
	return fromChar(str[pos]);
}