[go: up one dir, main page]

File: blast_run.h

package info (click to toggle)
seqan 1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 21,368 kB
  • ctags: 17,376
  • sloc: cpp: 81,339; ansic: 58,225; makefile: 96; sh: 14
file content (392 lines) | stat: -rw-r--r-- 10,124 bytes parent folder | download
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
/*==========================================================================
 SeqAn - The Library for Sequence Analysis
 http://www.seqan.de
 ============================================================================
 Copyright (C) 2007
 
 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 3 of the License, or (at your option) any later version.
 
 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 Lesser General Public License for more details.
 
 ============================================================================
 $Id: blast_run.h 4714 2009-08-24 13:38:02Z weese@PCPOOL.MI.FU-BERLIN.DE $
 ==========================================================================*/
#ifndef SEQAN_HEADER_BLAST_RUN_H
#define SEQAN_HEADER_BLAST_RUN_H

//SEQAN_NO_DDDOC: do not generate documentation for this file

namespace SEQAN_NAMESPACE_MAIN
{


//////////////////////////////////////////////////////////////////////////////
// Different Blast Program Types
//////////////////////////////////////////////////////////////////////////////

// DNA alignments
// blastn compares a nucleotide query sequence against a nucleotide sequence database
struct TagRunBlastN_;
typedef Tag<TagRunBlastN_> const RunBlastN;
// megablast
struct TagRunMegaBlast_;
typedef Tag<TagRunMegaBlast_> const RunMegaBlast;
//blat
struct TagRunBlat_;
typedef Tag<TagRunBlat_> const RunBlat;

// Protein alignments
// blastp compares an amino acid query sequence against a protein sequence database
struct TagRunBlastP_;
typedef Tag<TagRunBlastP_> const RunBlastP;
// blastx compares a nucleotide query sequence translated in all reading frames against a protein sequence database
struct TagRunBlastX_;
typedef Tag<TagRunBlastX_> const RunBlastX;
// tblastn compares a protein query sequence against a nucleotide sequence database dynamically translated in all reading frames
struct TagRunTBlastN_;
typedef Tag<TagRunTBlastN_> const RunTBlastN;
// tblastx compares the six-frame translations of a nucleotide query sequence against the six-frame translations of a nucleotide sequence database. Please note that tblastx program cannot be used with the nr database on the BLAST Web page.
struct TagRunTBlastX_;
typedef Tag<TagRunTBlastX_> const RunTBlastX;

//////////////////////////////////////////////////////////////////////////////




//////////////////////////////////////////////////////////////////////////////
// Blast Program Calls
//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
//blastn
template<typename TString, typename TPath1, typename TPath, typename TParamString>
void
_runBlast(TPath1 blast_path,
	TPath db_path,
	TString db_name,
	TPath query_path,
	TString query_name,
	TPath out_path,
	TString outfile_name,
	Tag<TagRunBlastN_>,
	TParamString params)
{
SEQAN_CHECKPOINT


	std::stringstream blastcall;
	blastcall << blast_path << "blastall"; 
	blastcall << " -p blastn"; 
	blastcall << " -d " << db_path << db_name; 
	blastcall << " -i " << query_path << query_name; 
	blastcall << " -o " << out_path << outfile_name; 
	blastcall << " " << params; 
	//process params?

	std::cout <<"\n"<< blastcall.str()<<"\n";
	system((blastcall.str()).c_str());	


}
	
//run without saving the blast report file (saves temporarily)
template<typename TBlast, typename TBlastReport, typename TString, typename TParamString>
void
run(Tag<TBlast> tag,
	TString blast_path,
	TString db_path,
	TString db_name,
	TString query_path,
	TString query_name,
	TBlastReport & blastObj, //BlastReport<BlastHsp<BlastN,THspInfoSpec>,TStoreSpec,TInfoSpec >
	TParamString params = "")
{
SEQAN_CHECKPOINT

#ifdef PLATFORM_WINDOWS
	String<char> out_path(blast_path);
	String<char> out_path2("D:\\emde\\blast\\bin\\data\\");
#else
	String<char> out_path(blast_path);
#endif

	String<char> outfile_name = "tempseqanblast.out";

	_runBlast(blast_path,db_path,db_name,query_path,query_name,out_path,outfile_name,tag,params);

	std::fstream strm;
	std::stringstream s;
	s <<out_path<< outfile_name; 

	strm.open((s.str()).c_str(),::std::ios_base::in);
	read(strm,blastObj, Blast());

}
	




//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
//megablast
template<typename TString, typename TPath1, typename TPath, typename TParamString>
void
_runBlast(TPath1 blast_path,
	TPath db_path,
	TString db_name,
	TPath query_path,
	TString query_name,
	TPath out_path,
	TString outfile_name,
	Tag<TagRunMegaBlast_>,
	TParamString params)
{
SEQAN_CHECKPOINT

	std::stringstream blastcall;
	blastcall << blast_path << "megablast"; 
	blastcall << " -d " << db_path << db_name; 
	blastcall << " -i " << query_path << query_name; 
	blastcall << " -o " << out_path << outfile_name; 
	blastcall << " " << params; 

	//process params

	system((blastcall.str()).c_str());	


}



//////////////////////////////////////////////////////////////////////////////
//blat
template<typename TString, typename TPath1, typename TPath, typename TParamString>
void
_runBlat(TPath1 blat_path,
	TPath db_path,
	TString db_name,
	TPath query_path,
	TString query_name,
	TPath out_path,
	TString outfile_name,
	Tag<TagRunBlat_>,
	TParamString params)
{
SEQAN_CHECKPOINT

	std::stringstream blatcall;
	blatcall << blat_path << "blat "; 
	blatcall << db_path << db_name<<" "; 
	blatcall << query_path << query_name<<" "; 
	blatcall << " " << params; 
	blatcall << " -out=blast " << out_path << outfile_name; 
	
	//process params

	std::cout << blatcall.str() << "\n";
	system((blatcall.str()).c_str());	


}



//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
//blastp
template<typename TString, typename TPath1, typename TPath, typename TParamString>
void
_runBlast(TPath1 blast_path,
	TPath db_path,
	TString db_name,
	TPath query_path,
	TString query_name,
	TPath out_path,
	TString outfile_name,
	Tag<TagRunBlastP_>,
	TParamString params)
{
SEQAN_CHECKPOINT


	std::stringstream blastcall;
	blastcall << blast_path << "blastall"; 
	blastcall << " -p blastp"; 
	blastcall << " -d " << db_path << db_name; 
	blastcall << " -i " << query_path << query_name; 
	blastcall << " -o " << out_path << outfile_name; 
	blastcall << " " << params; 

	//process params

	system((blastcall.str()).c_str());	


}



//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
//tblastn
template<typename TString, typename TPath1, typename TPath, typename TParamString>
void
_runBlast(TPath1 blast_path,
	TPath db_path,
	TString db_name,
	TPath query_path,
	TString query_name,
	TPath out_path,
	TString outfile_name,
	Tag<TagRunTBlastN_>,
	TParamString params)
{
SEQAN_CHECKPOINT


	std::stringstream blastcall;
	blastcall << blast_path << "blastall"; 
	blastcall << " -p tblastn"; 
	blastcall << " -d " << db_path << db_name; 
	blastcall << " -i " << query_path << query_name; 
	blastcall << " -o " << out_path << outfile_name; 
	blastcall << " " << params; 

	//process params

	system((blastcall.str()).c_str());	


}

//////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////
//tblastx
template<typename TString, typename TPath1, typename TPath, typename TParamString>
void
_runBlast(TPath1 blast_path,
	TPath db_path,
	TString db_name,
	TPath query_path,
	TString query_name,
	TPath out_path,
	TString outfile_name,
	Tag<TagRunTBlastX_>,
	TParamString params)
{
SEQAN_CHECKPOINT


	std::stringstream blastcall;
	blastcall << blast_path << "blastall"; 
	blastcall << " -p tblastx"; 
	blastcall << " -d " << db_path << db_name; 
	blastcall << " -i " << query_path << query_name; 
	blastcall << " -o " << out_path << outfile_name; 
	blastcall << " " << params; 
	//process params

	system((blastcall.str()).c_str());	


}



//////////////////////////////////////////////////////////////////////////////




//////////////////////////////////////////////////////////////////////////////
//blastx
template<typename TString, typename TPath1, typename TPath, typename TParamString>
void
_runBlast(TPath1 blast_path,
	TPath db_path,
	TString db_name,
	TPath query_path,
	TString query_name,
	TPath out_path,
	TString outfile_name,
	Tag<TagRunBlastX_>,
	TParamString params)
{
SEQAN_CHECKPOINT


	std::stringstream blastcall;
	blastcall << blast_path << "blastall"; 
	blastcall << " -p blastx"; 
	blastcall << " -d " << db_path << db_name; 
	blastcall << " -i " << query_path << query_name; 
	blastcall << " -o " << out_path << outfile_name; 
	blastcall << " " << params; 

	//process params

	system((blastcall.str()).c_str());	


}






//////////////////////////////////////////////////////////////////////////////
//formatdb
template<typename TStr,typename TString, typename TParamString>
void
_runFormatDB(TStr blast_path,
			 TStr db_path,
			 TString db_file,
			 TParamString params)
{
SEQAN_CHECKPOINT


	std::stringstream blastcall;
	blastcall << blast_path << "formatdb "; 
	blastcall << " -i " <<db_path << db_file; 
	blastcall << " " << params; 

	//process params

	system((blastcall.str()).c_str());	


}











}// namespace SEQAN_NAMESPACE_MAIN

#endif //#ifndef SEQAN_HEADER_...