ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/PrimerMatch/mapFile.h
Revision: 1.2
Committed: Wed May 4 18:03:45 2005 UTC (11 years, 2 months ago) by nje01
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +2 -2 lines
Log Message:
Small bug fixes, plus codon based edit distance for peptide searching.

Line File contents
1 /**************************************************************************
2 * This code is part of the supporting infrastructure for ATA Mapper.
3 * Copyright (C) 2002,2003,2004 Applera Corporation. All rights reserved.
4 * Author: Nathan Edwards
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received (LICENSE.txt) a copy of the GNU General Public
17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *************************************************************************/
20
21 #ifndef IBPEP_MMAPUTIL_H
22 #define IBPEP_MMAPUTIL_H
23
24 #include "types.h"
25
26 class MapFile {
27
28 public:
29 char *fileString;
30 FILE_SIZE_TYPE mapsize;
31 MapFile();
32 MapFile(const char *filename);
33 virtual ~MapFile();
34 void createMap(const char *filename);
35 char * const & file_string() const {
36 return fileString;
37 }
38 FILE_SIZE_TYPE map_size() const {
39 return mapsize;
40 }
41 inline bool endOfFile() const {
42 return(_pos>=mapsize);
43 }
44 inline bool endOfFile(const FILE_POSITION_TYPE pos) const {
45 return(pos>=mapsize);
46 }
47 inline FILE_SIZE_TYPE size() const {
48 return mapsize;
49 }
50 inline signed char readCharacter() const{
51 if (_pos < mapsize)
52 return fileString[_pos];
53 else return(-1);
54 }
55 inline char readCharacter( FILE_POSITION_TYPE const indx) const {
56 if (indx < mapsize-1)
57 return fileString[indx];
58 else
59 return fileString[mapsize-1];
60 }
61
62
63 inline char getCharacter () {
64 #ifdef CHECK_GETCHARACTER
65 if (_pos < mapsize)
66 return fileString[_pos++];
67 else
68 return -1;
69 #else
70 return fileString[_pos++];
71 #endif
72 }
73
74 inline char getCharacter (FILE_POSITION_TYPE indx) const {
75 #ifdef CHECK_GETCHAR
76 if (indx < mapsize - 1)
77 return fileString[indx];
78 else
79 return fileString[mapsize-1];
80 #else
81 return fileString[indx];
82 #endif
83 }
84
85 int setPos(const FILE_POSITION_TYPE);
86 FILE_POSITION_TYPE getPos() const{
87 return _pos;
88 }
89 virtual void reset() {
90 _pos=0;
91 }
92 protected:
93 FILE_POSITION_TYPE _pos;
94
95 };
96
97 #endif // MMAPUTIL_H