]>
Commit | Line | Data |
---|---|---|
91b72a4c | 1 | // Reads a motif file defined using gassiplex channel and converts |
2 | // it (using GCToBerg.dat file) into a motif file using berg pin numbering | |
3 | // (as used by mapping software). | |
4 | ||
5 | #include <fstream> | |
6 | #include <vector> | |
7 | #include <string> | |
8 | ||
9 | void readGCToBerg(std::vector<int>& gc2berg) | |
10 | { | |
11 | gc2berg.clear(); | |
12 | ||
13 | std::ifstream in("GCToBerg.dat"); | |
14 | ||
15 | int gc, berg; | |
16 | ||
17 | while ( in >> gc >> berg ) | |
18 | { | |
19 | gc2berg.push_back(berg); | |
20 | } | |
21 | ||
22 | in.close(); | |
23 | } | |
24 | ||
25 | void convertMotif(const char* inputfile, const char* outputfile) | |
26 | { | |
27 | std::vector<int> gc2berg; | |
28 | ||
29 | readGCToBerg(gc2berg); | |
30 | ||
31 | std::ifstream in(inputfile); | |
32 | std::ofstream out(outputfile); | |
33 | ||
34 | char line[80]; | |
35 | int n = 1; | |
36 | while ( in.getline(line,80) ) | |
37 | { | |
38 | ||
39 | if ( line[0] == '#' ) | |
40 | { | |
41 | // Comment line. No change. | |
42 | out << line << std::endl; | |
43 | } | |
44 | else | |
45 | { | |
46 | std::string sline(line); | |
47 | ||
48 | int gc = atoi(sline.c_str()); | |
49 | // assume the first 2 characters only are the gc number, | |
50 | // so replace them with berg number. | |
51 | int berg = gc2berg[gc]; | |
52 | out << berg << "\t1\t" << n << "\t-" << std::endl; | |
53 | ++n; | |
54 | } | |
55 | } | |
56 | ||
57 | in.close(); | |
58 | out.close(); | |
59 | } |