source: trunk/GDE/MAFFT/mafft-7.055-with-extensions/extensions/mxscarna_src/probconsRNA/ProjectPairwise.cc

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

updated mafft version. Added extensions (no svn ignore, yet)

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
22bool compressGaps = true;
23
24/////////////////////////////////////////////////////////////////
25// main()
26//
27// Main program.
28/////////////////////////////////////////////////////////////////
29
30int main (int argc, char **argv){
31
32  // check arguments
33  if (argc < 2){
34    cerr << "Usage: project ALIGNMENT [-nocompressgaps]" << endl;
35    exit (1);
36  }
37
38  for (int i = 2; i < argc; i++){
39    if (strcmp (argv[i], "-nocompressgaps") == 0)
40      compressGaps = false;
41    else {
42      cerr << "Unrecognized option: " << argv[i] << endl;
43      exit (1);
44    }
45  }
46
47  MultiSequence *align = new MultiSequence (string (argv[1])); assert (align);
48
49  int N = align->GetNumSequences();
50  for (int i = 0; i < N; i++){
51    for (int j = i+1; j < N; j++){
52      string name = align->GetSequence(i)->GetHeader() + "-" + align->GetSequence(j)->GetHeader() + ".fasta";
53      ofstream outfile (name.c_str());
54
55      if (compressGaps){
56        set<int> s;
57        s.insert (i); s.insert (j);
58        MultiSequence *proj = align->Project (s);
59        proj->WriteMFA (outfile);
60        delete proj;
61      }
62      else {
63        align->GetSequence(i)->WriteMFA (outfile, 60);
64        align->GetSequence(j)->WriteMFA (outfile, 60);
65      }
66      outfile.close();
67    }
68  }
69
70  delete align;
71}
Note: See TracBrowser for help on using the repository browser.