source: branches/items/GDE/PROBCONS/probcons/ProjectPairwise.cc

Last change on this file was 10411, checked in by aboeckma, 11 years ago

make probcons compile on linux (added cstring include )

File size: 1.7 KB
Line 
1/////////////////////////////////////////////////////////////////
2// ProjectPairwise
3//
4// Program for projecting multiple alignments to all pairwise
5// alignments.
6/////////////////////////////////////////////////////////////////
7
8#include "SafeVector.h"
9#include "MultiSequence.h"
10#include <string>
11#include <sstream>
12#include <iomanip>
13#include <iostream>
14#include <list>
15#include <set>
16#include <limits>
17#include <cstdio>
18#include <cstdlib>
19#include <cerrno>
20#include <iomanip>
21#include <cstring>
22
23bool compressGaps = true;
24
25/////////////////////////////////////////////////////////////////
26// main()
27//
28// Main program.
29/////////////////////////////////////////////////////////////////
30
31int main (int argc, char **argv){
32
33  // check arguments
34  if (argc < 2){
35    cerr << "Usage: project ALIGNMENT [-nocompressgaps]" << endl;
36    exit (1);
37  }
38
39  for (int i = 2; i < argc; i++){
40    if (strcmp (argv[i], "-nocompressgaps") == 0)
41      compressGaps = false;
42    else {
43      cerr << "Unrecognized option: " << argv[i] << endl;
44      exit (1);
45    }
46  }
47
48  MultiSequence *align = new MultiSequence (string (argv[1])); assert (align);
49
50  int N = align->GetNumSequences();
51  for (int i = 0; i < N; i++){
52    for (int j = i+1; j < N; j++){
53      string name = align->GetSequence(i)->GetHeader() + "-" + align->GetSequence(j)->GetHeader() + ".fasta";
54      ofstream outfile (name.c_str());
55
56      if (compressGaps){
57        set<int> s;
58        s.insert (i); s.insert (j);
59        MultiSequence *proj = align->Project (s);
60        proj->WriteMFA (outfile);
61        delete proj;
62      }
63      else {
64        align->GetSequence(i)->WriteMFA (outfile, 60);
65        align->GetSequence(j)->WriteMFA (outfile, 60);
66      }
67      outfile.close();
68    }
69  }
70
71  delete align;
72}
Note: See TracBrowser for help on using the repository browser.