File: seq.cxx

package info (click to toggle)
arb 6.0.6-8
  • links: PTS, VCS
  • area: non-free
  • in suites: sid, trixie
  • size: 66,204 kB
  • sloc: ansic: 394,911; cpp: 250,290; makefile: 19,644; sh: 15,879; perl: 10,473; fortran: 6,019; ruby: 683; xml: 503; python: 53; awk: 32
file content (55 lines) | stat: -rw-r--r-- 1,673 bytes parent folder | download | duplicates (6)
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
// =============================================================== //
//                                                                 //
//   File      : seq.cxx                                           //
//   Purpose   :                                                   //
//                                                                 //
// =============================================================== //

#include "seq.h"
#include "ali.h"
#include "reader.h"

void Seq::out(Writer& write, Format outType) const {
    ca_assert(outType == EMBL || outType == GENBANK); // others not implemented yet

    const char *sequence = get_seq();
    int         indk     = 1;

    for (int indi = 0, indj = 0; indi < get_len(); indi++) {
        if ((indk % 60) == 1) {
            switch (outType) {
                case EMBL: write.out("     "); break;
                case GENBANK: write.outf("   %6d ", indk); break;
                default: ca_assert(0); break;
            }
        }
        write.out(sequence[indi]);
        indj++;

        // blank space follows every 10 bases, but not before '\n'
        if ((indk % 60) == 0) {
            write.out('\n');
            indj = 0;
        }
        else if (indj == 10 && indi != (get_len() - 1)) {
            write.out(' ');
            indj = 0;
        }
        indk++;
    }

    if ((indk % 60) != 1)
        write.out('\n');
    write.out("//\n");
}

void read_alignment(Alignment& ali, const FormattedFile& in) {
    FormatReaderPtr reader = FormatReader::create(in);
    while (1) {
        SeqPtr seq = new Seq;
        if (!reader->read_one_entry(*seq)) break;
        ali.add(seq);
    }
}