-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAluSimulation.h
107 lines (89 loc) · 4.34 KB
/
AluSimulation.h
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//
// Created by snow on 4/9/15.
//
#ifndef GSIM_ALUSIMULATION_H
#define GSIM_ALUSIMULATION_H
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
string alu = "GGCTGGGCATGGTGGCTCATGCCTGTAATCCCAGCACTTTGGGAGGCTGA"
"GGTGGGCGGATCATGAGGTCAGGAGATTGAGACCGTCCTGGCTAACGTGG"
"TGAAACCCCGTCTTTACTAAAAATACAAAAAATTAGCCAGGCGTGGTGGT"
"GGGCACCTGTAGTCCCAGCCTCTCAGGAGCCTGAGGCAGGAGAATGGTGT"
"GAACCCAGGAGGCGGAGCTTGCAGTGAGCTATCACACCACTGCACTCCAG"
"CCTGGGCGAGAGAGAGACTCCATCTTAAAAAAAAAAAAAAAAAAAAAAAA"
"A";
string AddAlu(string original, int position){
if(position > original.length()){
cerr<<"invalid position"<<endl;
exit(1);
}
return original.substr(0,position) + alu + original.substr(position, original.length());
}
string rc(string& input){
string rcSq;
string result= "";
rcSq= input;
for (int i=0; i< rcSq.length(); i++)
{
if (input[i]== 'A')
rcSq[rcSq.length()-i+1]= 'T';
if (input[i]== 'T')
rcSq[rcSq.length()-i+1]= 'A';
if (input[i]== 'C')
rcSq[rcSq.length()-i+1]= 'G';
if (input[i]== 'G')
rcSq[rcSq.length()-i+1]= 'C';
}
return rcSq;
}
void GenerateSimplestSet(string inputgenome, string& reference_genome, string& target_genome){
size_t first = 1000;
size_t second = inputgenome.length() - 1000;
size_t new_pos = (first + second)/2;
reference_genome = inputgenome.substr(0,first) + alu +
inputgenome.substr(first, second - first) + alu + inputgenome.substr(second,inputgenome.length() -second);
target_genome = inputgenome.substr(0, first) + alu + inputgenome.substr(first,new_pos -first) + alu
+ inputgenome.substr(new_pos, second - new_pos) + alu + inputgenome.substr(second, inputgenome.length() -second);
return;
}
void GenerationTest2 (string inputgenome, string& reference_genome, string& target_genome){
size_t first = 1000;
size_t second = inputgenome.length()-1000;
size_t new_pos = (first+second)/2;
reference_genome= inputgenome.substr(0, first) + alu + inputgenome.substr(first,new_pos -first) + alu
+ inputgenome.substr(new_pos, second - new_pos) + alu + inputgenome.substr(second, inputgenome.length() -second);
target_genome= inputgenome.substr(0,first)+ alu
+ inputgenome.substr(first, (new_pos-first)/2) + (alu)
+ inputgenome.substr(first+(new_pos-first)/2, (new_pos-first)/2)+ alu
+ inputgenome.substr(new_pos, (second-new_pos)/2)+ (alu)
+ inputgenome.substr(new_pos+(second-new_pos)/2, (second-new_pos)/2)+ (alu)
+ inputgenome.substr(second, inputgenome.length()-second);
return;
}
void GenerationTestrc1 (string inputgenome, string& reference_genome, string& target_genome){
size_t first = 1000;
size_t second = inputgenome.length() - 1000;
size_t new_pos = (first + second)/2;
reference_genome = inputgenome.substr(0,first) + alu +
inputgenome.substr(first, second - first) + alu + inputgenome.substr(second,inputgenome.length() -second);
target_genome = inputgenome.substr(0, first) + rc(alu) + inputgenome.substr(first,new_pos -first) + alu
+ inputgenome.substr(new_pos, second - new_pos) + rc(alu) + inputgenome.substr(second, inputgenome.length() -second);
return;
}
void GenerationTestrc2 (string inputgenome, string& reference_genome, string& target_genome){
size_t first = 1000;
size_t second = inputgenome.length()-1000;
size_t new_pos = (first+second)/2;
reference_genome= inputgenome.substr(0, first) + alu + inputgenome.substr(first,new_pos -first) + alu
+ inputgenome.substr(new_pos, second - new_pos) + alu + inputgenome.substr(second, inputgenome.length() -second);
target_genome= inputgenome.substr(0,first)+ rc(alu)
+ inputgenome.substr(first, (new_pos-first)/2) + alu
+ inputgenome.substr(first+(new_pos-first)/2, (new_pos-first)/2)+ rc(alu)
+ inputgenome.substr(new_pos, (second-new_pos)/2)+ alu
+ inputgenome.substr(new_pos+(second-new_pos)/2, (second-new_pos)/2)+ rc(alu)
+ inputgenome.substr(second, inputgenome.length()-second);
return;
}
#endif //GSIM_ALUSIMULATION_H