annotate carpet-src-1/tools/CARPET/com_uni.cpp @ 0:cdd489d98766

Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
author matces
date Tue, 07 Jun 2011 16:50:41 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
1 /*
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
2 * Copyright 2009 Matteo Cesaroni, Lucilla Luzi
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
3 *
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
4 * This program is free software; ; you can redistribute it and/or modify
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
5 * it under the terms of the GNU Lesser General Public License as published by
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
6 * the Free Software Foundation; either version 3 of the License, or (at your
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
7 * option) any later version.
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
8 *
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
12 * GNU General Public License for more details.
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
13
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
14 */
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
15
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
16 #include <iostream>
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
17 #include <fstream>
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
18 #include <string>
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
19 #include <vector>
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
20 #include <algorithm>
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
21 #include <sstream>
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
22 #include <deque>
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
23 #include <map>
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
24 #include <ctime>
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
25 #include <cstdlib>
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
26
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
27 using namespace std;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
28
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
29 inline void Tokenize(const string& str,
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
30 vector<string>& tokens,
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
31 const string& delimiters = " ")
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
32 {
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
33 // Skip delimiters at beginning.
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
34 string::size_type lastPos = str.find_first_not_of(delimiters, 0);
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
35 // Find first "non-delimiter".
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
36 string::size_type pos = str.find_first_of(delimiters, lastPos);
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
37
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
38 while (string::npos != pos || string::npos != lastPos)
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
39 {
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
40 // Found a token, add it to the vector.
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
41 tokens.push_back(str.substr(lastPos, pos - lastPos));
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
42 // Skip delimiters. Note the "not_of"
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
43 lastPos = str.find_first_not_of(delimiters, pos);
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
44 // Find next "non-delimiter"
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
45 pos = str.find_first_of(delimiters, lastPos);
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
46 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
47 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
48
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
49
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
50 typedef struct {
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
51 int inizioprobe;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
52 int fineprobe;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
53 string score;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
54 string campo1;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
55 string campo2;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
56 string strand;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
57 string index;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
58 int file;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
59 } Probe;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
60
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
61 struct Comparatore2 {
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
62 bool operator()(const Probe& s1, const Probe& s2) const {
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
63 if (s1.inizioprobe < s2.inizioprobe) {
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
64 return true;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
65 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
66 else if (s1.inizioprobe == s2.inizioprobe) {
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
67 if (s1.fineprobe < s2.fineprobe) {
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
68 return true;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
69 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
70 else if (s1.fineprobe == s2.fineprobe){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
71 return true;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
72 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
73 else {
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
74 return false;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
75 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
76
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
77 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
78 else {
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
79 return false;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
80 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
81
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
82 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
83 };
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
84
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
85 int main (int argc, char * const argv[]) {
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
86
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
87 string concatenate=argv[3];
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
88 int dist_t=atoi(argv[1]);
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
89 string choice=argv[2];
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
90
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
91 string name_out= argv[6];
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
92 ofstream resfile;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
93 resfile.open (name_out.c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
94
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
95
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
96
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
97 if (concatenate=="no" && choice!="union"){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
98
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
99 //print "flank=$win , type=$type col6=%overlap, concatenate=$concatenate";
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
100 if (choice=="common"){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
101 cout<<"flank="<<dist_t<<" , type="<<choice<<" , col6=%overlap, concatenate="<<concatenate;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
102 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
103 if (choice=="unique"){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
104 cout<<"flank="<<dist_t<<" , type="<<choice<<" , col6=score o p-value";
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
105 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
106
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
107 string line;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
108 Probe thisprobe;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
109 Probe thisanno;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
110 int overlap=0;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
111 vector<string> arraypro;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
112 map<string, vector<Probe> > seq;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
113 map<string, vector<Probe> > annotation;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
114 map<string, vector<Probe> >::iterator itseq;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
115
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
116 ifstream seque_file(argv[4]);
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
117 while (getline(seque_file, line)) {
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
118 string s4;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
119 s4.assign(line, 0, 1);
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
120 if (line=="" || s4=="#"){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
121 continue;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
122 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
123 arraypro.clear();
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
124 Tokenize(line, arraypro, "\t");
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
125 string chr2 = (arraypro[0].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
126 thisprobe.inizioprobe=atoi(arraypro[3].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
127 thisprobe.fineprobe=atoi(arraypro[4].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
128 thisprobe.campo1=(arraypro[1].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
129 thisprobe.campo2=(arraypro[2].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
130 thisprobe.score=(arraypro[5].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
131 thisprobe.strand=(arraypro[6].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
132 thisprobe.index=(arraypro[8].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
133 seq[chr2].push_back(thisprobe);
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
134 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
135
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
136
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
137 ifstream anno_file(argv[5]);
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
138 while (getline(anno_file, line)) {
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
139 string s4;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
140 s4.assign(line, 0, 1);
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
141 if (line=="" || s4=="#"){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
142 continue;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
143 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
144 arraypro.clear();
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
145 Tokenize(line, arraypro, "\t");
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
146 string chr3= (arraypro[0].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
147 thisanno.inizioprobe=atoi(arraypro[3].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
148 thisanno.fineprobe=atoi(arraypro[4].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
149 thisanno.campo1=(arraypro[1].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
150 thisanno.campo2=(arraypro[2].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
151 thisanno.score=(arraypro[5].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
152 thisanno.strand=(arraypro[6].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
153 thisanno.index=(arraypro[8].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
154 annotation[chr3].push_back(thisanno);
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
155 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
156
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
157
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
158 for ( itseq=seq.begin() ; itseq != seq.end(); itseq++ ){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
159
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
160 vector <Probe> seq_chr = (*itseq).second;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
161 vector <Probe> anno_chr = annotation[(*itseq).first];
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
162 if(anno_chr.size()==0 && choice=="unique"){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
163 for (int i=0; i<seq_chr.size();i++){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
164 resfile<<(*itseq).first<<"\t"<<seq_chr[i].campo1<<"\t"<<seq_chr[i].campo2<<"\t"<<seq_chr[i].inizioprobe<<"\t"<<seq_chr[i].fineprobe<<"\t"<<seq_chr[i].score<<"\t"<<seq_chr[i].strand<<"\t.\t"<<seq_chr[i].index<<endl;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
165 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
166 continue;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
167 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
168 if(anno_chr.size()==0 && choice=="common"){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
169 continue;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
170 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
171 sort (seq_chr.begin(),seq_chr.end(),Comparatore2());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
172 sort (anno_chr.begin(),anno_chr.end(),Comparatore2());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
173
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
174 int finefine=0;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
175
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
176 for (int i=0; i<anno_chr.size();i++){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
177 if(anno_chr[i].fineprobe<=finefine){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
178 anno_chr[i].fineprobe=finefine;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
179 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
180 if(anno_chr[i].fineprobe>finefine){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
181 finefine=anno_chr[i].fineprobe;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
182 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
183 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
184
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
185 for (int i=0; i<seq_chr.size();i++){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
186 int start_array=0;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
187 int fine_array=anno_chr.size();
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
188 int pos=1;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
189 int trovato=0;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
190
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
191 while (pos>0){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
192 pos=(fine_array-start_array)/2;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
193 int position=start_array+pos;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
194
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
195 if((seq_chr[i].inizioprobe-dist_t)<anno_chr[position].inizioprobe){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
196 fine_array=position;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
197 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
198 if((seq_chr[i].inizioprobe-dist_t)>anno_chr[position].inizioprobe){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
199 start_array=position;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
200 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
201 if((seq_chr[i].inizioprobe-dist_t)<=anno_chr[position].fineprobe && (seq_chr[i].fineprobe+dist_t)>=anno_chr[position].inizioprobe){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
202 if (choice=="common"){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
203 if (seq_chr[i].inizioprobe<=anno_chr[position].inizioprobe && seq_chr[i].fineprobe<=anno_chr[position].fineprobe){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
204 overlap=(seq_chr[i].fineprobe-anno_chr[position].inizioprobe)*100/(seq_chr[i].fineprobe-seq_chr[i].inizioprobe);
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
205 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
206 if (seq_chr[i].inizioprobe<=anno_chr[position].inizioprobe && seq_chr[i].fineprobe>=anno_chr[position].fineprobe){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
207 overlap=(anno_chr[position].fineprobe-anno_chr[position].inizioprobe)*100/(seq_chr[i].fineprobe-seq_chr[i].inizioprobe);
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
208 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
209 if (seq_chr[i].inizioprobe>=anno_chr[position].inizioprobe && seq_chr[i].fineprobe>=anno_chr[position].fineprobe){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
210 overlap=(anno_chr[position].fineprobe-seq_chr[i].inizioprobe)*100/(seq_chr[i].fineprobe-seq_chr[i].inizioprobe);
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
211 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
212 if (seq_chr[i].inizioprobe>=anno_chr[position].inizioprobe && seq_chr[i].fineprobe<=anno_chr[position].fineprobe){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
213 overlap=100;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
214 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
215 if (overlap<0){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
216 overlap=-1;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
217 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
218 resfile<<(*itseq).first<<"\t"<<seq_chr[i].campo1<<"\t"<<seq_chr[i].campo2<<"\t"<<seq_chr[i].inizioprobe<<"\t"<<seq_chr[i].fineprobe<<"\t"<<overlap<<"\t"<<seq_chr[i].strand<<"\t.\t"<<"ValueA:"<<seq_chr[i].score<<"~"<<"ValueB:"<<anno_chr[position].score<<endl;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
219 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
220 trovato=1;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
221 break;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
222 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
223 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
224 if (choice=="unique" && trovato==0){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
225 resfile<<(*itseq).first<<"\t"<<seq_chr[i].campo1<<"\t"<<seq_chr[i].campo2<<"\t"<<seq_chr[i].inizioprobe<<"\t"<<seq_chr[i].fineprobe<<"\t"<<seq_chr[i].score<<"\t"<<seq_chr[i].strand<<"\t.\t"<<seq_chr[i].index<<endl;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
226 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
227 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
228 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
229 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
230
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
231 if (concatenate=="yes" || choice == "union"){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
232
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
233 cout<<"flank="<<dist_t<<" , type="<<choice<<" , col6=#overlaping regions, concatenate="<<concatenate;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
234
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
235 string line;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
236 Probe thisprobe;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
237 Probe thisanno;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
238 vector<string> arraypro;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
239 map<string, vector<Probe> > seq;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
240 map<string, vector<Probe> > annotation;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
241 map<string, vector<Probe> >::iterator itseq;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
242 string concatenate=argv[3];
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
243 int dist_t=atoi(argv[1]);
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
244 string choice=argv[2];
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
245
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
246 ifstream seque_file(argv[4]);
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
247 while (getline(seque_file, line)) {
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
248 string s4;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
249 s4.assign(line, 0, 1);
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
250 if (line=="" || s4=="#"){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
251 continue;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
252 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
253 arraypro.clear();
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
254 Tokenize(line, arraypro, "\t");
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
255 string chr2 = (arraypro[0].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
256 thisprobe.inizioprobe=atoi(arraypro[3].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
257 thisprobe.fineprobe=atoi(arraypro[4].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
258 thisprobe.campo2=(arraypro[2].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
259 thisprobe.campo1=(arraypro[1].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
260 thisprobe.score=(arraypro[5].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
261 thisprobe.index=(arraypro[8].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
262 thisprobe.strand=(arraypro[6].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
263 thisprobe.file=1;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
264 seq[chr2].push_back(thisprobe);
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
265 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
266
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
267 ifstream anno_file(argv[5]);
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
268 while (getline(anno_file, line)) {
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
269 string s4;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
270 s4.assign(line, 0, 1);
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
271 if (line=="" || s4=="#"){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
272 continue;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
273 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
274 arraypro.clear();
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
275 Tokenize(line, arraypro, "\t");
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
276 string chr3= (arraypro[0].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
277 thisanno.inizioprobe=atoi(arraypro[3].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
278 thisanno.fineprobe=atoi(arraypro[4].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
279 thisanno.campo2=(arraypro[2].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
280 thisanno.campo1=(arraypro[1].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
281 thisanno.score=(arraypro[5].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
282 thisanno.index=(arraypro[8].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
283 thisanno.strand=(arraypro[6].c_str());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
284 thisanno.file=2;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
285 seq[chr3].push_back(thisanno);
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
286 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
287
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
288 int inizio;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
289 int fine;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
290 string annot;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
291 int overlap;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
292 int inizio_ann;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
293 int fine_ann;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
294
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
295 for ( itseq=seq.begin() ; itseq != seq.end(); itseq++ ){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
296
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
297 vector <Probe> seq_chr = (*itseq).second;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
298 sort (seq_chr.begin(),seq_chr.end(),Comparatore2());
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
299
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
300 for (int i=0; i<seq_chr.size();i++){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
301 inizio = seq_chr[i].inizioprobe;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
302 fine=seq_chr[i].fineprobe;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
303 int file_t=0;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
304 int file_t2=0;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
305 int entrato=1;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
306 int z=1;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
307 if(seq_chr[i].file==1){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
308 file_t=1;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
309 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
310 if(seq_chr[i].file==2){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
311 file_t2=1;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
312 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
313 if(i==(seq_chr.size()-1)){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
314 if (choice=="union"){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
315 resfile<<(*itseq).first<<"\tfile_"<<seq_chr[i].file<<"\tunique\t"<<seq_chr[i].inizioprobe<<"\t"<<seq_chr[i].fineprobe<<"\t"<<seq_chr[i].score<<"\t"<<seq_chr[i].strand<<"\t.\t"<<seq_chr[i].index<<endl;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
316 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
317 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
318
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
319 //cout<<"x"<<(*itseq).first<<"\t"<<seq_chr[i].inizioprobe<<"\t"<<seq_chr[i].fineprobe<<"\t"<<seq_chr[i].file<<endl;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
320 for (int y=i+1; y<seq_chr.size(); y++){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
321 if((inizio-dist_t)<=seq_chr[y].fineprobe && (fine+dist_t)>=seq_chr[y].inizioprobe){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
322 if(seq_chr[y].file==1){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
323 file_t=1;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
324 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
325 if(seq_chr[y].file==2){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
326 file_t2=1;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
327 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
328 if(seq_chr[y].fineprobe>fine){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
329 fine=seq_chr[y].fineprobe;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
330 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
331 entrato=2;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
332 i++;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
333 z++;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
334 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
335 if(seq_chr[y].inizioprobe>fine || y==seq_chr.size()-1){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
336 if (choice == "union" && entrato==1){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
337 resfile<<(*itseq).first<<"\tfile_"<<seq_chr[i].file<<"\tunique\t"<<inizio<<"\t"<<fine<<"\t"<<seq_chr[i].score<<"\t"<<seq_chr[i].strand<<"\t.\t"<<seq_chr[i].index<<endl;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
338 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
339 if (choice == "union" && entrato==2){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
340 resfile<<(*itseq).first<<"\tcommon\tcommon\t"<<inizio<<"\t"<<fine<<"\t"<<z<<"\t.\t.\tcommon"<<endl;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
341 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
342 if (choice == "common" && entrato==2 && file_t == 1 && file_t2 == 1 && concatenate=="yes"){
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
343 resfile<<(*itseq).first<<"\t"<<seq_chr[i].campo1<<"\t"<<seq_chr[i].campo2<<"\t"<<inizio<<"\t"<<fine<<"\t"<<z<<"\t"<<seq_chr[i].strand<<"\t.\t"<<seq_chr[i].index<<endl;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
344 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
345 break;
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
346 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
347 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
348 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
349 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
350 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
351 }
cdd489d98766 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff changeset
352