| 1 | // This file is part of A2Amapper. |
| 2 | // Copyright (c) 2004 Applied Biosystems |
| 3 | // Copyright (c) 2005 J. Craig Venter Institute |
| 4 | // Author: Dan Fasulo |
| 5 | // Author: Brian Walenz |
| 6 | // |
| 7 | // This program is free software; you can redistribute it and/or modify |
| 8 | // it under the terms of the GNU General Public License as published by |
| 9 | // the Free Software Foundation; either version 2 of the License, or |
| 10 | // (at your option) any later version. |
| 11 | // |
| 12 | // This program is distributed in the hope that it will be useful, |
| 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | // GNU General Public License for more details. |
| 16 | // |
| 17 | // You should have received (LICENSE.txt) a copy of the GNU General Public |
| 18 | // License along with this program; if not, write to the Free Software |
| 19 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | |
| 21 | #include <stdio.h> |
| 22 | #include <stdlib.h> |
| 23 | #include <unistd.h> |
| 24 | |
| 25 | #include "bio++.H" |
| 26 | #include "match.H" |
| 27 | |
| 28 | |
| 29 | void |
| 30 | match_s::dump(FILE *out, const char *descr, bool showSeq) { |
| 31 | fprintf(out, "%s: ID:%s range1:"uint32FMT","uint32FMT" _pos="uint32FMT" (seqlen="uint32FMT")\n", |
| 32 | descr, _matchId, |
| 33 | _acc1->getRangeBegin(), _acc1->getRangeLength(), _acc1->_pos, _seq1->sequenceLength()); |
| 34 | fprintf(out, "%s ID:%s range2:"uint32FMT","uint32FMT" _pos="uint32FMT" (seqlen="uint32FMT") diag:"uint32FMT" %s\n", |
| 35 | descr, _matchId, |
| 36 | _acc2->getRangeBegin(), _acc2->getRangeLength(), _acc2->_pos, _seq2->sequenceLength(), |
| 37 | _diagonal, (_ori1 != _ori2) ? "reversed" : ""); |
| 38 | |
| 39 | if (showSeq) { |
| 40 | FastAAccessor &A = *_acc1; |
| 41 | FastAAccessor &B = *_acc2; |
| 42 | |
| 43 | // Save the position of the accessors |
| 44 | // |
| 45 | uint32 acc1pos = A._pos; |
| 46 | uint32 acc2pos = B._pos; |
| 47 | |
| 48 | A.setPosition(A.getRangeBegin()); |
| 49 | B.setPosition(B.getRangeBegin()); |
| 50 | |
| 51 | uint32 margin = 5; |
| 52 | uint32 i = 0; |
| 53 | char *seq = new char [_acc1->getRangeEnd() - _acc1->getRangeBegin() + margin + margin + 32]; |
| 54 | char *las = seq; |
| 55 | |
| 56 | strcpy(seq, ">>> "); |
| 57 | while (*las) las++; |
| 58 | |
| 59 | for (i=0; i<margin; i++) |
| 60 | --A; |
| 61 | for (i=0; i<margin; i++, ++A) |
| 62 | if (A.isValid()) |
| 63 | *las++ = *A; |
| 64 | else |
| 65 | *las++ = ' '; |
| 66 | *las++ = ':'; |
| 67 | for (i=0; i<_acc1->getRangeEnd() - _acc1->getRangeBegin(); i++, ++A) |
| 68 | if (A.isValid()) |
| 69 | *las++ = *A; |
| 70 | else |
| 71 | *las++ = ' '; |
| 72 | *las++ = ':'; |
| 73 | for (i=0; i<margin; i++, ++A) |
| 74 | if (A.isValid()) |
| 75 | *las++ = *A; |
| 76 | else |
| 77 | *las++ = ' '; |
| 78 | |
| 79 | *las++ = 0; |
| 80 | fprintf(out, "%s\n", seq); |
| 81 | |
| 82 | las = seq; |
| 83 | |
| 84 | strcpy(seq, (_ori1 == _ori2) ? ">>> " : "<<< "); |
| 85 | while (*las) las++; |
| 86 | |
| 87 | for (i=0; i<margin; i++) |
| 88 | --B; |
| 89 | for (i=0; i<margin; i++, ++B) |
| 90 | if (B.isValid()) |
| 91 | *las++ = *B; |
| 92 | else |
| 93 | *las++ = ' '; |
| 94 | *las++ = ':'; |
| 95 | for (i=0; i<_acc1->getRangeEnd() - _acc1->getRangeBegin(); i++, ++B) |
| 96 | if (B.isValid()) |
| 97 | *las++ = *B; |
| 98 | else |
| 99 | *las++ = ' '; |
| 100 | *las++ = ':'; |
| 101 | for (i=0; i<margin; i++, ++B) |
| 102 | if (B.isValid()) |
| 103 | *las++ = *B; |
| 104 | else |
| 105 | *las++ = ' '; |
| 106 | |
| 107 | *las++ = 0; |
| 108 | fprintf(out, "%s\n", seq); |
| 109 | |
| 110 | delete [] seq; |
| 111 | |
| 112 | // Restore positions |
| 113 | _acc1->_pos = acc1pos; |
| 114 | _acc2->_pos = acc2pos; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 |