| 1 | // ----------------------------------------------------------------------------- |
|---|
| 2 | // Include-Dateien |
|---|
| 3 | // ----------------------------------------------------------------------------- |
|---|
| 4 | |
|---|
| 5 | #include <iostream.h> |
|---|
| 6 | #include <fstream.h> |
|---|
| 7 | #include <stdio.h> |
|---|
| 8 | #include <stdlib.h> |
|---|
| 9 | |
|---|
| 10 | #include "a3_arbdb.hxx" |
|---|
| 11 | #include "a3_bihelix.hxx" |
|---|
| 12 | #include "a3_ali.hxx" |
|---|
| 13 | |
|---|
| 14 | // ----------------------------------------------------------------------------- |
|---|
| 15 | static void Usage ( void ) |
|---|
| 16 | // ----------------------------------------------------------------------------- |
|---|
| 17 | { |
|---|
| 18 | cout << "\nAUFRUF: aliv3 <Datenbank> <Sequenz>\n"; |
|---|
| 19 | cout << "\n <Datenbank> ::= Eine ARB-Datenbank (z.B.: 23sx.arb)."; |
|---|
| 20 | cout << "\n <Sequenz> ::= Name einer RNS-Sequenz (z.B.: ECOLI).\n"; |
|---|
| 21 | cout << "\nDarueberhinaus muss noch eine Datei matches.txt existieren, in der die Teilloesungen"; |
|---|
| 22 | cout << "\ndes Prealigners zeilenweise abgelegt sind. Innerhalb einer Zeile muessen die Positions-"; |
|---|
| 23 | cout << "\npaare der Loesung durch Kommata getrennt sein (z.B.: 5 10, 20 30, ...).\n\n"; |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | // ----------------------------------------------------------------------------- |
|---|
| 27 | static DArray *ReadMatches ( str file ) |
|---|
| 28 | // ----------------------------------------------------------------------------- |
|---|
| 29 | { |
|---|
| 30 | short error = 0; |
|---|
| 31 | DArray *pre = new DArray; |
|---|
| 32 | ifstream input(file); |
|---|
| 33 | |
|---|
| 34 | if (!pre || !input) error = 1; |
|---|
| 35 | else |
|---|
| 36 | { |
|---|
| 37 | str line = NULL; |
|---|
| 38 | |
|---|
| 39 | pre->Free(DARRAY_NOFREE); |
|---|
| 40 | pre->Null(DARRAY_NONULL); |
|---|
| 41 | |
|---|
| 42 | while (!error) |
|---|
| 43 | { |
|---|
| 44 | // if (!input.gets(&line) && !input.eof()) error = 2; |
|---|
| 45 | // else if (strlen(line)) |
|---|
| 46 | { |
|---|
| 47 | PSolution *psol = new PSolution; |
|---|
| 48 | |
|---|
| 49 | if (!psol) error = 3; |
|---|
| 50 | else |
|---|
| 51 | { |
|---|
| 52 | str tmp = strtok(line,","); |
|---|
| 53 | |
|---|
| 54 | while (!error && tmp) |
|---|
| 55 | { |
|---|
| 56 | HMatch *m = new HMatch; |
|---|
| 57 | |
|---|
| 58 | if (!m) error = 4; |
|---|
| 59 | else |
|---|
| 60 | { |
|---|
| 61 | sscanf(tmp,"%d%d",&m->first,&m->last); |
|---|
| 62 | |
|---|
| 63 | psol->match.Add(m); |
|---|
| 64 | psol->score += (m->last - m->first + 1); |
|---|
| 65 | |
|---|
| 66 | tmp = strtok(NULL,","); |
|---|
| 67 | } |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | if (!error) |
|---|
| 71 | { |
|---|
| 72 | psol->match.Sort(hmatchcmp); |
|---|
| 73 | pre->Add(psol); |
|---|
| 74 | } |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | delete line; |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | if (input.eof()) break; |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | if (!error) pre->Sort(psolcmp); |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | if (error) delete pre, pre = NULL; |
|---|
| 87 | |
|---|
| 88 | return pre; |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | // ----------------------------------------------------------------------------- |
|---|
| 92 | int main ( int argc, |
|---|
| 93 | char *argv[] ) |
|---|
| 94 | // ----------------------------------------------------------------------------- |
|---|
| 95 | { |
|---|
| 96 | int error = 0; |
|---|
| 97 | |
|---|
| 98 | if (argc != 3) Usage(); |
|---|
| 99 | else |
|---|
| 100 | { |
|---|
| 101 | A3Arbdb db; |
|---|
| 102 | |
|---|
| 103 | if (db.open(argv[1])) error = 1; |
|---|
| 104 | else |
|---|
| 105 | { |
|---|
| 106 | db.begin_transaction(); |
|---|
| 107 | |
|---|
| 108 | str seq = db.get_sequence_string(argv[2]), |
|---|
| 109 | fam = db.get_sequence_string("EscCol19"); |
|---|
| 110 | |
|---|
| 111 | db.commit_transaction(); |
|---|
| 112 | |
|---|
| 113 | if (!(seq && fam)) error = 2; |
|---|
| 114 | else |
|---|
| 115 | { |
|---|
| 116 | // DArray *pre = ReadMatches("matches.txt"); |
|---|
| 117 | |
|---|
| 118 | cout << "\n" << seq; |
|---|
| 119 | // cout << "\n" << fam << "\n"; |
|---|
| 120 | |
|---|
| 121 | // if (!pre) error = 3; |
|---|
| 122 | // else |
|---|
| 123 | { |
|---|
| 124 | A3_BI_Helix helix; |
|---|
| 125 | str err = helix.init(db.gb_main); |
|---|
| 126 | long pos = 0; |
|---|
| 127 | |
|---|
| 128 | if (err) cout << err << ", " << helix.size; |
|---|
| 129 | |
|---|
| 130 | while(pos < helix.size) |
|---|
| 131 | { |
|---|
| 132 | if (helix.entries[pos].pair_type != HELIX_PAIR) cout << "."; |
|---|
| 133 | else |
|---|
| 134 | { |
|---|
| 135 | if (helix.entries[pos].pair_pos < pos) cout << "]"; |
|---|
| 136 | else cout << "["; |
|---|
| 137 | } |
|---|
| 138 | |
|---|
| 139 | pos++; |
|---|
| 140 | } |
|---|
| 141 | |
|---|
| 142 | cout << flush; |
|---|
| 143 | |
|---|
| 144 | // Aligner ali(seq[2],seq[0],seq[1],*pre); |
|---|
| 145 | // DArray &tmp = ali.Align(); |
|---|
| 146 | |
|---|
| 147 | // delete &tmp; |
|---|
| 148 | // delete pre; |
|---|
| 149 | } |
|---|
| 150 | } |
|---|
| 151 | |
|---|
| 152 | if (seq) delete seq; |
|---|
| 153 | if (fam) delete fam; |
|---|
| 154 | |
|---|
| 155 | db.close(); |
|---|
| 156 | } |
|---|
| 157 | } |
|---|
| 158 | |
|---|
| 159 | if (error) cout << "\nALIV3: Fehler Nummer " << error << " ist aufgetreten!\n\n"; |
|---|
| 160 | |
|---|
| 161 | return error; |
|---|
| 162 | } |
|---|