00001 /* 00002 * Copyright (C) 2010 Regents of the University of Michigan 00003 * 00004 * This program is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation, either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #include "BaseUtilities.h" 00019 00020 #include <ctype.h> 00021 00022 bool BaseUtilities::isAmbiguous(char base) 00023 { 00024 switch(base) 00025 { 00026 case 'N': 00027 case 'n': 00028 case '.': 00029 return(true); 00030 break; 00031 default: 00032 break; 00033 }; 00034 00035 // Not 'N', 'n', or '.', so return false. 00036 return(false); 00037 } 00038 00039 bool BaseUtilities::areEqual(char base1, char base2) 00040 { 00041 // If they are the same, return true. 00042 if(base1 == base2) 00043 { 00044 return(true); 00045 } 00046 // If one of the bases is '=', return true. 00047 if((base1 == '=') || (base2 == '=')) 00048 { 00049 return(true); 00050 } 00051 00052 // Check both in upercase. 00053 if(toupper(base1) == toupper(base2)) 00054 { 00055 // same in upper case. 00056 return(true); 00057 } 00058 00059 // The bases are different. 00060 return(false); 00061 } 00062 00063 00064 // Get phred base quality from the specified ascii quality. 00065 uint8_t BaseUtilities::getPhredBaseQuality(char charQuality) 00066 { 00067 return(charQuality - 33); 00068 }