File: TestChromosomeNTdata.cpp

package info (click to toggle)
perm 0.4.0-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 976 kB
  • sloc: cpp: 13,499; makefile: 98; sh: 12
file content (56 lines) | stat: -rw-r--r-- 1,798 bytes parent folder | download | duplicates (5)
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
56
#include "TestChromosomeNTdata.h"

TestChromosomeNTdata::TestChromosomeNTdata(const char* testInputChrFileN, const char* testOutputChrFileN)
{
    cout << "Start TestChromosomeNTdata" << endl;
    bool bFasta = true;
    unsigned int ntPerLine = 96; // TODO manually test
    generateTestInput(testInputChrFileN);
    cout << "generateTestInput" << endl;
    CchromosomeNTdata* chr = new CchromosomeNTdata(testInputChrFileN, bFasta);
    cout << "Got Chr" << endl;
    outputFasta(testOutputChrFileN, ntPerLine, chr->caChromosome);
    cout << "end" << endl;
    delete chr;
}

TestChromosomeNTdata::~TestChromosomeNTdata(void)
{
}

int TestChromosomeNTdata::outputFasta(const char* filename, unsigned int ntPerLine, const char* ntStr)
{
    int lineCounter = 0;
    ofstream ofile(filename);
    int length = (int)strlen(ntStr);
    for(int ntCount = strlen(ntStr); ntCount > 0; ntCount = ntCount - ntPerLine) {
        for(int i = 0; i < ntPerLine; i++) {
            int index = lineCounter * ntPerLine + i;
            char c = ntStr[index];
            if( c != EOF && c != '\0' && index != length) {
                ofile << c;
            } else {
                ofile << "\n";
                break;
            }
        }
        ofile << endl;
        lineCounter ++;
    }
    ofile.close();
    return(0);
}

int TestChromosomeNTdata::generateTestInput(const char* filename)
{
    // defaultNtPerLine = 48;
    int lineNo = 500000;
    const char* line = "ACGTNNAnaCGTNNCnACGTNNGnAcGTNNTnACGTNNAnACgTNNCnACGtNNGnaCGTNNTnAcGTNNAnACgTNNCnACgTNNGnACGtNNTn";
    ofstream ofile(filename);
    ofile << ">Test Ref" << endl;
    for(int i = 0; i < lineNo; i++) {
        ofile << line << endl;
    }
    ofile.close();
    return(0);
}