ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/PrimerMatch/util.h
Revision: 1.2
Committed: Wed May 4 18:03:46 2005 UTC (11 years, 4 months ago) by nje01
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -0 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
22 #ifndef _IBPEP_UTIL_H_
23 #define _IBPEP_UTIL_H_
24
25 #include "types.h"
26
27 unsigned int least_common_multiple(unsigned int a, unsigned int b);
28 bool is_true(char const * const s);
29 bool is_false(char const * const s);
30
31 #include <string>
32
33 void uppercase(std::string & s);
34 std::string reverse_comp(std::string const & sequence);
35
36 char iupac_revcomp(char);
37 bool iupac_contains(char,char);
38 bool iupac_contained(char,char);
39 bool iupac_compatible(char,char);
40 char *iupac_contains(char);
41 char *iupac_contained(char);
42 char *iupac_compatible(char);
43
44 double monomolwt(char);
45 double avemolwt(char);
46 int aasubdist(char,char);
47
48 #define bigword long unsigned int
49
50 std::string binarystr(bigword val, int length);
51 std::string binary(long unsigned int val);
52 std::string binary(long long unsigned int val);
53 std::string binary(unsigned char val);
54
55 bool exist(std::string const & filename);
56 time_t modtime(std::string const & filename);
57
58 int anypos(std::string const & s0, std::string const & s1, int pos=0);
59
60 #ifdef PROFILE
61 void set_profile_signal_handler();
62 #endif
63
64 #include <stdio.h>
65 #include <time.h>
66 #include <string.h>
67 #define timestamp(m) { time_t t(time(NULL)); ASCTIME(s,localtime(&t)); fprintf(stderr,"[%24.*s] %s\n",(int)strlen(s)-1,s,(m));}
68 #define timestampli(m,v) { time_t t(time(NULL)); ASCTIME(s,localtime(&t)); fprintf(stderr,"[%24.*s] %s%ld\n",(int)strlen(s)-1,s,(m),(v));}
69 #define timestampi(m,v) { time_t t(time(NULL)); ASCTIME(s,localtime(&t)); fprintf(stderr,"[%24.*s] %s%d\n",(int)strlen(s)-1,s,(m),(v));}
70 #define timestampd(m,v) { time_t t(time(NULL)); ASCTIME(s,localtime(&t)); fprintf(stderr,"[%24.*s] %s%g\n",(int)strlen(s)-1,s,(m),(v));}
71 #define checkpoint { time_t t(time(NULL)); ASCTIME(s,localtime(&t)); fprintf(stderr,"[%24.*s] Checkpoint %s:%d.\n",(int)strlen(s)-1,s,__FILE__,__LINE__); }
72
73 extern time_t tictoctime_;
74 #define tic {tictoctime_ = time(NULL);}
75 #define toc { time_t t; time(&t); t-=tictoctime_; fprintf(stderr,"Elapsed time: %d:%02d:%02d\n",t/3600,(t%3600)/60,t%60);}
76 #define tocassgn(tsec) { time_t t; time(&t); t-=tictoctime_; fprintf(stderr,"Elapsed time: %ld:%02ld:%02ld\n",t/3600,(t%3600)/60,t%60); tsec = t;}
77
78 #endif