source: branches/profile/CONVERTALN/seq.cxx

Last change on this file was 7187, checked in by westram, 13 years ago

merges [7099] [7106] [7107] from refactor

  • name+type → FormattedFile
  • simplyfied command line parsing and interactive mode
  • renamed output-format 'phylip2' to 'fastdnaml'
  • fixed broken calls to arb_convert_aln
    • raxml and puzzle expect PHYLIP format
    • arb_dnarates and arb_fastdnaml expect FASTDNAML format
File size: 1.6 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : seq.cxx                                           //
4//   Purpose   :                                                   //
5//                                                                 //
6// =============================================================== //
7
8#include "seq.h"
9#include "ali.h"
10#include "reader.h"
11
12void Seq::out(Writer& write, Format outType) const {
13    ca_assert(outType == EMBL || outType == GENBANK); // others not implemented yet
14
15    const char *sequence = get_seq();
16    int         indk     = 1;
17
18    for (int indi = 0, indj = 0; indi < get_len(); indi++) {
19        if ((indk % 60) == 1) {
20            switch (outType) {
21                case EMBL: write.out("     "); break;
22                case GENBANK: write.outf("   %6d ", indk); break;
23                default: ca_assert(0); break;
24            }
25        }
26        write.out(sequence[indi]);
27        indj++;
28
29        // blank space follows every 10 bases, but not before '\n'
30        if ((indk % 60) == 0) {
31            write.out('\n');
32            indj = 0;
33        }
34        else if (indj == 10 && indi != (get_len() - 1)) {
35            write.out(' ');
36            indj = 0;
37        }
38        indk++;
39    }
40
41    if ((indk % 60) != 1)
42        write.out('\n');
43    write.out("//\n");
44}
45
46void read_alignment(Alignment& ali, const FormattedFile& in) {
47    FormatReaderPtr reader = FormatReader::create(in);
48    while (1) {
49        SeqPtr seq = new Seq;
50        if (!reader->read_one_entry(*seq)) break;
51        ali.add(seq);
52    }
53}
54
55
Note: See TracBrowser for help on using the repository browser.