1 /************************************************************
2 * Copyright (C) 2005, BGI of Chinese Academy of Sciences
5 * Filename: ConcatenatePairs.cpp
6 * Abstract: Concatenate all pairs of sequences with AXT format
7 to a pair of sequences (maybe very long).
10 * Author: Zhang Zhang (zhanghzhang@genomics.org.cn)
16 *************************************************************/
23 string result
; //Result for outputing into a file
25 bool readFile(const char *filename
) {
32 ifstream
is(filename
);
34 cout
<<"\nError in opening file..."<<endl
;
38 cout
<<"\nPlease wait while reading sequences and concatenating..."<<endl
;
40 string temp
="", name
="", str
="";
42 while (getline(is
, temp
, '\n')) {
46 getline(is
, temp
, '\n');
49 getline(is
, temp
, '\n');
52 seq1
+= str
.substr(0, str
.length()/2);
53 seq2
+= str
.substr(str
.length()/2, str
.length()/2);
60 result
+= "Concatenate-"; result
+= filename
; result
+= '\n';
61 result
+= seq1
; result
+= '\n';
62 result
+= seq2
; result
+= '\n';
74 bool writeFile(const char *filename
, const char *content
) {
79 ofstream
os(filename
);
84 cout
<<"Error in writing file..."<<endl
;
92 int main(int argc
, char* argv
[]) {
95 cout
<<"Description: Concatenate all pairs of sequences with AXT format to a pair of sequences."<<endl
;
96 cout
<<"Usage: ConPairs [AXT Filename] [Output Filename]"<<endl
;
101 if (!readFile(argv
[1])) throw 1;
102 if (!writeFile(argv
[2], result
.c_str())) throw 1;
103 cout
<<"Mission accomplished."<<endl
;
107 cout
<<"Mission failed."<<endl
;